tvplanit: Support contacts in VCard import/export.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8396 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-08-19 10:53:49 +00:00
parent 83950d045a
commit 33b73bbc8b
9 changed files with 158 additions and 31 deletions

View File

@ -50,10 +50,16 @@ type
FBirthDay: TDateTime;
FAnniversary: TDateTime;
FCategories: TStrings;
FPickedCategory: Integer;
FSkip: Boolean;
function GetCategory(AIndex: Integer): String;
function GetCategoryCount: Integer;
public
constructor Create;
destructor Destroy; override;
procedure Analyze; override;
function FindItem(AKey, ATags: String): TVpVCardItem;
@ -93,8 +99,12 @@ type
property ISDN: String read FISDN write FISDN;
property Pager: String read FPager write FPager;
property BirthDay: TDateTime read FBirthday write FBirthDay;
property Anniversary: TDateTime read FAnniversary write FAnniversary;
property BirthDay: TDateTime read FBirthday write FBirthDay;
property Category[AIndex: Integer]: string read GetCategory;
property CategoryCount: Integer read GetCategoryCount;
property Categories: TStrings read FCategories write FCategories;
property PickedCategory: Integer read FPickedCategory write FPickedCategory;
property Version: String read FVersion;
property Skip: Boolean read FSkip write FSkip; // Flag to skip import
@ -208,6 +218,15 @@ end;
constructor TVpVCard.Create;
begin
inherited Create(TVpVCardItem);
FCategories := TStringList.Create;
FCategories.Delimiter := ','; // VCard categories are separated by comma in vcf file.
FCategories.StrictDelimiter := true;
end;
destructor TVpVCard.Destroy;
begin
FCategories.Free;
inherited;
end;
procedure TVpVCard.Analyze;
@ -298,6 +317,8 @@ begin
FAnniversary := dt;
end;
end;
'CATEGORIES':
FCategories.CommaText := item.Value;
end;
end;
@ -314,6 +335,16 @@ begin
Result := TVpVCardItem(inherited FindItem(AKey, ATags));
end;
function TVpVCard.GetCategory(AIndex: Integer): String;
begin
Result := FCategories[AIndex];
end;
function TVpVCard.GetCategoryCount: Integer;
begin
Result := FCategories.Count;
end;
function TVpVCard.GetEMail: String;
begin
Result := '';
@ -417,6 +448,10 @@ begin
if HomeEMail <> '' then
AList.Add('EMAIL;TYPE=HOME:' + HomeEMail);
// Categories
if Categories.Count > 0 then
AList.Add('CATEGORIES:' + Categories.CommaText);
AList.Add('END:VCARD');
end;