Read recent filters from registry following a numeric counter, instead of taking GetValueNames, which has a wrong sort order. See http://www.heidisql.com/forum.php?t=11161

This commit is contained in:
Ansgar Becker
2012-09-09 17:52:30 +00:00
parent f96f4de2b7
commit 0c42aa62f1

View File

@ -8849,7 +8849,6 @@ end;
procedure TMainForm.EnumerateRecentFilters; procedure TMainForm.EnumerateRecentFilters;
var var
flt: TStringList;
i: Integer; i: Integer;
item: TMenuItem; item: TMenuItem;
rx: TRegExpr; rx: TRegExpr;
@ -8864,25 +8863,23 @@ begin
Path := GetRegKeyTable+'\'+REGKEY_RECENTFILTERS; Path := GetRegKeyTable+'\'+REGKEY_RECENTFILTERS;
if AppSettings.SessionPathExists(Path) then begin if AppSettings.SessionPathExists(Path) then begin
AppSettings.SessionPath := Path; AppSettings.SessionPath := Path;
flt := AppSettings.GetValueNames;
rx := TRegExpr.Create; rx := TRegExpr.Create;
rx.Expression := '\s+'; rx.Expression := '\s+';
for i:=0 to flt.Count-1 do begin for i:=1 to 20 do begin
// Previously introduced bugs stored some other settings here, see issue #2127 // Previously introduced bugs stored some other settings here, see issue #2127
if flt[i] <> IntToStr(MakeInt(flt[i])) then
continue;
item := TMenuItem.Create(popupFilter); item := TMenuItem.Create(popupFilter);
capt := AppSettings.ReadString(flt[i]); capt := AppSettings.ReadString(asRecentFilter, IntToStr(i));
if IsEmpty(capt) then
Break;
capt := rx.Replace(capt, ' ', True); capt := rx.Replace(capt, ' ', True);
item.Hint := capt; item.Hint := capt;
item.Caption := sstr(capt, 50); item.Caption := sstr(capt, 50);
item.Tag := MakeInt(flt[i]); item.Tag := i;
item.OnClick := LoadRecentFilter; item.OnClick := LoadRecentFilter;
menuRecentFilters.Add(item); menuRecentFilters.Add(item);
comboRecentFilters.Items.Add(sstr(capt, 100)); comboRecentFilters.Items.Add(sstr(capt, 100));
end; end;
FreeAndNil(rx); FreeAndNil(rx);
FreeAndNil(flt);
AppSettings.ResetPath; AppSettings.ResetPath;
menuRecentFilters.Enabled := menuRecentFilters.Count > 0; menuRecentFilters.Enabled := menuRecentFilters.Count > 0;
end; end;
@ -8914,7 +8911,7 @@ begin
SynMemoFilter.UndoList.AddGroupBreak; SynMemoFilter.UndoList.AddGroupBreak;
SynMemoFilter.BeginUpdate; SynMemoFilter.BeginUpdate;
SynMemoFilter.SelectAll; SynMemoFilter.SelectAll;
SynMemoFilter.SelText := AppSettings.ReadString(IntToStr(key)); SynMemoFilter.SelText := AppSettings.ReadString(asRecentFilter, IntToStr(key));
SynMemoFilter.EndUpdate; SynMemoFilter.EndUpdate;
AppSettings.ResetPath; AppSettings.ResetPath;
end; end;