Changeset 104 for trunk/UContact.pas
- Timestamp:
- Feb 9, 2022, 5:07:14 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UContact.pas
r103 r104 71 71 72 72 TContactFields = class(TFPGObjectList<TContactField>) 73 private 74 Indexes: array[TContactFieldIndex] of TContactField; 75 IndexesUpdated: Boolean; 76 public 77 procedure UpdateIndexes; 73 78 function AddNew(Name: string; Groups: array of string; NoGroups: array of string; 74 79 Title: string; Index: TContactFieldIndex; DataType: … … 209 214 resourcestring 210 215 SVCardFile = 'vCard file'; 216 SFieldIndexRedefined = 'Field index %d redefined'; 211 217 SExpectedVCardBegin = 'Expected vCard begin'; 212 218 SFieldIndexNotDefined = 'Field index not defined'; … … 779 785 { TContactFields } 780 786 787 procedure TContactFields.UpdateIndexes; 788 var 789 I: Integer; 790 Index: TContactFieldIndex; 791 begin 792 for Index := Low(TContactFieldIndex) to High(TContactFieldIndex) do 793 Indexes[Index] := nil; 794 for I := 0 to Count - 1 do 795 if not Assigned(Indexes[Items[I].Index]) then Indexes[Items[I].Index] := Items[I] 796 else raise Exception.Create(Format(SFieldIndexRedefined, [Integer(Items[I].Index)])); 797 IndexesUpdated := True; 798 end; 799 781 800 function TContactFields.AddNew(Name: string; Groups: array of string; 782 801 NoGroups: array of string; Title: string; Index: TContactFieldIndex; … … 798 817 Result.DataType := DataType; 799 818 Add(Result); 819 IndexesUpdated := False; 800 820 end; 801 821 … … 825 845 I: Integer; 826 846 begin 827 I := 0; 828 while (I < Count) and (Items[I].Index <> Index) do Inc(I); 829 if I < Count then Result := Items[I] 830 else Result := nil; 847 if IndexesUpdated then Result := Indexes[Index] 848 else begin 849 I := 0; 850 while (I < Count) and (Items[I].Index <> Index) do Inc(I); 851 if I < Count then Result := Items[I] 852 else Result := nil; 853 end; 831 854 end; 832 855 … … 958 981 with AddNew('X-MYSPACE', [], [], SMySpace, cfMySpace, dtString) do 959 982 AddAlternative('X-SOCIALPROFILE', ['MYSPACE'], []); 983 UpdateIndexes; 960 984 end; 961 985 end;
Note:
See TracChangeset
for help on using the changeset viewer.