Changeset 145


Ignore:
Timestamp:
Jan 24, 2017, 1:55:43 PM (8 years ago)
Author:
chronos
Message:
  • Added: Allow to disable selected acronym categories so acronyms without any enabled category won't be shown in main acronym search filter.
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormCategories.lfm

    r123 r145  
    11object FormCategories: TFormCategories
    2   Left = 592
     2  Left = 516
    33  Height = 429
    4   Top = 490
     4  Top = 439
    55  Width = 784
    66  Caption = 'Acronym categories'
     
    1111  OnShow = FormShow
    1212  Position = poScreenCenter
    13   LCLVersion = '1.6.0.4'
     13  LCLVersion = '1.6.2.0'
    1414  object ListViewCategories: TListView
    1515    Left = 4
     
    1919    Align = alClient
    2020    BorderSpacing.Around = 4
     21    Checkboxes = True
    2122    Columns = <   
    2223      item
     
    3536    TabOrder = 0
    3637    ViewStyle = vsReport
     38    OnChange = ListViewCategoriesChange
    3739    OnData = ListViewCategoriesData
    3840    OnDblClick = ListViewCategoriesDblClick
     
    9395      OnExecute = ASelectAllExecute
    9496      ShortCut = 16449
     97    end
     98    object AEnable: TAction
     99      Caption = 'Enable'
     100      OnExecute = AEnableExecute
     101    end
     102    object ADisable: TAction
     103      Caption = 'Disable'
     104      OnExecute = ADisableExecute
    95105    end
    96106  end
     
    219229      Action = ASelectAll
    220230    end
     231    object MenuItem5: TMenuItem
     232      Caption = '-'
     233    end
     234    object MenuItem6: TMenuItem
     235      Action = AEnable
     236    end
     237    object MenuItem7: TMenuItem
     238      Action = ADisable
     239    end
     240  end
     241  object ListViewSort1: TListViewSort
     242    ListView = ListViewCategories
     243    OnCompareItem = ListViewSort1CompareItem
     244    OnFilter = ListViewSort1Filter
     245    Column = 0
     246    Order = soNone
     247    left = 536
     248    top = 184
    221249  end
    222250end
  • trunk/Forms/UFormCategories.lrt

    r123 r145  
    77TFORMCATEGORIES.AMODIFY.CAPTION=Modify
    88TFORMCATEGORIES.ASELECTALL.CAPTION=Select all
     9TFORMCATEGORIES.AENABLE.CAPTION=Enable
     10TFORMCATEGORIES.ADISABLE.CAPTION=Disable
     11TFORMCATEGORIES.MENUITEM5.CAPTION=-
  • trunk/Forms/UFormCategories.pas

    r123 r145  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
    9   ActnList, Menus, UAcronym;
     9  ActnList, Menus, UAcronym, UListViewSort;
    1010
    1111type
     
    1515  TFormCategories = class(TForm)
    1616    AAdd: TAction;
     17    AEnable: TAction;
     18    ADisable: TAction;
    1719    ASelectAll: TAction;
    1820    ARemove: TAction;
     
    2022    ActionList1: TActionList;
    2123    ListViewCategories: TListView;
     24    ListViewSort1: TListViewSort;
    2225    MenuItem1: TMenuItem;
    2326    MenuItem2: TMenuItem;
    2427    MenuItem3: TMenuItem;
    2528    MenuItem4: TMenuItem;
     29    MenuItem5: TMenuItem;
     30    MenuItem6: TMenuItem;
     31    MenuItem7: TMenuItem;
    2632    PopupMenuCategory: TPopupMenu;
    2733    ToolBar1: TToolBar;
     
    3036    ToolButton3: TToolButton;
    3137    procedure AAddExecute(Sender: TObject);
     38    procedure ADisableExecute(Sender: TObject);
     39    procedure AEnableExecute(Sender: TObject);
    3240    procedure AModifyExecute(Sender: TObject);
    3341    procedure ARemoveExecute(Sender: TObject);
     
    3644    procedure FormCreate(Sender: TObject);
    3745    procedure FormShow(Sender: TObject);
     46    procedure ListViewCategoriesChange(Sender: TObject; Item: TListItem;
     47      Change: TItemChange);
    3848    procedure ListViewCategoriesData(Sender: TObject; Item: TListItem);
    3949    procedure ListViewCategoriesDblClick(Sender: TObject);
     
    4151    procedure ListViewCategoriesSelectItem(Sender: TObject; Item: TListItem;
    4252      Selected: Boolean);
     53    function ListViewSort1CompareItem(Item1, Item2: TObject): Integer;
     54    procedure ListViewSort1Filter(ListViewSort: TListViewSort);
    4355  private
    4456    { private declarations }
     
    7385  UpdateList;
    7486  Core.ScaleDPI1.ScaleControl(ToolBar1, Core.ScaleDPI1.DesignDPI);
     87end;
     88
     89procedure TFormCategories.ListViewCategoriesChange(Sender: TObject;
     90  Item: TListItem; Change: TItemChange);
     91begin
     92  if Assigned(Item) and (Change = ctState) then begin
     93    TAcronymCategory(Item.Data).Enabled := Item.Checked;
     94    Core.AcronymDb.Modified := True;
     95  end;
    7596end;
    7697
     
    87108    end else ShowMessage(Format(SCategoryAlreadyExists, [S]));
    88109  end;
     110end;
     111
     112procedure TFormCategories.ADisableExecute(Sender: TObject);
     113var
     114  I: Integer;
     115begin
     116  for I := ListViewCategories.Items.Count - 1 downto 0 do
     117  if ListViewCategories.Items[I].Selected then begin
     118    TAcronymCategory(ListViewCategories.Items[I].Data).Enabled := False;
     119    Core.AcronymDb.Modified := True;
     120  end;
     121  UpdateList;
     122end;
     123
     124procedure TFormCategories.AEnableExecute(Sender: TObject);
     125var
     126  I: Integer;
     127begin
     128  for I := ListViewCategories.Items.Count - 1 downto 0 do
     129  if ListViewCategories.Items[I].Selected then begin
     130    TAcronymCategory(ListViewCategories.Items[I].Data).Enabled := True;
     131    Core.AcronymDb.Modified := True;
     132  end;
     133  UpdateList;
    89134end;
    90135
     
    145190procedure TFormCategories.ListViewCategoriesData(Sender: TObject; Item: TListItem);
    146191begin
    147   if Item.Index < Core.AcronymDb.Categories.Count then
    148   with TAcronymCategory(Core.AcronymDb.Categories[Item.Index]) do begin
     192  if Item.Index < ListViewSort1.List.Count then
     193  with TAcronymCategory(ListViewSort1.List[Item.Index]) do begin
    149194    Item.Caption := Name;
    150     Item.Data := Core.AcronymDb.Categories[Item.Index];
     195    Item.Data := ListViewSort1.List[Item.Index];
    151196    Item.SubItems.Add(IntToStr(AcronymMeanings.Count));
     197    Item.Checked := Enabled;
    152198  end;
    153199end;
     
    170216end;
    171217
     218function TFormCategories.ListViewSort1CompareItem(Item1, Item2: TObject
     219  ): Integer;
     220begin
     221  Result := 0;
     222  if Assigned(Item1) and Assigned(Item2) and (ListViewSort1.Order <> soNone) then begin
     223    with ListViewSort1 do
     224    case Column of
     225      0: Result := CompareString(TAcronymCategory(Item1).Name, TAcronymCategory(Item2).Name);
     226      1: Result := CompareInteger(TAcronymCategory(Item1).AcronymMeanings.Count, TAcronymCategory(Item2).AcronymMeanings.Count);
     227    end;
     228    if ListViewSort1.Order = soDown then Result := -Result;
     229  end else Result := 0;
     230end;
     231
     232procedure TFormCategories.ListViewSort1Filter(ListViewSort: TListViewSort);
     233begin
     234  Core.AcronymDb.Categories.AssignToList(ListViewSort1.List);
     235end;
     236
    172237procedure TFormCategories.UpdateList;
    173238begin
     239  ListViewSort1.Refresh;
    174240  ListViewCategories.Items.Count := Core.AcronymDb.Categories.Count;
    175241  ListViewCategories.Refresh;
  • trunk/Forms/UFormImportSources.lfm

    r123 r145  
    1111  OnShow = FormShow
    1212  Position = poScreenCenter
    13   LCLVersion = '1.6.0.4'
     13  LCLVersion = '1.6.2.0'
    1414  object ToolBar1: TToolBar
    1515    Left = 0
     
    296296      }
    297297    end
     298    object MenuItem7: TMenuItem
     299      Caption = '-'
     300    end
    298301    object MenuItem5: TMenuItem
    299302      Action = AEnable
  • trunk/Forms/UFormImportSources.lrt

    r123 r145  
    1212TFORMIMPORTSOURCES.AENABLE.CAPTION=Enable
    1313TFORMIMPORTSOURCES.ADISABLE.CAPTION=Disable
     14TFORMIMPORTSOURCES.MENUITEM7.CAPTION=-
  • trunk/Forms/UFormImportSources.pas

    r123 r145  
    3232    MenuItem5: TMenuItem;
    3333    MenuItem6: TMenuItem;
     34    MenuItem7: TMenuItem;
    3435    PopupMenuImportSource: TPopupMenu;
    3536    ToolBar1: TToolBar;
     
    182183  if Assigned(Item) and (Change = ctState) then begin
    183184    TImportSource(Item.Data).Enabled := Item.Checked;
     185    Core.AcronymDb.Modified := True;
    184186  end;
    185187end;
     
    226228begin
    227229  for I := ListView1.Items.Count - 1 downto 0 do
    228   if ListView1.Items[I].Selected then
     230  if ListView1.Items[I].Selected then begin
    229231    TImportSource(ListView1.Items[I].Data).Enabled := False;
     232    Core.AcronymDb.Modified := True;
     233  end;
    230234  UpdateList;
    231235end;
     
    236240begin
    237241  for I := ListView1.Items.Count - 1 downto 0 do
    238   if ListView1.Items[I].Selected then
     242  if ListView1.Items[I].Selected then begin
    239243    TImportSource(ListView1.Items[I].Data).Enabled := True;
     244    Core.AcronymDb.Modified := True;
     245  end;
    240246  UpdateList;
    241247end;
  • trunk/Forms/UFormMain.pas

    r144 r145  
    499499procedure TFormMain.ListViewSort1Filter(ListViewSort: TListViewSort);
    500500begin
    501   Core.AcronymDb.AssignToList(ListViewSort1.List);
     501  Core.AcronymDb.AssignToList(ListViewSort1.List, True);
    502502  FilterList(ListViewSort1.List);
    503503end;
  • trunk/Languages/AcronymDecoder.cs.po

    r139 r145  
    138138msgstr "Přidat"
    139139
     140#: tformcategories.adisable.caption
     141msgctxt "tformcategories.adisable.caption"
     142msgid "Disable"
     143msgstr "Zakázat"
     144
     145#: tformcategories.aenable.caption
     146msgctxt "tformcategories.aenable.caption"
     147msgid "Enable"
     148msgstr "Povolit"
     149
    140150#: tformcategories.amodify.caption
    141151msgctxt "tformcategories.amodify.caption"
     
    167177msgstr "Počet použití"
    168178
     179#: tformcategories.menuitem5.caption
     180msgctxt "tformcategories.menuitem5.caption"
     181msgid "-"
     182msgstr "-"
     183
    169184#: tformcategories.toolbar1.caption
    170185msgctxt "tformcategories.toolbar1.caption"
     
    442457
    443458#: tformimportsources.adisable.caption
     459msgctxt "tformimportsources.adisable.caption"
    444460msgid "Disable"
    445461msgstr "Zakázat"
    446462
    447463#: tformimportsources.aenable.caption
     464msgctxt "tformimportsources.aenable.caption"
    448465msgid "Enable"
    449466msgstr "Povolit"
     
    492509msgstr "Datum"
    493510
     511#: tformimportsources.menuitem7.caption
     512msgctxt "tformimportsources.menuitem7.caption"
     513msgid "-"
     514msgstr "-"
     515
    494516#: tformimportsources.toolbar1.caption
    495517msgctxt "tformimportsources.toolbar1.caption"
     
    893915msgid "Process import sources"
    894916msgstr "Zpracovat zdroje importu"
    895 
  • trunk/Languages/AcronymDecoder.po

    r139 r145  
    128128msgstr ""
    129129
     130#: tformcategories.adisable.caption
     131msgctxt "TFORMCATEGORIES.ADISABLE.CAPTION"
     132msgid "Disable"
     133msgstr ""
     134
     135#: tformcategories.aenable.caption
     136msgctxt "TFORMCATEGORIES.AENABLE.CAPTION"
     137msgid "Enable"
     138msgstr ""
     139
    130140#: tformcategories.amodify.caption
    131141msgctxt "TFORMCATEGORIES.AMODIFY.CAPTION"
     
    157167msgstr ""
    158168
     169#: tformcategories.menuitem5.caption
     170msgctxt "TFORMCATEGORIES.MENUITEM5.CAPTION"
     171msgid "-"
     172msgstr ""
     173
    159174#: tformcategories.toolbar1.caption
    160175msgctxt "TFORMCATEGORIES.TOOLBAR1.CAPTION"
     
    432447
    433448#: tformimportsources.adisable.caption
     449msgctxt "tformimportsources.adisable.caption"
    434450msgid "Disable"
    435451msgstr ""
    436452
    437453#: tformimportsources.aenable.caption
     454msgctxt "tformimportsources.aenable.caption"
    438455msgid "Enable"
    439456msgstr ""
     
    482499msgstr ""
    483500
     501#: tformimportsources.menuitem7.caption
     502msgctxt "TFORMIMPORTSOURCES.MENUITEM7.CAPTION"
     503msgid "-"
     504msgstr ""
     505
    484506#: tformimportsources.toolbar1.caption
    485507msgctxt "TFORMIMPORTSOURCES.TOOLBAR1.CAPTION"
  • trunk/UAcronym.pas

    r113 r145  
    7575    AcronymMeanings: TAcronymMeanings;
    7676    ImportSources: TImportSources;
     77    Enabled: Boolean;
    7778    procedure SaveToNode(Node: TDOMNode);
    7879    procedure LoadFromNode(Node: TDOMNode);
     
    9697    procedure AssignFromStrings(Strings: TStrings);
    9798    procedure AddFromStrings(Strings: TStrings);
     99    procedure AssignToList(List: TListObject);
    98100    function GetString: string;
    99101    procedure UpdateLinkImportSources(Item: TImportSource);
    100102    procedure UpdateLinkAcronymMeanings(Item: TAcronymMeaning);
     103    function IsAnyEnabled: Boolean;
    101104  end;
    102105
     
    230233    procedure RemoveMeaning(Meaning: TAcronymMeaning);
    231234    procedure RemoveAcronym(AcronymName, MeaningName: string);
    232     procedure AssignToList(List: TListObject);
     235    procedure AssignToList(List: TListObject; EnabledCategoryOnly: Boolean = False);
    233236  end;
    234237
     
    13001303end;
    13011304
     1305procedure TAcronymCategories.AssignToList(List: TListObject);
     1306var
     1307  I: Integer;
     1308begin
     1309  List.Clear;
     1310  for I := 0 to Count - 1 do
     1311    List.Add(TAcronymCategory(Items[I]))
     1312end;
     1313
    13021314function TAcronymCategories.GetString: string;
    13031315var
     
    13281340end;
    13291341
     1342function TAcronymCategories.IsAnyEnabled: Boolean;
     1343var
     1344  I: Integer;
     1345begin
     1346  Result := False;
     1347  for I := 0 to Count - 1 do
     1348  if TAcronymCategory(Items[I]).Enabled then begin
     1349    Result := True;
     1350    Break;
     1351  end;
     1352end;
    13301353
    13311354{ TAcronym }
     
    13711394  WriteString(Node, 'Name', Name);
    13721395  WriteInteger(Node, 'Id', Id);
     1396  WriteBoolean(Node, 'Enabled', Enabled);
    13731397end;
    13741398
     
    13771401  Name := ReadString(Node, 'Name', '');
    13781402  Id := ReadInteger(Node, 'Id', 0);
     1403  Enabled := ReadBoolean(Node, 'Enabled', True);
    13791404end;
    13801405
    13811406constructor TAcronymCategory.Create;
    13821407begin
     1408  Id := 0;
     1409  Name := '';
     1410  Enabled := True;
    13831411  AcronymMeanings := TAcronymMeanings.Create(False);
    13841412  ImportSources := TImportSources.Create(False);
     
    16571685end;
    16581686
    1659 procedure TAcronymDb.AssignToList(List: TListObject);
     1687procedure TAcronymDb.AssignToList(List: TListObject; EnabledCategoryOnly: Boolean = False);
    16601688var
    16611689  I: Integer;
     
    16661694  with TAcronym(Acronyms[I]) do begin
    16671695    for J := 0 to Meanings.Count - 1 do
    1668     with TAcronymMeaning(Meanings[J]) do begin
    1669       List.Add(TAcronymMeaning(Meanings[J]))
     1696    with TAcronymMeaning(Meanings[J]) do
     1697    if not EnabledCategoryOnly or (EnabledCategoryOnly and Categories.IsAnyEnabled) then begin
     1698      List.Add(TAcronymMeaning(Meanings[J]));
    16701699    end;
    16711700  end;
Note: See TracChangeset for help on using the changeset viewer.