Changeset 52 for trunk/Forms/UFormContacts.pas
- Timestamp:
- Dec 3, 2021, 8:50:43 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormContacts.pas
r51 r52 53 53 private 54 54 FContacts: TContacts; 55 FUpdateCount: Integer; 55 56 procedure FilterList(List: TFPGObjectList<TObject>); 56 57 procedure SetContacts(AValue: TContacts); 57 58 procedure FormContactPrevious(Sender: TObject); 58 59 procedure FormContactNext(Sender: TObject); 60 procedure DoUpdateInterface; 59 61 public 60 62 property Contacts: TContacts read FContacts write SetContacts; 61 63 procedure ReloadList; 64 procedure BeginUpdate; 65 procedure EndUpdate; 62 66 procedure UpdateInterface; 63 67 end; … … 80 84 SFiltered = 'Filtered'; 81 85 SSelected = 'Selected'; 86 SEndUpdateTooLow = 'Update counter error'; 82 87 83 88 { TFormContacts } … … 99 104 if Item.Index < ListViewSort1.List.Count then 100 105 with TContact(ListViewSort1.List[Item.Index]) do begin 101 102 106 AddItem(Fields[cfFullName], True); 103 107 AddItem(Fields[cfFirstName]); … … 220 224 end; 221 225 226 procedure TFormContacts.DoUpdateInterface; 227 var 228 Text: string; 229 SelectedCount: Integer; 230 begin 231 AAdd.Enabled := Assigned(Contacts); 232 AModify.Enabled := Assigned(Contacts) and Assigned(ListView1.Selected); 233 ARemove.Enabled := Assigned(Contacts) and Assigned(ListView1.Selected); 234 235 Text := ''; 236 if Assigned(Contacts) then begin 237 Text := STotal + ': ' + IntToStr(Contacts.Count); 238 if ListView1.Items.Count < Contacts.Count then 239 Text := Text + ', ' + SFiltered + ': ' + IntToStr(ListView1.Items.Count); 240 SelectedCount := ListView1.SelCount; 241 if SelectedCount > 0 then 242 Text := Text + ', ' + SSelected + ': ' + IntToStr(SelectedCount); 243 end; 244 StatusBar1.Panels[0].Text := Text; 245 end; 246 222 247 procedure TFormContacts.FormShow(Sender: TObject); 223 248 begin … … 268 293 Contact := TContact.Create; 269 294 try 295 Contact.Parent := Contacts.ContactsFile; 270 296 Contact.Assign(TContact(ListView1.Selected.Data)); 271 297 FormContact.Contact := Contact; … … 297 323 Contact := TContact.Create; 298 324 try 325 Contact.Parent := Contacts.ContactsFile; 299 326 Contact.Assign(TContact(ListView1.Selected.Data)); 300 327 FormContact.Contact := Contact; … … 333 360 334 361 procedure TFormContacts.ASelectAllExecute(Sender: TObject); 335 begin 336 ListView1.SelectAll; 337 UpdateInterface; 362 var 363 I: Integer; 364 begin 365 BeginUpdate; 366 ListView1.BeginUpdate; 367 for I := 0 to ListView1.Items.Count - 1 do 368 ListView1.Items[I].Selected := True; 369 //ListView1.SelectAll; 370 ListView1.EndUpdate; 371 EndUpdate; 338 372 end; 339 373 … … 360 394 end; 361 395 396 procedure TFormContacts.BeginUpdate; 397 begin 398 Inc(FUpdateCount); 399 end; 400 401 procedure TFormContacts.EndUpdate; 402 begin 403 if FUpdateCount <= 0 then raise Exception(SEndUpdateTooLow); 404 Dec(FUpdateCount); 405 if FUpdateCount = 0 then DoUpdateInterface; 406 end; 407 362 408 procedure TFormContacts.UpdateInterface; 363 var 364 Text: string; 365 SelectedCount: Integer; 366 begin 367 AAdd.Enabled := Assigned(Contacts); 368 AModify.Enabled := Assigned(Contacts) and Assigned(ListView1.Selected); 369 ARemove.Enabled := Assigned(Contacts) and Assigned(ListView1.Selected); 370 371 Text := ''; 372 if Assigned(Contacts) then begin 373 Text := STotal + ': ' + IntToStr(Contacts.Count); 374 if ListView1.Items.Count < Contacts.Count then 375 Text := Text + ', ' + SFiltered + ': ' + IntToStr(ListView1.Items.Count); 376 SelectedCount := ListView1.SelCount; 377 if SelectedCount > 0 then 378 Text := Text + ', ' + SSelected + ': ' + IntToStr(SelectedCount); 379 end; 380 StatusBar1.Panels[0].Text := Text; 409 begin 410 if FUpdateCount = 0 then DoUpdateInterface; 381 411 end; 382 412
Note:
See TracChangeset
for help on using the changeset viewer.