summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2019-02-06 16:23:00 +0100
committerKatarina Behrens <Katarina.Behrens@cib.de>2019-05-21 21:40:34 +0200
commite4a1c8ec2743d970ced202c04c643865f7c2570b (patch)
treed2e8ff934da343aba578fd66001ee207a3139b47
parent2b122709b0c8258a7b825a3c4d71d1168741db21 (diff)
kde5 fpicker: Reuse existing handle{G,S}etListValue
Turn existing functions in Qt5FilePicker into protected static class methods and reuse them in KDE5FilePicker. The qt5 implementation covers everything that kde5 had, and a little more (e.g. covers case 'ControlActions::DELETE_ITEM' in 'handleSetListValue' as well). Reviewed-on: https://gerrit.libreoffice.org/68054 Tested-by: Jenkins Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de> (cherry picked from commit 0dda9db8b5610ee31020258d7e4c83342d0ceefc) Change-Id: I9673b20e3313c0628a76f0d94e018327f4af8523 Reviewed-on: https://gerrit.libreoffice.org/72651 Tested-by: Jenkins Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
-rw-r--r--vcl/inc/qt5/Qt5FilePicker.hxx6
-rw-r--r--vcl/qt5/Qt5FilePicker.cxx9
-rw-r--r--vcl/unx/kde5/KDE5FilePicker.hxx2
-rw-r--r--vcl/unx/kde5/KDE5FilePicker2.cxx75
4 files changed, 13 insertions, 79 deletions
diff --git a/vcl/inc/qt5/Qt5FilePicker.hxx b/vcl/inc/qt5/Qt5FilePicker.hxx
index 74fb25f57e20..4a546da46b53 100644
--- a/vcl/inc/qt5/Qt5FilePicker.hxx
+++ b/vcl/inc/qt5/Qt5FilePicker.hxx
@@ -43,6 +43,7 @@
#include <memory>
+class QComboBox;
class QGridLayout;
class QLabel;
class QWidget;
@@ -147,6 +148,11 @@ public:
virtual OUString SAL_CALL getDirectory() override;
virtual void SAL_CALL setDescription(const OUString& rDescription) override;
+protected:
+ static css::uno::Any handleGetListValue(QComboBox* pWidget, sal_Int16 nControlAction);
+ static void handleSetListValue(QComboBox* pQComboBox, sal_Int16 nAction,
+ const css::uno::Any& rValue);
+
private Q_SLOTS:
// XExecutableDialog functions
/// @throws css::uno::RuntimeException
diff --git a/vcl/qt5/Qt5FilePicker.cxx b/vcl/qt5/Qt5FilePicker.cxx
index 6390f0d1474e..9a0d6e820783 100644
--- a/vcl/qt5/Qt5FilePicker.cxx
+++ b/vcl/qt5/Qt5FilePicker.cxx
@@ -384,7 +384,7 @@ void SAL_CALL Qt5FilePicker::appendFilterGroup(const OUString& rGroupTitle,
}
}
-static uno::Any HandleGetListValue(QComboBox* pWidget, sal_Int16 nControlAction)
+uno::Any Qt5FilePicker::handleGetListValue(QComboBox* pWidget, sal_Int16 nControlAction)
{
uno::Any aAny;
switch (nControlAction)
@@ -417,7 +417,8 @@ static uno::Any HandleGetListValue(QComboBox* pWidget, sal_Int16 nControlAction)
return aAny;
}
-static void HandleSetListValue(QComboBox* pWidget, sal_Int16 nControlAction, const uno::Any& rValue)
+void Qt5FilePicker::handleSetListValue(QComboBox* pWidget, sal_Int16 nControlAction,
+ const uno::Any& rValue)
{
switch (nControlAction)
{
@@ -478,7 +479,7 @@ void SAL_CALL Qt5FilePicker::setValue(sal_Int16 controlId, sal_Int16 nControlAct
{
QComboBox* combo = dynamic_cast<QComboBox*>(widget);
if (combo)
- HandleSetListValue(combo, nControlAction, value);
+ handleSetListValue(combo, nControlAction, value);
}
}
else
@@ -504,7 +505,7 @@ uno::Any SAL_CALL Qt5FilePicker::getValue(sal_Int16 controlId, sal_Int16 nContro
{
QComboBox* combo = dynamic_cast<QComboBox*>(widget);
if (combo)
- res = HandleGetListValue(combo, nControlAction);
+ res = handleGetListValue(combo, nControlAction);
}
}
else
diff --git a/vcl/unx/kde5/KDE5FilePicker.hxx b/vcl/unx/kde5/KDE5FilePicker.hxx
index 65b67b37c7b1..3d3a428cd5a0 100644
--- a/vcl/unx/kde5/KDE5FilePicker.hxx
+++ b/vcl/unx/kde5/KDE5FilePicker.hxx
@@ -100,8 +100,6 @@ public:
private:
//add a custom control widget to the file dialog
void addCustomControl(sal_Int16 controlId);
- void handleSetListValue(QComboBox* pQComboBox, sal_Int16 nAction, const css::uno::Any& rValue);
- css::uno::Any handleGetListValue(QComboBox* pQComboBox, sal_Int16 nAction);
protected:
bool eventFilter(QObject* watched, QEvent* event) override;
diff --git a/vcl/unx/kde5/KDE5FilePicker2.cxx b/vcl/unx/kde5/KDE5FilePicker2.cxx
index 6d39aeb23bdf..7e683a59884f 100644
--- a/vcl/unx/kde5/KDE5FilePicker2.cxx
+++ b/vcl/unx/kde5/KDE5FilePicker2.cxx
@@ -161,7 +161,7 @@ void SAL_CALL KDE5FilePicker::setValue(sal_Int16 controlId, sal_Int16 nControlAc
{
QComboBox* cb = dynamic_cast<QComboBox*>(_customListboxes.value(controlId));
if (cb)
- handleSetListValue(cb, nControlAction, value);
+ Qt5FilePicker::handleSetListValue(cb, nControlAction, value);
}
else
SAL_WARN("vcl.kde5", "set value on unknown control " << controlId);
@@ -194,7 +194,7 @@ uno::Any SAL_CALL KDE5FilePicker::getValue(sal_Int16 controlId, sal_Int16 nContr
{
QComboBox* cb = dynamic_cast<QComboBox*>(_customListboxes.value(controlId));
if (cb)
- return handleGetListValue(cb, nControlAction);
+ return Qt5FilePicker::handleGetListValue(cb, nControlAction);
}
else
SAL_WARN("vcl.kde5", "get value on unknown control" << controlId);
@@ -363,77 +363,6 @@ void KDE5FilePicker::addCustomControl(sal_Int16 controlId)
}
}
-void KDE5FilePicker::handleSetListValue(QComboBox* pQComboBox, sal_Int16 nAction,
- const css::uno::Any& rValue)
-{
- switch (nAction)
- {
- case ControlActions::ADD_ITEM:
- {
- OUString sItem;
- rValue >>= sItem;
- pQComboBox->addItem(toQString(sItem));
- }
- break;
- case ControlActions::ADD_ITEMS:
- {
- Sequence<OUString> aStringList;
- rValue >>= aStringList;
- sal_Int32 nItemCount = aStringList.getLength();
- for (sal_Int32 i = 0; i < nItemCount; ++i)
- {
- pQComboBox->addItem(toQString(aStringList[i]));
- }
- }
- break;
- case ControlActions::SET_SELECT_ITEM:
- {
- sal_Int32 nPos = 0;
- rValue >>= nPos;
- pQComboBox->setCurrentIndex(nPos);
- }
- break;
- default:
- SAL_WARN("vcl.kde5", "unknown action on list control " << nAction);
- break;
- }
-}
-
-uno::Any KDE5FilePicker::handleGetListValue(QComboBox* pQComboBox, sal_Int16 nAction)
-{
- uno::Any aAny;
- switch (nAction)
- {
- case ControlActions::GET_ITEMS:
- {
- uno::Sequence<OUString> aItemList;
-
- for (int i = 0; i < pQComboBox->count(); ++i)
- {
- aItemList[i] = toOUString(pQComboBox->itemText(i));
- }
- aAny <<= aItemList;
- }
- break;
- case ControlActions::GET_SELECTED_ITEM:
- {
- OUString sItem = toOUString(pQComboBox->currentText());
- aAny <<= sItem;
- }
- break;
- case ControlActions::GET_SELECTED_ITEM_INDEX:
- {
- int nCurrent = pQComboBox->currentIndex();
- aAny <<= static_cast<sal_Int32>(nCurrent);
- }
- break;
- default:
- SAL_WARN("vcl.kde5", "unknown action on list control " << nAction);
- break;
- }
- return aAny;
-}
-
// XInitialization
void SAL_CALL KDE5FilePicker::initialize(const uno::Sequence<uno::Any>& args)
{