source: tags/1.4.0/Forms/UFormContacts.pas

Last change on this file was 138, checked in by chronos, 3 years ago
  • Added: Allow to configure visible columns in contacts table.
File size: 19.7 KB
Line 
1unit UFormContacts;
2
3interface
4
5uses
6 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
7 Menus, ActnList, UVCard, UListViewSort, LazUTF8, Clipbrd, URegistry,
8 Generics.Collections, Types;
9
10type
11
12 { TFormContacts }
13
14 TFormContacts = class(TForm)
15 AAdd: TAction;
16 AClone: TAction;
17 ACopy: TAction;
18 AColumns: TAction;
19 ACut: TAction;
20 APaste: TAction;
21 ALoadFromFile: TAction;
22 ASaveToFile: TAction;
23 ASelectAll: TAction;
24 ARemove: TAction;
25 AModify: TAction;
26 ActionList1: TActionList;
27 ListView1: TListView;
28 ListViewFilter1: TListViewFilter;
29 ListViewSort1: TListViewSort;
30 MenuItem1: TMenuItem;
31 MenuItem10: TMenuItem;
32 MenuItem11: TMenuItem;
33 MenuItem12: TMenuItem;
34 Separator1: TMenuItem;
35 MenuItemColumns: TMenuItem;
36 MenuItem2: TMenuItem;
37 MenuItem3: TMenuItem;
38 MenuItem4: TMenuItem;
39 MenuItem5: TMenuItem;
40 MenuItem6: TMenuItem;
41 MenuItem7: TMenuItem;
42 MenuItem8: TMenuItem;
43 MenuItem9: TMenuItem;
44 OpenDialog1: TOpenDialog;
45 PopupMenuContact: TPopupMenu;
46 SaveDialog1: TSaveDialog;
47 StatusBar1: TStatusBar;
48 ToolBar1: TToolBar;
49 ToolButton1: TToolButton;
50 ToolButton2: TToolButton;
51 ToolButton3: TToolButton;
52 ToolButton4: TToolButton;
53 ToolButton5: TToolButton;
54 ToolButton6: TToolButton;
55 ToolButton7: TToolButton;
56 procedure AAddExecute(Sender: TObject);
57 procedure ACloneExecute(Sender: TObject);
58 procedure AColumnsExecute(Sender: TObject);
59 procedure ACopyExecute(Sender: TObject);
60 procedure ACutExecute(Sender: TObject);
61 procedure ALoadFromFileExecute(Sender: TObject);
62 procedure AModifyExecute(Sender: TObject);
63 procedure APasteExecute(Sender: TObject);
64 procedure ARemoveExecute(Sender: TObject);
65 procedure ASaveToFileExecute(Sender: TObject);
66 procedure ASelectAllExecute(Sender: TObject);
67 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
68 procedure FormCreate(Sender: TObject);
69 procedure FormDestroy(Sender: TObject);
70 procedure FormResize(Sender: TObject);
71 procedure FormShow(Sender: TObject);
72 procedure ListView1Data(Sender: TObject; Item: TListItem);
73 procedure ListView1DblClick(Sender: TObject);
74 procedure ListView1SelectItem(Sender: TObject; Item: TListItem;
75 Selected: Boolean);
76 procedure ListViewFilter1Change(Sender: TObject);
77 procedure ListViewSort1ColumnWidthChanged(Sender: TObject);
78 function ListViewSort1CompareItem(Item1, Item2: TObject): Integer;
79 procedure ListViewSort1Filter(ListViewSort: TListViewSort);
80 private
81 FContacts: TContacts;
82 FUpdateCount: Integer;
83 procedure FilterList(List: TObjectList<TObject>);
84 procedure SetContacts(AValue: TContacts);
85 function GetPreviousContact(Contact: TContact): TContact;
86 function GetNextContact(Contact: TContact): TContact;
87 procedure DoUpdateInterface;
88 procedure UpdateColumns;
89 procedure LoadFromRegistry(Context: TRegistryContext);
90 procedure SaveToRegistry(Context: TRegistryContext);
91 public
92 ListViewColumns: TContactFieldIndexes;
93 FilterItems: TContactFilterItems;
94 Context: TRegistryContext;
95 procedure ReloadList;
96 procedure BeginUpdate;
97 procedure EndUpdate;
98 procedure UpdateInterface;
99 property Contacts: TContacts read FContacts write SetContacts;
100 end;
101
102var
103 FormContacts: TFormContacts;
104
105
106implementation
107
108{$R *.lfm}
109
110uses
111 UFormContact, UCore, UVCardFile, UFormColumns;
112
113resourcestring
114 SRemoveContacts = 'Remove contacts';
115 SRemoveContactsQuery = 'Do you want to remove selected contacts?';
116 STotal = 'Total';
117 SFiltered = 'Filtered';
118 SSelected = 'Selected';
119 SEndUpdateTooLow = 'Update counter error';
120
121{ TFormContacts }
122
123procedure TFormContacts.ListView1Data(Sender: TObject; Item: TListItem);
124
125 procedure AddItem(Text: string; IsCaption: Boolean = False);
126 begin
127 if IsCaption then begin
128 if Text <> '' then Item.Caption := Text
129 else Item.Caption := ' ';
130 end else begin
131 if Text <> '' then Item.SubItems.Add(Text)
132 else Item.SubItems.Add(' ');
133 end;
134 end;
135
136var
137 I: Integer;
138begin
139 if Item.Index < ListViewSort1.List.Count then
140 with TContact(ListViewSort1.List[Item.Index]) do begin
141 for I := 0 to ListViewColumns.Count - 1 do begin
142 AddItem(Fields[ListViewColumns[I]], I = 0);
143 end;
144 Item.Data := ListViewSort1.List[Item.Index];
145 end;
146end;
147
148procedure TFormContacts.ListView1DblClick(Sender: TObject);
149begin
150 AModify.Execute;
151end;
152
153procedure TFormContacts.ListView1SelectItem(Sender: TObject; Item: TListItem;
154 Selected: Boolean);
155begin
156 UpdateInterface;
157end;
158
159procedure TFormContacts.ListViewFilter1Change(Sender: TObject);
160var
161 I: Integer;
162begin
163 // Load filter StringGrid cells into filter
164 FilterItems.Clear;
165 for I := 0 to ListViewColumns.Count - 1 do
166 if I < ListViewFilter1.StringGrid.ColCount then
167 if ListViewFilter1.StringGrid.Cells[I, 0] <> '' then
168 FilterItems.AddNew(ListViewColumns[I], ListViewFilter1.StringGrid.Cells[I, 0]);
169
170 ReloadList;
171 UpdateInterface;
172end;
173
174procedure TFormContacts.ListViewSort1ColumnWidthChanged(Sender: TObject);
175begin
176 ListViewFilter1.UpdateFromListView(ListView1);
177end;
178
179function TFormContacts.ListViewSort1CompareItem(Item1, Item2: TObject): Integer;
180begin
181 Result := 0;
182 if Assigned(Item1) and Assigned(Item2) and (ListViewSort1.Order <> soNone) then begin
183 with ListViewSort1 do
184 Result := CompareString(TContact(Item1).Fields[ListViewColumns[Column]], TContact(Item2).Fields[ListViewColumns[Column]]);
185 if ListViewSort1.Order = soDown then Result := -Result;
186 end else Result := 0;
187end;
188
189procedure TFormContacts.ListViewSort1Filter(ListViewSort: TListViewSort);
190begin
191 if Assigned(Contacts) then Contacts.AssignToList(ListViewSort1.List)
192 else begin
193 ListViewSort1.List.Clear;
194 end;
195 FilterList(ListViewSort1.List);
196end;
197
198procedure TFormContacts.FilterList(List: TObjectList<TObject>);
199var
200 I: Integer;
201 J: Integer;
202 K: Integer;
203 FoundCount: Integer;
204 Item: TContact;
205begin
206 for I := List.Count - 1 downto 0 do begin
207 if List.Items[I] is TContact then begin
208 Item := TContact(List.Items[I]);
209 with Item do begin
210 FoundCount := 0;
211 for J := 0 to FilterItems.Count - 1 do
212 if FilterItems[J].FieldIndex = cfNone then begin
213 for K := 0 to Item.GetFields.Count - 1 do begin
214 if Pos(UTF8LowerCase(FilterItems[J].Value),
215 UTF8LowerCase(Item.Fields[TContact.GetFields[K].Index])) > 0 then begin
216 Inc(FoundCount);
217 Break;
218 end;
219 end;
220 end else begin
221 if Pos(UTF8LowerCase(FilterItems[J].Value),
222 UTF8LowerCase(Item.Fields[FilterItems[J].FieldIndex])) > 0 then
223 Inc(FoundCount);
224 end;
225 end;
226 if FoundCount <> FilterItems.Count then List.Delete(I);
227 end;
228 end;
229end;
230
231procedure TFormContacts.SetContacts(AValue: TContacts);
232begin
233 if FContacts = AValue then Exit;
234 FContacts := AValue;
235 ReloadList;
236 BeginUpdate;
237 try
238 ListViewFilter1.Reset;
239 finally
240 EndUpdate;
241 end;
242end;
243
244function TFormContacts.GetPreviousContact(Contact: TContact): TContact;
245var
246 I: Integer;
247begin
248 I := ListViewSort1.List.IndexOf(Contact);
249 if (I <> -1) and (I > 0) then
250 Result := TContact(ListViewSort1.List[I - 1])
251 else Result := nil;
252end;
253
254function TFormContacts.GetNextContact(Contact: TContact): TContact;
255var
256 I: Integer;
257begin
258 I := ListViewSort1.List.IndexOf(Contact);
259 if (I <> -1) and (I < ListViewSort1.List.Count - 1) then
260 Result := TContact(ListViewSort1.List[I + 1])
261 else Result := nil;
262end;
263
264procedure TFormContacts.DoUpdateInterface;
265var
266 Text: string;
267 SelectedCount: Integer;
268 Selected: Boolean;
269begin
270 if not ListView1.HandleAllocated then Exit;
271
272 Selected := Assigned(ListView1.Selected);
273 AAdd.Enabled := Assigned(Contacts);
274 AModify.Enabled := Assigned(Contacts) and Selected;
275 ARemove.Enabled := Assigned(Contacts) and Selected;
276 AAdd.Enabled := Assigned(Contacts);
277 AModify.Enabled := Assigned(Contacts) and Selected;
278 AClone.Enabled := Assigned(Contacts) and Selected;
279 ARemove.Enabled := Assigned(Contacts) and Selected;
280 ASelectAll.Enabled := ListView1.Items.Count > 0;
281 ALoadFromFile.Enabled := Assigned(Contacts) and Selected;
282 ASaveToFile.Enabled := Assigned(Contacts) and Selected;
283 ACopy.Enabled := Assigned(Contacts) and Selected;
284 ACut.Enabled := Assigned(Contacts) and Selected;
285 APaste.Enabled := Assigned(Contacts) and (Clipboard.AsText <> '');
286
287 Text := '';
288 if Assigned(Contacts) then begin
289 Text := STotal + ': ' + IntToStr(Contacts.Count);
290 if ListView1.Items.Count < Contacts.Count then
291 Text := Text + ', ' + SFiltered + ': ' + IntToStr(ListView1.Items.Count);
292 SelectedCount := ListView1.SelCount;
293 if SelectedCount > 0 then
294 Text := Text + ', ' + SSelected + ': ' + IntToStr(SelectedCount);
295 end;
296 StatusBar1.Panels[0].Text := Text;
297
298 UpdateColumns;
299end;
300
301procedure TFormContacts.UpdateColumns;
302var
303 I: Integer;
304 Field: TContactField;
305begin
306 ListView1.Columns.BeginUpdate;
307 try
308 while ListView1.Columns.Count < ListViewColumns.Count do
309 ListView1.Columns.Add;
310 while ListView1.Columns.Count > ListViewColumns.Count do
311 ListView1.Columns.Delete(ListView1.Columns.Count - 1);
312 for I := 0 to ListView1.Columns.Count - 1 do begin
313 if Assigned(Contacts) and Assigned(Contacts.ParentVCard) then begin
314 Field := TContact.GetFields.GetByIndex(ListViewColumns[I]);
315 if Assigned(Field) then
316 ListView1.Columns[I].Caption := Field.Title;
317 end;
318 end;
319 finally
320 ListView1.Columns.EndUpdate;
321 end;
322end;
323
324procedure TFormContacts.LoadFromRegistry(Context: TRegistryContext);
325var
326 I: Integer;
327 Registry: TRegistryEx;
328 ContactFieldIndex: TContactFieldIndex;
329begin
330 Registry := TRegistryEx.Create;
331 with Registry do
332 try
333 RootKey := Context.RootKey;
334 OpenKey(Context.Key, True);
335 ListViewColumns.Clear;
336 I := 0;
337 while ValueExists('Column' + IntToStr(I)) do begin
338 ContactFieldIndex := TContactFieldIndex(ReadIntegerWithDefault('Column' + IntToStr(I), -1));
339 ListViewColumns.Add(ContactFieldIndex);
340 Inc(I);
341 end;
342
343 if ListViewColumns.Count = 0 then begin
344 with ListViewColumns do begin
345 Add(cfFullName);
346 Add(cfFirstName);
347 Add(cfMiddleName);
348 Add(cfLastName);
349 Add(cfTel);
350 Add(cfTelCell);
351 Add(cfTelHome);
352 Add(cfTelWork);
353 Add(cfEmailWork);
354 Add(cfOrganization);
355 end;
356 end;
357 finally
358 Free;
359 end;
360end;
361
362procedure TFormContacts.SaveToRegistry(Context: TRegistryContext);
363var
364 I: Integer;
365 Registry: TRegistryEx;
366begin
367 Registry := TRegistryEx.Create;
368 with Registry do
369 try
370 RootKey := Context.RootKey;
371 OpenKey(Context.Key, True);
372 for I := 0 to ListViewColumns.Count - 1 do
373 WriteInteger('Column' + IntToStr(I), Integer(ListViewColumns[I]));
374
375 // Remove old columns
376 I := ListViewColumns.Count;
377 while ValueExists('Column' + IntToStr(I)) do begin
378 DeleteValue('Column' + IntToStr(I));
379 Inc(I);
380 end;
381 finally
382 Free;
383 end;
384end;
385
386procedure TFormContacts.FormShow(Sender: TObject);
387begin
388 Core.Translator.TranslateComponentRecursive(Self);
389 Core.ThemeManager1.UseTheme(Self);
390 Core.PersistentForm1.Load(Self);
391 LoadFromRegistry(Context);
392 ReloadList;
393 UpdateInterface;
394 ListViewFilter1.UpdateFromListView(ListView1);
395end;
396
397procedure TFormContacts.AAddExecute(Sender: TObject);
398var
399 FormContact: TFormContact;
400 Contact: TContact;
401begin
402 FormContact := TFormContact.Create(nil);
403 try
404 Contact := TContact.Create;
405 try
406 Contact.ParentVCard := Contacts.ParentVCard;
407 FormContact.Contact := Contact;
408 FormContact.OnGetPrevious := GetPreviousContact;
409 FormContact.OnGetNext := GetNextContact;
410 Contact.Properties.AddNew('VERSION', Core.DefaultVcardVersion);
411 if FormContact.ShowModal = mrOK then begin
412 Contacts.Add(Contact);
413 Core.DataFile.Modified := True;
414 ReloadList;
415 UpdateInterface;
416 Contact := nil;
417 end;
418 finally
419 if Assigned(Contact) then
420 Contact.Free;
421 end;
422 finally
423 FormContact.Free;
424 end;
425end;
426
427procedure TFormContacts.ACloneExecute(Sender: TObject);
428var
429 FormContact: TFormContact;
430 Contact: TContact;
431begin
432 FormContact := TFormContact.Create(nil);
433 try
434 Contact := TContact.Create;
435 try
436 Contact.ParentVCard := Contacts.ParentVCard;
437 Contact.Assign(TContact(ListView1.Selected.Data));
438 FormContact.Contact := Contact;
439 FormContact.OnGetPrevious := GetPreviousContact;
440 FormContact.OnGetNext := GetNextContact;
441 if FormContact.ShowModal = mrOK then begin
442 Contacts.Add(Contact);
443 Contact := nil;
444 Core.DataFile.Modified := True;
445 ReloadList;
446 UpdateInterface;
447 end;
448 finally
449 if Assigned(Contact) then
450 Contact.Free;
451 end;
452 finally
453 FormContact.Free;
454 end;
455end;
456
457procedure TFormContacts.AColumnsExecute(Sender: TObject);
458var
459 FormColumns: TFormColumns;
460 I: Integer;
461 Field: TContactField;
462begin
463 FormColumns := TFormColumns.Create(nil);
464 with FormColumns do
465 try
466 for I := 0 to ListViewColumns.Count - 1 do begin
467 Field := TContact.GetFields.GetByIndex(ListViewColumns[I]);
468 if Assigned(Field) then
469 ActiveColumns.AddObject(Field.Title, Field);
470 end;
471 for I := 0 to TContact.GetFields.Count - 1 do begin
472 Field := TContact.GetFields[I];
473 if ListViewColumns.IndexOf(Field.Index) = -1 then
474 AvailableColumns.AddObject(Field.Title, Field);
475 end;
476 if ShowModal = mrOK then begin
477 ListViewColumns.Clear;
478 for I := 0 to ActiveColumns.Count - 1 do begin
479 ListViewColumns.Add(TContactField(ActiveColumns.Objects[I]).Index);
480 end;
481 UpdateColumns;
482 ReloadList;
483 end;
484 finally
485 Free;
486 end;
487end;
488
489procedure TFormContacts.ACopyExecute(Sender: TObject);
490var
491 Text: string;
492 Strings: TStringList;
493 I: Integer;
494begin
495 Strings := TStringList.Create;
496 try
497 Text := '';
498 for I := 0 to ListView1.Items.Count - 1 do
499 if ListView1.Items[I].Selected then begin
500 Strings.Clear;
501 TContact(ListView1.Items[I].Data).SaveToStrings(Strings);
502 Text := Text + Strings.Text;
503 end;
504 Clipboard.AsText := Text;
505 finally
506 Strings.Free;
507 end;
508end;
509
510procedure TFormContacts.ACutExecute(Sender: TObject);
511var
512 Text: string;
513 Strings: TStringList;
514 I: Integer;
515begin
516 Strings := TStringList.Create;
517 try
518 Text := '';
519 for I := 0 to ListView1.Items.Count - 1 do
520 if ListView1.Items[I].Selected then begin
521 Strings.Clear;
522 TContact(ListView1.Items[I].Data).SaveToStrings(Strings);
523 Text := Text + Strings.Text;
524 end;
525 Clipboard.AsText := Text;
526 for I := 0 to ListView1.Items.Count - 1 do
527 if ListView1.Items[I].Selected then begin
528 Contacts.Delete(Contacts.IndexOf(ListView1.Items[I].Data));
529 end;
530 ReloadList;
531 ListView1.ClearSelection;
532 UpdateInterface;
533 finally
534 Strings.Free;
535 end;
536end;
537
538procedure TFormContacts.ALoadFromFileExecute(Sender: TObject);
539var
540 TempFile: TVCardFile;
541begin
542 if Assigned(ListView1.Selected) then begin
543 TempFile := TVCardFile.Create(nil);
544 try
545 OpenDialog1.Filter := TempFile.GetFileFilter;
546 OpenDialog1.DefaultExt := TempFile.GetFileExt;
547 finally
548 TempFile.Free;
549 end;
550 OpenDialog1.InitialDir := ExtractFileDir(Core.LastContactFileName);
551 OpenDialog1.FileName := ExtractFileName(Core.LastContactFileName);
552 if OpenDialog1.Execute then begin
553 TContact(ListView1.Selected.Data).LoadFromFile(OpenDialog1.FileName);
554 Core.LastContactFileName := OpenDialog1.FileName;
555 ReloadList;
556 end;
557 end;
558end;
559
560procedure TFormContacts.AModifyExecute(Sender: TObject);
561var
562 FormContact: TFormContact;
563 Contact: TContact;
564begin
565 FormContact := TFormContact.Create(nil);
566 try
567 Contact := TContact.Create;
568 try
569 Contact.ParentVCard := Contacts.ParentVCard;
570 Contact.Assign(TContact(ListView1.Selected.Data));
571 FormContact.Contact := Contact;
572 FormContact.OnGetPrevious := GetPreviousContact;
573 FormContact.OnGetNext := GetNextContact;
574 if FormContact.ShowModal = mrOK then begin
575 if not TContact(ListView1.Selected.Data).CompareTo(Contact) then
576 Core.DataFile.Modified := True;
577 TContact(ListView1.Selected.Data).Assign(Contact);
578 ReloadList;
579 UpdateInterface;
580 end;
581 finally
582 Contact.Free;
583 end;
584 finally
585 FormContact.Free;
586 end;
587end;
588
589procedure TFormContacts.APasteExecute(Sender: TObject);
590var
591 PasteContacts: TVCardFile;
592 Lines: TStringList;
593begin
594 PasteContacts := TVCardFile.Create(nil);
595 Lines := TStringList.Create;
596 try
597 Lines.Text := Clipboard.AsText;
598 PasteContacts.VCard.LoadFromStrings(Lines);
599 if PasteContacts.VCard.Contacts.Count > 0 then begin
600 if Assigned(ListView1.Selected) then begin
601 Contacts.InsertContacts(Contacts.IndexOf(ListView1.Selected.Data),
602 PasteContacts.VCard.Contacts);
603 end else Contacts.AddContacts(PasteContacts.VCard.Contacts);
604 Core.DataFile.Modified := True;
605 ReloadList;
606 UpdateInterface;
607 end;
608 finally
609 Lines.Free;
610 PasteContacts.Free;
611 end;
612end;
613
614procedure TFormContacts.ARemoveExecute(Sender: TObject);
615var
616 I: Integer;
617begin
618 if Assigned(ListView1.Selected) then
619 if MessageDlg(SRemoveContacts, SRemoveContactsQuery,
620 TMsgDlgType.mtConfirmation, [mbCancel, mbOk], 0) = mrOk then begin
621 for I := ListView1.Items.Count - 1 downto 0 do
622 if ListView1.Items[I].Selected then begin
623 Contacts.Delete(Contacts.IndexOf(ListView1.Items[I].Data));
624 end;
625 Core.DataFile.Modified := True;
626 ReloadList;
627 UpdateInterface;
628 end;
629end;
630
631procedure TFormContacts.ASaveToFileExecute(Sender: TObject);
632var
633 TempFile: TVCardFile;
634begin
635 if Assigned(ListView1.Selected) then begin
636 TempFile := TVCardFile.Create(nil);
637 try
638 SaveDialog1.Filter := TempFile.GetFileFilter;
639 SaveDialog1.DefaultExt := TempFile.GetFileExt;
640 finally
641 TempFile.Free;
642 end;
643 SaveDialog1.InitialDir := ExtractFileDir(Core.LastContactFileName);
644 SaveDialog1.FileName := TContact(ListView1.Selected.Data).FullNameToFileName +
645 VCardFileExt;
646 if SaveDialog1.Execute then begin
647 TContact(ListView1.Selected.Data).SaveToFile(SaveDialog1.FileName);
648 Core.LastContactFileName := SaveDialog1.FileName;
649 end;
650 end;
651end;
652
653procedure TFormContacts.ASelectAllExecute(Sender: TObject);
654var
655 I: Integer;
656begin
657 BeginUpdate;
658 try
659 ListView1.BeginUpdate;
660 try
661 for I := 0 to ListView1.Items.Count - 1 do
662 ListView1.Items[I].Selected := True;
663 //ListView1.SelectAll;
664 finally
665 ListView1.EndUpdate;
666 end;
667 finally
668 EndUpdate;
669 end;
670end;
671
672procedure TFormContacts.FormClose(Sender: TObject; var CloseAction: TCloseAction
673 );
674begin
675 SaveToRegistry(Context);
676 Core.PersistentForm1.Save(Self);
677end;
678
679procedure TFormContacts.FormCreate(Sender: TObject);
680var
681 I: Integer;
682begin
683 FilterItems := TContactFilterItems.Create;
684 ListViewColumns := TContactFieldIndexes.Create;
685
686 FContacts := nil;
687 for I := 0 to ToolBar1.ButtonCount - 1 do begin
688 ToolBar1.Buttons[I].ShowHint := True;
689 ToolBar1.Buttons[I].Hint := ToolBar1.Buttons[I].Caption;
690 end;
691end;
692
693procedure TFormContacts.FormDestroy(Sender: TObject);
694begin
695 FreeAndNil(ListViewColumns);
696 FreeAndNil(FilterItems);
697end;
698
699procedure TFormContacts.FormResize(Sender: TObject);
700begin
701 ListViewFilter1.UpdateFromListView(ListView1);
702end;
703
704procedure TFormContacts.ReloadList;
705begin
706 ListViewSort1.Refresh;
707end;
708
709procedure TFormContacts.BeginUpdate;
710begin
711 Inc(FUpdateCount);
712end;
713
714procedure TFormContacts.EndUpdate;
715begin
716 if FUpdateCount <= 0 then raise Exception(SEndUpdateTooLow);
717 Dec(FUpdateCount);
718 if FUpdateCount = 0 then DoUpdateInterface;
719end;
720
721procedure TFormContacts.UpdateInterface;
722begin
723 if FUpdateCount = 0 then DoUpdateInterface;
724end;
725
726end.
727
Note: See TracBrowser for help on using the repository browser.