You've already forked lazarus-ccr
tvplanit: Add preview for importing VCard files.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8381 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -47,10 +47,18 @@ type
|
||||
FCarPhone: String;
|
||||
FISDN: String;
|
||||
FPager: String;
|
||||
|
||||
FSkip: Boolean;
|
||||
public
|
||||
constructor Create;
|
||||
procedure Analyze; override;
|
||||
function FindItem(AKey, ATags: String): TVpVCardItem;
|
||||
|
||||
function GetEMail: String;
|
||||
function GetFullName: String;
|
||||
function GetHomeAddress: String;
|
||||
function GetPhone: String;
|
||||
function GetWorkAddress: String;
|
||||
|
||||
property FirstName: String read FFirstName;
|
||||
property LastName: String read FLastName;
|
||||
@ -81,6 +89,7 @@ type
|
||||
property Pager: String read FPager;
|
||||
|
||||
property Version: String read FVersion;
|
||||
property Skip: Boolean read FSkip write FSkip;
|
||||
end;
|
||||
|
||||
TVpVCards = class
|
||||
@ -193,6 +202,7 @@ var
|
||||
i: Integer;
|
||||
item: TVpVCardItem;
|
||||
fn, ln, t: String;
|
||||
fullName: String;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
@ -201,7 +211,9 @@ begin
|
||||
case item.Key of
|
||||
'VERSION':
|
||||
FVersion := item.Value;
|
||||
'FN', 'N':
|
||||
'FN':
|
||||
fullName := item.Value;
|
||||
'N':
|
||||
begin
|
||||
VCardName(item.Value, ln, fn, t);
|
||||
if FLastName = '' then FLastName := ln;
|
||||
@ -250,6 +262,13 @@ begin
|
||||
FWorkPhone := IfThen(FWorkPhone = '', item.Value, FWorkPhone + ITEM_SEPARATOR + item.Value);
|
||||
end;
|
||||
end;
|
||||
|
||||
if (FFirstName = '') and (FLastName = '') then
|
||||
begin
|
||||
FLastName := fullName;
|
||||
FFirstName := '';
|
||||
FTitle := '';
|
||||
end;
|
||||
end;
|
||||
|
||||
function TVpVCard.FindItem(AKey, ATags: String): TVpVCardItem;
|
||||
@ -257,6 +276,96 @@ begin
|
||||
Result := TVpVCardItem(inherited FindItem(AKey, ATags));
|
||||
end;
|
||||
|
||||
function TVpVCard.GetEMail: String;
|
||||
var
|
||||
sw, sh: String;
|
||||
begin
|
||||
if WorkEMail <> '' then sw := Format('%s (work)', [WorkEMail]) else sw := '';
|
||||
if HomeEMail <> '' then sh := Format('%s (home)', [HomeEMail]) else sh := '';
|
||||
if (sw <> '') and (sh <> '') then
|
||||
Result := sw + '; ' + sh
|
||||
else if (sw <> '') then
|
||||
Result := sw
|
||||
else if (sh <> '') then
|
||||
Result := sh
|
||||
else
|
||||
Result := '';
|
||||
end;
|
||||
|
||||
function TVpVCard.GetFullName: String;
|
||||
begin
|
||||
Result := LastName;
|
||||
if FirstName <> '' then Result := FirstName + ' ' + Result;
|
||||
if Title <> '' then Result := Result + ', ' + Title;
|
||||
end;
|
||||
|
||||
function TVpVCard.GetHomeAddress: String;
|
||||
begin
|
||||
Result := '';
|
||||
if (HomeAddress = '') and (HomeZip = '') and (HomeCity = '') then
|
||||
exit;
|
||||
Result := HomeAddress + ', ' + HomeZip + ' ' + HomeCity;
|
||||
if HomeState <> '' then
|
||||
Result := Result + ', ' + HomeState;
|
||||
if HomeCountry <> '' then
|
||||
Result := Result + ', ' + HomeCountry;
|
||||
end;
|
||||
|
||||
function TVpVCard.GetPhone: String;
|
||||
var
|
||||
sw, sh: String;
|
||||
begin
|
||||
if WorkPhone <> '' then sw := Format('%s (work)', [WorkPhone]) else sw := '';
|
||||
if HomePhone <> '' then sh := Format('%s (home)', [HomePhone]) else sh := '';
|
||||
if (sw <> '') and (sh <> '') then
|
||||
Result := sw + '; ' + sh
|
||||
else if (sw <> '') then
|
||||
Result := sw
|
||||
else if (sh <> '') then
|
||||
Result := sh
|
||||
else
|
||||
Result := '';
|
||||
end;
|
||||
|
||||
function TVpVCard.GetWorkAddress: String;
|
||||
begin
|
||||
Result := '';
|
||||
if (Company = '') and (WorkAddress = '') and (WorkZip = '') and (WorkCity = '') then
|
||||
exit;
|
||||
|
||||
Result := Company + ', ' + WorkAddress + ', ' + WorkZip + ' ' + WorkCity;
|
||||
if WorkState <> '' then
|
||||
Result := Result + ', ' + WorkState;
|
||||
if WorkCountry <> '' then
|
||||
Result := Result + ', ' + WorkCountry;
|
||||
end;
|
||||
(*
|
||||
function GetHomeAddress: String;
|
||||
function GetWorkAddress: String;
|
||||
|
||||
property FirstName: String read FFirstName;
|
||||
property LastName: String read FLastName;
|
||||
property Title: String read FTitle;
|
||||
|
||||
property Company: String read FCompany;
|
||||
property WorkAddress: String read FWorkAddress;
|
||||
property WorkCity: String read FWorkCity;
|
||||
property WorkZip: String read FWorkZip;
|
||||
property WorkState: String read FWorkState;
|
||||
property WorkCountry: String read FWorkCountry;
|
||||
property WorkEMail: String read FWorkEMail;
|
||||
property WorkPhone: String read FWorkPhone;
|
||||
property WorkFax: String read FWorkFax;
|
||||
|
||||
property HomeAddress: String read FHomeAddress;
|
||||
property HomeCity: String read FHomeCity;
|
||||
property HomeZip: String read FHomeZip;
|
||||
property HomeState: String read FHomeState;
|
||||
property HomeCountry: String read FHomeCountry;
|
||||
property HomeEMail: String read FHomeEMail;
|
||||
property HomePhone: String read FHomePhone;
|
||||
property HomeFax: String read FHomeFax;
|
||||
*)
|
||||
|
||||
{==============================================================================}
|
||||
{ TVpCards }
|
||||
|
Reference in New Issue
Block a user