Changeset 73 for trunk/Forms/UFormImportSources.pas
- Timestamp:
- Aug 2, 2016, 11:21:21 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormImportSources.pas
r72 r73 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls, 9 ActnList, Menus, UAcronym, UJobProgressView; 9 ActnList, Menus, UAcronym, UJobProgressView, UListViewSort, SpecializedList, 10 LazUTF8; 10 11 11 12 type … … 23 24 JobProgressView1: TJobProgressView; 24 25 ListView1: TListView; 26 ListViewFilter1: TListViewFilter; 27 ListViewSort1: TListViewSort; 25 28 MenuItem1: TMenuItem; 26 29 MenuItem2: TMenuItem; … … 43 46 procedure FormCreate(Sender: TObject); 44 47 procedure FormShow(Sender: TObject); 48 procedure ListView1Change(Sender: TObject; Item: TListItem; 49 Change: TItemChange); 50 procedure ListView1Click(Sender: TObject); 45 51 procedure ListView1Data(Sender: TObject; Item: TListItem); 46 52 procedure ListView1DblClick(Sender: TObject); 53 procedure ListView1Resize(Sender: TObject); 47 54 procedure ListView1SelectItem(Sender: TObject; Item: TListItem; 48 55 Selected: Boolean); 56 procedure ListViewFilter1Change(Sender: TObject); 57 function ListViewSort1CompareItem(Item1, Item2: TObject): Integer; 58 procedure ListViewSort1Filter(ListViewSort: TListViewSort); 49 59 private 50 60 procedure ProcessImportJob(Job: TJob); 51 { private declarations }61 procedure FilterList(List: TListObject); 52 62 public 53 63 ImportSources: TImportSources; … … 77 87 procedure TFormImportSources.ListView1Data(Sender: TObject; Item: TListItem); 78 88 begin 79 if Item.Index < ImportSources.Count then80 with TImportSource( ImportSources[Item.Index]) do begin89 if Item.Index < ListViewSort1.List.Count then 90 with TImportSource(ListViewSort1.List[Item.Index]) do begin 81 91 Item.Caption := Name; 82 Item.Data := ImportSources[Item.Index];92 Item.Data := ListViewSort1.List[Item.Index]; 83 93 Item.SubItems.Add(URL); 84 94 Item.SubItems.Add(Categories.GetString); … … 96 106 end; 97 107 108 procedure TFormImportSources.ListView1Resize(Sender: TObject); 109 begin 110 ListViewFilter1.UpdateFromListView(ListView1); 111 end; 112 98 113 procedure TFormImportSources.ListView1SelectItem(Sender: TObject; 99 114 Item: TListItem; Selected: Boolean); … … 102 117 end; 103 118 119 procedure TFormImportSources.ListViewFilter1Change(Sender: TObject); 120 begin 121 UpdateList; 122 end; 123 124 function TFormImportSources.ListViewSort1CompareItem(Item1, Item2: TObject 125 ): Integer; 126 begin 127 Result := 0; 128 if Assigned(Item1) and Assigned(Item2) and (ListViewSort1.Order <> soNone) then begin 129 with ListViewSort1 do 130 case Column of 131 0: Result := CompareString(TImportSource(Item1).Name, TImportSource(Item2).Name); 132 1: Result := CompareString(TImportSource(Item1).URL, TImportSource(Item2).URL); 133 2: Result := CompareString(TImportSource(Item1).Categories.GetString, TImportSource(Item2).Categories.GetString); 134 3: Result := CompareInteger(TImportSource(Item1).ItemCount, TImportSource(Item2).ItemCount); 135 4: Result := CompareTime(TImportSource(Item1).LastImportTime, TImportSource(Item2).LastImportTime); 136 end; 137 if ListViewSort1.Order = soDown then Result := -Result; 138 end else Result := 0; 139 end; 140 141 procedure TFormImportSources.ListViewSort1Filter(ListViewSort: TListViewSort); 142 begin 143 ImportSources.AssignToList(ListViewSort1.List); 144 FilterList(ListViewSort1.List); 145 end; 146 104 147 procedure TFormImportSources.UpdateList; 105 148 begin 106 ListView1.Items.Count := ImportSources.Count; 107 ListView1.Refresh; 149 ListViewSort1.Refresh; 108 150 UpdateInterface; 109 151 end; … … 118 160 begin 119 161 UpdateList; 162 end; 163 164 procedure TFormImportSources.ListView1Change(Sender: TObject; Item: TListItem; 165 Change: TItemChange); 166 begin 167 if Assigned(Item) and (Change = ctState) then begin 168 TImportSource(Item.Data).Enabled := Item.Checked; 169 end; 170 end; 171 172 procedure TFormImportSources.ListView1Click(Sender: TObject); 173 begin 174 120 175 end; 121 176 … … 200 255 end; 201 256 257 procedure TFormImportSources.FilterList(List: TListObject); 258 var 259 I: Integer; 260 FoundCount: Integer; 261 EnteredCount: Integer; 262 begin 263 EnteredCount := ListViewFilter1.TextEnteredCount; 264 for I := List.Count - 1 downto 0 do begin 265 if List.Items[I] is TImportSource then begin 266 with TImportSource(List.Items[I]) do begin 267 with ListViewFilter1 do 268 if Visible and (EnteredCount > 0) then begin 269 FoundCount := 0; 270 if Pos(UTF8LowerCase(StringGrid.Cells[0, 0]), 271 UTF8LowerCase(TImportSource(List.Items[I]).Name)) > 0 then Inc(FoundCount); 272 if Pos(UTF8LowerCase(StringGrid.Cells[1, 0]), 273 UTF8LowerCase(TImportSource(List.Items[I]).URL)) > 0 then Inc(FoundCount); 274 if Pos(UTF8LowerCase(StringGrid.Cells[2, 0]), 275 UTF8LowerCase(TImportSource(List.Items[I]).Categories.GetString)) > 0 then Inc(FoundCount); 276 if Pos(UTF8LowerCase(StringGrid.Cells[2, 0]), 277 UTF8LowerCase(IntToStr(TImportSource(List.Items[I]).ItemCount))) > 0 then Inc(FoundCount); 278 if Pos(UTF8LowerCase(StringGrid.Cells[2, 0]), 279 UTF8LowerCase(DateTimeToStr(TImportSource(List.Items[I]).LastImportTime))) > 0 then Inc(FoundCount); 280 if FoundCount <> EnteredCount then List.Delete(I); 281 end; 282 end; 283 end else 284 if TImportSource(List.Items[I]) is TImportSource then begin 285 List.Delete(I); 286 end; 287 end; 288 end; 289 202 290 procedure TFormImportSources.ARemoveExecute(Sender: TObject); 203 291 var
Note:
See TracChangeset
for help on using the changeset viewer.