Permalink
Browse files

Apply a light gray background to fields in a grid which show the same…

… text as the focused field, in the same column. And add a checkbox in preference dialog to disable this new feature. Closes #71.
  • Loading branch information...
ansgarbecker committed Apr 7, 2018
1 parent 19fe598 commit 7e28c51e3b36860e6b35aaa7e99c098bd0a285df
Showing with 63 additions and 28 deletions.
  1. +4 −1 out/locale/en/LC_MESSAGES/default.po
  2. +2 −1 source/apphelpers.pas
  3. +44 −26 source/main.pas
  4. +10 −0 source/options.dfm
  5. +3 −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: 2018-02-25 15:32+0100\n"
"PO-Revision-Date: 2018-04-07 17:59+0200\n"
"Last-Translator: Ansgar Becker <anse@heidisql.com>\n"
"Language-Team: English (http://www.transifex.com/projects/p/heidisql/language/en/)\n"
"MIME-Version: 1.0\n"
@@ -5813,6 +5813,9 @@ msgstr "Connection attempts:"
msgid "Pop up SQL text over result tabs"
msgstr "Pop up SQL text over result tabs"
msgid "Hightlight fields with same text as in focused field"
msgstr "Hightlight fields with same text as in focused field"
msgid "Default linebreak style:"
msgstr "Default linebreak style:"
@@ -130,7 +130,7 @@ TQueryThread = class(TThread)
TAppSettingDataType = (adInt, adBool, adString);
TAppSettingIndex = (asHiddenColumns, asFilter, asSort, asDisplayedColumnsSorted, asLastSessions,
asLastActiveSession, asAutoReconnect, asRestoreLastUsedDB, asLastUsedDB, asTreeBackground,
asFontName, asFontSize, asTabWidth, asDataFontName, asDataFontSize, asDataLocalNumberFormat, asHintsOnResultTabs,
asFontName, asFontSize, asTabWidth, asDataFontName, asDataFontSize, asDataLocalNumberFormat, asHintsOnResultTabs, asHightlightSameText,
asLogsqlnum, asLogsqlwidth, asSessionLogsDirectory, asLogHorizontalScrollbar, asSQLColActiveLine,
asSQLColMatchingBraceForeground, asSQLColMatchingBraceBackground,
asMaxColWidth, asDatagridMaximumRows, asDatagridRowsPerStep, asGridRowLineCount, asReuseEditorConfiguration,
@@ -3327,6 +3327,7 @@ constructor TAppSettings.Create;
InitSetting(asDataFontSize, 'DataFontSize', 8);
InitSetting(asDataLocalNumberFormat, 'DataLocalNumberFormat', 0, True);
InitSetting(asHintsOnResultTabs, 'HintsOnResultTabs', 0, True);
InitSetting(asHightlightSameText, 'HightlightSameText', 0, True);
InitSetting(asLogsqlnum, 'logsqlnum', 300);
InitSetting(asLogsqlwidth, 'logsqlwidth', 2000);
InitSetting(asSessionLogsDirectory, 'SessionLogsDirectory', 0, False, DirnameUserAppData + 'Sessionlogs\');
@@ -8850,6 +8850,8 @@ procedure TMainForm.AnyGridFocusChanged(Sender: TBaseVirtualTree; Node: PVirtual
// Vtree does not focus cell after tab pressing. See issue #3139.
// Most probably a missing thing / bug in TBaseVirtualTree.SetFocusedNodeAndColumn
Sender.ScrollIntoView(Sender.FocusedNode, False, True);
// Required for highlighting fields with same text
Sender.Repaint;
end;
@@ -9143,45 +9145,61 @@ procedure TMainForm.AnyGridBeforeCellPaint(Sender: TBaseVirtualTree;
TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect);
var
VT: TVirtualStringTree;
r: TDBQuery;
cl, clNull, clEven, clOdd: TColor;
RowNumber: PInt64;
isEven: Boolean;
FieldText, FocusedFieldText: String;
begin
if Column = -1 then
Exit;
VT := Sender as TVirtualStringTree;
r := GridResult(Sender);
if not r.Connection.Active then begin
// This event (BeforeCellPaint) is the very first one to notice a broken connection
Sender.Enabled := False;
end else begin
RowNumber := Sender.GetNodeData(Node);
r.RecNo := RowNumber^;
clEven := AppSettings.ReadInt(asRowBackgroundEven);
clOdd := AppSettings.ReadInt(asRowBackgroundOdd);
isEven := Node.Index mod 2 = 0;
if IsEven and (clEven <> clNone) then
cl := AppSettings.ReadInt(asRowBackgroundEven)
else if (not IsEven) and (clOdd <> clNone) then
cl := AppSettings.ReadInt(asRowBackgroundOdd)
else
cl := clNone;
if (vsSelected in Node.States) and (Node = Sender.FocusedNode) and (Column = Sender.FocusedColumn) then
cl := clHighlight
else if vsSelected in Node.States then
cl := $00DDDDDD
else if r.IsNull(Column) then begin
clNull := AppSettings.ReadInt(asFieldNullBackground);
if clNull <> clNone then
cl := clNull;
end;
if cl <> clNone then begin
TargetCanvas.Brush.Color := cl;
TargetCanvas.FillRect(CellRect);
Exit;
end;
RowNumber := Sender.GetNodeData(Node);
r.RecNo := RowNumber^;
clEven := AppSettings.ReadInt(asRowBackgroundEven);
clOdd := AppSettings.ReadInt(asRowBackgroundOdd);
isEven := Node.Index mod 2 = 0;
if IsEven and (clEven <> clNone) then
cl := AppSettings.ReadInt(asRowBackgroundEven)
else if (not IsEven) and (clOdd <> clNone) then
cl := AppSettings.ReadInt(asRowBackgroundOdd)
else
cl := clNone;
if (vsSelected in Node.States) and (Node = Sender.FocusedNode) and (Column = Sender.FocusedColumn) then
cl := clHighlight
else if vsSelected in Node.States then
cl := $00DDDDDD
else if r.IsNull(Column) then begin
clNull := AppSettings.ReadInt(asFieldNullBackground);
if clNull <> clNone then
cl := clNull;
end;
if cl <> clNone then begin
TargetCanvas.Brush.Color := cl;
TargetCanvas.FillRect(CellRect);
end;
if (Sender.FocusedNode <> nil) and (Node <> Sender.FocusedNode) and (Column = Sender.FocusedColumn) then begin
if AppSettings.ReadBool(asHightlightSameText) then begin
FieldText := r.Col(Column);
FocusedFieldText := VT.Text[Sender.FocusedNode, Sender.FocusedColumn];
if CompareText(FieldText, FocusedFieldText) = 0 then begin
TargetCanvas.Brush.Color := $00DDDDDD; //clInfoBk;
TargetCanvas.FillRect(CellRect);
end;
end;
end;
end;
@@ -942,6 +942,16 @@ object optionsform: Toptionsform
TabOrder = 15
OnClick = Modified
end
object chkHightlightSameText: TCheckBox
Left = 8
Top = 239
Width = 691
Height = 17
Anchors = [akLeft, akTop, akRight]
Caption = 'Hightlight fields with same text as in focused field'
TabOrder = 16
OnClick = Modified
end
end
object tabDataEditors: TTabSheet
Caption = 'Data editors'
@@ -139,6 +139,7 @@ Toptionsform = class(TForm)
editQueryHistoryKeepDays: TEdit;
updownQueryHistoryKeepDays: TUpDown;
lblQueryHistoryKeepDays: TLabel;
chkHightlightSameText: TCheckBox;
procedure FormShow(Sender: TObject);
procedure Modified(Sender: TObject);
procedure Apply(Sender: TObject);
@@ -311,6 +312,7 @@ procedure Toptionsform.Apply(Sender: TObject);
AppSettings.WriteInt(asRowBackgroundOdd, cboxRowBackgroundOdd.Selected);
AppSettings.WriteBool(asDataLocalNumberFormat, chkLocalNumberFormat.Checked);
AppSettings.WriteBool(asHintsOnResultTabs, chkHintsOnResultTabs.Checked);
AppSettings.WriteBool(asHightlightSameText, chkHightlightSameText.Checked);
// Editor Configuration
AppSettings.WriteBool(asFieldEditorBinary, chkEditorBinary.Checked);
@@ -533,6 +535,7 @@ procedure Toptionsform.FormShow(Sender: TObject);
cboxRowBackgroundOdd.Selected := AppSettings.ReadInt(asRowBackgroundOdd);
chkLocalNumberFormat.Checked := AppSettings.ReadBool(asDataLocalNumberFormat);
chkHintsOnResultTabs.Checked := AppSettings.ReadBool(asHintsOnResultTabs);
chkHightlightSameText.Checked := AppSettings.ReadBool(asHightlightSameText);
// Editor Configuration
chkEditorBinary.Checked := AppSettings.ReadBool(asFieldEditorBinary);

0 comments on commit 7e28c51

Please sign in to comment.