[Libreoffice-commits] core.git: dbaccess/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Mar 11 20:00:31 UTC 2019


 dbaccess/source/ui/dlg/advancedsettings.cxx |   31 +++++++++++++++++++++++++++-
 dbaccess/source/ui/dlg/advancedsettings.hxx |    3 ++
 2 files changed, 33 insertions(+), 1 deletion(-)

New commits:
commit d89dc81a63a36d75f13064ae2a321f1d8903bf30
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Mar 11 11:35:44 2019 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Mar 11 21:00:07 2019 +0100

    Resolves: tdf#123975 support tri-state for PrimaryKey ui
    
    typically indeterminate is an initial state which is not returnable
    to, this is not the case for PrimaryKey
    
    Change-Id: I82f318e18ad9beabd9ca6e3003a736fee9a5e931
    Reviewed-on: https://gerrit.libreoffice.org/69043
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Tested-by: Mike Kaganski <mike.kaganski at collabora.com>
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/dbaccess/source/ui/dlg/advancedsettings.cxx b/dbaccess/source/ui/dlg/advancedsettings.cxx
index 3a60598aac8f..38c50c6467bc 100644
--- a/dbaccess/source/ui/dlg/advancedsettings.cxx
+++ b/dbaccess/source/ui/dlg/advancedsettings.cxx
@@ -87,7 +87,10 @@ namespace dbaui
                 const SfxPoolItem& rItem = _rCoreAttrs.Get(nItemId);
                 booleanSetting.bOptionalBool = dynamic_cast<const OptionalBoolItem*>(&rItem) != nullptr;
                 booleanSetting.xControl = m_xBuilder->weld_check_button(booleanSetting.sControlId);
-                booleanSetting.xControl->connect_toggled(LINK(this, SpecialSettingsPage, OnToggleHdl));
+                if (booleanSetting.bOptionalBool)
+                    booleanSetting.xControl->connect_toggled(LINK(this, SpecialSettingsPage, OnTriStateToggleHdl));
+                else
+                    booleanSetting.xControl->connect_toggled(LINK(this, SpecialSettingsPage, OnToggleHdl));
                 booleanSetting.xControl->show();
             }
         }
@@ -112,6 +115,25 @@ namespace dbaui
         }
     }
 
+    IMPL_LINK(SpecialSettingsPage, OnTriStateToggleHdl, weld::ToggleButton&, rToggle, void)
+    {
+        auto eOldState = m_aTriStates[&rToggle];
+        switch (eOldState)
+        {
+            case TRISTATE_INDET:
+                rToggle.set_state(TRISTATE_FALSE);
+                break;
+            case TRISTATE_TRUE:
+                rToggle.set_state(TRISTATE_INDET);
+                break;
+            case TRISTATE_FALSE:
+                rToggle.set_state(TRISTATE_TRUE);
+                break;
+        }
+        m_aTriStates[&rToggle] = rToggle.get_state();
+        OnToggleHdl(rToggle);
+    }
+
     IMPL_LINK(SpecialSettingsPage, OnToggleHdl, weld::ToggleButton&, rBtn, void)
     {
         if (&rBtn == m_xAppendTableAlias.get() && m_xAsBeforeCorrelationName)
@@ -172,12 +194,16 @@ namespace dbaui
             return;
         }
 
+        m_aTriStates.clear();
+
         // the boolean items
         for (auto const& booleanSetting : m_aBooleanSettings)
         {
             if (!booleanSetting.xControl)
                 continue;
 
+            bool bTriState = false;
+
             boost::optional<bool> aValue;
 
             const SfxPoolItem* pItem = _rSet.GetItem<SfxPoolItem>(booleanSetting.nItemId);
@@ -188,6 +214,7 @@ namespace dbaui
             else if (const OptionalBoolItem *pOptionalItem = dynamic_cast<const OptionalBoolItem*>( pItem) )
             {
                 aValue = pOptionalItem->GetFullValue();
+                bTriState = true;
             }
             else
                 OSL_FAIL( "SpecialSettingsPage::implInitControls: unknown boolean item type!" );
@@ -203,6 +230,8 @@ namespace dbaui
                     bValue = !bValue;
                 booleanSetting.xControl->set_active(bValue);
             }
+            if (bTriState)
+                m_aTriStates[booleanSetting.xControl.get()] = booleanSetting.xControl->get_state();
         }
 
         if (m_xAppendTableAlias && m_xAsBeforeCorrelationName)
diff --git a/dbaccess/source/ui/dlg/advancedsettings.hxx b/dbaccess/source/ui/dlg/advancedsettings.hxx
index c4b7d7894c71..2c6314606135 100644
--- a/dbaccess/source/ui/dlg/advancedsettings.hxx
+++ b/dbaccess/source/ui/dlg/advancedsettings.hxx
@@ -59,6 +59,8 @@ namespace dbaui
         std::unique_ptr<weld::Label> m_xMaxRowScanLabel;
         std::unique_ptr<weld::SpinButton> m_xMaxRowScan;
 
+        std::map<weld::ToggleButton*, TriState> m_aTriStates;
+
         BooleanSettingDescs m_aBooleanSettings;
 
         bool                m_bHasBooleanComparisonMode;
@@ -66,6 +68,7 @@ namespace dbaui
 
     public:
         DECL_LINK(OnToggleHdl, weld::ToggleButton&, void);
+        DECL_LINK(OnTriStateToggleHdl, weld::ToggleButton&, void);
 
         virtual bool        FillItemSet ( SfxItemSet* _rCoreAttrs ) override;
 


More information about the Libreoffice-commits mailing list