Changeset 76 for trunk/Forms
- Timestamp:
- Dec 15, 2021, 8:56:06 PM (3 years ago)
- Location:
- trunk/Forms
- Files:
-
- 3 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormContacts.lfm
r74 r76 10 10 OnClose = FormClose 11 11 OnCreate = FormCreate 12 OnDestroy = FormDestroy 13 OnResize = FormResize 12 14 OnShow = FormShow 13 15 LCLVersion = '2.0.12.0' 14 16 object ListView1: TListView 15 17 Left = 0 16 Height = 8 1018 Height = 801 17 19 Top = 0 18 20 Width = 1210 … … 66 68 Left = 0 67 69 Height = 39 68 Top = 8 4270 Top = 833 69 71 Width = 1210 70 72 Align = alBottom … … 114 116 Left = 0 115 117 Height = 32 116 Top = 8 10118 Top = 801 117 119 Width = 1210 118 120 OnChange = ListViewFilter1Change … … 121 123 object StatusBar1: TStatusBar 122 124 Left = 0 123 Height = 27124 Top = 8 81125 Height = 36 126 Top = 872 125 127 Width = 1210 126 128 Panels = < -
trunk/Forms/UFormContacts.pas
r74 r76 64 64 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 65 65 procedure FormCreate(Sender: TObject); 66 procedure FormDestroy(Sender: TObject); 67 procedure FormResize(Sender: TObject); 66 68 procedure FormShow(Sender: TObject); 67 69 procedure ListView1Data(Sender: TObject; Item: TListItem); … … 81 83 procedure FormContactNext(Sender: TObject); 82 84 procedure DoUpdateInterface; 85 procedure UpdateColumns; 83 86 public 87 ListViewColumns: TContactFieldIndexes; 88 FilterItems: TContactFilterItems; 84 89 property Contacts: TContacts read FContacts write SetContacts; 85 90 procedure ReloadList; … … 123 128 end; 124 129 130 var 131 I: Integer; 125 132 begin 126 133 if Item.Index < ListViewSort1.List.Count then 127 134 with TContact(ListViewSort1.List[Item.Index]) do begin 128 AddItem(Fields[cfFullName], True); 129 AddItem(Fields[cfFirstName]); 130 AddItem(Fields[cfMiddleName]); 131 AddItem(Fields[cfLastName]); 132 AddItem(Fields[cfTel]); 133 AddItem(Fields[cfTelCell]); 134 AddItem(Fields[cfTelHome]); 135 AddItem(Fields[cfTelWork]); 135 for I := 0 to ListViewColumns.Count - 1 do begin 136 AddItem(Fields[ListViewColumns[I]], I = 0); 137 end; 136 138 Item.Data := ListViewSort1.List[Item.Index]; 137 139 end; … … 150 152 151 153 procedure TFormContacts.ListViewFilter1Change(Sender: TObject); 152 begin 154 var 155 I: Integer; 156 begin 157 // Load filter StringGrid cells into filter 158 FilterItems.Clear; 159 for I := 0 to ListViewColumns.Count - 1 do 160 if I < ListViewFilter1.StringGrid.ColCount then 161 if ListViewFilter1.StringGrid.Cells[I, 0] <> '' then 162 FilterItems.AddNew(ListViewColumns[I], ListViewFilter1.StringGrid.Cells[I, 0]); 163 153 164 ReloadList; 154 165 UpdateInterface; … … 165 176 if Assigned(Item1) and Assigned(Item2) and (ListViewSort1.Order <> soNone) then begin 166 177 with ListViewSort1 do 167 case Column of 168 0: Result := CompareString(TContact(Item1).Fields[cfFullName], TContact(Item2).Fields[cfFullName]); 169 1: Result := CompareString(TContact(Item1).Fields[cfFirstName], TContact(Item2).Fields[cfFirstName]); 170 2: Result := CompareString(TContact(Item1).Fields[cfMiddleName], TContact(Item2).Fields[cfMiddleName]); 171 3: Result := CompareString(TContact(Item1).Fields[cfLastName], TContact(Item2).Fields[cfLastName]); 172 4: Result := CompareString(TContact(Item1).Fields[cfTel], TContact(Item2).Fields[cfTel]); 173 5: Result := CompareString(TContact(Item1).Fields[cfTelCell], TContact(Item2).Fields[cfTelCell]); 174 6: Result := CompareString(TContact(Item1).Fields[cfTelHome], TContact(Item2).Fields[cfTelHome]); 175 7: Result := CompareString(TContact(Item1).Fields[cfTelWork], TContact(Item2).Fields[cfTelWork]); 176 end; 178 Result := CompareString(TContact(Item1).Fields[ListViewColumns[Column]], TContact(Item2).Fields[ListViewColumns[Column]]); 177 179 if ListViewSort1.Order = soDown then Result := -Result; 178 180 end else Result := 0; … … 191 193 var 192 194 I: Integer; 195 J: Integer; 196 K: Integer; 193 197 FoundCount: Integer; 194 EnteredCount: Integer; 195 begin 196 EnteredCount := ListViewFilter1.TextEnteredCount; 198 begin 197 199 for I := List.Count - 1 downto 0 do begin 198 200 if List.Items[I] is TContact then begin 199 201 with TContact(List.Items[I]) do begin 200 with ListViewFilter1 do 201 if Visible and (EnteredCount > 0) then begin 202 FoundCount := 0; 203 if Pos(UTF8LowerCase(StringGrid.Cells[0, 0]), 204 UTF8LowerCase(TContact(List.Items[I]).Fields[cfFullName])) > 0 then Inc(FoundCount); 205 if Pos(UTF8LowerCase(StringGrid.Cells[1, 0]), 206 UTF8LowerCase(TContact(List.Items[I]).Fields[cfFirstName])) > 0 then Inc(FoundCount); 207 if Pos(UTF8LowerCase(StringGrid.Cells[2, 0]), 208 UTF8LowerCase(TContact(List.Items[I]).Fields[cfMiddleName])) > 0 then Inc(FoundCount); 209 if Pos(UTF8LowerCase(StringGrid.Cells[3, 0]), 210 UTF8LowerCase(TContact(List.Items[I]).Fields[cfLastName])) > 0 then Inc(FoundCount); 211 if Pos(UTF8LowerCase(StringGrid.Cells[4, 0]), 212 UTF8LowerCase(TContact(List.Items[I]).Fields[cfTel])) > 0 then Inc(FoundCount); 213 if Pos(UTF8LowerCase(StringGrid.Cells[5, 0]), 214 UTF8LowerCase(TContact(List.Items[I]).Fields[cfTelCell])) > 0 then Inc(FoundCount); 215 if Pos(UTF8LowerCase(StringGrid.Cells[6, 0]), 216 UTF8LowerCase(TContact(List.Items[I]).Fields[cfTelHome])) > 0 then Inc(FoundCount); 217 if Pos(UTF8LowerCase(StringGrid.Cells[7, 0]), 218 UTF8LowerCase(TContact(List.Items[I]).Fields[cfTelWork])) > 0 then Inc(FoundCount); 219 if FoundCount <> EnteredCount then List.Delete(I); 220 end; 202 FoundCount := 0; 203 for J := 0 to FilterItems.Count - 1 do begin 204 if FilterItems[J].FieldIndex = cfNone then begin 205 for K := 0 to TContact(List.Items[I]).Parent.Fields.Count - 1 do begin 206 if Pos(UTF8LowerCase(FilterItems[J].Value), 207 UTF8LowerCase(TContact(List.Items[I]).Fields[TContact(List.Items[I]).Parent.Fields[K].Index])) > 0 then begin 208 Inc(FoundCount); 209 Break; 210 end; 211 end; 212 end else begin 213 if Pos(UTF8LowerCase(FilterItems[J].Value), 214 UTF8LowerCase(TContact(List.Items[I]).Fields[FilterItems[J].FieldIndex])) > 0 then 215 Inc(FoundCount); 216 end; 217 end; 218 if FoundCount <> FilterItems.Count then List.Delete(I); 221 219 end; 222 220 end else … … 273 271 end; 274 272 StatusBar1.Panels[0].Text := Text; 273 end; 274 275 procedure TFormContacts.UpdateColumns; 276 var 277 I: Integer; 278 Field: TContactField; 279 begin 280 while ListView1.Columns.Count < ListViewColumns.Count do 281 ListView1.Columns.Add; 282 while ListView1.Columns.Count > ListViewColumns.Count do 283 ListView1.Columns.Delete(ListView1.Columns.Count - 1); 284 for I := 0 to ListView1.Columns.Count - 1 do begin 285 if Assigned(Contacts) and Assigned(Contacts.ContactsFile) then begin 286 Field := Contacts.ContactsFile.Fields.GetByIndex(ListViewColumns[I]); 287 if Assigned(Field) then 288 ListView1.Columns[I].Caption := Field.Title; 289 end; 290 end; 275 291 end; 276 292 … … 512 528 begin 513 529 BeginUpdate; 514 ListView1.BeginUpdate; 515 for I := 0 to ListView1.Items.Count - 1 do 516 ListView1.Items[I].Selected := True; 517 //ListView1.SelectAll; 518 ListView1.EndUpdate; 519 EndUpdate; 530 try 531 ListView1.BeginUpdate; 532 try 533 for I := 0 to ListView1.Items.Count - 1 do 534 ListView1.Items[I].Selected := True; 535 //ListView1.SelectAll; 536 finally 537 ListView1.EndUpdate; 538 end; 539 finally 540 EndUpdate; 541 end; 520 542 end; 521 543 … … 530 552 I: Integer; 531 553 begin 554 FilterItems := TContactFilterItems.Create; 555 556 ListViewColumns := TContactFieldIndexes.Create; 557 ListViewColumns.Add(cfFullName); 558 ListViewColumns.Add(cfFirstName); 559 ListViewColumns.Add(cfMiddleName); 560 ListViewColumns.Add(cfLastName); 561 ListViewColumns.Add(cfTel); 562 ListViewColumns.Add(cfTelCell); 563 ListViewColumns.Add(cfTelHome); 564 ListViewColumns.Add(cfTelWork); 565 ListViewColumns.Add(cfEmailWork); 566 532 567 FContacts := nil; 533 568 for I := 0 to ToolBar1.ButtonCount - 1 do begin … … 535 570 ToolBar1.Buttons[I].Hint := ToolBar1.Buttons[I].Caption; 536 571 end; 572 end; 573 574 procedure TFormContacts.FormDestroy(Sender: TObject); 575 begin 576 FreeAndNil(ListViewColumns); 577 FreeAndNil(FilterItems); 578 end; 579 580 procedure TFormContacts.FormResize(Sender: TObject); 581 begin 582 ListViewFilter1.UpdateFromListView(ListView1); 537 583 end; 538 584 … … 567 613 ACut.Enabled := Assigned(Contacts) and Assigned(ListView1.Selected); 568 614 APaste.Enabled := Assigned(Contacts) and (Clipboard.AsText <> ''); 615 616 UpdateColumns; 569 617 end; 570 618 -
trunk/Forms/UFormMain.lfm
r73 r76 148 148 end 149 149 end 150 object MenuItem7: TMenuItem 151 Caption = 'Find' 152 object MenuItem8: TMenuItem 153 Action = Core.AFind 154 end 155 object MenuItem9: TMenuItem 156 Action = Core.AFindDuplicate 157 end 158 end 150 159 object MenuItemView: TMenuItem 151 160 Caption = 'View' … … 161 170 Action = Core.ASettings 162 171 end 163 object MenuItem 4: TMenuItem164 Action = Core.AFindDuplicate172 object MenuItem10: TMenuItem 173 Caption = '-' 165 174 end 166 175 object MenuItem5: TMenuItem -
trunk/Forms/UFormMain.lrj
r62 r76 3 3 {"hash":315429,"name":"tformmain.menuitemfile.caption","sourcebytes":[70,105,108,101],"value":"File"}, 4 4 {"hash":131987540,"name":"tformmain.menuitemfileopenrecent.caption","sourcebytes":[79,112,101,110,32,114,101,99,101,110,116],"value":"Open recent"}, 5 {"hash":315460,"name":"tformmain.menuitem7.caption","sourcebytes":[70,105,110,100],"value":"Find"}, 5 6 {"hash":380871,"name":"tformmain.menuitemview.caption","sourcebytes":[86,105,101,119],"value":"View"}, 6 7 {"hash":8267778,"name":"tformmain.menuitemtoolbar.caption","sourcebytes":[77,97,105,110,32,116,111,111,108,98,97,114],"value":"Main toolbar"}, -
trunk/Forms/UFormMain.pas
r62 r76 17 17 MainMenu1: TMainMenu; 18 18 MenuItem1: TMenuItem; 19 MenuItem10: TMenuItem; 19 20 MenuItem3: TMenuItem; 20 MenuItem4: TMenuItem;21 21 MenuItem5: TMenuItem; 22 22 MenuItem6: TMenuItem; 23 MenuItem7: TMenuItem; 24 MenuItem8: TMenuItem; 25 MenuItem9: TMenuItem; 23 26 MenuItemToolbar: TMenuItem; 24 27 MenuItemView: TMenuItem; … … 90 93 procedure TFormMain.FormCreate(Sender: TObject); 91 94 begin 95 FormContacts := TFormContacts.Create(nil); 92 96 end; 93 97 94 98 procedure TFormMain.FormDestroy(Sender: TObject); 95 99 begin 96 F ormContacts.Free;100 FreeAndNil(FormContacts); 97 101 end; 98 102 … … 111 115 CoolBar1.AutosizeBands; 112 116 113 FormContacts := TFormContacts.Create(nil);114 117 FormContacts.Contacts := TContactsFile(Core.DataFile).Contacts; 115 118 FormContacts.ManualDock(Self, nil, alClient);
Note:
See TracChangeset
for help on using the changeset viewer.