Changeset 14 for trunk/UContact.pas
- Timestamp:
- Feb 4, 2018, 2:01:05 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UContact.pas
r12 r14 15 15 TDataType = (dtString, dtInteger, dtDate, dtDateTime, dtImage); 16 16 17 TContactFieldIndex = (cfFirstName, cfMiddleName, cfLastName, cfTelPrefCell, 18 cfTelCell, cfTelHome, cfTelHome2, cfTelWork, cfTitle, cfOrganization, 19 cfAddress, cfNote); 17 TContactFieldIndex = (cfFirstName, cfMiddleName, cfLastName, cfTitleBefore, 18 cfTitleAfter, cfFullName, cfTelPrefCell, 19 cfTelCell, cfTelHome, cfTelHome2, cfTelWork, cfTelVoip, 20 cfTelPrefWorkVoice, cfTelPrefHomeVoice, cfTelHomeVoice, cfTelWorkVoice, 21 cfEmailHome, cfEmailInternet, cfNickName, cfNote, cfRole, cfTitle, 22 cfCategories, cfOrganization, cfAdrHome, cfHomeAddressStreet, 23 cfHomeAddressCity, cfHomeAddressCountry, cfXTimesContacted, 24 cfXLastTimeContacted, cfPhoto, cfXJabber); 20 25 21 26 TContactField = class … … 73 78 Photo: string; 74 79 XJabber: string; 80 procedure Assign(Source: TContact); 81 function UpdateFrom(Source: TContact): Boolean; 75 82 property Fields[Index: TContactFieldIndex]: string read GetField write SetField; 76 83 end; 84 85 { TContacts } 77 86 78 87 TContacts = class(TObjectList) 79 88 ContactsFile: TContactsFile; 89 function Search(FullName: string): TContact; 80 90 end; 81 91 … … 106 116 SVCardFile = 'vCard file'; 107 117 SUnknownCommand = 'Unknown command: %s'; 118 SUnsupportedContactFieldsIndex = 'Unsupported contact field index'; 119 120 { TContacts } 121 122 function TContacts.Search(FullName: string): TContact; 123 var 124 Contact: TContact; 125 begin 126 Result := nil; 127 for Contact in Self do 128 if Contact.FullName = FullName then begin 129 Result := Contact; 130 Break; 131 end; 132 end; 108 133 109 134 { TContactFields } … … 127 152 cfMiddleName: Result := MiddleName; 128 153 cfLastName: Result := LastName; 154 cfTitleBefore: Result := TitleBefore; 155 cfTitleAfter: Result := TitleAfter; 156 cfFullName: Result := FullName; 129 157 cfTelPrefCell: Result := TelPrefCell; 130 158 cfTelCell: Result := TelCell; … … 132 160 cfTelHome2: Result := TelHome2; 133 161 cfTelWork: Result := TelWork; 162 cfTelVoip: Result := TelVoip; 163 cfTelPrefWorkVoice: Result := TelPrefWorkVoice; 164 cfTelPrefHomeVoice: Result := TelPrefHomeVoice; 165 cfTelHomeVoice: Result := TelHomeVoice; 166 cfTelWorkVoice: Result := TelWorkVoice; 167 cfEmailHome: Result := EmailHome; 168 cfEmailInternet: Result := EmailInternet; 169 cfNickName: Result := NickName; 170 cfNote: Result := Note; 171 cfRole: Result := Role; 134 172 cfTitle: Result := Title; 173 cfCategories: Result := Categories; 135 174 cfOrganization: Result := Organization; 136 cfAddress: Result := AdrHome; 137 cfNote: Result := Note; 175 cfAdrHome: Result := AdrHome; 176 cfHomeAddressStreet: Result := HomeAddressStreet; 177 cfHomeAddressCity: Result := HomeAddressCity; 178 cfHomeAddressCountry: Result := HomeAddressCountry; 179 cfXTimesContacted: Result := XTimesContacted; 180 cfXLastTimeContacted: Result := XLastTimeContacted; 181 cfPhoto: Result := Photo; 182 cfXJabber: Result := XJabber; 183 else raise Exception.Create(SUnsupportedContactFieldsIndex); 138 184 end; 139 185 end; … … 145 191 cfMiddleName: MiddleName := AValue; 146 192 cfLastName: LastName := AValue; 193 cfTitleBefore: TitleBefore := AValue; 194 cfTitleAfter: TitleAfter := AValue; 195 cfFullName: FullName := AValue; 147 196 cfTelPrefCell: TelPrefCell := AValue; 148 197 cfTelCell: TelCell := AValue; … … 150 199 cfTelHome2: TelHome2 := AValue; 151 200 cfTelWork: TelWork := AValue; 201 cfTelVoip: TelVoip := AValue; 202 cfTelPrefWorkVoice: TelPrefWorkVoice := AValue; 203 cfTelPrefHomeVoice: TelPrefHomeVoice := AValue; 204 cfTelHomeVoice: TelHomeVoice := AValue; 205 cfTelWorkVoice: TelWorkVoice := AValue; 206 cfEmailHome: EmailHome := AValue; 207 cfEmailInternet: EmailInternet := AValue; 208 cfNickName: NickName := AValue; 209 cfNote: Note := AValue; 210 cfRole: Role := AValue; 152 211 cfTitle: Title := AValue; 212 cfCategories: Categories := AValue; 153 213 cfOrganization: Organization := AValue; 154 cfAddress: AdrHome := AValue; 155 cfNote: Note := AValue; 214 cfAdrHome: AdrHome := AValue; 215 cfHomeAddressStreet: HomeAddressStreet := AValue; 216 cfHomeAddressCity: HomeAddressCity := AValue; 217 cfHomeAddressCountry: HomeAddressCountry := AValue; 218 cfXTimesContacted: XTimesContacted := AValue; 219 cfXLastTimeContacted: XLastTimeContacted := AValue; 220 cfPhoto: Photo := AValue; 221 cfXJabber: XJabber := AValue; 222 else raise Exception.Create(SUnsupportedContactFieldsIndex); 223 end; 224 end; 225 226 procedure TContact.Assign(Source: TContact); 227 begin 228 Version := Source.Version; 229 FirstName := Source.FirstName; 230 MiddleName := Source.MiddleName; 231 LastName := Source.LastName; 232 TitleBefore := Source.TitleBefore; 233 TitleAfter := Source.TitleAfter; 234 FullName := Source.FullName; 235 TelPrefCell := Source.TelPrefCell; 236 TelCell := Source.TelCell; 237 TelHome := Source.TelHome; 238 TelHome2 := Source.TelHome2; 239 TelWork := Source.TelWork; 240 TelVoip := Source.TelVoip; 241 TelPrefWorkVoice := Source.TelPrefWorkVoice; 242 TelPrefHomeVoice := Source.TelPrefHomeVoice; 243 TelHomeVoice := Source.TelHomeVoice; 244 TelWorkVoice := Source.TelWorkVoice; 245 EmailHome := Source.EmailHome; 246 EmailInternet := Source.EmailInternet; 247 NickName := Source.NickName; 248 Note := Source.Note; 249 Role := Source.Role; 250 Title := Source.Title; 251 Categories := Source.Categories; 252 Organization := Source.Organization; 253 AdrHome := Source.AdrHome; 254 HomeAddressStreet := Source.HomeAddressStreet; 255 HomeAddressCity := Source.HomeAddressCity; 256 HomeAddressCountry := Source.HomeAddressCountry; 257 XTimesContacted := Source.XTimesContacted; 258 XLastTimeContacted := Source.XLastTimeContacted; 259 Photo := Source.Photo; 260 XJabber := Source.XJabber; 261 end; 262 263 function TContact.UpdateFrom(Source: TContact): Boolean; 264 var 265 I: Integer; 266 begin 267 Result := False; 268 for I := 0 to Parent.Fields.Count - 1 do begin 269 if (Source.Fields[TContactField(Parent.Fields[I]).Index] <> '') and 270 (Source.Fields[TContactField(Parent.Fields[I]).Index] <> 271 Fields[TContactField(Parent.Fields[I]).Index]) then begin 272 Result := True; 273 Fields[TContactField(Parent.Fields[I]).Index] := Source.Fields[TContactField(Parent.Fields[I]).Index]; 274 end; 156 275 end; 157 276 end; … … 176 295 AddNew('Middle Name', cfMiddleName, dtString); 177 296 AddNew('Last Name', cfLastName, dtString); 297 AddNew('Title Before', cfTitleBefore, dtString); 298 AddNew('Title After', cfTitleAfter, dtString); 299 AddNew('Full Name', cfFullName, dtString); 178 300 AddNew('Preferred cell phone', cfTelPrefCell, dtString); 179 301 AddNew('Cell phone', cfTelCell, dtString); … … 181 303 AddNew('Home phone 2', cfTelHome2, dtString); 182 304 AddNew('Home work', cfTelWork, dtString); 305 AddNew('Tel Voip', cfTelVoip, dtString); 306 AddNew('Tel Pref Work Voice', cfTelPrefWorkVoice, dtString); 307 AddNew('Tel Pref Home Voice', cfTelPrefHomeVoice, dtString); 308 AddNew('Tel Home Voice', cfTelHomeVoice, dtString); 309 AddNew('Tel Work Voice', cfTelWorkVoice, dtString); 310 AddNew('Email Home', cfEmailHome, dtString); 311 AddNew('Email Internet', cfEmailInternet, dtString); 312 AddNew('Nick Name', cfNickName, dtString); 313 AddNew('Note', cfNote, dtString); 314 AddNew('Role', cfRole, dtString); 183 315 AddNew('Title', cfTitle, dtString); 316 AddNew('Categories', cfCategories, dtString); 184 317 AddNew('Organization', cfOrganization, dtString); 185 AddNew('Address', cfAddress, dtString); 186 AddNew('Note', cfNote, dtString); 318 AddNew('Home Address', cfAdrHome, dtString); 319 AddNew('Home Address Street', cfHomeAddressStreet, dtString); 320 AddNew('Home Address City', cfHomeAddressCity, dtString); 321 AddNew('Home Address Country', cfHomeAddressCountry, dtString); 322 AddNew('Times Contacted', cfXTimesContacted, dtString); 323 AddNew('Last Time Contacted', cfXLastTimeContacted, dtString); 324 AddNew('Photo', cfPhoto, dtString); 325 AddNew('Jabber', cfXJabber, dtString); 187 326 end; 188 327 end;
Note:
See TracChangeset
for help on using the changeset viewer.