Skip to content

Commit

Permalink
Issue #861: support hiding row id column through new preference checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
ansgarbecker committed Oct 12, 2023
1 parent fa571f7 commit 0444ebb
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 44 deletions.
5 changes: 4 additions & 1 deletion out/locale/en/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: HeidiSQL\n"
"POT-Creation-Date: 2012-11-05 21:40\n"
"PO-Revision-Date: 2023-10-02 18:16+0200\n"
"PO-Revision-Date: 2023-10-12 07:21+0200\n"
"Last-Translator: Ansgar Becker <anse@heidisql.com>\n"
"Language-Team: English (http://www.transifex.com/projects/p/heidisql/language/en/)\n"
"Language: en\n"
Expand Down Expand Up @@ -6623,3 +6623,6 @@ msgstr "Query exact row count"

msgid "Code reformatted in %s, using formatter %s"
msgstr "Code reformatted in %s, using formatter %s"

msgid "Show static row id column"
msgstr "Show static row id column"
2 changes: 2 additions & 0 deletions source/apphelpers.pas
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ TClipboardHelper = class helper for TClipboard
TAppSettingIndex = (asHiddenColumns, asFilter, asSort, asDisplayedColumnsSorted, asLastSessions,
asLastActiveSession, asAutoReconnect, asRestoreLastUsedDB, asLastUsedDB, asTreeBackground, asIgnoreDatabasePattern, asLogFileDdl, asLogFileDml, asLogFilePath,
asFontName, asFontSize, asTabWidth, asDataFontName, asDataFontSize, asDataLocalNumberFormat, asLowercaseHex, asHintsOnResultTabs, asHightlightSameTextBackground,
asShowRowId,
asLogsqlnum, asLogsqlwidth, asSessionLogsDirectory, asLogHorizontalScrollbar, asSQLColActiveLine,
asSQLColMatchingBraceForeground, asSQLColMatchingBraceBackground,
asMaxColWidth, asDatagridMaximumRows, asDatagridRowsPerStep, asGridRowLineCount, asColumnHeaderClick, asReuseEditorConfiguration,
Expand Down Expand Up @@ -3653,6 +3654,7 @@ constructor TAppSettings.Create;
InitSetting(asDataLocalNumberFormat, 'DataLocalNumberFormat', 0, True);
InitSetting(asLowercaseHex, 'LowercaseHex', 0, True);
InitSetting(asHintsOnResultTabs, 'HintsOnResultTabs', 0, True);
InitSetting(asShowRowId, 'ShowRowId', 0, True);
InitSetting(asHightlightSameTextBackground, 'HightlightSameTextBackground', GetThemeColor(clInfoBk));
InitSetting(asLogsqlnum, 'logsqlnum', 300);
InitSetting(asLogsqlwidth, 'logsqlwidth', 2000);
Expand Down
13 changes: 11 additions & 2 deletions source/column_selection.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ object frmColumnSelection: TfrmColumnSelection
end
object chkSort: TCheckBox
Left = 8
Top = 187
Top = 167
Width = 168
Height = 17
Anchors = [akLeft, akRight, akBottom]
Expand All @@ -68,7 +68,7 @@ object frmColumnSelection: TfrmColumnSelection
Left = 8
Top = 31
Width = 168
Height = 150
Height = 130
Anchors = [akLeft, akTop, akRight, akBottom]
ItemHeight = 13
TabOrder = 4
Expand All @@ -89,4 +89,13 @@ object frmColumnSelection: TfrmColumnSelection
OnChange = PopulateList
OnLeftButtonClick = editFilterLeftButtonClick
end
object chkShowRowId: TCheckBox
Left = 8
Top = 190
Width = 168
Height = 17
Anchors = [akLeft, akRight, akBottom]
Caption = 'Show static row id column'
TabOrder = 6
end
end
3 changes: 3 additions & 0 deletions source/column_selection.pas
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ TfrmColumnSelection = class(TExtForm)
chklistColumns: TCheckListBox;
chkSort: TCheckBox;
editFilter: TButtonedEdit;
chkShowRowId: TCheckBox;
procedure btnCancelClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure chklistColumnsClickCheck(Sender: TObject);
Expand Down Expand Up @@ -76,6 +77,7 @@ procedure TfrmColumnSelection.FormShow(Sender: TObject);

// Restore last used sorting state from registry
chkSort.Checked := AppSettings.ReadBool(asDisplayedColumnsSorted);
chkShowRowId.Checked := AppSettings.ReadBool(asShowRowId);
end;


Expand All @@ -87,6 +89,7 @@ procedure TfrmColumnSelection.btnOKClick(Sender: TObject);
i: Integer;
Col: String;
begin
AppSettings.WriteBool(asShowRowId, chkShowRowId.Checked);
// Prepare string for storing in registry.
// Use quote-character as separator to ensure columnnames can
// be extracted safely later
Expand Down
4 changes: 4 additions & 0 deletions source/main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3360,6 +3360,8 @@ procedure TMainForm.AfterQueryExecution(Thread: TQueryThread);
col.CaptionAlignment := taRightJustify;
col.Alignment := taRightJustify;
col.Options := col.Options + [coFixed]- [coAllowClick, coAllowFocus, coEditable, coResizable];
if not AppSettings.ReadBool(asShowRowId) then
col.Options := col.Options - [coVisible];
col.Text := '#';
for i:=0 to NewTab.Results.ColumnCount-1 do begin
col := NewTab.Grid.Header.Columns.Add;
Expand Down Expand Up @@ -6031,6 +6033,8 @@ procedure TMainForm.DataGridBeforePaint(Sender: TBaseVirtualTree; TargetCanvas:
Col.CaptionAlignment := taRightJustify;
Col.Alignment := taRightJustify;
Col.Options := col.Options + [coFixed]- [coAllowClick, coAllowFocus, coEditable, coResizable];
if not AppSettings.ReadBool(asShowRowId) then
Col.Options := col.Options - [coVisible];
Col.Text := '#';
for i:=0 to WantedColumns.Count-1 do begin
InitColumn(i, WantedColumns[i]);
Expand Down

0 comments on commit 0444ebb

Please sign in to comment.