mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Add combobox containing recent filters to above filter memo. rfe #637: Reintroduce filter history drop down.
This commit is contained in:
@ -1195,6 +1195,13 @@ object MainForm: TMainForm
|
||||
Anchors = [akTop, akRight]
|
||||
Caption = 'Create table wide filter:'
|
||||
end
|
||||
object lblRecentFilters: TLabel
|
||||
Left = 1
|
||||
Top = 3
|
||||
Width = 68
|
||||
Height = 13
|
||||
Caption = 'Recent filters:'
|
||||
end
|
||||
object btnFilterApply: TButton
|
||||
Left = 339
|
||||
Top = 41
|
||||
@ -1215,9 +1222,9 @@ object MainForm: TMainForm
|
||||
end
|
||||
object SynMemoFilter: TSynMemo
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 335
|
||||
Height = 63
|
||||
Top = 21
|
||||
Width = 336
|
||||
Height = 42
|
||||
SingleLineMode = False
|
||||
Anchors = [akLeft, akTop, akRight, akBottom]
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
@ -1274,6 +1281,17 @@ object MainForm: TMainForm
|
||||
OnEnter = editFilterSearchEnter
|
||||
OnExit = editFilterSearchExit
|
||||
end
|
||||
object comboRecentFilters: TTntComboBox
|
||||
Left = 75
|
||||
Top = 0
|
||||
Width = 261
|
||||
Height = 21
|
||||
Style = csDropDownList
|
||||
Anchors = [akLeft, akTop, akRight]
|
||||
ItemHeight = 13
|
||||
TabOrder = 4
|
||||
OnSelect = LoadRecentFilter
|
||||
end
|
||||
end
|
||||
object DataGrid: TVirtualStringTree
|
||||
Left = 0
|
||||
@ -6483,7 +6501,6 @@ object MainForm: TMainForm
|
||||
end
|
||||
object popupFilter: TPopupMenu
|
||||
Images = PngImageListMain
|
||||
OnPopup = popupFilterPopup
|
||||
Left = 72
|
||||
Top = 128
|
||||
object menuFilterCopy: TMenuItem
|
||||
|
@ -453,6 +453,8 @@ type
|
||||
N13: TMenuItem;
|
||||
ProgressBarStatus: TProgressBar;
|
||||
menuRecentFilters: TMenuItem;
|
||||
comboRecentFilters: TTntComboBox;
|
||||
lblRecentFilters: TLabel;
|
||||
procedure refreshMonitorConfig;
|
||||
procedure loadWindowConfig;
|
||||
procedure saveWindowConfig;
|
||||
@ -723,7 +725,7 @@ type
|
||||
procedure actCopyOrCutExecute(Sender: TObject);
|
||||
procedure actPasteExecute(Sender: TObject);
|
||||
procedure actSelectAllExecute(Sender: TObject);
|
||||
procedure popupFilterPopup(Sender: TObject);
|
||||
procedure EnumerateRecentFilters;
|
||||
procedure LoadRecentFilter(Sender: TObject);
|
||||
private
|
||||
FDelimiter: String;
|
||||
@ -3140,7 +3142,6 @@ var
|
||||
OldNumbers, Filters: TStringList;
|
||||
val: String;
|
||||
begin
|
||||
viewdata(Sender);
|
||||
// Recreate recent filters list
|
||||
Filters := TStringList.Create;
|
||||
OldNumbers := TStringList.Create;
|
||||
@ -3164,6 +3165,7 @@ begin
|
||||
end;
|
||||
FreeAndNil(OldNumbers);
|
||||
FreeAndNil(Filters);
|
||||
viewdata(Sender);
|
||||
end;
|
||||
|
||||
|
||||
@ -3690,6 +3692,7 @@ begin
|
||||
FreeAndNil(sl_query);
|
||||
AutoCalcColWidths(DataGrid, PrevTableColWidths);
|
||||
viewingdata := false;
|
||||
EnumerateRecentFilters;
|
||||
Screen.Cursor := crDefault;
|
||||
end;
|
||||
DataGridDB := ActiveDatabase;
|
||||
@ -8863,7 +8866,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TMainForm.popupFilterPopup(Sender: TObject);
|
||||
procedure TMainForm.EnumerateRecentFilters;
|
||||
var
|
||||
flt: TStringList;
|
||||
i: Integer;
|
||||
@ -8871,10 +8874,11 @@ var
|
||||
rx: TRegExpr;
|
||||
capt: String;
|
||||
begin
|
||||
// Reset menu items
|
||||
// Reset menu and combobox
|
||||
menuRecentFilters.Enabled := False;
|
||||
for i := menuRecentFilters.Count - 1 downto 0 do
|
||||
menuRecentFilters.Delete(i);
|
||||
comboRecentFilters.Items.Clear;
|
||||
// Enumerate recent filters from registry
|
||||
if MainReg.OpenKey(GetRegKeyTable+'\'+REGNAME_FILTERS, False) then begin
|
||||
flt := TStringList.Create;
|
||||
@ -8890,24 +8894,39 @@ begin
|
||||
item.Tag := MakeInt(flt[i]);
|
||||
item.OnClick := LoadRecentFilter;
|
||||
menuRecentFilters.Add(item);
|
||||
capt := Utf8Decode(capt);
|
||||
comboRecentFilters.Items.Add(sstr(capt, 100));
|
||||
end;
|
||||
FreeAndNil(rx);
|
||||
FreeAndNil(flt);
|
||||
menuRecentFilters.Enabled := menuRecentFilters.Count > 0;
|
||||
end;
|
||||
comboRecentFilters.Visible := comboRecentFilters.Items.Count > 0;
|
||||
lblRecentFilters.Visible := comboRecentFilters.Visible;
|
||||
SynMemoFilter.Height := pnlFilter.Height - 3;
|
||||
SynMemoFilter.Top := comboRecentFilters.Top;
|
||||
if comboRecentFilters.Visible then begin
|
||||
SynMemoFilter.Height := SynMemoFilter.Height - comboRecentFilters.Height;
|
||||
SynMemoFilter.Top := SynMemoFilter.Top + comboRecentFilters.Height;
|
||||
comboRecentFilters.ItemIndex := 0;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TMainForm.LoadRecentFilter(Sender: TObject);
|
||||
var
|
||||
key: String;
|
||||
key: Integer;
|
||||
begin
|
||||
// Event handler for both dynamic popup menu items and filter combobox
|
||||
if Sender is TMenuItem then
|
||||
key := (Sender as TMenuItem).Tag
|
||||
else
|
||||
key := (Sender as TTNTComboBox).ItemIndex+1;
|
||||
if MainReg.OpenKey(GetRegKeyTable+'\'+REGNAME_FILTERS, False) then begin
|
||||
key := IntToStr((Sender as TMenuItem).Tag);
|
||||
SynMemoFilter.UndoList.AddGroupBreak;
|
||||
SynMemoFilter.BeginUpdate;
|
||||
SynMemoFilter.SelectAll;
|
||||
SynMemoFilter.SelText := Utf8Decode( MainReg.ReadString(key) );
|
||||
SynMemoFilter.SelText := Utf8Decode( MainReg.ReadString(IntToStr(key)) );
|
||||
SynMemoFilter.EndUpdate;
|
||||
end;
|
||||
end;
|
||||
|
Reference in New Issue
Block a user