Make usage of query history optionally. Fixes issue #3122.

This commit is contained in:
Ansgar Becker
2013-02-26 20:24:33 +00:00
parent 2097a5926d
commit 6fa32dc9fc
5 changed files with 42 additions and 16 deletions

View File

@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: HeidiSQL\n"
"POT-Creation-Date: 2012-11-05 21:40\n"
"PO-Revision-Date: 2013-02-25 18:39+0100\n"
"PO-Revision-Date: 2013-02-26 21:22+0100\n"
"Last-Translator: Ansgar Becker <heidisql@anse.de>\n"
"Language-Team: English (http://www.transifex.com/projects/p/heidisql/"
"language/en/)\n"
@@ -2613,6 +2613,10 @@ msgstr "Information messages"
msgid "Debug messages"
msgstr "Debug messages"
#. Preferences
msgid "Enable query history"
msgstr "Enable query history"
#. optionsform..pagecontrolMain..tabSQL..lblFont..Caption
#: options.dfm:357
msgid "Editor font:"

View File

@@ -172,7 +172,8 @@ type
asFieldEditorSet, asFieldNullBackground, asGroupTreeObjects, asDisplayObjectSizeColumn, asSQLfile,
asActionShortcut1, asActionShortcut2, asHighlighterForeground, asHighlighterBackground, asHighlighterStyle,
asListColWidths, asListColsVisible, asListColPositions, asListColSort, asSessionFolder,
asRecentFilter, asDateTimeEditorCursorPos, asAppLanguage, asAutoExpand, asForeignDropDown, asUnused);
asRecentFilter, asDateTimeEditorCursorPos, asAppLanguage, asAutoExpand, asForeignDropDown, asQueryHistoryEnabled,
asUnused);
TAppSetting = record
Name: String;
Session: Boolean;
@@ -3211,6 +3212,7 @@ begin
InitSetting(asAppLanguage, 'Language', 0, False, '');
InitSetting(asAutoExpand, 'AutoExpand', 0, False);
InitSetting(asForeignDropDown, 'ForeignDropDown', 0, True);
InitSetting(asQueryHistoryEnabled, 'QueryHistory', 0, True);
end;

View File

@@ -2391,7 +2391,12 @@ begin
// Store successful query packet in history if it's not a batch.
// Assume that a bunch of up to 5 queries is not a batch.
if IsEmpty(Thread.ErrorMessage) and (Thread.Batch.Count <= 5) and (Thread.Batch.Size <= SIZE_MB) then begin
AppSettings.ResetPath;
if AppSettings.ReadBool(asQueryHistoryEnabled)
and IsEmpty(Thread.ErrorMessage)
and (Thread.Batch.Count <= 5)
and (Thread.Batch.Size <= SIZE_MB)
then begin
ShowStatusMsg(_('Updating query history ...'));
// Load all items so we can clean up
@@ -10496,7 +10501,8 @@ begin
Node.CheckType := ctCheckbox;
end;
1: begin
if Node.Parent.Index = HELPERNODE_HISTORY then
AppSettings.ResetPath;
if (Node.Parent.Index = HELPERNODE_HISTORY) and AppSettings.ReadBool(asQueryHistoryEnabled) then
Include(InitialStates, ivsHasChildren);
end;
end;
@@ -10531,19 +10537,22 @@ begin
HELPERNODE_KEYWORDS: ChildCount := MySQLKeywords.Count;
HELPERNODE_SNIPPETS: ChildCount := FSnippetFilenames.Count;
HELPERNODE_HISTORY: begin
// Find all unique days in history
if not Assigned(Tab.HistoryDays) then
Tab.HistoryDays := TStringList.Create;
Tab.HistoryDays.Clear;
History := TQueryHistory.Create(ActiveConnection.Parameters.SessionPath);
for Item in History do begin
QueryDay := DateToStr(Item.Time);
if Tab.HistoryDays.IndexOf(QueryDay) = -1 then
Tab.HistoryDays.Add(QueryDay);
AppSettings.ResetPath;
if AppSettings.ReadBool(asQueryHistoryEnabled) then begin
// Find all unique days in history
if not Assigned(Tab.HistoryDays) then
Tab.HistoryDays := TStringList.Create;
Tab.HistoryDays.Clear;
History := TQueryHistory.Create(ActiveConnection.Parameters.SessionPath);
for Item in History do begin
QueryDay := DateToStr(Item.Time);
if Tab.HistoryDays.IndexOf(QueryDay) = -1 then
Tab.HistoryDays.Add(QueryDay);
end;
History.Free;
Tab.HistoryDays.CustomSort(StringListCompareAnythingDesc);
ChildCount := Tab.HistoryDays.Count;
end;
History.Free;
Tab.HistoryDays.CustomSort(StringListCompareAnythingDesc);
ChildCount := Tab.HistoryDays.Count;
end;
HELPERNODE_PROFILE: if not Assigned(Tab.QueryProfile) then ChildCount := 0
else ChildCount := Tab.QueryProfile.RecordCount;

View File

@@ -344,6 +344,14 @@ object optionsform: Toptionsform
OnDblClick = editLogDirRightButtonClick
OnRightButtonClick = editLogDirRightButtonClick
end
object chkQueryHistory: TCheckBox
Left = 8
Top = 200
Width = 429
Height = 17
Caption = 'Enable query history'
TabOrder = 11
end
end
object tabSQL: TTabSheet
Caption = 'SQL'

View File

@@ -120,6 +120,7 @@ type
lblLanguage: TLabel;
comboAppLanguage: TComboBox;
chkForeignDropDown: TCheckBox;
chkQueryHistory: TCheckBox;
procedure FormShow(Sender: TObject);
procedure Modified(Sender: TObject);
procedure Apply(Sender: TObject);
@@ -228,6 +229,7 @@ begin
AppSettings.WriteBool(asLogSQL, chkLogEventSQL.Checked);
AppSettings.WriteBool(asLogInfos, chkLogEventInfo.Checked);
AppSettings.WriteBool(asLogDebug, chkLogEventDebug.Checked);
AppSettings.WriteBool(asQueryHistoryEnabled, chkQueryHistory.Checked);
for i:=0 to SynSQLSynSQLSample.AttrCount - 1 do begin
Attri := SynSQLSynSQLSample.Attribute[i];
AppSettings.WriteInt(asHighlighterForeground, Attri.Foreground, Attri.Name);
@@ -441,6 +443,7 @@ begin
chkLogEventSQL.Checked := AppSettings.ReadBool(asLogSQL);
chkLogEventInfo.Checked := AppSettings.ReadBool(asLogInfos);
chkLogEventDebug.Checked := AppSettings.ReadBool(asLogDebug);
chkQueryHistory.Checked := AppSettings.ReadBool(asQueryHistoryEnabled);
// Default Column-Width in DBGrids:
updownMaxColWidth.Position := AppSettings.ReadInt(asMaxColWidth);