Changeset 73 for trunk/Forms


Ignore:
Timestamp:
Aug 2, 2016, 11:21:21 AM (8 years ago)
Author:
chronos
Message:
  • Added: Text filtering in list of import sources.
  • Fixed: Now checkboxes in list of import sources are visible and working for enabling item.
Location:
trunk/Forms
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormImportSources.lfm

    r72 r73  
    1010  OnShow = FormShow
    1111  Position = poScreenCenter
    12   LCLVersion = '1.7'
    13   object ListView1: TListView
    14     Left = 8
    15     Height = 376
    16     Top = 8
    17     Width = 798
    18     Anchors = [akTop, akLeft, akRight, akBottom]
    19     Checkboxes = True
    20     Columns = <   
    21       item
    22         Caption = 'Name'
    23         Width = 150
    24       end   
    25       item
    26         Caption = 'URL'
    27         Width = 250
    28       end   
    29       item
    30         Caption = 'Categories'
    31         Width = 200
    32       end   
    33       item
    34         Caption = 'Count'
    35         Width = 70
    36       end   
    37       item
    38         Caption = 'Date'
    39         Width = 108
    40       end>
    41     MultiSelect = True
    42     OwnerData = True
    43     PopupMenu = PopupMenuImportSource
    44     ReadOnly = True
    45     RowSelect = True
    46     TabOrder = 0
    47     ViewStyle = vsReport
    48     OnData = ListView1Data
    49     OnDblClick = ListView1DblClick
    50     OnSelectItem = ListView1SelectItem
    51   end
     12  LCLVersion = '1.6.0.4'
    5213  object ToolBar1: TToolBar
    5314    Left = 0
     
    6021    ParentShowHint = False
    6122    ShowHint = True
    62     TabOrder = 1
     23    TabOrder = 0
    6324    object ToolButton1: TToolButton
    6425      Left = 1
     
    8142      Action = AProcess
    8243    end
     44  end
     45  object ListView1: TListView
     46    Left = 8
     47    Height = 340
     48    Top = 44
     49    Width = 798
     50    Anchors = [akTop, akLeft, akRight, akBottom]
     51    Checkboxes = True
     52    Columns = <   
     53      item
     54        Caption = 'Name'
     55        Width = 150
     56      end   
     57      item
     58        Caption = 'URL'
     59        Width = 250
     60      end   
     61      item
     62        Caption = 'Categories'
     63        Width = 200
     64      end   
     65      item
     66        Caption = 'Count'
     67        Width = 70
     68      end   
     69      item
     70        Caption = 'Date'
     71        Width = 100
     72      end>
     73    MultiSelect = True
     74    OwnerData = True
     75    PopupMenu = PopupMenuImportSource
     76    ReadOnly = True
     77    RowSelect = True
     78    TabOrder = 1
     79    ViewStyle = vsReport
     80    OnChange = ListView1Change
     81    OnClick = ListView1Click
     82    OnData = ListView1Data
     83    OnDblClick = ListView1DblClick
     84    OnResize = ListView1Resize
     85    OnSelectItem = ListView1SelectItem
     86  end
     87  object ListViewFilter1: TListViewFilter
     88    Left = 8
     89    Height = 29
     90    Top = 11
     91    Width = 798
     92    OnChange = ListViewFilter1Change
     93    Anchors = [akTop, akLeft, akRight]
    8394  end
    8495  object ActionList1: TActionList
     
    108119      ImageIndex = 5
    109120      OnExecute = AProcessExecute
    110     end
    111     object AEnable: TAction
    112       Caption = 'Enable'
    113       OnExecute = AEnableExecute
    114     end
    115     object ADisable: TAction
    116       Caption = 'Disable'
    117       OnExecute = ADisableExecute
    118121    end
    119122  end
     
    278281      }
    279282    end
    280     object MenuItem6: TMenuItem
    281       Action = AEnable
    282     end
    283     object MenuItem5: TMenuItem
    284       Action = ADisable
    285     end
    286283  end
    287284  object JobProgressView1: TJobProgressView
     
    292289    top = 119
    293290  end
     291  object ListViewSort1: TListViewSort
     292    ListView = ListView1
     293    OnCompareItem = ListViewSort1CompareItem
     294    OnFilter = ListViewSort1Filter
     295    Column = 0
     296    Order = soNone
     297    left = 547
     298    top = 172
     299  end
    294300end
  • trunk/Forms/UFormImportSources.lrt

    r72 r73  
    11TFORMIMPORTSOURCES.CAPTION=Import sources
     2TFORMIMPORTSOURCES.TOOLBAR1.CAPTION=ToolBar1
    23TFORMIMPORTSOURCES.LISTVIEW1.COLUMNS[0].CAPTION=Name
    34TFORMIMPORTSOURCES.LISTVIEW1.COLUMNS[1].CAPTION=URL
     
    56TFORMIMPORTSOURCES.LISTVIEW1.COLUMNS[3].CAPTION=Count
    67TFORMIMPORTSOURCES.LISTVIEW1.COLUMNS[4].CAPTION=Date
    7 TFORMIMPORTSOURCES.TOOLBAR1.CAPTION=ToolBar1
    88TFORMIMPORTSOURCES.AADD.CAPTION=Add
    99TFORMIMPORTSOURCES.AREMOVE.CAPTION=Remove
    1010TFORMIMPORTSOURCES.AMODIFY.CAPTION=Modify
    1111TFORMIMPORTSOURCES.APROCESS.CAPTION=Process
    12 TFORMIMPORTSOURCES.AENABLE.CAPTION=Enable
    13 TFORMIMPORTSOURCES.ADISABLE.CAPTION=Disable
  • trunk/Forms/UFormImportSources.pas

    r72 r73  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
    9   ActnList, Menus, UAcronym, UJobProgressView;
     9  ActnList, Menus, UAcronym, UJobProgressView, UListViewSort, SpecializedList,
     10  LazUTF8;
    1011
    1112type
     
    2324    JobProgressView1: TJobProgressView;
    2425    ListView1: TListView;
     26    ListViewFilter1: TListViewFilter;
     27    ListViewSort1: TListViewSort;
    2528    MenuItem1: TMenuItem;
    2629    MenuItem2: TMenuItem;
     
    4346    procedure FormCreate(Sender: TObject);
    4447    procedure FormShow(Sender: TObject);
     48    procedure ListView1Change(Sender: TObject; Item: TListItem;
     49      Change: TItemChange);
     50    procedure ListView1Click(Sender: TObject);
    4551    procedure ListView1Data(Sender: TObject; Item: TListItem);
    4652    procedure ListView1DblClick(Sender: TObject);
     53    procedure ListView1Resize(Sender: TObject);
    4754    procedure ListView1SelectItem(Sender: TObject; Item: TListItem;
    4855      Selected: Boolean);
     56    procedure ListViewFilter1Change(Sender: TObject);
     57    function ListViewSort1CompareItem(Item1, Item2: TObject): Integer;
     58    procedure ListViewSort1Filter(ListViewSort: TListViewSort);
    4959  private
    5060    procedure ProcessImportJob(Job: TJob);
    51     { private declarations }
     61    procedure FilterList(List: TListObject);
    5262  public
    5363    ImportSources: TImportSources;
     
    7787procedure TFormImportSources.ListView1Data(Sender: TObject; Item: TListItem);
    7888begin
    79   if Item.Index < ImportSources.Count then
    80   with TImportSource(ImportSources[Item.Index]) do begin
     89  if Item.Index < ListViewSort1.List.Count then
     90  with TImportSource(ListViewSort1.List[Item.Index]) do begin
    8191    Item.Caption := Name;
    82     Item.Data := ImportSources[Item.Index];
     92    Item.Data := ListViewSort1.List[Item.Index];
    8393    Item.SubItems.Add(URL);
    8494    Item.SubItems.Add(Categories.GetString);
     
    96106end;
    97107
     108procedure TFormImportSources.ListView1Resize(Sender: TObject);
     109begin
     110  ListViewFilter1.UpdateFromListView(ListView1);
     111end;
     112
    98113procedure TFormImportSources.ListView1SelectItem(Sender: TObject;
    99114  Item: TListItem; Selected: Boolean);
     
    102117end;
    103118
     119procedure TFormImportSources.ListViewFilter1Change(Sender: TObject);
     120begin
     121  UpdateList;
     122end;
     123
     124function TFormImportSources.ListViewSort1CompareItem(Item1, Item2: TObject
     125  ): Integer;
     126begin
     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;
     139end;
     140
     141procedure TFormImportSources.ListViewSort1Filter(ListViewSort: TListViewSort);
     142begin
     143  ImportSources.AssignToList(ListViewSort1.List);
     144  FilterList(ListViewSort1.List);
     145end;
     146
    104147procedure TFormImportSources.UpdateList;
    105148begin
    106   ListView1.Items.Count := ImportSources.Count;
    107   ListView1.Refresh;
     149  ListViewSort1.Refresh;
    108150  UpdateInterface;
    109151end;
     
    118160begin
    119161  UpdateList;
     162end;
     163
     164procedure TFormImportSources.ListView1Change(Sender: TObject; Item: TListItem;
     165  Change: TItemChange);
     166begin
     167  if Assigned(Item) and (Change = ctState) then begin
     168    TImportSource(Item.Data).Enabled := Item.Checked;
     169  end;
     170end;
     171
     172procedure TFormImportSources.ListView1Click(Sender: TObject);
     173begin
     174
    120175end;
    121176
     
    200255end;
    201256
     257procedure TFormImportSources.FilterList(List: TListObject);
     258var
     259  I: Integer;
     260  FoundCount: Integer;
     261  EnteredCount: Integer;
     262begin
     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;
     288end;
     289
    202290procedure TFormImportSources.ARemoveExecute(Sender: TObject);
    203291var
  • trunk/Forms/UFormMain.lfm

    r64 r73  
    14181418    OnChange = LastOpenedList1Change
    14191419    left = 264
    1420     top = 267
     1420    top = 240
    14211421  end
    14221422  object CoolTranslator1: TCoolTranslator
     
    19901990    ShowDelay = 0
    19911991    AutoClose = False
    1992     left = 370
    1993     top = 143
     1992    left = 264
     1993    top = 296
    19941994  end
    19951995end
  • trunk/Forms/UFormMain.pas

    r71 r73  
    388388  with TAcronymMeaning(ListViewSort1.List[Item.Index]) do begin
    389389    Item.Caption := Acronym.Name;
     390    Item.Data := TAcronymMeaning(ListViewSort1.List[Item.Index]);
    390391    Item.SubItems.Add(Name);
    391     Item.Data := TAcronymMeaning(ListViewSort1.List[Item.Index]);
    392392    Item.SubItems.Add(Categories.GetString);
    393393  end;
Note: See TracChangeset for help on using the changeset viewer.