diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-02-22 14:40:54 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-02-22 20:25:38 +0100 |
commit | 216d7c42a8ccc5fa1379e84cb6b32d21857f774d (patch) | |
tree | 6dfb9f4fba82a343be38abea20bb1f300e88c417 /dbaccess | |
parent | e651dcd9820b2472e66f512ad2669e21d23ef465 (diff) |
weld colsmenu
Change-Id: I733e101905137abc0b3f93b9fe03e4a26c1bd520
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111348
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/inc/helpids.h | 3 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/sbagrid.cxx | 54 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/sbagrid.hxx | 6 |
3 files changed, 25 insertions, 38 deletions
diff --git a/dbaccess/inc/helpids.h b/dbaccess/inc/helpids.h index 459cc26bef6d..c2720688f9b3 100644 --- a/dbaccess/inc/helpids.h +++ b/dbaccess/inc/helpids.h @@ -27,9 +27,6 @@ #define HID_DSADMIN_BROWSECONN "DBACCESS_HID_DSADMIN_BROWSECONN" -#define HID_BROWSER_COLUMNFORMAT "DBACCESS_HID_BROWSER_COLUMNFORMAT" -#define HID_BROWSER_COLUMNWIDTH "DBACCESS_HID_BROWSER_COLUMNWIDTH" - #define HID_CTL_QRYSQLEDIT "DBACCESS_HID_CTL_QRYSQLEDIT" #define HID_CTL_QRYDGNTAB "DBACCESS_HID_CTL_QRYDGNTAB" diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx index 2251be4d629d..e293a481b07b 100644 --- a/dbaccess/source/ui/browser/sbagrid.cxx +++ b/dbaccess/source/ui/browser/sbagrid.cxx @@ -39,7 +39,6 @@ #include <svl/numuno.hxx> #include <toolkit/helper/vclunohelper.hxx> -#include <vcl/menu.hxx> #include <vcl/svapp.hxx> #include <svl/zforlist.hxx> @@ -544,26 +543,21 @@ void SbaGridHeader::ImplStartColumnDrag(sal_Int8 _nAction, const Point& _rMouseP ); } -void SbaGridHeader::PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu) +void SbaGridHeader::PreExecuteColumnContextMenu(sal_uInt16 nColId, weld::Menu& rMenu, + weld::Menu& rInsertMenu, weld::Menu& rChangeMenu, + weld::Menu& rShowMenu) { - FmGridHeader::PreExecuteColumnContextMenu(nColId, rMenu); + FmGridHeader::PreExecuteColumnContextMenu(nColId, rMenu, rInsertMenu, rChangeMenu, rShowMenu); // some items are valid only if the db isn't readonly bool bDBIsReadOnly = static_cast<SbaGridControl*>(GetParent())->IsReadOnlyDB(); if (bDBIsReadOnly) { - rMenu.EnableItem(rMenu.GetItemId("hide"), false); - PopupMenu* pShowColsMenu = rMenu.GetPopupMenu(rMenu.GetItemId("show")); - if (pShowColsMenu) - { - // at most 16 items which mean "show column <name>" - for (sal_uInt16 i=1; i<16; ++i) - pShowColsMenu->EnableItem(i, false); - // "show cols/more..." and "show cols/all" - pShowColsMenu->EnableItem(pShowColsMenu->GetItemId("more"), false); - pShowColsMenu->EnableItem(pShowColsMenu->GetItemId("all"), false); - } + rMenu.set_visible("hide", false); + rMenu.set_sensitive("hide", false); + rMenu.set_visible("show", false); + rMenu.set_sensitive("show", false); } // prepend some new items @@ -589,31 +583,25 @@ void SbaGridHeader::PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rM case DataType::REF: break; default: - rMenu.InsertItem(ID_BROWSER_COLATTRSET, DBA_RES(RID_STR_COLUMN_FORMAT), MenuItemBits::NONE, OString(), nPos++); - rMenu.SetHelpId(ID_BROWSER_COLATTRSET, HID_BROWSER_COLUMNFORMAT); - rMenu.InsertSeparator(OString(), nPos++); + rMenu.insert(nPos++, "colattrset", DBA_RES(RID_STR_COLUMN_FORMAT), + nullptr, nullptr, nullptr, TRISTATE_INDET); + rMenu.insert_separator(nPos++, "seperator1"); } } - rMenu.InsertItem(ID_BROWSER_COLWIDTH, DBA_RES(RID_STR_COLUMN_WIDTH), MenuItemBits::NONE, OString(), nPos++); - rMenu.SetHelpId(ID_BROWSER_COLWIDTH, HID_BROWSER_COLUMNWIDTH); - rMenu.InsertSeparator(OString(), nPos++); + rMenu.insert(nPos++, "colwidth", DBA_RES(RID_STR_COLUMN_WIDTH), + nullptr, nullptr, nullptr, TRISTATE_INDET); + rMenu.insert_separator(nPos++, "seperator2"); } -void SbaGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMenu& rMenu, sal_uInt16 nExecutionResult) +void SbaGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, const weld::Menu& rMenu, const OString& rExecutionResult) { - switch (nExecutionResult) - { - case ID_BROWSER_COLWIDTH: - static_cast<SbaGridControl*>(GetParent())->SetColWidth(nColId); - break; - - case ID_BROWSER_COLATTRSET: - static_cast<SbaGridControl*>(GetParent())->SetColAttrs(nColId); - break; - - default: FmGridHeader::PostExecuteColumnContextMenu(nColId, rMenu, nExecutionResult); - } + if (rExecutionResult == "colwidth") + static_cast<SbaGridControl*>(GetParent())->SetColWidth(nColId); + else if (rExecutionResult == "colattrset") + static_cast<SbaGridControl*>(GetParent())->SetColAttrs(nColId); + else + FmGridHeader::PostExecuteColumnContextMenu(nColId, rMenu, rExecutionResult); } // SbaGridControl diff --git a/dbaccess/source/ui/inc/sbagrid.hxx b/dbaccess/source/ui/inc/sbagrid.hxx index 5bf7752311ba..14e39e9581ef 100644 --- a/dbaccess/source/ui/inc/sbagrid.hxx +++ b/dbaccess/source/ui/inc/sbagrid.hxx @@ -161,8 +161,10 @@ namespace dbaui protected: // FmGridHeader overridables - virtual void PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu) override; - virtual void PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMenu& rMenu, sal_uInt16 nExecutionResult) override; + virtual void PreExecuteColumnContextMenu(sal_uInt16 nColId, weld::Menu& rMenu, + weld::Menu& rInsertMenu, weld::Menu& rChangeMenu, + weld::Menu& rShowMenu) override; + virtual void PostExecuteColumnContextMenu(sal_uInt16 nColId, const weld::Menu& rMenu, const OString& rExecutionResult) override; private: // DragSourceHelper overridables |