Ignore:
Timestamp:
Nov 26, 2016, 12:35:41 AM (8 years ago)
Author:
chronos
Message:
  • Added: Acronym search filter options also availabel as toolbar buttons.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r121 r122  
    1616
    1717  TFormMain = class(TForm)
     18    AFilterCaseSensitive: TAction;
     19    AFilterExactMatch: TAction;
    1820    AHide: TAction;
    1921    AExport: TAction;
     
    7577    ToolButton11: TToolButton;
    7678    ToolButton12: TToolButton;
     79    ToolButton13: TToolButton;
     80    ToolButton14: TToolButton;
     81    ToolButton16: TToolButton;
    7782    ToolButton2: TToolButton;
    7883    ToolButton3: TToolButton;
     
    9095    procedure AFileSaveAsExecute(Sender: TObject);
    9196    procedure AFileSaveExecute(Sender: TObject);
     97    procedure AFilterCaseSensitiveExecute(Sender: TObject);
     98    procedure AFilterExactMatchExecute(Sender: TObject);
    9299    procedure AHideExecute(Sender: TObject);
    93100    procedure AImportExecute(Sender: TObject);
     
    100107    procedure AShowImportFormatsExecute(Sender: TObject);
    101108    procedure AShowImportSourcesExecute(Sender: TObject);
    102     procedure CheckBoxExactMatchChange(Sender: TObject);
    103109    procedure EditSearchChange(Sender: TObject);
    104110    procedure FormHide(Sender: TObject);
     
    123129    ProjectClosed: Boolean;
    124130    ImportTotalItemCount: Integer;
    125     function GetFilteredCase(Text: string): string;
     131    function FilterCell(Text1, Text2: string): Boolean;
    126132    procedure ProcessImportsJob(Job: TJob);
    127133    procedure FilterList(List: TListObject);
     
    280286end;
    281287
     288procedure TFormMain.AFilterCaseSensitiveExecute(Sender: TObject);
     289begin
     290  UpdateAcronymsList;
     291end;
     292
     293procedure TFormMain.AFilterExactMatchExecute(Sender: TObject);
     294begin
     295  UpdateAcronymsList;
     296end;
     297
    282298procedure TFormMain.AHideExecute(Sender: TObject);
    283299begin
     
    401417    FreeAndNil(FormImportSources);
    402418  end;
    403 end;
    404 
    405 procedure TFormMain.CheckBoxExactMatchChange(Sender: TObject);
    406 begin
    407   UpdateAcronymsList;
    408419end;
    409420
     
    496507end;
    497508
    498 function TFormMain.GetFilteredCase(Text: string): string;
    499 begin
    500   if not CheckBoxCaseSensitive.Checked then Result := UTF8LowerCase(Text)
    501     else Result := Text;
     509function TFormMain.FilterCell(Text1, Text2: string): Boolean;
     510begin
     511  if not AFilterCaseSensitive.Checked then begin
     512    Text1 := UTF8LowerCase(Text1);
     513    Text2 := UTF8LowerCase(Text2);
     514  end;
     515  if AFilterExactMatch.Checked then
     516    Result := Text1 = Text2
     517    else Result := Pos(Text1, Text2) > 0;
    502518end;
    503519
     
    543559         if Visible and (EnteredCount > 0) then begin
    544560           FoundCount := 0;
    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);
    552            end else begin
    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);
    559            end;
     561           if TextEnteredColumn(0) and (FilterCell(StringGrid.Cells[0, 0],
     562             TAcronymMeaning(List.Items[I]).Acronym.Name)) then Inc(FoundCount);
     563           if TextEnteredColumn(1) and (FilterCell(StringGrid.Cells[1, 0],
     564             TAcronymMeaning(List.Items[I]).Name)) then Inc(FoundCount);
     565           if TextEnteredColumn(2) and (FilterCell(StringGrid.Cells[2, 0],
     566             TAcronymMeaning(List.Items[I]).Categories.GetString)) then Inc(FoundCount);
    560567           if FoundCount <> EnteredCount then List.Delete(I);
    561568         end else List.Delete(I);
     
    640647    Core.AlwaysOnTop := ReadBoolWithDefault('AlwaysOnTop', False);
    641648    Core.StartMinimizedToTray := ReadBoolWithDefault('StartMinimizedToTray', False);
    642     CheckBoxExactMatch.Checked := ReadBoolWithDefault('ExactMatch', False);
    643     CheckBoxCaseSensitive.Checked := ReadBoolWithDefault('CaseSensitive', False);
     649    AFilterExactMatch.Checked := ReadBoolWithDefault('ExactMatch', False);
     650    AFilterCaseSensitive.Checked := ReadBoolWithDefault('CaseSensitive', False);
    644651    MenuItemToolbar.Checked := ReadBoolWithDefault('ToolBarVisible', True);
    645652    MenuItemParam.Checked := ReadBoolWithDefault('FilterParamVisible', True);
     
    672679    WriteBool('AlwaysOnTop', Core.AlwaysOnTop);
    673680    WriteBool('StartMinimizedToTray', Core.StartMinimizedToTray);
    674     WriteBool('ExactMatch', CheckBoxExactMatch.Checked);
    675     WriteBool('CaseSensitive', CheckBoxCaseSensitive.Checked);
     681    WriteBool('ExactMatch', AFilterExactMatch.Checked);
     682    WriteBool('CaseSensitive', AFilterCaseSensitive.Checked);
    676683    WriteBool('ToolBarVisible', MenuItemToolbar.Checked);
    677684    WriteBool('FilterParamVisible', MenuItemParam.Checked);
Note: See TracChangeset for help on using the changeset viewer.