Permalink
Browse files

Add custom setting for number of days to keep queries in the query hi…

  • Loading branch information...
ansgarbecker committed Mar 13, 2017
1 parent f6a405b commit 444a5bd97fa01642f69e1ce7ab92ec8d66e396e4
Showing with 57 additions and 6 deletions.
  1. +4 −1 out/locale/en/LC_MESSAGES/default.po
  2. +3 −1 source/helpers.pas
  3. +3 −2 source/main.pas
  4. +32 −2 source/options.dfm
  5. +15 −0 source/options.pas
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: HeidiSQL\n"
"POT-Creation-Date: 2012-11-05 21:40\n"
"PO-Revision-Date: 2017-03-07 21:07+0100\n"
"PO-Revision-Date: 2017-03-13 21:17+0100\n"
"Last-Translator: Ansgar Becker <anse@heidisql.com>\n"
"Language-Team: English (http://www.transifex.com/projects/p/heidisql/"
"language/en/)\n"
@@ -2720,6 +2720,9 @@ msgstr "Debug messages"
msgid "Enable query history"
msgstr "Enable query history"
msgid "days to keep queries before removing them"
msgstr "days to keep queries before removing them"
#. optionsform..pagecontrolMain..tabSQL..lblFont..Caption
#: options.dfm:357
msgid "Editor font:"
View
@@ -174,7 +174,8 @@ TQueryThread = class(TThread)
asFieldEditorSet, asFieldNullBackground, asRowBackgroundEven, asRowBackgroundOdd, asGroupTreeObjects, asDisplayObjectSizeColumn, asSQLfile,
asActionShortcut1, asActionShortcut2, asHighlighterForeground, asHighlighterBackground, asHighlighterStyle,
asListColWidths, asListColsVisible, asListColPositions, asListColSort, asSessionFolder,
asRecentFilter, asTimestampColumns, asDateTimeEditorCursorPos, asAppLanguage, asAutoExpand, asDoubleClickInsertsNodeText, asForeignDropDown, asQueryHistoryEnabled,
asRecentFilter, asTimestampColumns, asDateTimeEditorCursorPos, asAppLanguage, asAutoExpand, asDoubleClickInsertsNodeText, asForeignDropDown,
asQueryHistoryEnabled, asQueryHistoryKeepDays,
asColumnSelectorWidth, asColumnSelectorHeight, asDonatedEmail, asFavoriteObjects, asFavoriteObjectsOnly, asFullTableStatus, asLineBreakStyle,
asFileDialogEncoding,
asUnused);
@@ -3427,6 +3428,7 @@ constructor TAppSettings.Create;
InitSetting(asDoubleClickInsertsNodeText, 'DoubleClickInsertsNodeText', 0, True);
InitSetting(asForeignDropDown, 'ForeignDropDown', 0, True);
InitSetting(asQueryHistoryEnabled, 'QueryHistory', 0, True);
InitSetting(asQueryHistoryKeepDays, 'QueryHistoryKeeypDays', 30);
InitSetting(asColumnSelectorWidth, 'ColumnSelectorWidth', 200, False, '');
InitSetting(asColumnSelectorHeight, 'ColumnSelectorHeight', 270, False, '');
InitSetting(asDonatedEmail, 'DonatedEmail', 0, False, '');
View
@@ -2754,7 +2754,7 @@ procedure TMainForm.FinishedQueryExecution(Thread: TQueryThread);
History: TQueryHistory;
HistoryItem: TQueryHistoryItem;
Warnings: TDBQuery;
HistoryNum, MaxWarnings, RegItemsSize: Integer;
HistoryNum, MaxWarnings, RegItemsSize, KeepDays: Integer;
DoDelete, ValueFound: Boolean;
MinDate: TDateTime;
@@ -2877,6 +2877,7 @@ procedure TMainForm.FinishedQueryExecution(Thread: TQueryThread);
and (Thread.Batch.Size <= SIZE_MB)
then begin
ShowStatusMsg(_('Updating query history ...'));
KeepDays := AppSettings.ReadInt(asQueryHistoryKeepDays);
// Load all items so we can clean up
History := TQueryHistory.Create(Thread.Connection.Parameters.SessionPath);
@@ -2901,7 +2902,7 @@ procedure TMainForm.FinishedQueryExecution(Thread: TQueryThread);
// Delete old items
// Delete items which exceed a max datasize barrier
AppSettings.SessionPath := Thread.Connection.Parameters.SessionPath + '\' + REGKEY_QUERYHISTORY;
MinDate := IncDay(Now, -30);
MinDate := IncDay(Now, -KeepDays);
RegItemsSize := Thread.Batch.Size;
for HistoryItem in History do begin
Inc(RegItemsSize, Length(HistoryItem.SQL));
View
@@ -304,6 +304,13 @@ object optionsform: Toptionsform
Height = 13
Caption = 'Log events:'
end
object lblQueryHistoryKeepDays: TLabel
Left = 278
Top = 201
Width = 209
Height = 13
Caption = 'days to keep queries before removing them'
end
object editLogLines: TEdit
Left = 202
Top = 8
@@ -421,11 +428,11 @@ object optionsform: Toptionsform
object chkQueryHistory: TCheckBox
Left = 8
Top = 200
Width = 429
Width = 176
Height = 17
Caption = 'Enable query history'
TabOrder = 11
OnClick = Modified
OnClick = chkQueryHistoryClick
end
object chkHorizontalScrollbar: TCheckBox
Left = 8
@@ -436,6 +443,29 @@ object optionsform: Toptionsform
TabOrder = 12
OnClick = Modified
end
object editQueryHistoryKeepDays: TEdit
Left = 202
Top = 198
Width = 53
Height = 21
Enabled = False
TabOrder = 13
Text = '1'
OnChange = Modified
end
object updownQueryHistoryKeepDays: TUpDown
Left = 255
Top = 198
Width = 16
Height = 21
Associate = editQueryHistoryKeepDays
Enabled = False
Min = 1
Max = 365
Position = 1
TabOrder = 14
OnChanging = anyUpDownLimitChanging
end
end
object tabSQL: TTabSheet
Caption = 'SQL'
View
@@ -136,6 +136,9 @@ Toptionsform = class(TForm)
updownGUIFontSize: TUpDown;
lblGUIFontSize: TLabel;
chkHorizontalScrollbar: TCheckBox;
editQueryHistoryKeepDays: TEdit;
updownQueryHistoryKeepDays: TUpDown;
lblQueryHistoryKeepDays: TLabel;
procedure FormShow(Sender: TObject);
procedure Modified(Sender: TObject);
procedure Apply(Sender: TObject);
@@ -174,6 +177,7 @@ Toptionsform = class(TForm)
procedure editGridRowCountExit(Sender: TObject);
procedure editCustomSnippetsDirectoryRightButtonClick(Sender: TObject);
procedure comboGUIFontChange(Sender: TObject);
procedure chkQueryHistoryClick(Sender: TObject);
private
{ Private declarations }
FWasModified: Boolean;
@@ -248,6 +252,7 @@ procedure Toptionsform.Apply(Sender: TObject);
AppSettings.WriteBool(asLogInfos, chkLogEventInfo.Checked);
AppSettings.WriteBool(asLogDebug, chkLogEventDebug.Checked);
AppSettings.WriteBool(asQueryHistoryEnabled, chkQueryHistory.Checked);
AppSettings.WriteInt(asQueryHistoryKeepDays, updownQueryHistoryKeepDays.Position);
AppSettings.WriteBool(asLogHorizontalScrollbar, chkHorizontalScrollbar.Checked);
for i:=0 to SynSQLSynSQLSample.AttrCount - 1 do begin
Attri := SynSQLSynSQLSample.Attribute[i];
@@ -488,6 +493,7 @@ procedure Toptionsform.FormShow(Sender: TObject);
chkLogEventInfo.Checked := AppSettings.ReadBool(asLogInfos);
chkLogEventDebug.Checked := AppSettings.ReadBool(asLogDebug);
chkQueryHistory.Checked := AppSettings.ReadBool(asQueryHistoryEnabled);
updownQueryHistoryKeepDays.Position := AppSettings.ReadInt(asQueryHistoryKeepDays);
chkHorizontalScrollbar.Checked := AppSettings.ReadBool(asLogHorizontalScrollbar);
// Default column width in grids:
@@ -672,6 +678,15 @@ procedure Toptionsform.chkLogToFileClick(Sender: TObject);
end;
procedure Toptionsform.chkQueryHistoryClick(Sender: TObject);
begin
editQueryHistoryKeepDays.Enabled := chkQueryHistory.Checked;
updownQueryHistoryKeepDays.Enabled := chkQueryHistory.Checked;
lblQueryHistoryKeepDays.Enabled := chkQueryHistory.Checked;
Modified(Sender);
end;
procedure Toptionsform.comboGridTextColorsSelect(Sender: TObject);
begin
// Data type category selected

0 comments on commit 444a5bd

Please sign in to comment.