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:
@ -567,6 +567,10 @@ msgstr ""
|
||||
msgid "Import ICalendar Task"
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsimportvcard
|
||||
msgid "Import VCard"
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsinches
|
||||
msgid "Inches"
|
||||
msgstr "Zoll"
|
||||
@ -775,6 +779,11 @@ msgstr "Ohne Alarm"
|
||||
msgid "TCanvas not assigned"
|
||||
msgstr "TCanvas wurde nicht zugewiesen"
|
||||
|
||||
#: vpsr.rsnocontactsfoundinvcard
|
||||
#, object-pascal-format
|
||||
msgid "No contact items found in \"%s\"."
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsnocontrollink
|
||||
msgid "Component must be linked to a TVpControlLink"
|
||||
msgstr "Komponente muss mit einem TVpControlLink verbunden sein"
|
||||
|
@ -561,6 +561,10 @@ msgstr ""
|
||||
msgid "Import ICalendar Task"
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsimportvcard
|
||||
msgid "Import VCard"
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsinches
|
||||
msgid "Inches"
|
||||
msgstr "Inches"
|
||||
@ -767,6 +771,11 @@ msgstr "No alarm"
|
||||
msgid "TCanvas not assigned"
|
||||
msgstr "TCanvas not assigned"
|
||||
|
||||
#: vpsr.rsnocontactsfoundinvcard
|
||||
#, object-pascal-format
|
||||
msgid "No contact items found in \"%s\"."
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsnocontrollink
|
||||
msgid "Component must be linked to a TVpControlLink"
|
||||
msgstr "Component must be linked to a TVpControlLink"
|
||||
|
@ -558,6 +558,10 @@ msgstr ""
|
||||
msgid "Import ICalendar Task"
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsimportvcard
|
||||
msgid "Import VCard"
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsinches
|
||||
msgid "Inches"
|
||||
msgstr ""
|
||||
@ -766,6 +770,11 @@ msgstr ""
|
||||
msgid "TCanvas not assigned"
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsnocontactsfoundinvcard
|
||||
#, object-pascal-format
|
||||
msgid "No contact items found in \"%s\"."
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsnocontrollink
|
||||
msgid "Component must be linked to a TVpControlLink"
|
||||
msgstr ""
|
||||
|
@ -573,6 +573,10 @@ msgstr ""
|
||||
msgid "Import ICalendar Task"
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsimportvcard
|
||||
msgid "Import VCard"
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsinches
|
||||
msgid "Inches"
|
||||
msgstr ""
|
||||
@ -781,6 +785,11 @@ msgstr ""
|
||||
msgid "TCanvas not assigned"
|
||||
msgstr "TCanvas non spécifié"
|
||||
|
||||
#: vpsr.rsnocontactsfoundinvcard
|
||||
#, object-pascal-format
|
||||
msgid "No contact items found in \"%s\"."
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsnocontrollink
|
||||
msgid "Component must be linked to a TVpControlLink"
|
||||
msgstr "Le composant doit être lié à un TVpControlLink"
|
||||
|
@ -567,6 +567,10 @@ msgstr ""
|
||||
msgid "Import ICalendar Task"
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsimportvcard
|
||||
msgid "Import VCard"
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsinches
|
||||
msgid "Inches"
|
||||
msgstr ""
|
||||
@ -775,6 +779,11 @@ msgstr ""
|
||||
msgid "TCanvas not assigned"
|
||||
msgstr "TCanvas is niet toegewezen."
|
||||
|
||||
#: vpsr.rsnocontactsfoundinvcard
|
||||
#, object-pascal-format
|
||||
msgid "No contact items found in \"%s\"."
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsnocontrollink
|
||||
msgid "Component must be linked to a TVpControlLink"
|
||||
msgstr "Component moet moet met een TVpControlLink verbonden zijn"
|
||||
|
@ -567,6 +567,10 @@ msgstr ""
|
||||
msgid "Import ICalendar Task"
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsimportvcard
|
||||
msgid "Import VCard"
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsinches
|
||||
msgid "Inches"
|
||||
msgstr "Cale"
|
||||
@ -775,6 +779,11 @@ msgstr ""
|
||||
msgid "TCanvas not assigned"
|
||||
msgstr "TCanvas nie został przypisany."
|
||||
|
||||
#: vpsr.rsnocontactsfoundinvcard
|
||||
#, object-pascal-format
|
||||
msgid "No contact items found in \"%s\"."
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsnocontrollink
|
||||
msgid "Component must be linked to a TVpControlLink"
|
||||
msgstr "Komponent musi być przypisany do TVpControlLink."
|
||||
|
@ -551,6 +551,10 @@ msgstr ""
|
||||
msgid "Import ICalendar Task"
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsimportvcard
|
||||
msgid "Import VCard"
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsinches
|
||||
msgid "Inches"
|
||||
msgstr ""
|
||||
@ -757,6 +761,11 @@ msgstr ""
|
||||
msgid "TCanvas not assigned"
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsnocontactsfoundinvcard
|
||||
#, object-pascal-format
|
||||
msgid "No contact items found in \"%s\"."
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsnocontrollink
|
||||
msgid "Component must be linked to a TVpControlLink"
|
||||
msgstr ""
|
||||
|
@ -567,6 +567,10 @@ msgstr ""
|
||||
msgid "Import ICalendar Task"
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsimportvcard
|
||||
msgid "Import VCard"
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsinches
|
||||
msgid "Inches"
|
||||
msgstr "Дюймы"
|
||||
@ -775,6 +779,11 @@ msgstr ""
|
||||
msgid "TCanvas not assigned"
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsnocontactsfoundinvcard
|
||||
#, object-pascal-format
|
||||
msgid "No contact items found in \"%s\"."
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rsnocontrollink
|
||||
msgid "Component must be linked to a TVpControlLink"
|
||||
msgstr ""
|
||||
|
@ -32,7 +32,7 @@ Portions created by TurboPower Software Inc. are Copyright (C) 2002 TurboPower S
|
||||
|
||||
Contributor(s): "/>
|
||||
<Version Major="1" Minor="7"/>
|
||||
<Files Count="65">
|
||||
<Files Count="66">
|
||||
<Item1>
|
||||
<Filename Value="source\vpbase.pas"/>
|
||||
<UnitName Value="VpBase"/>
|
||||
@ -293,6 +293,10 @@ Contributor(s): "/>
|
||||
<Filename Value="source\vpimportpreview_icaltask.pas"/>
|
||||
<UnitName Value="VpImportPreview_ICalTask"/>
|
||||
</Item65>
|
||||
<Item66>
|
||||
<Filename Value="source\vpimportpreview_vcard.pas"/>
|
||||
<UnitName Value="VpImportPreview_VCard"/>
|
||||
</Item66>
|
||||
</Files>
|
||||
<CompatibilityMode Value="True"/>
|
||||
<i18n>
|
||||
|
@ -184,10 +184,12 @@ resourcestring
|
||||
RSICalFilter = 'iCalendar files (*.ical;*.ics)|*.ical;*.ics';
|
||||
RSImportICalEvent = 'Import ICalendar Event';
|
||||
RSImportICalTask = 'Import ICalendar Task';
|
||||
RSImportVCard = 'Import VCard';
|
||||
RSRepeat = 'Repeat:';
|
||||
RSNoEventItemsFoundInICAL = 'No event items found in "%s".';
|
||||
RSNoTaskItemsFoundInICAL = 'No task items found in "%s".';
|
||||
|
||||
RSNoContactsFoundInVCARD = 'No contact items found in "%s".';
|
||||
|
||||
{Task Specific}
|
||||
RSConfirmDeleteTask = 'Delete this task from your list?';
|
||||
RSTaskPopupAdd = 'Add task...';
|
||||
|
@ -246,6 +246,8 @@ type
|
||||
Angle: TVpRotationAngle; Scale: Extended; RenderDate: TDateTime;
|
||||
StartLine, StopLine: Integer; UseGran: TVpGranularity;
|
||||
DisplayOnly: Boolean); override;
|
||||
function ImportVCardFile(const AFileName: String;
|
||||
APreview: Boolean = false): TVpContactArr;
|
||||
|
||||
{ - Added to support the buttonbar component. }
|
||||
function SelectContactByName(const Name: String): Boolean;
|
||||
@ -1556,7 +1558,24 @@ begin
|
||||
{ Allow the user to fill in all the new information }
|
||||
cgSpawnContactEditDialog(True);
|
||||
end;
|
||||
{=====}
|
||||
|
||||
function TVpContactGrid.ImportVCardFile(const AFileName: String;
|
||||
APreview: Boolean = false): TVpContactArr;
|
||||
begin
|
||||
if ReadOnly or (not CheckCreateResource) or
|
||||
(not Assigned(Datastore)) or (not Assigned(Datastore.Resource))
|
||||
then
|
||||
exit(nil);
|
||||
|
||||
Result := Datastore.Resource.Contacts.ImportVCardFile(AFileName, APreview);
|
||||
if Length(Result) > 0 then
|
||||
begin
|
||||
FActiveContact := Result[High(Result)];
|
||||
Datastore.PostContacts;
|
||||
Datastore.NotifyDependents;
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpContactGrid.PopupAddVCards(Sender: TObject);
|
||||
var
|
||||
@ -1578,6 +1597,9 @@ begin
|
||||
dlg.FileName := '';
|
||||
dlg.Options := dlg.Options + [ofAllowMultiSelect, ofFileMustExist];
|
||||
if dlg.Execute then begin
|
||||
for fn in dlg.Files do
|
||||
ImportVCardFile(fn, dlg.Files.Count=1);
|
||||
(*
|
||||
Screen.Cursor := crHourGlass;
|
||||
Application.ProcessMessages;
|
||||
vcards := TVpVCards.Create;
|
||||
@ -1597,6 +1619,7 @@ begin
|
||||
vcards.Free;
|
||||
Screen.Cursor := crDefault;
|
||||
end;
|
||||
*)
|
||||
end;
|
||||
finally
|
||||
dlg.Free;
|
||||
|
@ -78,6 +78,7 @@ type
|
||||
|
||||
TVpEventArr = array of TVpEvent;
|
||||
TVpTaskArr = array of TVpTask;
|
||||
TVpContactArr = array of TVpContact;
|
||||
|
||||
TVpResources = class
|
||||
private
|
||||
@ -391,7 +392,7 @@ type
|
||||
function LastByDay(Date: TDateTime): TVpTask;
|
||||
procedure Sort;
|
||||
function GetTask(Index: Integer): TVpTask;
|
||||
property Owner: TVpREsource read FOwner;
|
||||
property Owner: TVpResource read FOwner;
|
||||
end;
|
||||
|
||||
TVpTask = class
|
||||
@ -494,12 +495,14 @@ type
|
||||
CaseInsensitive: Boolean = True): Integer;
|
||||
function GetContact(Index: Integer): TVpContact;
|
||||
function Last:TVpContact;
|
||||
function ImportVCardFile(const AFileName: String; const APreview: Boolean = false): TVpContactArr;
|
||||
procedure Sort;
|
||||
|
||||
property ContactsList: TList
|
||||
read FContactsList;
|
||||
property ContactSort: TVpContactSort
|
||||
read FContactSort write SetContactSort default csLastFirst;
|
||||
property Owner: TVpResource read FOwner;
|
||||
end;
|
||||
|
||||
TVpContact = class
|
||||
@ -712,7 +715,7 @@ implementation
|
||||
uses
|
||||
Math, DateUtils,
|
||||
VpException, VpConst, VpMisc, VpBaseDS,
|
||||
VpImportPreview_ICalEvent, VpImportPreview_ICalTask;
|
||||
VpImportPreview_ICalEvent, VpImportPreview_ICalTask, VpImportPreview_VCard;
|
||||
|
||||
const
|
||||
TIME_EPS = 1.0 / SecondsInDay; // Epsilon for comparing times
|
||||
@ -2792,6 +2795,68 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TVpContacts.ImportVCardFile(const AFileName: String;
|
||||
const APreview: Boolean = false): TVpContactArr;
|
||||
const
|
||||
BLOCK_SIZE = 10;
|
||||
var
|
||||
vCards: TVpVCards;
|
||||
lContact: TVpContact;
|
||||
contactCounter: Integer;
|
||||
i: Integer;
|
||||
id: Integer;
|
||||
datastore: TVpCustomDatastore;
|
||||
previewForm: TVpImportPreviewVCardForm;
|
||||
begin
|
||||
Result := nil;
|
||||
SetLength(Result, BLOCK_SIZE);
|
||||
contactCounter := 0;
|
||||
|
||||
datastore := Owner.Owner.Owner as TVpCustomDatastore;
|
||||
|
||||
vcards := TVpVCards.Create;
|
||||
try
|
||||
vCards.LoadFromFile(AFileName);
|
||||
if vCards.Count = 0 then
|
||||
begin
|
||||
MessageDlg(Format(RSNoContactsFoundInVCARD, [AFileName]), mtInformation, [mbOK], 0);
|
||||
SetLength(Result, 0);
|
||||
exit;
|
||||
end;
|
||||
if APreview then
|
||||
begin
|
||||
previewForm := TVPImportPreviewVCardForm.Create(nil);
|
||||
previewForm.Position := poMainFormcenter;
|
||||
previewForm.VCards := vCards;
|
||||
if not previewForm.Execute then
|
||||
begin
|
||||
SetLength(Result, 0);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
for i := 0 to vcards.Count-1 do begin
|
||||
if vCards[i].Skip then
|
||||
Continue;
|
||||
id := datastore.GetNextID(ContactsTableName);
|
||||
lContact := AddContact(id);
|
||||
lContact.LoadFromVCard(vcards[i]);
|
||||
Result[contactCounter] := lContact;
|
||||
inc(contactCounter);
|
||||
if contactCounter mod BLOCK_SIZE = 0 then
|
||||
SetLength(Result, contactCounter + BLOCK_SIZE);
|
||||
end;
|
||||
|
||||
SetLength(Result, contactCounter);
|
||||
if Length(Result) = 0 then
|
||||
MessageDlg(Format(RSNoContactsFoundInVCARD, [AFileName]), mtInformation, [mbOK], 0);
|
||||
finally
|
||||
if APreview then
|
||||
previewForm.Free;
|
||||
vCards.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
(*****************************************************************************)
|
||||
{ TVpTask }
|
||||
@ -3022,6 +3087,7 @@ begin
|
||||
if ical.ToDoCount = 0 then
|
||||
begin
|
||||
MessageDlg(Format(RSNoTaskItemsFoundInICAL, [AFileName]), mtInformation, [mbOK], 0);
|
||||
SetLength(Result, 0);
|
||||
exit;
|
||||
end;
|
||||
if APreview then
|
||||
|
41
components/tvplanit/source/vpimportpreview_vcard.lfm
Normal file
41
components/tvplanit/source/vpimportpreview_vcard.lfm
Normal file
@ -0,0 +1,41 @@
|
||||
inherited VpImportPreviewVCardForm: TVpImportPreviewVCardForm
|
||||
Height = 400
|
||||
Width = 667
|
||||
Caption = ''
|
||||
ClientHeight = 400
|
||||
ClientWidth = 667
|
||||
inherited Grid: TDrawGrid
|
||||
Height = 363
|
||||
Width = 667
|
||||
Columns = <
|
||||
item
|
||||
Alignment = taCenter
|
||||
ButtonStyle = cbsCheckboxColumn
|
||||
PickList.Strings = ( )
|
||||
SizePriority = 0
|
||||
Title.Caption = ''
|
||||
Width = 33
|
||||
end
|
||||
item
|
||||
PickList.Strings = ( )
|
||||
ReadOnly = True
|
||||
Title.Caption = 'Items'
|
||||
Width = 634
|
||||
end>
|
||||
ColWidths = (
|
||||
33
|
||||
634
|
||||
)
|
||||
end
|
||||
inherited ButtonPanel: TPanel
|
||||
Top = 369
|
||||
Width = 655
|
||||
ClientWidth = 655
|
||||
inherited btnExecute: TButton
|
||||
Left = 439
|
||||
end
|
||||
inherited btnCancel: TButton
|
||||
Left = 580
|
||||
end
|
||||
end
|
||||
end
|
5
components/tvplanit/source/vpimportpreview_vcard.lrj
Normal file
5
components/tvplanit/source/vpimportpreview_vcard.lrj
Normal file
@ -0,0 +1,5 @@
|
||||
{"version":1,"strings":[
|
||||
{"hash":4294967295,"name":"tvpimportpreviewvcardform.caption","sourcebytes":[],"value":""},
|
||||
{"hash":4294967295,"name":"tvpimportpreviewvcardform.grid.columns[0].title.caption","sourcebytes":[],"value":""},
|
||||
{"hash":5286979,"name":"tvpimportpreviewvcardform.grid.columns[1].title.caption","sourcebytes":[73,116,101,109,115],"value":"Items"}
|
||||
]}
|
150
components/tvplanit/source/vpimportpreview_vcard.pas
Normal file
150
components/tvplanit/source/vpimportpreview_vcard.pas
Normal file
@ -0,0 +1,150 @@
|
||||
unit VpImportPreview_VCard;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs,
|
||||
VpData, VpBaseDS, VpImportPreview, VpVCard;
|
||||
|
||||
type
|
||||
|
||||
{ TVpImportPreviewVCardForm }
|
||||
|
||||
TVpImportPreviewVCardForm = class(TVpImportPreviewForm)
|
||||
private
|
||||
FVCards: TVpVCards;
|
||||
FDatastore: TVpCustomDatastore;
|
||||
function GetCardText(ACard: TVpVCard): String;
|
||||
procedure SetVCards(const AValue: TVpVCards);
|
||||
|
||||
protected
|
||||
function GetCellText(ACol, ARow: Integer): String; override;
|
||||
procedure PrepareItems; override;
|
||||
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
procedure CheckItem(ARow: Integer; AChecked: Boolean); override;
|
||||
function IsChecked(ARow: Integer): Boolean; override;
|
||||
property VCards: TVpVCards read FVCards write SetVCards;
|
||||
property Datastore: TVpCustomDatastore read FDatastore write FDatastore;
|
||||
end;
|
||||
|
||||
var
|
||||
VpImportPreviewVCardForm: TVpImportPreviewVCardForm;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
VpSR;
|
||||
|
||||
constructor TVPImportPreviewVCardForm.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited;
|
||||
Caption := RSImportVCard;
|
||||
end;
|
||||
|
||||
procedure TVpImportPreviewVCardForm.CheckItem(ARow: Integer; AChecked: Boolean);
|
||||
var
|
||||
card: TVpVCard;
|
||||
begin
|
||||
if ARow < Grid.FixedRows then
|
||||
exit;
|
||||
card := TVpVCard(FItems[ARow - Grid.FixedRows]);
|
||||
if card <> nil then
|
||||
card.Skip := not AChecked;
|
||||
end;
|
||||
|
||||
function TVpImportPreviewVCardForm.GetCellText(ACol, ARow: Integer): String;
|
||||
var
|
||||
card: TVpVCard;
|
||||
begin
|
||||
Result := '';
|
||||
if (ACol = 1) and (ARow >= Grid.FixedRows) then
|
||||
begin
|
||||
card := TVpVCard(FItems[ARow - Grid.FixedRows]);
|
||||
if card <> nil then
|
||||
Result := GetCardText(card);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TVpImportPreviewVCardForm.GetCardText(ACard: TVpVCard): String;
|
||||
var
|
||||
s: String;
|
||||
begin
|
||||
Result := ACard.GetFullName;
|
||||
|
||||
s := ACard.GetWorkAddress;
|
||||
if s <> '' then
|
||||
Result := Result + LineEnding + 'Work address: ' + s;
|
||||
|
||||
s := ACard.GetHomeAddress;
|
||||
if s <> '' then
|
||||
Result := Result + LineEnding + 'Home address: ' + s;
|
||||
|
||||
s := ACard.GetPhone;
|
||||
if s <> '' then
|
||||
Result := Result + LineEnding + 'Phone: ' + s;
|
||||
|
||||
s := ACard.GetEMail;
|
||||
if s <> '' then
|
||||
Result := Result + LineEnding + 'E-Mail: ' + s;
|
||||
|
||||
(*
|
||||
Result := RSDescriptionLbl + ' ' + AToDo.Summary + LineEnding +
|
||||
RSDueDateLabel + ' ' + FormatDateTime(FTimeFormat, AToDo.DueTime[false]) + LineEnding +
|
||||
RSCreatedOn + ' ' + FormatDateTime(FTimeFormat, AToDo.StartTime[false]);
|
||||
|
||||
case TVpTask.GetTaskPriority(AToDo.Priority) of
|
||||
tpLow: s := RSLow;
|
||||
tpNormal: s := RSNormal;
|
||||
tpHigh: s := RSHigh;
|
||||
end;
|
||||
Result := Result + LineEnding + RSPriorityLabel + ' ' + s + LineEnding + RSCategoryLabel + ' ';
|
||||
|
||||
if Assigned(FDatastore) then
|
||||
begin
|
||||
cat := FDatastore.FindBestTaskCategory(AToDo.Categories);
|
||||
if cat = '' then cat := FDefaultCategory;
|
||||
Result := Result + cat;
|
||||
end;
|
||||
*)
|
||||
end;
|
||||
|
||||
function TVpImportPreviewVCardForm.IsChecked(ARow: Integer): Boolean;
|
||||
var
|
||||
card: TVpVCard;
|
||||
begin
|
||||
Result := false;
|
||||
if ARow < Grid.FixedRows then
|
||||
exit;
|
||||
card := TVpVCard(FItems[ARow - Grid.FixedRows]);
|
||||
if (card <> nil) then
|
||||
Result := not card.Skip;
|
||||
end;
|
||||
|
||||
procedure TVpImportPreviewVCardForm.PrepareItems;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
FItems.Clear;
|
||||
if FVCards <> nil then
|
||||
for i := 0 to FVCards.Count-1 do
|
||||
FItems.Add(FVCards.Card[i]);
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TVpImportPreviewVCardForm.SetVCards(const AValue: TVpVCards);
|
||||
begin
|
||||
if AValue <> FVCards then
|
||||
begin
|
||||
FVCards := AValue;
|
||||
PrepareItems;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -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