tvplanit: TVpWeekView supports export of events to ical files.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8403 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-08-20 19:38:02 +00:00
parent b54393de63
commit 774c1feda3
2 changed files with 63 additions and 29 deletions

View File

@ -2411,10 +2411,8 @@ end;
procedure TVpDayview.ExportICalFile(const AFileName: String;
const AEvents: TVpEventArr);
begin
if (not Assigned(Datastore)) or (not Assigned(Datastore.Resource)) then
exit;
Datastore.Resource.Schedule.ExportICalFile(AFileName, AEvents);
if Assigned(Datastore) and Assigned(Datastore.Resource) then
Datastore.Resource.Schedule.ExportICalFile(AFileName, AEvents);
end;
{ Reads the events listed in the specified ical file and adds them to the

View File

@ -205,10 +205,12 @@ type
{ Popup }
function GetPopupMenu: TPopupMenu; override;
procedure InitializeDefaultPopup;
procedure PopupAddEvent(Sender: TObject);
procedure PopupAddFromICalFile(Sender: TObject);
procedure PopupDeleteEvent(Sender: TObject);
procedure PopupEditEvent(Sender: TObject);
procedure PopupExportToICalFile(Sender: TObject);
procedure PopupImportFromICalFile(Sender: TObject);
procedure PopupToday(Sender: TObject);
procedure PopupNextWeek(Sender: TObject);
procedure PopupPrevWeek(Sender: TObject);
@ -218,7 +220,6 @@ type
procedure PopupPrevYear(Sender: TObject);
procedure PopupCustomDate(Sender: TObject);
procedure PopupPickResourceGroupEvent(Sender: TObject);
procedure InitializeDefaultPopup;
{ internal methods }
procedure SpinButtonClick(Sender: TObject);
@ -279,6 +280,7 @@ type
procedure LoadLanguage;
procedure DeleteActiveEvent(Verify: Boolean);
procedure DragDrop(Source: TObject; X, Y: Integer); override;
procedure ExportICalFile(const AFileName: String; const AEvents: TVpEventArr);
function ImportICalFile(const AFileName: String; APreview: Boolean = false;
ADefaultCategory: Integer = -1): TVpEventArr;
procedure Invalidate; override;
@ -1106,6 +1108,13 @@ begin
end;
end;
procedure TVpWeekView.ExportICalFile(const AFileName: String;
const AEvents: TVpEventArr);
begin
if Assigned(Datastore) and Assigned(Datastore.Resource) then
Datastore.Resource.Schedule.ExportICalFile(AFileName, AEvents);
end;
{ Reads the events listed in the specified ical file and adds them to the
day view control. All events imported are collected in the Result array.
ADefaultCategory is the category to which the event is assigned if no fitting
@ -1230,12 +1239,20 @@ begin
if RSPopupImportEventFromICal <> '' then begin
NewItem := TVpMenuItem.Create(Self);
NewItem.Kind := mikImportEventFromICal; // Import from iCal
NewItem.OnClick := PopupAddFromICalFile;
NewItem.OnClick := PopupImportFromICalFile;
NewItem.Tag := 0;
FDefaultPopup.Items.Add(NewItem);
end;
NewItem := TVpMenuItem.Create(Self); // ---
if RSPopupExportEventToICal <> '' then begin
NewItem := TVpMenuItem.Create(Self);
NewItem.Kind := mikExportEventToICal; // Export to iCal
NewItem.OnClick := PopupExportToICalFile;
NewItem.Tag := 1;
FDefaultPopup.Items.Add(NewItem);
end;
NewItem := TVpMenuItem.Create(Self); // ---
NewItem.Kind := mikSeparator;
FDefaultPopup.Items.Add(NewItem);
@ -1352,9 +1369,47 @@ begin
{ edit this new event }
wvSpawnEventEditDialog(True);
end;
{=====}
procedure TVpWeekView.PopupAddFromICalFile(Sender: TObject);
procedure TVpWeekView.PopupDeleteEvent(Sender: TObject);
begin
if ReadOnly then
Exit;
if ActiveEvent <> nil then
DeleteActiveEvent (True);
end;
procedure TVpWeekView.PopupEditEvent(Sender: TObject);
begin
if ReadOnly then
Exit;
if ActiveEvent <> nil then
{ edit this Event }
wvSpawnEventEditDialog(False);
end;
procedure TVpWeekView.PopupExportToICalFile(Sender: TObject);
var
dlg: TSaveDialog;
begin
if (not Assigned(Datastore)) or (not Assigned(Datastore.Resource)) or
(FActiveEvent = nil)
then
exit;
dlg := TSaveDialog.Create(nil);
try
dlg.Title := RSSaveICalTitle;
dlg.Filter := RSICalFilter;
dlg.FileName := '';
dlg.Options := dlg.Options - [ofAllowMultiSelect] + [ofOverwritePrompt];
if dlg.Execute then
ExportICalFile(dlg.FileName, [FActiveEvent]);
finally
dlg.Free;
end;
end;
procedure TVpWeekView.PopupImportFromICalFile(Sender: TObject);
var
dlg: TOpenDialog;
fn: String;
@ -1379,25 +1434,6 @@ begin
end;
end;
procedure TVpWeekView.PopupDeleteEvent(Sender: TObject);
begin
if ReadOnly then
Exit;
if ActiveEvent <> nil then
DeleteActiveEvent (True);
end;
{=====}
procedure TVpWeekView.PopupEditEvent(Sender: TObject);
begin
if ReadOnly then
Exit;
if ActiveEvent <> nil then
{ edit this Event }
wvSpawnEventEditDialog(False);
end;
{=====}
procedure TVpWeekView.EditSelectedEvent(IsNewEvent: Boolean = false);
begin
if ActiveEvent <> nil then