📄 addrbk.pas
字号:
(*
# (C) Copyright 2003
# Miha Vrhovnik, miha.vrhovnik@guest.arnes.si
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
# The Initial Developer of the Original Code is Miha Vrhovnik (Slovenia).
# Portions created by Miha Vrhovnik are Copyright (c)2000-2003.
# All Rights Reserved.
#==============================================================================
# Contributor(s):
#==============================================================================
# History: see whats new.txt from distribution package
#==============================================================================
*)
unit addrBk;
interface
uses Classes, SysUtils, Windows, OmniXML, OmniMyXMLPersistent;
//all this classes form the xml Tree structure
type TGender = (geUnspecifed, geMale, geFemale);
type TGeneral = class(TPersistent)
private
FMiddleName: String;
FFirstName: String;
FNickName: String;
FPhotoName: String;
FLastName: String;
FGender: TGender;
public
procedure Assign(Source: TPersistent); override;
published
property FirstName: String read FFirstName write FFirstName;
property MiddleName: String read FMiddleName write FMiddleName;
property LastName: String read FLastName write FLastName;
property NickName: String read FNickName write FNickName;
property Gender: TGender read FGender write FGender;
property PhotoName: String read FPhotoName write FPhotoName;
end;
type TChat = class(TCollectionItem)
private
FApplication: String;
FID: String;
public
procedure Assign(Source: TPersistent); override;
published
property Application: String read FApplication write FApplication;
property ID: String read FID write FID;
end;
type TChats = class(TCollection)
private
function GetChat(Index: Integer): TChat;
procedure SetChat(Index: Integer; const Value: TChat);
public
property Chats[Index: Integer]: TChat read GetChat write SetChat;
function Add(app, id: String): TChat;
function FindItemID(ID: Integer): TChat;
function FindItem(Value: TChat): Integer;
function Insert(Index: Integer): TChat;
published
end;
type TPersonal = class(TPersistent)
private
FCustomFieldLabel2: String;
FCustomField4: String;
FCustomFieldLabel3: String;
FCustomFieldLabel4: String;
FCustomFieldLabel1: String;
FCustomField2: String;
FCustomField3: String;
FCustomField1: String;
FChats: TChats;
FAnniversary: TDateTime;
FBirthday: TDateTime;
public
constructor Create;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
published
property Birthday: TDateTime read FBirthday write FBirthday;
property Anniversary: TDateTime read FAnniversary write FAnniversary;
property CustomField1: String read FCustomField1 write FCustomField1;
property CustomField2: String read FCustomField2 write FCustomField2;
property CustomField3: String read FCustomField3 write FCustomField3;
property CustomField4: String read FCustomField4 write FCustomField4;
property CustomFieldLabel1: String read FCustomFieldLabel1 write FCustomFieldLabel1;
property CustomFieldLabel2: String read FCustomFieldLabel2 write FCustomFieldLabel2;
property CustomFieldLabel3: String read FCustomFieldLabel3 write FCustomFieldLabel3;
property CustomFieldLabel4: String read FCustomFieldLabel4 write FCustomFieldLabel4;
property Chats: TChats read FChats;
end;
type THome = class(TPersistent)
private
FExtension: String;
FTelephone: String;
FCountry: String;
FHomepage: String;
FPager: String;
FFax: String;
FStreet: String;
FMobile: String;
FZIP: String;
FState: String;
public
procedure Assign(Source: TPersistent); override;
published
property Telephone: String read FTelephone write FTelephone;
property Extension: String read FExtension write FExtension;
property Mobile: String read FMobile write FMobile;
property Fax: String read FFax write FFax;
property Pager: String read FPager write FPager;
property Street: String read FStreet write FStreet;
property ZIP: String read FZIP write FZIP;
property State: String read FState write FState;
property Country: String read FCountry write FCountry;
property Homepage: String read FHomepage write FHomepage;
end;
type TWork = class(THome)
private
FJobTitle: String;
FCompanyName: String;
FDepartment: String;
public
procedure Assign(Source: TPersistent); override;
published
property CompanyName: String read FCompanyName write FCompanyName;
property JobTitle: String read FJobTitle write FJobTitle;
property Department: String read FDepartment write FDepartment;
end;
type TEmail = class(TCollectionItem)
private
FEmail: String;
public
procedure Assign(Source: TPersistent); override;
published
property Email: String read FEmail write FEmail;
end;
type TEmails = class(TCollection)
private
function GetEmail(Index: Integer): TEmail;
procedure SetEmail(Index: Integer; const Value: TEmail);
public
property Emails[Index: Integer]: TEmail read GetEmail write SetEmail;
function Add: TEmail;
function FindItemID(ID: Integer): TEmail;
function FindItem(Value: TEmail): Integer;
function Insert(Index: Integer): TEmail;
published
end;
type TPerson = class(TCollectionItem)
private
Fid: Integer;
FNotes: String;
FGeneral: TGeneral;
FHome: THome;
FPersonal: TPersonal;
FWork: TWork;
FEmails: TEmails;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
procedure Delete;
procedure Assign(Source: TPersistent); override;
published
property id: Integer read Fid write Fid;
property Notes: String read FNotes write FNotes;
property General: TGeneral read FGeneral write FGeneral;
property Personal: TPersonal read FPersonal write FPersonal;
property Work: TWork read FWork write FWork;
property Home: THome read FHome write FHome;
property Emails: TEmails read FEmails write FEmails;
end;
type TPersons = class(TCollection)
private
FLastID: Integer;
function GetPerson(Index: Integer): TPerson;
procedure SetPerson(Index: Integer; const Value: TPerson);
public
property Persons[Index: Integer]: TPerson read GetPerson write SetPerson;
function Add: TPerson;
function FindItemID(ID: Integer): TPerson;
function FindItem(Value: TPerson): Integer;
function Insert(Index: Integer): TPerson;
published
property LastID: Integer read FLastID write FLastID;
end;
type TAddressBook = class(TCollectionItem)
private
FPersons: TPersons;
FBookName: String;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
procedure Delete;
published
property BookName: String read FBookName write FBookName;
property Persons: TPersons read FPersons write FPersons;
end;
type TAddressBooks = class(TCollection)
private
FFileName: String;
FPicturesPath: String;
FCertificatesPath: String;
FDirty: Boolean;
function GetAddressBook(Index: Integer): TAddressBook;
procedure SetAddressBook(Index: Integer; const Value: TAddressBook);
public
property AddressBooks[Index: Integer]: TAddressBook read GetAddressBook write SetAddressBook;
function Add(addrBkName: String): TAddressBook;
function FindItemID(ID: Integer): TAddressBook;
function FindItem(Value: TAddressBook): Integer;
function Insert(Index: Integer): TAddressBook;
procedure Load;
procedure Save;
function GetNoForName(bookName: String): Integer;
constructor Create(fileName: String);
//this properties has to be public otherwise they will be saved to file
property PicturesPath: String read FPicturesPath;
property CertificatesPath: String read FCertificatesPath;
property Dirty: Boolean read FDirty write FDirty;
published
end;
implementation
{ TChats }
function TChats.Add(app, id: String): TChat;
begin
Result := (inherited Add) as TChat;
Result.Application := app;
Result.ID := id;
end;
function TChats.FindItemID(ID: Integer): TChat;
begin
Result := (inherited FindItemID(ID)) as TChat;
end;
function TChats.Insert(Index: Integer): TChat;
begin
Result := (inherited Insert(Index)) as TChat;
end;
function TChats.GetChat(Index: Integer): TChat;
begin
Result := (inherited GetItem(Index)) as TChat;
end;
procedure TChats.SetChat(Index: Integer; const Value: TChat);
begin
inherited SetItem(Index, Value);
end;
function TChats.FindItem(Value: TChat): Integer;
var i: Integer;
begin
Result := -1;
for i := 0 to Count - 1 do begin
if Chats[i] = Value then begin
Result := i;
break;
end;
end;
end;
{ TEmails }
function TEmails.Add: TEmail;
begin
Result := (inherited Add) as TEmail;
end;
function TEmails.FindItemID(ID: Integer): TEmail;
begin
Result := (inherited FindItemID(ID)) as TEmail;
end;
function TEmails.Insert(Index: Integer): TEmail;
begin
Result := (inherited Insert(Index)) as TEmail;
end;
function TEmails.GetEmail(Index: Integer): TEmail;
begin
Result := (inherited GetItem(Index)) as TEmail;
end;
procedure TEmails.SetEmail(Index: Integer; const Value: TEmail);
begin
inherited SetItem(Index, Value);
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -