[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/unx

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Feb 20 15:53:49 UTC 2019


 vcl/inc/qt5/Qt5FilePicker.hxx    |    6 +++
 vcl/qt5/Qt5FilePicker.cxx        |    9 ++--
 vcl/unx/kde5/KDE5FilePicker.hxx  |    3 -
 vcl/unx/kde5/KDE5FilePicker2.cxx |   75 +--------------------------------------
 4 files changed, 13 insertions(+), 80 deletions(-)

New commits:
commit 0dda9db8b5610ee31020258d7e4c83342d0ceefc
Author:     Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Wed Feb 6 16:23:00 2019 +0100
Commit:     Katarina Behrens <Katarina.Behrens at cib.de>
CommitDate: Wed Feb 20 16:53:21 2019 +0100

    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).
    
    Change-Id: I9673b20e3313c0628a76f0d94e018327f4af8523
    Reviewed-on: https://gerrit.libreoffice.org/68054
    Tested-by: Jenkins
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>

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 d5271577704e..3d3a428cd5a0 100644
--- a/vcl/unx/kde5/KDE5FilePicker.hxx
+++ b/vcl/unx/kde5/KDE5FilePicker.hxx
@@ -100,9 +100,6 @@ public:
 private:
     //add a custom control widget to the file dialog
     void addCustomControl(sal_Int16 controlId);
-    static void handleSetListValue(QComboBox* pQComboBox, sal_Int16 nAction,
-                                   const css::uno::Any& rValue);
-    static 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 578cb983aee0..582bff27e494 100644
--- a/vcl/unx/kde5/KDE5FilePicker2.cxx
+++ b/vcl/unx/kde5/KDE5FilePicker2.cxx
@@ -162,7 +162,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);
@@ -195,7 +195,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);
@@ -364,77 +364,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)
 {


More information about the Libreoffice-commits mailing list