From a430be7bcf880b0d0ddc7e335e52f007ef6475fa Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Fri, 19 Aug 2022 14:06:54 +0000 Subject: [PATCH] tvplanit: Refactor ical/vcard import (property Skip --> Checked) git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8398 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/tvplanit/source/vpdata.pas | 6 +++--- components/tvplanit/source/vpical.pas | 5 +++-- components/tvplanit/source/vpimportpreview_icalevent.pas | 4 ++-- components/tvplanit/source/vpimportpreview_icaltask.pas | 4 ++-- components/tvplanit/source/vpimportpreview_vcard.pas | 4 ++-- components/tvplanit/source/vpvcard.pas | 5 +++-- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/components/tvplanit/source/vpdata.pas b/components/tvplanit/source/vpdata.pas index a944e464e..252037881 100644 --- a/components/tvplanit/source/vpdata.pas +++ b/components/tvplanit/source/vpdata.pas @@ -1791,7 +1791,7 @@ begin end; for i := 0 to ical.Count-1 do begin - if ical[i].Skip or (not (ical[i] is TVpICalEvent)) then + if (not ical[i].Checked) or (not (ical[i] is TVpICalEvent)) then Continue; startTime := TVpICalEvent(ical[i]).StartTime[false]; // use local times endTime := TVpICalEvent(ical[i]).EndTime[false]; @@ -2971,7 +2971,7 @@ begin end; for i := 0 to vcards.Count-1 do begin - if vCards[i].Skip then + if (not vCards[i].Checked) then Continue; id := datastore.GetNextID(ContactsTableName); lContact := AddContact(id); @@ -3246,7 +3246,7 @@ begin end; for i := 0 to ical.Count-1 do begin - if ical[i].Skip or (not (ical[i] is TVpICalToDo)) then + if (not ical[i].Checked) or (not (ical[i] is TVpICalToDo)) then Continue; id := dataStore.GetNextID(TasksTableName); diff --git a/components/tvplanit/source/vpical.pas b/components/tvplanit/source/vpical.pas index 08a824723..3c5b44bf4 100644 --- a/components/tvplanit/source/vpical.pas +++ b/components/tvplanit/source/vpical.pas @@ -18,11 +18,11 @@ type TVpICalEntry = class(TVpFileBlock) private FCalendar: TVpICalendar; - FSkip: Boolean; + FChecked: Boolean; public constructor Create(ACalendar: TVpICalendar); virtual; function FindItem(AKey: String): TVpICalItem; - property Skip: Boolean read FSkip write FSkip default false; + property Checked: Boolean read FChecked write FChecked default true; end; TVpICalTimeZoneInfo = class(TVpICalEntry) @@ -283,6 +283,7 @@ end; constructor TVpICalEntry.Create(ACalendar: TVpICalendar); begin inherited Create(TVpICalItem); + FChecked := true; FCalendar := ACalendar; end; diff --git a/components/tvplanit/source/vpimportpreview_icalevent.pas b/components/tvplanit/source/vpimportpreview_icalevent.pas index a48f444c3..29df13715 100644 --- a/components/tvplanit/source/vpimportpreview_icalevent.pas +++ b/components/tvplanit/source/vpimportpreview_icalevent.pas @@ -66,7 +66,7 @@ begin exit; item := TVpICalEntry(FItems[ARow - Grid.FixedRows]); if item <> nil then - item.Skip := not AChecked; + item.Checked := AChecked; end; function TVpImportPreviewICalEventForm.GetCellText(ACol, ARow: Integer): String; @@ -208,7 +208,7 @@ begin exit; item := TVpICalEntry(FItems[ARow - Grid.FixedRows]); if (item <> nil) then - Result := not item.Skip; + Result := item.Checked; end; procedure TVpImportPreviewICalEventForm.PrepareItems; diff --git a/components/tvplanit/source/vpimportpreview_icaltask.pas b/components/tvplanit/source/vpimportpreview_icaltask.pas index 5f1ac5731..c8dab878e 100644 --- a/components/tvplanit/source/vpimportpreview_icaltask.pas +++ b/components/tvplanit/source/vpimportpreview_icaltask.pas @@ -66,7 +66,7 @@ begin exit; item := TVpICalEntry(FItems[ARow - Grid.FixedRows]); if item <> nil then - item.Skip := not AChecked; + item.Checked := AChecked; end; function TVpImportPreviewICalTaskForm.GetCellText(ACol, ARow: Integer): String; @@ -146,7 +146,7 @@ begin exit; item := TVpICalEntry(FItems[ARow - Grid.FixedRows]); if (item <> nil) then - Result := not item.Skip; + Result := item.Checked; end; procedure TVpImportPreviewICalTaskForm.PrepareItems; diff --git a/components/tvplanit/source/vpimportpreview_vcard.pas b/components/tvplanit/source/vpimportpreview_vcard.pas index 0f68265e1..e3f9c3212 100644 --- a/components/tvplanit/source/vpimportpreview_vcard.pas +++ b/components/tvplanit/source/vpimportpreview_vcard.pas @@ -61,7 +61,7 @@ begin exit; card := TVpVCard(FItems[ARow - Grid.FixedRows]); if card <> nil then - card.Skip := not AChecked; + card.Checked := AChecked; end; function TVpImportPreviewVCardForm.GetCellText(ACol, ARow: Integer): String; @@ -135,7 +135,7 @@ begin exit; card := TVpVCard(FItems[ARow - Grid.FixedRows]); if (card <> nil) then - Result := not card.Skip; + Result := card.Checked; end; procedure TVpImportPreviewVCardForm.PrepareItems; diff --git a/components/tvplanit/source/vpvcard.pas b/components/tvplanit/source/vpvcard.pas index 5e8517caf..4ef71e838 100644 --- a/components/tvplanit/source/vpvcard.pas +++ b/components/tvplanit/source/vpvcard.pas @@ -53,7 +53,7 @@ type FCategories: TStrings; FPickedCategory: Integer; - FSkip: Boolean; + FChecked: Boolean; function GetCategory(AIndex: Integer): String; function GetCategoryCount: Integer; @@ -107,7 +107,7 @@ type property PickedCategory: Integer read FPickedCategory write FPickedCategory; property Version: String read FVersion; - property Skip: Boolean read FSkip write FSkip; // Flag to skip import + property Checked: Boolean read FChecked write FChecked default true; // Flag to skip import end; TVpVCards = class @@ -218,6 +218,7 @@ end; constructor TVpVCard.Create; begin inherited Create(TVpVCardItem); + FChecked := true; FCategories := TStringList.Create; FCategories.Delimiter := ','; // VCard categories are separated by comma in vcf file. FCategories.StrictDelimiter := true;