diff options
4 files changed, 35 insertions, 11 deletions
diff --git a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/contactmanager.pas b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/contactmanager.pas index 7e764460..c8518f30 100644 --- a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/contactmanager.pas +++ b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/contactmanager.pas @@ -21,6 +21,7 @@ type FCountryList: TCountryList; procedure PopulateCountries; procedure PopulateCities; + procedure PopulateAddressTypes; function GenPhone: string; public constructor Create; override; @@ -158,6 +159,28 @@ begin FCityList[i].ObjectState := posClean; end; +procedure TContactManager.PopulateAddressTypes; +var + a: TAddressType; + i: integer; +begin + a := TAddressType.CreateNew; + a.Name := 'Home'; + FAddressTypeList.Add(a); + + a := TAddressType.CreateNew; + a.Name := 'Work'; + FAddressTypeList.Add(a); + + a := TAddressType.CreateNew; + a.Name := 'Postal'; + FAddressTypeList.Add(a); + + { reset ObjectState property } + for i := 0 to FAddressTypeList.Count - 1 do + FAddressTypeList[i].ObjectState := posClean; +end; + function TContactManager.GenPhone: string; begin result:= '+27 ' + IntToStr(Random(9)) + IntToStr(Random(9)) + ' ' @@ -170,10 +193,13 @@ begin inherited Create; 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; @@ -195,7 +221,8 @@ var begin PopulateCountries; PopulateCities; - for I:= 1 to 10 do + PopulateAddressTypes; + for I := 1 to 10 do begin C:= TContact.CreateNew; C.FirstName:= FirstNames[I]; @@ -205,6 +232,7 @@ begin for J:= 1 to 1+Random(2) do begin A:= TAddress.CreateNew; + A.AddressType := FAddressTypeList[Random(3)]; A.Street := StreetNames[1+Random(10)]; A.Nr := Random(100)+1; A.City := FCityList[Random(10)]; 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 7139239e..6d1a6205 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 @@ -9,7 +9,6 @@ </Flags> <SessionStorage Value="InProjectDir"/> <MainUnit Value="0"/> - <IconPath Value="./"/> <TargetFileExt Value=""/> </General> <VersionInfo> diff --git a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmmain.pas b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmmain.pas index 7dae329e..d589e20b 100644 --- a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmmain.pas +++ b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/frmmain.pas @@ -87,8 +87,10 @@ end; procedure TMainForm.miEditEditClick(Sender: TObject); var c: TContact; + rowmed: TStringGridRowMediator; begin - c := TContact(TStringGridMediator(FMediator.FindByComponent(grdContacts).Mediator).SelectedObject); + rowmed := TStringGridRowMediator(TStringGridMediator(FMediator.FindByComponent(grdContacts).Mediator).SelectedObject); + c := TContact(rowmed.Model); // tiShowString(c.AsDebugString); if not Assigned(c) then diff --git a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/model.pas b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/model.pas index 54f95b02..bf8e289a 100644 --- a/extras/tiopf/demos/Demo_21_AdrsBook_MGM/model.pas +++ b/extras/tiopf/demos/Demo_21_AdrsBook_MGM/model.pas @@ -354,7 +354,7 @@ end; procedure TAddress.AssignClassProps(ASource: TtiObject); begin - FAddressType.Assign(ASource); + FAddressType := TAddress(ASource).AddressType; // reference only FCity:= TAddress(ASource).City; // reference only end; @@ -370,11 +370,11 @@ end; procedure TAddress.SetAddressType(const AValue: TAddressType); begin - if FAddressType.Name = AValue.Name then + if FAddressType = AValue then Exit; //==> BeginUpdate; - FAddressType.Assign(AValue); + FAddressType := AValue; Mark; EndUpdate; end; @@ -486,7 +486,6 @@ end; function TCountryList.Add(const AObject: TCountry): integer; begin Result:= inherited Add(AObject); - NotifyObservers; end; { TCityList } @@ -504,7 +503,6 @@ end; function TCityList.Add(const AObject: TCity): integer; begin result:= inherited Add(AObject); - NotifyObservers; end; { TAddressList } @@ -522,7 +520,6 @@ end; function TAddressList.Add(const AObject: TAddress): integer; begin result:= inherited Add(AObject); - NotifyObservers; end; { TContactList } @@ -540,7 +537,6 @@ end; function TContactList.Add(const AObject: TContact): integer; begin result:= inherited Add(AObject); - NotifyObservers; end; @@ -559,7 +555,6 @@ end; function TAddressTypeList.Add(const AObject: TAddressType): integer; begin result := inherited Add(AObject); - NotifyObservers; end; end. |