Ignore:
Timestamp:
Nov 26, 2016, 12:09:42 AM (8 years ago)
Author:
chronos
Message:
  • Added: Option to filter acronyms by same letters case.
  • Added: Search filter in main window can be hidden from View menu.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r112 r121  
    3434    AExit: TAction;
    3535    ActionList1: TActionList;
    36     CheckBoxExactMath: TCheckBox;
     36    CheckBoxExactMatch: TCheckBox;
     37    CheckBoxCaseSensitive: TCheckBox;
    3738    LastOpenedList1: TLastOpenedList;
    3839    ListViewAcronyms: TListView;
     
    4041    ListViewSort1: TListViewSort;
    4142    MainMenu1: TMainMenu;
     43    MenuItemParam: TMenuItem;
    4244    MenuItem10: TMenuItem;
    4345    MenuItem11: TMenuItem;
     
    6466    MenuItem9: TMenuItem;
    6567    OpenDialog1: TOpenDialog;
    66     Panel1: TPanel;
     68    PanelParam: TPanel;
     69    PanelMain: TPanel;
    6770    PopupMenuOpenRecent: TPopupMenu;
    6871    SaveDialog1: TSaveDialog;
     
    97100    procedure AShowImportFormatsExecute(Sender: TObject);
    98101    procedure AShowImportSourcesExecute(Sender: TObject);
    99     procedure CheckBoxExactMathChange(Sender: TObject);
     102    procedure CheckBoxExactMatchChange(Sender: TObject);
    100103    procedure EditSearchChange(Sender: TObject);
    101104    procedure FormHide(Sender: TObject);
     
    114117    function ListViewSort1CompareItem(Item1, Item2: TObject): Integer;
    115118    procedure ListViewSort1Filter(ListViewSort: TListViewSort);
     119    procedure MenuItemParamClick(Sender: TObject);
    116120    procedure MenuItemToolbarClick(Sender: TObject);
    117121  private
     
    119123    ProjectClosed: Boolean;
    120124    ImportTotalItemCount: Integer;
     125    function GetFilteredCase(Text: string): string;
    121126    procedure ProcessImportsJob(Job: TJob);
    122127    procedure FilterList(List: TListObject);
     
    398403end;
    399404
    400 procedure TFormMain.CheckBoxExactMathChange(Sender: TObject);
     405procedure TFormMain.CheckBoxExactMatchChange(Sender: TObject);
    401406begin
    402407  UpdateAcronymsList;
     
    479484end;
    480485
     486procedure TFormMain.MenuItemParamClick(Sender: TObject);
     487begin
     488  MenuItemParam.Checked := not MenuItemParam.Checked;
     489  UpdateInterface;
     490end;
     491
    481492procedure TFormMain.MenuItemToolbarClick(Sender: TObject);
    482493begin
    483494  MenuItemToolbar.Checked := not MenuItemToolbar.Checked;
    484495  UpdateInterface;
     496end;
     497
     498function TFormMain.GetFilteredCase(Text: string): string;
     499begin
     500  if not CheckBoxCaseSensitive.Checked then Result := UTF8LowerCase(Text)
     501    else Result := Text;
    485502end;
    486503
     
    526543         if Visible and (EnteredCount > 0) then begin
    527544           FoundCount := 0;
    528            if CheckBoxExactMath.Checked then begin
    529              if TextEnteredColumn(0) and (StringGrid.Cells[0, 0] =
    530                TAcronymMeaning(List.Items[I]).Acronym.Name) then Inc(FoundCount);
    531              if TextEnteredColumn(1) and (StringGrid.Cells[1, 0] =
    532                TAcronymMeaning(List.Items[I]).Name) then Inc(FoundCount);
    533              if TextEnteredColumn(2) and (StringGrid.Cells[2, 0] =
    534                TAcronymMeaning(List.Items[I]).Categories.GetString) then Inc(FoundCount);
     545           if CheckBoxExactMatch.Checked then begin
     546             if TextEnteredColumn(0) and (GetFilteredCase(StringGrid.Cells[0, 0]) =
     547               GetFilteredCase(TAcronymMeaning(List.Items[I]).Acronym.Name)) then Inc(FoundCount);
     548             if TextEnteredColumn(1) and (GetFilteredCase(StringGrid.Cells[1, 0]) =
     549               GetFilteredCase(TAcronymMeaning(List.Items[I]).Name)) then Inc(FoundCount);
     550             if TextEnteredColumn(2) and (GetFilteredCase(StringGrid.Cells[2, 0]) =
     551               GetFilteredCase(TAcronymMeaning(List.Items[I]).Categories.GetString)) then Inc(FoundCount);
    535552           end else begin
    536              if Pos(UTF8LowerCase(StringGrid.Cells[0, 0]),
    537                UTF8LowerCase(TAcronymMeaning(List.Items[I]).Acronym.Name)) > 0 then Inc(FoundCount);
    538              if Pos(UTF8LowerCase(StringGrid.Cells[1, 0]),
    539                UTF8LowerCase(TAcronymMeaning(List.Items[I]).Name)) > 0 then Inc(FoundCount);
    540              if Pos(UTF8LowerCase(StringGrid.Cells[2, 0]),
    541                UTF8LowerCase(TAcronymMeaning(List.Items[I]).Categories.GetString)) > 0 then Inc(FoundCount);
     553             if Pos(GetFilteredCase(StringGrid.Cells[0, 0]),
     554               GetFilteredCase(TAcronymMeaning(List.Items[I]).Acronym.Name)) > 0 then Inc(FoundCount);
     555             if Pos(GetFilteredCase(StringGrid.Cells[1, 0]),
     556               GetFilteredCase(TAcronymMeaning(List.Items[I]).Name)) > 0 then Inc(FoundCount);
     557             if Pos(GetFilteredCase(StringGrid.Cells[2, 0]),
     558               GetFilteredCase(TAcronymMeaning(List.Items[I]).Categories.GetString)) > 0 then Inc(FoundCount);
    542559           end;
    543560           if FoundCount <> EnteredCount then List.Delete(I);
     
    591608  AShowImportFormats.Enabled := Assigned(Core.AcronymDb);
    592609  ToolBar1.Visible := MenuItemToolbar.Checked;
     610  PanelParam.Visible := MenuItemParam.Checked;
    593611  AHide.Enabled := FormMain.Visible;
    594612
     
    622640    Core.AlwaysOnTop := ReadBoolWithDefault('AlwaysOnTop', False);
    623641    Core.StartMinimizedToTray := ReadBoolWithDefault('StartMinimizedToTray', False);
    624     CheckBoxExactMath.Checked := ReadBoolWithDefault('ExactMatch', False);
     642    CheckBoxExactMatch.Checked := ReadBoolWithDefault('ExactMatch', False);
     643    CheckBoxCaseSensitive.Checked := ReadBoolWithDefault('CaseSensitive', False);
    625644    MenuItemToolbar.Checked := ReadBoolWithDefault('ToolBarVisible', True);
     645    MenuItemParam.Checked := ReadBoolWithDefault('FilterParamVisible', True);
    626646  finally
    627647    Free;
     
    652672    WriteBool('AlwaysOnTop', Core.AlwaysOnTop);
    653673    WriteBool('StartMinimizedToTray', Core.StartMinimizedToTray);
    654     WriteBool('ExactMatch', CheckBoxExactMath.Checked);
     674    WriteBool('ExactMatch', CheckBoxExactMatch.Checked);
     675    WriteBool('CaseSensitive', CheckBoxCaseSensitive.Checked);
    655676    WriteBool('ToolBarVisible', MenuItemToolbar.Checked);
     677    WriteBool('FilterParamVisible', MenuItemParam.Checked);
    656678  finally
    657679    Free;
Note: See TracChangeset for help on using the changeset viewer.