summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-12-08 10:32:31 +0000
committerCaolán McNamara <caolanm@redhat.com>2021-12-10 10:55:25 +0100
commite2d498b778a3dac70a7faee4d1bbabb50cdcc103 (patch)
treed4ddd10168705d8a1312a257ac7491032263cfa1 /sc/source/ui
parent9e8789f2186d16a895cd659b321e5001ea239658 (diff)
tdf#146018 group filtering options under a single dropdown
Change-Id: I91afb746485654ed8e1418d17d4b172332b3f1f5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126532 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/cctrl/checklistmenu.cxx26
-rw-r--r--sc/source/ui/inc/checklistmenu.hxx1
-rw-r--r--sc/source/ui/inc/gridwin.hxx1
-rw-r--r--sc/source/ui/view/gridwin.cxx24
4 files changed, 37 insertions, 15 deletions
diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx
index a4d7fbfc5fb8..7dce50e60e24 100644
--- a/sc/source/ui/cctrl/checklistmenu.cxx
+++ b/sc/source/ui/cctrl/checklistmenu.cxx
@@ -89,12 +89,10 @@ IMPL_LINK(ScCheckListMenuControl, MenuKeyInputHdl, const KeyEvent&, rKEvt, bool)
break;
const MenuItemData& rMenu = maMenuItems[mnSelectedMenu];
- if (!rMenu.mbEnabled || !rMenu.mxSubMenuWin)
+ if (!rMenu.mxSubMenuWin)
break;
- maOpenTimer.mnMenuPos = mnSelectedMenu;
- maOpenTimer.mpSubMenu = rMenu.mxSubMenuWin.get();
- launchSubMenu();
+ executeMenuItem(mnSelectedMenu);
}
}
@@ -200,6 +198,18 @@ void ScCheckListMenuControl::executeMenuItem(size_t nPos)
if (nPos >= maMenuItems.size())
return;
+ const MenuItemData& rMenu = maMenuItems[nPos];
+ if (rMenu.mxSubMenuWin)
+ {
+ if (rMenu.mbEnabled)
+ {
+ maOpenTimer.mnMenuPos = nPos;
+ maOpenTimer.mpSubMenu = rMenu.mxSubMenuWin.get();
+ launchSubMenu();
+ }
+ return;
+ }
+
if (!maMenuItems[nPos].mxAction)
// no action is defined.
return;
@@ -1568,6 +1578,14 @@ void ScListSubMenuControl::addMenuColorItem(const OUString& rText, bool bActive,
mnBackColorMenuPrefHeight = mxBackColorMenu->get_preferred_size().Height();
}
+void ScListSubMenuControl::addSeparator()
+{
+ ScCheckListMenuControl::MenuItemData aItem;
+ maMenuItems.emplace_back(std::move(aItem));
+
+ mxMenu->append_separator("separator" + OUString::number(maMenuItems.size()));
+}
+
void ScListSubMenuControl::clearMenuItems()
{
maMenuItems.clear();
diff --git a/sc/source/ui/inc/checklistmenu.hxx b/sc/source/ui/inc/checklistmenu.hxx
index bf38ea081f10..e414a224b150 100644
--- a/sc/source/ui/inc/checklistmenu.hxx
+++ b/sc/source/ui/inc/checklistmenu.hxx
@@ -335,6 +335,7 @@ public:
// nMenu of 0 for background color, nMenu of 1 for text color
void addMenuColorItem(const OUString& rText, bool bActive, VirtualDevice& rImage,
int nMenu, ScCheckListMenuControl::Action* pAction);
+ void addSeparator();
void clearMenuItems();
void resizeToFitMenuItems();
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 419a29e74560..2f8ac0deacfc 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -330,7 +330,6 @@ protected:
public:
enum class AutoFilterMode
{
- None,
Normal,
Top10,
Custom,
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 568fcb91ccb5..9e0328ba7991 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -635,7 +635,7 @@ class AutoFilterColorPopupStartAction : public AutoFilterSubMenuAction
{
public:
AutoFilterColorPopupStartAction(ScGridWindow* p, ScListSubMenuControl* pSubMenu)
- : AutoFilterSubMenuAction(p, pSubMenu, ScGridWindow::AutoFilterMode::None)
+ : AutoFilterSubMenuAction(p, pSubMenu, ScGridWindow::AutoFilterMode::Normal)
{
}
@@ -976,17 +976,21 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow)
ScResId(STR_MENU_SORT_DESC),
new AutoFilterAction(this, AutoFilterMode::SortDescending));
mpAutoFilterPopup->addSeparator();
- mpAutoFilterPopup->addMenuItem(
- ScResId(SCSTR_TOP10FILTER), new AutoFilterAction(this, AutoFilterMode::Top10));
- mpAutoFilterPopup->addMenuItem(
- ScResId(SCSTR_FILTER_EMPTY), new AutoFilterAction(this, AutoFilterMode::Empty));
- mpAutoFilterPopup->addMenuItem(
- ScResId(SCSTR_FILTER_NOTEMPTY), new AutoFilterAction(this, AutoFilterMode::NonEmpty));
- mpAutoFilterPopup->addSeparator();
if (ScListSubMenuControl* pSubMenu = mpAutoFilterPopup->addSubMenuItem(ScResId(SCSTR_FILTER_COLOR), true, true))
pSubMenu->setPopupStartAction(new AutoFilterColorPopupStartAction(this, pSubMenu));
- mpAutoFilterPopup->addMenuItem(
- ScResId(SCSTR_STDFILTER), new AutoFilterAction(this, AutoFilterMode::Custom));
+ if (ScListSubMenuControl* pSubMenu = mpAutoFilterPopup->addSubMenuItem(ScResId(SCSTR_FILTER_CONDITION), true, false))
+ {
+ pSubMenu->addMenuItem(
+ ScResId(SCSTR_TOP10FILTER), new AutoFilterAction(this, AutoFilterMode::Top10));
+ pSubMenu->addMenuItem(
+ ScResId(SCSTR_FILTER_EMPTY), new AutoFilterAction(this, AutoFilterMode::Empty));
+ pSubMenu->addMenuItem(
+ ScResId(SCSTR_FILTER_NOTEMPTY), new AutoFilterAction(this, AutoFilterMode::NonEmpty));
+ pSubMenu->addSeparator();
+ pSubMenu->addMenuItem(
+ ScResId(SCSTR_STDFILTER), new AutoFilterAction(this, AutoFilterMode::Custom));
+ pSubMenu->resizeToFitMenuItems();
+ }
if (aEntries.size())
mpAutoFilterPopup->addMenuItem(
ScResId(SCSTR_CLEAR_FILTER), new AutoFilterAction(this, AutoFilterMode::Clear));