summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--extras/tiopf/demos/Demo_21_AdrsBook_MGM/contactmanager.pas17
-rw-r--r--extras/tiopf/demos/Demo_21_AdrsBook_MGM/demo_adrsbook_mgm.lpi7
-rw-r--r--extras/tiopf/demos/Demo_21_AdrsBook_MGM/demo_adrsbook_mgm.lpr2
-rw-r--r--extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmaddressmaint.pas269
-rw-r--r--extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmcitylist.pas2
-rw-r--r--extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmcitymaint.pas5
-rw-r--r--extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmcontactmaint.pas28
-rw-r--r--extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmcountrylist.pas3
-rw-r--r--extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmmain.pas24
-rw-r--r--extras/tiopf/demos/Demo_21_AdrsBook_MGM/model.pas76
10 files changed, 376 insertions, 57 deletions
diff --git a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/contactmanager.pas b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/contactmanager.pas
index 94c876ee..7e764460 100644
--- a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/contactmanager.pas
+++ b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/contactmanager.pas
@@ -15,6 +15,7 @@ type
TContactManager = class(TMarkObject)
private
+ FAddressTypeList: TAddressTypeList;
FCityList: TCityList;
FContactList: TContactList;
FCountryList: TCountryList;
@@ -26,6 +27,7 @@ type
destructor Destroy; override;
procedure PopulateContacts;
published
+ property AddressTypeList: TAddressTypeList read FAddressTypeList;
property CountryList: TCountryList read FCountryList;
property CityList: TCityList read FCityList;
property ContactList: TContactList read FContactList;
@@ -166,12 +168,14 @@ end;
constructor TContactManager.Create;
begin
inherited Create;
- FCountryList:= TCountryList.Create;
- FCountryList.Owner:= self;
- FCityList:= TCityList.Create;
- FCityList.Owner:= self;
- FContactList:= TContactList.Create;
- FContactList.Owner:= self;
+ FAddressTypeList := TAddressTypeList.Create;
+ FAddressTypeList.Owner := self;
+ FCountryList := TCountryList.Create;
+ FCountryList.Owner := self;
+ FCityList := TCityList.Create;
+ FCityList.Owner := self;
+ FContactList := TContactList.Create;
+ FContactList.Owner := self;
end;
destructor TContactManager.Destroy;
@@ -179,6 +183,7 @@ begin
FContactList.Free;
FCityList.Free;
FCountryList.Free;
+ FAddressTypeList.Free;
inherited Destroy;
end;
diff --git a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/demo_adrsbook_mgm.lpi b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/demo_adrsbook_mgm.lpi
index 6a4a1600..7139239e 100644
--- a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/demo_adrsbook_mgm.lpi
+++ b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/demo_adrsbook_mgm.lpi
@@ -32,7 +32,7 @@
<PackageName Value="tiOPFfpGUI"/>
</Item1>
</RequiredPackages>
- <Units Count="8">
+ <Units Count="9">
<Unit0>
<Filename Value="demo_adrsbook_mgm.lpr"/>
<IsPartOfProject Value="True"/>
@@ -73,6 +73,11 @@
<IsPartOfProject Value="True"/>
<UnitName Value="frmCountryList"/>
</Unit7>
+ <Unit8>
+ <Filename Value="frmaddressmaint.pas"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="frmAddressMaint"/>
+ </Unit8>
</Units>
</ProjectOptions>
<CompilerOptions>
diff --git a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/demo_adrsbook_mgm.lpr b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/demo_adrsbook_mgm.lpr
index c9fe0fff..f062e4d8 100644
--- a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/demo_adrsbook_mgm.lpr
+++ b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/demo_adrsbook_mgm.lpr
@@ -7,7 +7,7 @@ uses
cthreads,
{$ENDIF}{$ENDIF}
Classes, fpgfx, frmmain, frmcontactmaint, frmCityList, frmcitymaint,
- frmcountrylist;
+ frmcountrylist, frmaddressmaint;
diff --git a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmaddressmaint.pas b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmaddressmaint.pas
new file mode 100644
index 00000000..1b042cd9
--- /dev/null
+++ b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmaddressmaint.pas
@@ -0,0 +1,269 @@
+unit frmAddressMaint;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ SysUtils, Classes, gfxbase, fpgfx, gui_edit,
+ gfx_widget, gui_form, gui_label, gui_button,
+ gui_listbox, gui_memo, gui_combobox, gui_basegrid, gui_grid,
+ gui_dialogs, gui_checkbox, gui_tree, gui_trackbar,
+ gui_progressbar, gui_radiobutton, gui_tab, gui_menu,
+ gui_panel, gui_popupcalendar, gui_gauge,
+ model, tiFormMediator;
+
+type
+ TAddressEditForm = class(TfpgForm)
+ private
+ {@VFD_HEAD_BEGIN: AddressEditForm}
+ cbType: TfpgComboBox;
+ edNo: TfpgEdit;
+ edStreet: TfpgEdit;
+ cbCity: TfpgComboBox;
+ edPhone1: TfpgEdit;
+ edPhone2: TfpgEdit;
+ edFax: TfpgEdit;
+ lblName1: TfpgLabel;
+ lblName2: TfpgLabel;
+ lblName3: TfpgLabel;
+ lblName4: TfpgLabel;
+ lblName5: TfpgLabel;
+ lblName6: TfpgLabel;
+ lblName7: TfpgLabel;
+ btnSave: TfpgButton;
+ btnCancel: TfpgButton;
+ {@VFD_HEAD_END: AddressEditForm}
+ FData: TAddress;
+ FMediator: TFormMediator;
+ procedure SetData(const AValue: TAddress);
+ procedure SetupMediators;
+ public
+ procedure AfterCreate; override;
+ property Data: TAddress read FData write SetData;
+ end;
+
+{@VFD_NEWFORM_DECL}
+
+function EditAddress(AData: TAddress): Boolean;
+
+implementation
+
+uses
+ tiListMediators, tiMediators, contactmanager;
+
+
+function EditAddress(AData: TAddress): Boolean;
+var
+ frm: TAddressEditForm;
+begin
+ frm:= TAddressEditForm.Create(nil);
+ try
+ frm.SetData(AData);
+ result:= frm.ShowModal = mrOK;
+ finally
+ frm.Free;
+ end;
+end;
+
+{@VFD_NEWFORM_IMPL}
+
+procedure TAddressEditForm.SetData(const AValue: TAddress);
+begin
+ if FData=AValue then exit;
+ FData:=AValue;
+ SetupMediators;
+end;
+
+procedure TAddressEditForm.SetupMediators;
+begin
+ if not Assigned(FMediator) then
+ begin
+ FMediator := TFormMediator.Create(self);
+ FMediator.AddProperty('AddressType', cbType).ValueList := gContactManager.AddressTypeList;
+ FMediator.AddProperty('Nr', edNo);
+ FMediator.AddProperty('Street', edStreet);
+ FMediator.AddProperty('City', cbCity).ValueList := gContactManager.CityList;
+ FMediator.AddProperty('Telephone1', edPhone1);
+ FMediator.AddProperty('Telephone2', edPhone2);
+ FMediator.AddProperty('Fax', edFax);
+ end;
+ FMediator.Subject := FData;
+ FMediator.Active := True;
+end;
+
+procedure TAddressEditForm.AfterCreate;
+begin
+ {@VFD_BODY_BEGIN: AddressEditForm}
+ Name := 'AddressEditForm';
+ SetPosition(300, 231, 296, 282);
+ WindowTitle := 'Address Edit Form';
+
+ cbType := TfpgComboBox.Create(self);
+ with cbType do
+ begin
+ Name := 'cbType';
+ SetPosition(8, 24, 272, 22);
+ FontDesc := '#List';
+ end;
+
+ edNo := TfpgEdit.Create(self);
+ with edNo do
+ begin
+ Name := 'edNo';
+ SetPosition(8, 68, 56, 22);
+ TabOrder := 1;
+ Text := '';
+ FontDesc := '#Edit1';
+ end;
+
+ edStreet := TfpgEdit.Create(self);
+ with edStreet do
+ begin
+ Name := 'edStreet';
+ SetPosition(76, 68, 204, 22);
+ TabOrder := 2;
+ Text := '';
+ FontDesc := '#Edit1';
+ end;
+
+ cbCity := TfpgComboBox.Create(self);
+ with cbCity do
+ begin
+ Name := 'cbCity';
+ SetPosition(8, 112, 272, 22);
+ FontDesc := '#List';
+ TabOrder := 3;
+ end;
+
+ edPhone1 := TfpgEdit.Create(self);
+ with edPhone1 do
+ begin
+ Name := 'edPhone1';
+ SetPosition(8, 160, 120, 22);
+ TabOrder := 4;
+ Text := '';
+ FontDesc := '#Edit1';
+ end;
+
+ edPhone2 := TfpgEdit.Create(self);
+ with edPhone2 do
+ begin
+ Name := 'edPhone2';
+ SetPosition(160, 160, 120, 22);
+ TabOrder := 5;
+ Text := '';
+ FontDesc := '#Edit1';
+ end;
+
+ edFax := TfpgEdit.Create(self);
+ with edFax do
+ begin
+ Name := 'edFax';
+ SetPosition(8, 204, 120, 22);
+ TabOrder := 6;
+ Text := '';
+ FontDesc := '#Edit1';
+ end;
+
+ lblName1 := TfpgLabel.Create(self);
+ with lblName1 do
+ begin
+ Name := 'lblName1';
+ SetPosition(76, 52, 120, 16);
+ FontDesc := '#Label1';
+ Hint := '';
+ Text := 'Street:';
+ end;
+
+ lblName2 := TfpgLabel.Create(self);
+ with lblName2 do
+ begin
+ Name := 'lblName2';
+ SetPosition(8, 52, 60, 16);
+ FontDesc := '#Label1';
+ Hint := '';
+ Text := 'Number:';
+ end;
+
+ lblName3 := TfpgLabel.Create(self);
+ with lblName3 do
+ begin
+ Name := 'lblName3';
+ SetPosition(8, 144, 120, 16);
+ FontDesc := '#Label1';
+ Hint := '';
+ Text := 'Telephone #1:';
+ end;
+
+ lblName4 := TfpgLabel.Create(self);
+ with lblName4 do
+ begin
+ Name := 'lblName4';
+ SetPosition(160, 144, 112, 16);
+ FontDesc := '#Label1';
+ Hint := '';
+ Text := 'Telephone #2:';
+ end;
+
+ lblName5 := TfpgLabel.Create(self);
+ with lblName5 do
+ begin
+ Name := 'lblName5';
+ SetPosition(8, 188, 80, 16);
+ FontDesc := '#Label1';
+ Hint := '';
+ Text := 'Fax:';
+ end;
+
+ lblName6 := TfpgLabel.Create(self);
+ with lblName6 do
+ begin
+ Name := 'lblName6';
+ SetPosition(8, 8, 80, 16);
+ FontDesc := '#Label1';
+ Hint := '';
+ Text := 'Type:';
+ end;
+
+ lblName7 := TfpgLabel.Create(self);
+ with lblName7 do
+ begin
+ Name := 'lblName7';
+ SetPosition(8, 96, 80, 16);
+ FontDesc := '#Label1';
+ Hint := '';
+ Text := 'City:';
+ end;
+
+ btnSave := TfpgButton.Create(self);
+ with btnSave do
+ begin
+ Name := 'btnSave';
+ SetPosition(124, 248, 80, 24);
+ Text := 'Save';
+ FontDesc := '#Label1';
+ Hint := '';
+ ImageName := '';
+ TabOrder := 7;
+ ModalResult := mrOK;
+ end;
+
+ btnCancel := TfpgButton.Create(self);
+ with btnCancel do
+ begin
+ Name := 'btnCancel';
+ SetPosition(208, 248, 80, 24);
+ Text := 'Cancel';
+ FontDesc := '#Label1';
+ Hint := '';
+ ImageName := '';
+ TabOrder := 8;
+ ModalResult := mrCancel;
+ end;
+
+ {@VFD_BODY_END: AddressEditForm}
+end;
+
+
+end.
diff --git a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmcitylist.pas b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmcitylist.pas
index 81a7b415..37143a72 100644
--- a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmcitylist.pas
+++ b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmcitylist.pas
@@ -117,6 +117,7 @@ begin
Text := 'Add';
FontDesc := '#Label1';
ImageName := '';
+ Enabled := False;
end;
btnEdit := TfpgButton.Create(bvlName1);
@@ -140,6 +141,7 @@ begin
FontDesc := '#Label1';
ImageName := '';
TabOrder := 2;
+ Enabled := False;
end;
grdName1 := TfpgStringGrid.Create(self);
diff --git a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmcitymaint.pas b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmcitymaint.pas
index 64aa988d..d2f281a0 100644
--- a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmcitymaint.pas
+++ b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmcitymaint.pas
@@ -43,7 +43,7 @@ function EditCity(AData: TCity): boolean;
implementation
uses
- tiBaseMediator, tiMediators, contactmanager, typinfo, tiDialogs;
+ tiBaseMediator, contactmanager, typinfo, tiDialogs;
function EditCity(AData: TCity): boolean;
@@ -72,9 +72,6 @@ procedure TCityEditForm.SetupMediators;
begin
if not Assigned(FMediator) then
begin
- RegisterFallBackMediators;
- gMediatorManager.RegisterMediator(TMediatorDynamicComboBoxView, TCity, 'Country');
-
FMediator := TFormMediator.Create(self);
FMediator.AddProperty('Name', edName);
FMediator.AddProperty('ZIP', edZIP);
diff --git a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmcontactmaint.pas b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmcontactmaint.pas
index e414937c..f78dc0f3 100644
--- a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmcontactmaint.pas
+++ b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmcontactmaint.pas
@@ -8,14 +8,12 @@ uses
SysUtils, Classes, gfxbase, fpgfx, gui_edit,
gfx_widget, gui_form, gui_label, gui_button,
gui_listview, gui_memo,
- model, tiFormMediator,
- tiMediators;
+ model, tiFormMediator;
type
TContactEditForm = class(TfpgForm)
private
- FData: TContact;
{@VFD_HEAD_BEGIN: ContactEditForm}
lblName1: TfpgLabel;
edFName: TfpgEdit;
@@ -36,11 +34,13 @@ type
btnDelete: TfpgButton;
btnDebug: TfpgButton;
{@VFD_HEAD_END: ContactEditForm}
+ FData: TContact;
FMediator: TFormMediator;
FAdrsMediator: TFormMediator;
procedure SetData(const AValue: TContact);
procedure SetupMediators;
procedure btnDebugClicked(Sender: TObject);
+ procedure btnEditClicked(Sender: TObject);
public
procedure AfterCreate; override;
property Data: TContact read FData write SetData;
@@ -54,7 +54,7 @@ function EditContact(AData: TContact): Boolean;
implementation
uses
- contactmanager, tiDialogs;
+ contactmanager, tiDialogs, frmAddressMaint, tiListMediators;
function EditContact(AData: TContact): Boolean;
@@ -77,7 +77,6 @@ procedure TContactEditForm.SetupMediators;
begin
if not Assigned(FMediator) then
begin
- RegisterFallBackMediators;
FMediator := TFormMediator.Create(self);
FMediator.AddProperty('FirstName', edFName);
FMediator.AddProperty('LastName', edLName);
@@ -102,6 +101,22 @@ begin
tiShowString(FData.AsDebugString);
end;
+procedure TContactEditForm.btnEditClicked(Sender: TObject);
+var
+ obj: TAddress;
+begin
+ obj := TAddress(TListViewMediator(FAdrsMediator.FindByComponent(lvAddresses).Mediator).SelectedObject);
+// tiShowString(obj.AsDebugString);
+
+ if not Assigned(obj) then
+ Exit; //==>
+
+ if EditAddress(obj) then
+ begin
+ // do nothing
+ end;
+end;
+
procedure TContactEditForm.SetData(const AValue: TContact);
begin
if FData=AValue then exit;
@@ -271,6 +286,7 @@ begin
Hint := '';
ImageName := '';
TabOrder := 14;
+ Enabled := False;
end;
btnEdit := TfpgButton.Create(self);
@@ -283,6 +299,7 @@ begin
Hint := '';
ImageName := '';
TabOrder := 15;
+ OnClick := @btnEditClicked;
end;
btnDelete := TfpgButton.Create(self);
@@ -295,6 +312,7 @@ begin
Hint := '';
ImageName := '';
TabOrder := 16;
+ Enabled := False;
end;
btnDebug := TfpgButton.Create(self);
diff --git a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmcountrylist.pas b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmcountrylist.pas
index e38f7082..104e8137 100644
--- a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmcountrylist.pas
+++ b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmcountrylist.pas
@@ -109,6 +109,7 @@ begin
FontDesc := '#Label1';
Hint := '';
ImageName := '';
+ Enabled := False;
end;
btnEdit := TfpgButton.Create(bvlName1);
@@ -122,6 +123,7 @@ begin
ImageName := '';
TabOrder := 1;
OnClick := @btnEditClicked;
+ Enabled := False;
end;
btnDelete := TfpgButton.Create(bvlName1);
@@ -134,6 +136,7 @@ begin
Hint := '';
ImageName := '';
TabOrder := 2;
+ Enabled := False;
end;
grdName1 := TfpgStringGrid.Create(self);
diff --git a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmmain.pas b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmmain.pas
index e373eb90..df6edbf1 100644
--- a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmmain.pas
+++ b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmmain.pas
@@ -32,6 +32,7 @@ type
procedure miEditDeleteClick(Sender: TObject);
procedure miSystemCityList(Sender: TObject);
procedure miSystemCountryList(Sender: TObject);
+ procedure miSystemAddressTypeList(Sender: TObject);
procedure miFileExit(Sender: TObject);
public
procedure AfterCreate; override;
@@ -44,8 +45,8 @@ type
implementation
uses
- model, contactmanager, tiListMediators, tiBaseMediator, frmcontactmaint,
- frmcitylist, frmcountrylist;
+ model, contactmanager, tiListMediators, tiBaseMediator, tiMediators,
+ frmcontactmaint, frmcitylist, frmcountrylist;
{@VFD_NEWFORM_IMPL}
@@ -66,8 +67,14 @@ begin
end;
procedure TMainForm.miEditAddClick(Sender: TObject);
+var
+ c: TContact;
begin
- //
+ c := TContact.CreateNew;
+ if EditContact(c) then
+ gContactManager.ContactList.Add(c)
+ else
+ c.Free;
end;
procedure TMainForm.miEditEditClick(Sender: TObject);
@@ -101,6 +108,11 @@ begin
ShowCountries(gContactManager.CountryList);
end;
+procedure TMainForm.miSystemAddressTypeList(Sender: TObject);
+begin
+ // ShowAddressTypeList(gContactManager.AddressTypeList);
+end;
+
procedure TMainForm.miFileExit(Sender: TObject);
begin
Close;
@@ -160,6 +172,7 @@ begin
ImageName := '';
TabOrder := 3;
OnClick := @miEditDeleteClick;
+ Enabled := False;
end;
MainMenu := TfpgMenuBar.Create(self);
@@ -195,6 +208,7 @@ begin
SetPosition(344, 176, 120, 20);
AddMenuItem('City List', '', @miSystemCityList);
AddMenuItem('Country List', '', @miSystemCountryList);
+ AddMenuItem('Address Type List', '', @miSystemAddressTypeList).Enabled := False;
end;
{@VFD_BODY_END: MainForm}
@@ -220,9 +234,13 @@ end;
initialization
+ RegisterFallBackMediators;
+
gMediatorManager.RegisterMediator(TStringGridMediator, TContactList);
gMediatorManager.RegisterMediator(TListViewMediator, TAddressList);
gMediatorManager.RegisterMediator(TStringGridMediator, TCityList);
gMediatorManager.RegisterMediator(TStringGridMediator, TCountryList);
+ gMediatorManager.RegisterMediator(TMediatorDynamicComboBoxView, TCity, 'Country');
+ gMediatorManager.RegisterMediator(TMediatorDynamicComboBoxView, TAddressType, 'AddressType');
end.
diff --git a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/model.pas b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/model.pas
index 147213e1..54f95b02 100644
--- a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/model.pas
+++ b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/model.pas
@@ -14,24 +14,18 @@ uses
type
- { TMarkObject }
-
TMarkObject = class(TtiObject)
protected
procedure Mark;
end;
- { TMarkObjectList }
-
TMarkObjectList = class(TtiObjectList)
protected
procedure Mark;
end;
- { TCountry }
-
TCountry = class(TMarkObject)
private
FISO: string;
@@ -48,8 +42,6 @@ type
end;
- { TCountryList }
-
TCountryList = class(TMarkObjectList)
protected
function GetItems(i: integer): TCountry; reintroduce;
@@ -60,8 +52,6 @@ type
end;
- { TCity }
-
TCity = class(TMarkObject)
private
FZIP: string;
@@ -71,6 +61,8 @@ type
procedure SetCountry(const AValue: TCountry);
procedure SetName(const AValue: string);
procedure SetZIP(const AValue: string);
+ protected
+ function GetCaption: string; override;
public
procedure AssignClassProps(ASource: TtiObject); override;
published
@@ -81,8 +73,6 @@ type
end;
- { TCityList }
-
TCityList = class(TMarkObjectList)
protected
function GetItems(i: integer): TCity; reintroduce;
@@ -93,17 +83,27 @@ type
end;
- { TAddressType }
-
TAddressType = class(TMarkObject)
private
FName: string;
procedure SetName(const AValue: string);
+ protected
+ function GetCaption: string; override;
published
property Name: string read FName write SetName;
end;
+ TAddressTypeList = class(TMarkObjectList)
+ protected
+ function GetItems(i: integer): TAddressType; reintroduce;
+ procedure SetItems(i: integer; const AValue: TAddressType); reintroduce;
+ public
+ function Add(const AObject: TAddressType): integer; reintroduce;
+ property Items[i: integer]: TAddressType read GetItems write SetItems; default;
+ end;
+
+
TAddress = class(TMarkObject)
private
FAddressType: TAddressType;
@@ -137,8 +137,6 @@ type
end;
- { TAddressList }
-
TAddressList = class(TMarkObjectList)
protected
function GetItems(i: integer): TAddress; reintroduce;
@@ -149,8 +147,6 @@ type
end;
- { TContact }
-
TContact = class(TMarkObject)
private
FAddressList: TAddressList;
@@ -177,8 +173,6 @@ type
end;
- { TContactList }
-
TContactList = class(TMarkObjectList)
protected
function GetItems(i: integer): TContact; reintroduce;
@@ -189,18 +183,6 @@ type
end;
- { TContactAddressList }
-
- TContactAddressList = class(TAddressList)
- protected
- function GetOwner: TContact; reintroduce;
- procedure SetOwner(const AValue: TContact); reintroduce;
- public
- property Owner: TContact read GetOwner write SetOwner;
- end;
-
-
-
implementation
@@ -297,6 +279,11 @@ begin
EndUpdate;
end;
+function TCity.GetCaption: string;
+begin
+ Result := Name;
+end;
+
procedure TCity.AssignClassProps(ASource: TtiObject);
begin
FCountry:= TCity(ASource).Country; // reference only
@@ -315,6 +302,11 @@ begin
EndUpdate;
end;
+function TAddressType.GetCaption: string;
+begin
+ Result := Name;
+end;
+
{ TAddress }
procedure TAddress.SetStreet(const AValue: string);
@@ -494,6 +486,7 @@ end;
function TCountryList.Add(const AObject: TCountry): integer;
begin
Result:= inherited Add(AObject);
+ NotifyObservers;
end;
{ TCityList }
@@ -511,6 +504,7 @@ end;
function TCityList.Add(const AObject: TCity): integer;
begin
result:= inherited Add(AObject);
+ NotifyObservers;
end;
{ TAddressList }
@@ -528,6 +522,7 @@ end;
function TAddressList.Add(const AObject: TAddress): integer;
begin
result:= inherited Add(AObject);
+ NotifyObservers;
end;
{ TContactList }
@@ -545,20 +540,27 @@ end;
function TContactList.Add(const AObject: TContact): integer;
begin
result:= inherited Add(AObject);
+ NotifyObservers;
end;
-{ TContactAddressList }
-function TContactAddressList.GetOwner: TContact;
+{ TAddressTypeList }
+
+function TAddressTypeList.GetItems(i: integer): TAddressType;
begin
- result:= TContact(inherited GetOwner);
+ result := TAddressType(inherited GetItems(i));
end;
-procedure TContactAddressList.SetOwner(const AValue: TContact);
+procedure TAddressTypeList.SetItems(i: integer; const AValue: TAddressType);
begin
- inherited SetOwner(AValue);
+ inherited SetItems(i, AValue);
end;
+function TAddressTypeList.Add(const AObject: TAddressType): integer;
+begin
+ result := inherited Add(AObject);
+ NotifyObservers;
+end;
end.