From ddcb54a5385f8826117b3adf5e9dc0a0718fc89c Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Sun, 13 Oct 2013 05:48:43 +0000 Subject: [PATCH] Introduce tree favorites: * Add a button right besides db/table filter for hiding non-favorites * Add an icon on the very left of table nodes, showing whether they are favorites Fixes issue #3366 --- out/locale/en/LC_MESSAGES/default.po | 6 +- res/icons/bullet_star_gray.png | Bin 0 -> 329 bytes source/dbconnection.pas | 8 + source/helpers.pas | 3 +- source/main.dfm | 248 +++++++++++++++++++++------ source/main.pas | 160 +++++++++++++---- 6 files changed, 337 insertions(+), 88 deletions(-) create mode 100644 res/icons/bullet_star_gray.png diff --git a/out/locale/en/LC_MESSAGES/default.po b/out/locale/en/LC_MESSAGES/default.po index 99ecce8f..2fa113e1 100644 --- a/out/locale/en/LC_MESSAGES/default.po +++ b/out/locale/en/LC_MESSAGES/default.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: HeidiSQL\n" "POT-Creation-Date: 2012-11-05 21:40\n" -"PO-Revision-Date: 2013-10-10 06:24+0100\n" +"PO-Revision-Date: 2013-10-13 07:30+0100\n" "Last-Translator: Ansgar Becker \n" "Language-Team: English (http://www.transifex.com/projects/p/heidisql/" "language/en/)\n" @@ -1182,6 +1182,10 @@ msgstr "Table filter" msgid "Table filter|Can contain regular expressions, e.g. \"phpbb_\\d\"" msgstr "Table filter|Can contain regular expressions, e.g. \"phpbb_\\d\"" +#. Tree favorites button +msgid "Hide non-favorite marked tree items" +msgstr "Hide non-favorite marked tree items" + #. MainForm..panelTop..pnlLeft..DBtree......WideText #. MainForm..panelTop..pnlRight..PageControlMain..tabDatabase..ListTables......WideText #. frmRoutineEditor..PageControlMain..tabParameters..listParameters......WideText diff --git a/res/icons/bullet_star_gray.png b/res/icons/bullet_star_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..4d4ea7a53680dd3ee2bf3e85cd2ca47478a405e1 GIT binary patch literal 329 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmUzPnffIy#(?(3p^r= z85sBufiR<}hF1enP^!c=q9iy!t)x7$D3u`~F*C13&(AePq0Cs%RL{`R{j-xfP}NaS z7sn6_|F;u%bG8HsxXMe+ywz^XA$_yuu1-XADo0mGS6643{DZ*-i2QO+I{-BiEr@K)X2i0@}F&1A2yKKu>W}Bl6~(rPa9eHB`fnd zPrZF^=CYHH9J;5Se($@yYh8<{#`$8drUMVR6(@uzl<#M}y)E$eHkRG5fA2e#yT37T zdf3lMwxyX`Z>{X(n@`U+V%RNzNNHFTWkaL5QC?ypUXO@geCyD34&Gt literal 0 HcmV?d00001 diff --git a/source/dbconnection.pas b/source/dbconnection.pas index d59822c9..b110b754 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -25,6 +25,7 @@ type function GetObjType: String; function GetImageIndex: Integer; function GetOverlayImageIndex: Integer; + function GetPath: String; function GetCreateCode: String; procedure SetCreateCode(Value: String); public @@ -47,6 +48,7 @@ type property ObjType: String read GetObjType; property ImageIndex: Integer read GetImageIndex; property OverlayImageIndex: Integer read GetOverlayImageIndex; + property Path: String read GetPath; property CreateCode: String read GetCreateCode write SetCreateCode; property WasSelected: Boolean read FWasSelected write FWasSelected; property Connection: TDBConnection read FConnection; @@ -5205,6 +5207,12 @@ begin end; +function TDBObject.GetPath: String; +begin + Result := Database + DELIM + Schema + DELIM + Name; +end; + + function TDBObject.GetCreateCode: String; begin if not FCreateCodeFetched then try diff --git a/source/helpers.pas b/source/helpers.pas index ab3dcfd8..efbead30 100644 --- a/source/helpers.pas +++ b/source/helpers.pas @@ -176,7 +176,7 @@ type asActionShortcut1, asActionShortcut2, asHighlighterForeground, asHighlighterBackground, asHighlighterStyle, asListColWidths, asListColsVisible, asListColPositions, asListColSort, asSessionFolder, asRecentFilter, asTimestampColumns, asDateTimeEditorCursorPos, asAppLanguage, asAutoExpand, asForeignDropDown, asQueryHistoryEnabled, - asColumnSelectorWidth, asColumnSelectorHeight, asDonatedEmail, + asColumnSelectorWidth, asColumnSelectorHeight, asDonatedEmail, asFavoriteObjects, asUnused); TAppSetting = record Name: String; @@ -3373,6 +3373,7 @@ begin InitSetting(asColumnSelectorWidth, 'ColumnSelectorWidth', 200, False, ''); InitSetting(asColumnSelectorHeight, 'ColumnSelectorHeight', 270, False, ''); InitSetting(asDonatedEmail, 'DonatedEmail', 0, False, ''); + InitSetting(asFavoriteObjects, 'FavoriteObjects', 0, False, '', True); end; diff --git a/source/main.dfm b/source/main.dfm index 7eee525f..a5f6b4ba 100644 --- a/source/main.dfm +++ b/source/main.dfm @@ -645,9 +645,9 @@ object MainForm: TMainForm end object DBtree: TVirtualStringTree Left = 0 - Top = 25 + Top = 22 Width = 169 - Height = 228 + Height = 231 Align = alClient Constraints.MinWidth = 40 DragMode = dmAutomatic @@ -667,9 +667,10 @@ object MainForm: TMainForm ParentShowHint = False PopupMenu = popupDB ShowHint = True - TabOrder = 1 + TabOrder = 0 TreeOptions.PaintOptions = [toHotTrack, toShowButtons, toShowDropmark, toShowRoot, toShowTreeLines, toThemeAware, toUseBlendedImages, toGhostedIfUnfocused, toUseExplorerTheme, toHideTreeLinesIfThemed] TreeOptions.SelectionOptions = [toFullRowSelect, toRightClickSelect] + OnAfterCellPaint = DBtreeAfterCellPaint OnBeforeCellPaint = DBtreeBeforeCellPaint OnChange = DBtreeChange OnDblClick = DBtreeDblClick @@ -685,10 +686,11 @@ object MainForm: TMainForm OnGetNodeDataSize = DBtreeGetNodeDataSize OnInitChildren = DBtreeInitChildren OnInitNode = DBtreeInitNode + OnNodeClick = DBtreeNodeClick Columns = < item Position = 0 - Width = 110 + Width = 165 WideText = 'Name' end item @@ -708,7 +710,7 @@ object MainForm: TMainForm Height = 100 Align = alBottom BevelOuter = bvNone - TabOrder = 2 + TabOrder = 1 Visible = False DesignSize = ( 169 @@ -773,36 +775,22 @@ object MainForm: TMainForm end end end - object pnlTreeFilter: TPanel + object ToolBarTree: TToolBar Left = 0 Top = 0 Width = 169 - Height = 25 - Align = alTop - BevelOuter = bvNone - Caption = 'pnlTreeFilter' - ShowCaption = False - TabOrder = 0 - object editTableFilter: TButtonedEdit - Left = 78 - Top = 2 - Width = 89 - Height = 21 - Hint = 'Table filter|Can contain regular expressions, e.g. "phpbb_\d"' - Images = ImageListMain - LeftButton.ImageIndex = 14 - LeftButton.Visible = True - TabOrder = 1 - TextHint = 'Table filter' - OnChange = editDatabaseTableFilterChange - OnExit = editDatabaseTableFilterExit - OnLeftButtonClick = editDatabaseTableFilterLeftButtonClick - end + Height = 22 + Caption = 'ToolBarTree' + Images = ImageListMain + ParentShowHint = False + ShowHint = True + TabOrder = 2 + Wrapable = False object editDatabaseFilter: TButtonedEdit - Left = 3 - Top = 2 - Width = 75 - Height = 21 + Left = 0 + Top = 0 + Width = 50 + Height = 22 Hint = 'Database filter|A list of databases, separated by semicolon. Can' + ' contain regular expressions, e.g. "mydb;test.*;project\d+".' @@ -815,6 +803,26 @@ object MainForm: TMainForm OnExit = editDatabaseTableFilterExit OnLeftButtonClick = editDatabaseTableFilterLeftButtonClick end + object editTableFilter: TButtonedEdit + Left = 50 + Top = 0 + Width = 50 + Height = 22 + Hint = 'Table filter|Can contain regular expressions, e.g. "phpbb_\d"' + Images = ImageListMain + LeftButton.ImageIndex = 14 + LeftButton.Visible = True + TabOrder = 1 + TextHint = 'Table filter' + OnChange = editDatabaseTableFilterChange + OnExit = editDatabaseTableFilterExit + OnLeftButtonClick = editDatabaseTableFilterLeftButtonClick + end + object btnTreeFavorites: TToolButton + Left = 100 + Top = 0 + Action = actTreeFavorites + end end end object pnlRight: TPanel @@ -2905,6 +2913,14 @@ object MainForm: TMainForm Enabled = False OnExecute = actUnixTimestampColumnExecute end + object actTreeFavorites: TAction + Category = 'Various' + AutoCheck = True + Caption = 'actTreeFavorites' + Hint = 'Hide non-favorite marked tree items' + ImageIndex = 112 + OnExecute = editDatabaseTableFilterChange + end end object menuConnections: TPopupMenu AutoHotkeys = maManual @@ -2919,73 +2935,201 @@ object MainForm: TMainForm Left = 504 Top = 104 Bitmap = { - 494C0101B7005001E40210001000FFFFFFFF2110FFFFFFFFFFFFFFFF424D3600 - 000000000000360000002800000040000000E0020000010020000000000000E0 + 494C0101B80050011C0310001000FFFFFFFF2110FFFFFFFFFFFFFFFF424D3600 + 000000000000360000002800000040000000F0020000010020000000000000F0 0200000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000006DFFFFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFFFFFFFFFFFF0000006D0000000000000000000000000000 00000000000000000000000000000000000000000000000000000200011A3300 1A80870043D57E003DD5270012800100001A0000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000C09 07497D6047D6BA8F66FF7A583DDA0D0A074C0000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000001A1A1A5D363636870000 + 001200000012323232871717175D000000000000000000000000000000000000 0000000000000000000000000000000000000000006DFCFCFCFF0F0F0F6D0F0F 0F6D0F0F0F6D0F0F0F6DFCFCFCFF0000006D0000000000000000000000000000 000000000000000000000000000000000000000000000000000039001E80EE7A B8FFF58FC9FFF384C2FFE476B0FF280012800000000000000000000000000000 000000000000000000000000000000000000000000000B100B561B2C1D87C4A0 7EFFD6BCA1FFC4A07AFFB78C5FFFB08054FF0000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000010101048CCCCCCFFADAD + ADF3A9A9A9F3C0C0C0FF0E0E0E48000000000000000000000000000000000000 0000000000000000000000000000000000000000006DFCFCFCFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFFFFFBFBFBFF0000006D0000000000000000000000000000 0000000000000000000000000000000000000000000000000000A70059D5F8A8 D6FFF56EBCFFF465B6FFF385C1FF820040D50000000000000000000000000000 0000000000000000000000000000000000004B684EC88FBD96FF84B78BFFC7A4 82FFC9A98BFFCBA782FFB88C61FFB48558FF0000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000606062DCCCCCCFFDBDB + DBFFD7D7D7FFBEBEBEFF0505052D000000000000000000000000000000000000 0000000000000000000000000000000000000000006DFCFCFCFF0F0F0F6D0F0F 0F6D0F0F0F6D0F0F0F6DFAFAFAFF0000006D0000000000000000000000000000 0000000000000000000000000000000000000000000000000000AD005ED5FBB7 DFFFF87CC7FFF56CBBFFF590C9FF8D0047D50000000000000000000000000000 00000000000000000000000000000000000091BD97FFABCFB1FF79A29DFF6765 C3FF6367E8FF605FC2FFA48B8CFFA17F5CF10000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000003636363B1D7D7D7FFDEDE + DEFFDBDBDBFFCDCDCDFF595959B1000000030000000000000000000000000000 0000000000000000000000000000000000000000006DFFFFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFFFFF6F6F6FF0000006D0000000000000000000000000000 000000000000000000000000000000000000000000000000000040002380FD7E C3FFFBB8DFFFFAB0DBFFF07BBAFF36001C800000000000000000000000000000 0000000000000000000000000000000000007EB386FF80B588FF6D71E9FF9493 F4FF7174ECFF5B5FE8FF5057E2FF0101021F0000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000004B4B4B99D5D5D5FFD7D7D7FFDEDE + DEFFDADADAFFCCCCCCFFC0C0C0FF414141990000000000000000000000000000 0000000000000000000000000000000000000000006DFBFBFBFF0F0F0F6D0F0F 0F6D0F0F0F6DF4F4F4FFF7F7F7FF0000006D0000000000000000000000000000 00000000000000000000000000000000000000000000000000000200011A4000 2380AF005ED5AB005BD53B0020800200011A0000000000000000000000000000 0000000000000000000000000000000000001F2C21834D7554D67A7CECFF7072 EEFF8281F2FF5E61E8FF555BE5FF000101180000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000090C0C0C3F37373784D3D3 + D3FFCFCFCFFF353535870B0B0B3F000000090000000000000000000000000000 0000000000000000000000000000000000000000006DF8F8F8FFF7F7F7FFF4F4 F4FFEDEDEDFFF5F5F5FF0000006D000000090000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000005F61CBF16E6F EDFF6265EAFF6F70EDFF5D60CAF10000000A0000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000007F7F + 7FC97C7C7CC90000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000006D0000006D0000006D0000 006D0000006D0000006D00000009000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000110B0B 1957141538800B0B195700000011000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000D0D + 0D420D0D0D420000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 @@ -8810,7 +8954,7 @@ object MainForm: TMainForm 000000000000000000000000000000000000854F2FAAA46B43CEB1764ADEAE74 48DBAF7448DBAE7349DBA46A3FD054331B6E0603020800000000000000000000 000000000000000000000000000000000000424D3E000000000000003E000000 - 2800000040000000E00200000100010000000000001700000000000000000000 + 2800000040000000F00200000100010000000000801700000000000000000000 000000000000000000000000FFFFFF0000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 @@ -8996,6 +9140,10 @@ object MainForm: TMainForm 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 000000000000} end object PopupQueryLoad: TPopupMenu diff --git a/source/main.pas b/source/main.pas index 3cfbce8c..864dc1fb 100644 --- a/source/main.pas +++ b/source/main.pas @@ -561,9 +561,6 @@ type Explainanalyzerforcurrentquery1: TMenuItem; menuAutoExpand: TMenuItem; menuTreeOptions: TMenuItem; - pnlTreeFilter: TPanel; - editTableFilter: TButtonedEdit; - editDatabaseFilter: TButtonedEdit; menuClearDataTabFilter: TMenuItem; actUnixTimestampColumn: TAction; actTimestampColumn1: TMenuItem; @@ -572,6 +569,11 @@ type Save1: TMenuItem; Saveassnippet1: TMenuItem; imgDonate: TImage; + ToolBarTree: TToolBar; + editDatabaseFilter: TButtonedEdit; + editTableFilter: TButtonedEdit; + btnTreeFavorites: TToolButton; + actTreeFavorites: TAction; procedure actCreateDBObjectExecute(Sender: TObject); procedure menuConnectionsPopup(Sender: TObject); procedure actExitApplicationExecute(Sender: TObject); @@ -909,6 +911,11 @@ type procedure imgDonateClick(Sender: TObject); procedure DBtreeExpanded(Sender: TBaseVirtualTree; Node: PVirtualNode); procedure ApplicationDeActivate(Sender: TObject); + procedure DBtreeAfterCellPaint(Sender: TBaseVirtualTree; + TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; + CellRect: TRect); + procedure DBtreeNodeClick(Sender: TBaseVirtualTree; + const HitInfo: THitInfo); private // Executable file details FAppVerMajor: Integer; @@ -2827,11 +2834,15 @@ end; procedure TMainForm.pnlLeftResize(Sender: TObject); +var + WidthAvail: Integer; begin + WidthAvail := editDatabaseFilter.Parent.Width - btnTreeFavorites.Width; editDatabaseFilter.Left := 0; - editDatabaseFilter.Width := (editDatabaseFilter.Parent.Width div 2) - 1; + editDatabaseFilter.Width := (WidthAvail div 2) - 1; editTableFilter.Width := editDatabaseFilter.Width; - editTableFilter.Left := editDatabaseFilter.Width + 2; + editTableFilter.Left := editDatabaseFilter.Width + 1; + btnTreeFavorites.Left := editTableFilter.Left + editTableFilter.Width + 1; spltPreview.OnMoved(Sender); end; @@ -7797,8 +7808,7 @@ procedure TMainForm.DBtreeExpanded(Sender: TBaseVirtualTree; begin // Table and database filter both need initialized children Sender.ReinitChildren(Node, False); - if edittablefilter.Text <> '' then - editTableFilter.OnChange(editTableFilter); + editDatabaseTableFilterChange(Self); end; @@ -9687,51 +9697,72 @@ end; procedure TMainForm.editDatabaseTableFilterChange(Sender: TObject); var - Edit: TButtonedEdit; Node: PVirtualNode; Obj: PDBObject; - rx: TRegExpr; - FilterError, NodeMatches: Boolean; - VisibleCount: Cardinal; + rxdb, rxtable: TRegExpr; + NodeMatches: Boolean; + Errors, Favorites: TStringList; begin // Immediately apply database filter LogSQL('editDatabaseTableFilterChange', lcDebug); - Edit := Sender as TButtonedEdit; - rx := TRegExpr.Create; - rx.ModifierI := True; - rx.Expression := '('+StringReplace(Edit.Text, ';', '|', [rfReplaceAll])+')'; - VisibleCount := 0; - FilterError := False; + + rxdb := TRegExpr.Create; + rxdb.ModifierI := True; + rxdb.Expression := '('+StringReplace(editDatabaseFilter.Text, ';', '|', [rfReplaceAll])+')'; + rxtable := TRegExpr.Create; + rxtable.ModifierI := True; + rxtable.Expression := '('+StringReplace(editTableFilter.Text, ';', '|', [rfReplaceAll])+')'; + + Errors := TStringList.Create; + Favorites := nil; DBtree.BeginUpdate; Node := DBtree.GetFirst; while Assigned(Node) do begin Obj := DBtree.GetNodeData(Node); - if ((Edit = editDatabaseFilter) and (Obj.NodeType = lntDb)) - or - ((Edit = editTableFilter) and (Obj.NodeType in [lntTable..lntEvent])) - then begin - try - NodeMatches := rx.Exec(DBtree.Text[Node, 0]); - except - FilterError := True; - NodeMatches := True; + NodeMatches := True; + try + case Obj.NodeType of + lntNone: begin + // Get favorite paths from session settings + if Favorites <> nil then + Favorites.Free; + AppSettings.SessionPath := FConnections[Node.Index].Parameters.SessionPath; + Favorites := Explode(CRLF, AppSettings.ReadString(asFavoriteObjects)); end; - DBtree.IsVisible[Node] := NodeMatches; - if NodeMatches then - Inc(VisibleCount); + lntDb: begin + // Match against database filter + if editDatabaseFilter.Text <> '' then + NodeMatches := rxdb.Exec(DBtree.Text[Node, 0]); + end; + lntTable..lntEvent: begin + // Match against table filter + if editTableFilter.Text <> '' then + NodeMatches := rxtable.Exec(DBtree.Text[Node, 0]); + if actTreeFavorites.Checked then + // Hide non-favorite object path + NodeMatches := NodeMatches and (Favorites.IndexOf(Obj.Path) > -1); + end; + end; + except + on E:Exception do begin + // Log regex errors, but avoid duplicate messages + if Errors.IndexOf(E.Message) = -1 then begin + LogSQL(E.Message); + Errors.Add(E.Message); + end; + end; end; + DBtree.IsVisible[Node] := NodeMatches; + Node := DBtree.GetNextInitialized(Node); end; DBtree.EndUpdate; - rx.Free; - if VisibleCount = 0 then - FilterError := True; - if FilterError then - Edit.Color := clWebPink - else - Edit.Color := clWindow; + rxdb.Free; + rxtable.Free; + if Favorites <> nil then + Favorites.Free; end; @@ -10466,6 +10497,63 @@ begin end; +procedure TMainForm.DBtreeAfterCellPaint(Sender: TBaseVirtualTree; + TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; + CellRect: TRect); +var + Obj: PDBObject; + Favorites: TStringList; +begin + // Paint favorite icon on table node + if Column <> 0 then + Exit; + Obj := Sender.GetNodeData(Node); + if Obj.NodeType in [lntTable..lntEvent] then begin + AppSettings.SessionPath := Obj.Connection.Parameters.SessionPath; + Favorites := Explode(CRLF, AppSettings.ReadString(asFavoriteObjects)); + if Favorites.IndexOf(Obj.Path) > -1 then + ImageListMain.Draw(TargetCanvas, CellRect.Left, CellRect.Top, 168) + else if Node = Sender.HotNode then + ImageListMain.Draw(TargetCanvas, CellRect.Left, CellRect.Top, 183); + Favorites.Free; + end; +end; + + +procedure TMainForm.DBtreeNodeClick(Sender: TBaseVirtualTree; const HitInfo: THitInfo); +var + Obj: PDBObject; + Favorites: TStringList; + idx: Integer; +begin + // Watch out for clicks on favorite icon + // Add or remove object path from favorite list on click + if (HitInfo.HitColumn <> 0) + or (not Assigned(HitInfo.HitNode)) + then Exit; + if + (not (hiOnItem in HitInfo.HitPositions)) + or (hiOnItemLabel in HitInfo.HitPositions) + or (hiOnItemRight in HitInfo.HitPositions) + or (hiOnNormalIcon in HitInfo.HitPositions) + then Exit; + + Obj := Sender.GetNodeData(HitInfo.HitNode); + if Obj.NodeType in [lntTable..lntEvent] then begin + AppSettings.SessionPath := Obj.Connection.Parameters.SessionPath; + Favorites := TStringList.Create; + Favorites.Text := AppSettings.ReadString(asFavoriteObjects); + idx := Favorites.IndexOf(Obj.Path); + if idx > -1 then + Favorites.Delete(idx) + else + Favorites.Add(Obj.Path); + AppSettings.WriteString(asFavoriteObjects, Favorites.Text); + Favorites.Free; + end; +end; + + procedure TMainForm.DBtreeBeforeCellPaint(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect);