Changeset 56 for trunk/UContact.pas
- Timestamp:
- Dec 8, 2021, 4:44:21 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UContact.pas
r55 r56 30 30 cfVersion, cfAnniversary); 31 31 32 { TContactField } 33 32 34 TContactField = class 33 35 SysName: string; … … 38 40 ValueIndex: Integer; 39 41 DataType: TDataType; 42 function GroupsContain(Name: string): Boolean; 43 function Match(ASysName: string; AGroups: TStringArray): Boolean; 40 44 end; 41 45 … … 46 50 Title: string; Index: TContactFieldIndex; DataType: 47 51 TDataType; ValueIndex: Integer = -1): TContactField; 52 function GetBySysName(SysName: string): TContactField; 53 function GetBySysNameGroups(SysName: string; Groups: TStringArray): TContactField; 48 54 function GetByIndex(Index: TContactFieldIndex): TContactField; 49 55 procedure LoadToStrings(AItems: TStrings); … … 238 244 end; 239 245 246 { TContactField } 247 248 function TContactField.GroupsContain(Name: string): Boolean; 249 var 250 I: Integer; 251 begin 252 Result := False; 253 for I := 0 to Length(Groups) - 1 do 254 if Groups[I] = Name then begin 255 Result := True; 256 Break; 257 end; 258 end; 259 260 function TContactField.Match(ASysName: string; AGroups: TStringArray): Boolean; 261 var 262 I: Integer; 263 begin 264 Result := ASysName = SysName; 265 if Result then begin 266 for I := 0 to Length(AGroups) - 1 do begin 267 if not GroupsContain(AGroups[I]) then begin 268 Result := False; 269 Break; 270 end; 271 end; 272 end; 273 end; 274 240 275 { TContactProperties } 241 276 … … 491 526 Result.DataType := DataType; 492 527 Add(Result); 528 end; 529 530 function TContactFields.GetBySysName(SysName: string): TContactField; 531 var 532 I: Integer; 533 C: Integer; 534 begin 535 C := Count; 536 I := 0; 537 while (I < Count) and (Items[I].SysName <> SysName) do Inc(I); 538 if I < Count then Result := Items[I] 539 else Result := nil; 540 end; 541 542 function TContactFields.GetBySysNameGroups(SysName: string; Groups: TStringArray 543 ): TContactField; 544 var 545 I: Integer; 546 C: Integer; 547 begin 548 C := Count; 549 I := 0; 550 while (I < Count) and not Items[I].Match(SysName, Groups) do Inc(I); 551 if I < Count then Result := Items[I] 552 else Result := nil; 493 553 end; 494 554
Note:
See TracChangeset
for help on using the changeset viewer.