Changeset 14
- Timestamp:
- Feb 4, 2018, 2:01:05 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormContacts.lfm
r13 r14 34 34 Width = 387 35 35 end> 36 MultiSelect = True 36 37 OwnerData = True 37 38 PopupMenu = PopupMenuContact … … 75 76 Action = AAdd 76 77 end 78 object MenuItem3: TMenuItem 79 Action = ARemove 80 end 77 81 object MenuItem2: TMenuItem 78 82 Action = AModify 79 83 end 80 object MenuItem 3: TMenuItem81 Action = A Remove84 object MenuItem4: TMenuItem 85 Action = ASelectAll 82 86 end 83 87 end … … 104 108 ShortCut = 46 105 109 end 110 object ASelectAll: TAction 111 Caption = 'Select all' 112 OnExecute = ASelectAllExecute 113 ShortCut = 16449 114 end 106 115 end 107 116 end -
trunk/Forms/UFormContacts.pas
r13 r14 15 15 TFormContacts = class(TForm) 16 16 AAdd: TAction; 17 ASelectAll: TAction; 17 18 ARemove: TAction; 18 19 AModify: TAction; … … 22 23 MenuItem2: TMenuItem; 23 24 MenuItem3: TMenuItem; 25 MenuItem4: TMenuItem; 24 26 PopupMenuContact: TPopupMenu; 25 27 ToolBar1: TToolBar; … … 30 32 procedure AModifyExecute(Sender: TObject); 31 33 procedure ARemoveExecute(Sender: TObject); 34 procedure ASelectAllExecute(Sender: TObject); 32 35 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 33 36 procedure FormCreate(Sender: TObject); … … 158 161 end; 159 162 163 procedure TFormContacts.ASelectAllExecute(Sender: TObject); 164 begin 165 ListView1.SelectAll; 166 end; 167 160 168 procedure TFormContacts.FormClose(Sender: TObject; var CloseAction: TCloseAction 161 169 ); -
trunk/Forms/UFormMain.lfm
r13 r14 1 1 object FormMain: TFormMain 2 Left = 6 132 Left = 601 3 3 Height = 531 4 Top = 4 014 Top = 447 5 5 Width = 785 6 Caption = ' FormMain'6 Caption = 'vCard Studio' 7 7 ClientHeight = 497 8 8 ClientWidth = 785 … … 132 132 Action = Core.AFileClose 133 133 end 134 object MenuItem1: TMenuItem 135 Caption = '-' 136 end 137 object MenuItem3: TMenuItem 138 Action = Core.AFileMerge 139 end 134 140 object MenuItem2: TMenuItem 135 141 Caption = '-' -
trunk/Forms/UFormMain.pas
r13 r14 16 16 CoolBar1: TCoolBar; 17 17 MainMenu1: TMainMenu; 18 MenuItem1: TMenuItem; 19 MenuItem3: TMenuItem; 18 20 MenuItemToolbar: TMenuItem; 19 21 MenuItemView: TMenuItem; -
trunk/Languages/vCardStudio.cs.po
r13 r14 25 25 msgstr "Zavřít" 26 26 27 #: tcore.afilemerge.caption 28 msgid "Merge..." 29 msgstr "Sloučení..." 30 27 31 #: tcore.afilenew.caption 28 32 msgid "New" … … 215 219 msgstr "Odstranit" 216 220 221 #: tformcontacts.aselectall.caption 222 msgid "Select all" 223 msgstr "Vybrat vše" 224 217 225 #: tformcontacts.caption 218 226 msgid "Contacts" … … 238 246 239 247 #: tformmain.caption 240 msgid " FormMain"241 msgstr " FormMain"248 msgid "vCard Studio" 249 msgstr "vCard Studio" 242 250 243 251 #: tformmain.menuitemfile.caption … … 303 311 msgstr "Neznámý příkaz: %s" 304 312 313 #: ucontact.sunsupportedcontactfieldsindex 314 msgid "Unsupported contact field index" 315 msgstr "Nepodporovaný index pole kontaktu" 316 305 317 #: ucontact.svcardfile 306 318 msgctxt "ucontact.svcardfile" … … 320 332 msgstr "Soubor '%s' nenalezen." 321 333 334 #: ucore.smergedcontacts 335 msgid "Contacts merged. Loaded: %d, New: %d, Updated: %d" 336 msgstr "Kontakty sloučeny. Načteno: %d, Nových: %d, Aktualizovaných: %d" 337 322 338 #: udatafile.sallfiles 323 339 msgid "All files" -
trunk/Languages/vCardStudio.po
r13 r14 15 15 msgstr "" 16 16 17 #: tcore.afilemerge.caption 18 msgid "Merge..." 19 msgstr "" 20 17 21 #: tcore.afilenew.caption 18 22 msgid "New" … … 205 209 msgstr "" 206 210 211 #: tformcontacts.aselectall.caption 212 msgid "Select all" 213 msgstr "" 214 207 215 #: tformcontacts.caption 208 216 msgid "Contacts" … … 228 236 229 237 #: tformmain.caption 230 msgid " FormMain"238 msgid "vCard Studio" 231 239 msgstr "" 232 240 … … 291 299 msgstr "" 292 300 301 #: ucontact.sunsupportedcontactfieldsindex 302 msgid "Unsupported contact field index" 303 msgstr "" 304 293 305 #: ucontact.svcardfile 294 306 msgctxt "ucontact.svcardfile" … … 308 320 msgstr "" 309 321 322 #: ucore.smergedcontacts 323 msgid "Contacts merged. Loaded: %d, New: %d, Updated: %d" 324 msgstr "" 325 310 326 #: udatafile.sallfiles 311 327 msgid "All files" -
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; -
trunk/UCore.lfm
r8 r14 7 7 VerticalOffset = 428 8 8 Width = 1020 9 PPI = 12010 9 object ImageList1: TImageList 11 10 left = 200 … … 429 428 OnExecute = ASettingsExecute 430 429 end 430 object AFileMerge: TAction 431 Category = 'File' 432 Caption = 'Merge...' 433 OnExecute = AFileMergeExecute 434 end 431 435 end 432 436 object LastOpenedList1: TLastOpenedList -
trunk/UCore.pas
r8 r14 12 12 type 13 13 14 { TMergeResult } 15 16 TMergeResult = record 17 Loaded: Integer; 18 New: Integer; 19 Updated: Integer; 20 procedure Clear; 21 class operator Add(const A, B: TMergeResult): TMergeResult; 22 end; 23 14 24 { TCore } 15 25 16 26 TCore = class(TDataModule) 17 27 AAbout: TAction; 28 AFileMerge: TAction; 18 29 ASettings: TAction; 19 30 AFileOpenRecent: TAction; … … 36 47 procedure AAboutExecute(Sender: TObject); 37 48 procedure AExitExecute(Sender: TObject); 49 procedure AFileMergeExecute(Sender: TObject); 38 50 procedure AFileNewExecute(Sender: TObject); 39 51 procedure AFileOpenExecute(Sender: TObject); … … 64 76 procedure FileOpen(FileName: string); 65 77 procedure FileClose; 78 function FileMerge(FileName: string): TMergeResult; 66 79 procedure Initialize; 67 80 procedure UpdateInterface; … … 83 96 SAppExitQuery = 'File was modified. Do you want to save it before exit?'; 84 97 SFileNotFound = 'File ''%s'' not found.'; 98 SMergedContacts = 'Contacts merged. Loaded: %d, New: %d, Updated: %d'; 99 100 { TMergeResult } 101 102 procedure TMergeResult.Clear; 103 begin 104 Loaded := 0; 105 New := 0; 106 Updated := 0; 107 end; 108 109 class operator TMergeResult.Add(const A, B: TMergeResult): TMergeResult; 110 begin 111 Result.Loaded := A.Loaded + B.Loaded; 112 Result.New := A.New + B.New; 113 Result.Updated := A.Updated + B.Updated; 114 end; 85 115 86 116 { TCore } … … 91 121 end; 92 122 93 procedure TCore.AAboutExecute(Sender: TObject); 94 begin 95 FormAbout := TFormAbout.Create(nil); 96 try 97 FormAbout.ApplicationInfo := ApplicationInfo1; 98 FormAbout.ShowModal; 99 finally 100 FormAbout.Free; 101 end; 102 end; 103 104 procedure TCore.AFileCloseExecute(Sender: TObject); 105 begin 106 FileClose; 107 UpdateFile; 108 end; 109 110 procedure TCore.AHomePageExecute(Sender: TObject); 111 begin 112 OpenWebPage(ApplicationInfo1.HomePage); 113 end; 114 115 procedure TCore.ASettingsExecute(Sender: TObject); 116 begin 117 FormSettings := TFormSettings.Create(nil); 118 try 119 FormSettings.LoadData; 120 if FormSettings.ShowModal = mrOK then 121 FormSettings.SaveData; 122 finally 123 FormSettings.Free; 124 end; 125 end; 126 127 procedure TCore.AFileNewExecute(Sender: TObject); 128 begin 129 FileNew; 130 UpdateFile; 131 end; 132 133 procedure TCore.AFileOpenExecute(Sender: TObject); 123 procedure TCore.AFileMergeExecute(Sender: TObject); 134 124 var 135 125 TempFile: TDataFile; 126 I: Integer; 127 MergeResult: TMergeResult; 128 TotalMergeResult: TMergeResult; 136 129 begin 137 130 TempFile := DefaultDataFileClass.Create; … … 146 139 OpenDialog1.FileName := ExtractFileName(DataFile.FileName); 147 140 end; 141 OpenDialog1.Options := OpenDialog1.Options + [ofAllowMultiSelect]; 142 if OpenDialog1.Execute then begin 143 TotalMergeResult.Clear; 144 for I := 0 to OpenDialog1.Files.Count - 1 do begin 145 MergeResult := FileMerge(OpenDialog1.Files[I]); 146 TotalMergeResult := TotalMergeResult + MergeResult; 147 end; 148 ShowMessage(Format(SMergedContacts, [TotalMergeResult.Loaded, 149 TotalMergeResult.New, TotalMergeResult.Updated])); 150 UpdateFile; 151 end; 152 end; 153 154 procedure TCore.AAboutExecute(Sender: TObject); 155 begin 156 FormAbout := TFormAbout.Create(nil); 157 try 158 FormAbout.ApplicationInfo := ApplicationInfo1; 159 FormAbout.ShowModal; 160 finally 161 FormAbout.Free; 162 end; 163 end; 164 165 procedure TCore.AFileCloseExecute(Sender: TObject); 166 begin 167 FileClose; 168 UpdateFile; 169 end; 170 171 procedure TCore.AHomePageExecute(Sender: TObject); 172 begin 173 OpenWebPage(ApplicationInfo1.HomePage); 174 end; 175 176 procedure TCore.ASettingsExecute(Sender: TObject); 177 begin 178 FormSettings := TFormSettings.Create(nil); 179 try 180 FormSettings.LoadData; 181 if FormSettings.ShowModal = mrOK then 182 FormSettings.SaveData; 183 finally 184 FormSettings.Free; 185 end; 186 end; 187 188 procedure TCore.AFileNewExecute(Sender: TObject); 189 begin 190 FileNew; 191 UpdateFile; 192 end; 193 194 procedure TCore.AFileOpenExecute(Sender: TObject); 195 var 196 TempFile: TDataFile; 197 begin 198 TempFile := DefaultDataFileClass.Create; 199 try 200 OpenDialog1.Filter := TempFile.GetFileFilter; 201 finally 202 TempFile.Free; 203 end; 204 OpenDialog1.DefaultExt := ''; 205 if Assigned(DataFile) then begin 206 OpenDialog1.InitialDir := ExtractFileDir(DataFile.FileName); 207 OpenDialog1.FileName := ExtractFileName(DataFile.FileName); 208 end; 209 OpenDialog1.Options := OpenDialog1.Options - [ofAllowMultiSelect]; 148 210 if OpenDialog1.Execute then begin 149 211 FileOpen(OpenDialog1.FileName); … … 241 303 end; 242 304 305 function TCore.FileMerge(FileName: string): TMergeResult; 306 var 307 TempFile: TContactsFile; 308 NewContact: TContact; 309 I: Integer; 310 CountNew: Integer; 311 CountUpdated: Integer; 312 begin 313 Result.Clear; 314 if FileExists(FileName) then begin 315 TempFile := TContactsFile.Create; 316 try 317 TempFile.LoadFromFile(FileName); 318 Result.Loaded := TempFile.Contacts.Count; 319 for I := 0 to TempFile.Contacts.Count - 1 do begin 320 NewContact := TContactsFile(DataFile).Contacts.Search(TContact(TempFile.Contacts[I]).FullName); 321 if not Assigned(NewContact) then begin 322 NewContact := TContact.Create; 323 NewContact.Parent := TContactsFile(DataFile); 324 NewContact.Assign(TContact(TempFile.Contacts[I])); 325 TContactsFile(DataFile).Contacts.Add(NewContact); 326 Inc(Result.New); 327 end else begin 328 if NewContact.UpdateFrom(TContact(TempFile.Contacts[I])) then 329 Inc(Result.Updated); 330 end; 331 end; 332 TContactsFile(DataFile).Modified := True; 333 finally 334 TempFile.Free; 335 end; 336 end else ShowMessage(Format(SFileNotFound, [FileName])); 337 end; 338 243 339 procedure TCore.FileNew; 244 340 begin … … 257 353 FormContacts.Contacts := TContactsFile(DataFile).Contacts 258 354 else FormContacts.Contacts := nil; 355 FormContacts.ReloadList; 259 356 end; 260 357
Note:
See TracChangeset
for help on using the changeset viewer.