From 2ef4e3c0eb6cb6eef859269d00b4157e21bdd30d Mon Sep 17 00:00:00 2001
From: olivierdalang <olivier.dalang@gmail.com>
Date: Sat, 9 Feb 2013 17:33:15 +0100
Subject: [PATCH] Set QgsCollapsibleGroupBox's autosave collapsed state to
 false by default. Added properties to allow to change those
 settings from within QtDesigner. Set the settings to keep
 current behaviour in all UI files containing a
 QgsCollapsibleGroupBox.

---
 python/gui/qgscollapsiblegroupbox.sip    | 14 ++++++++++
 src/gui/qgscollapsiblegroupbox.cpp       |  2 +-
 src/gui/qgscollapsiblegroupbox.h         | 15 ++++++++++-
 src/ui/qgscomposeritemwidgetbase.ui      |  6 +++++
 src/ui/qgslabelingguibase.ui             | 45 ++++++++++++++++++++++++++++++++
 src/ui/qgsoptionsbase.ui                 |  6 +++++
 src/ui/qgsprojectpropertiesbase.ui       | 15 +++++++++++
 src/ui/qgsrasterlayerpropertiesbase.ui   |  3 +++
 src/ui/qgsrasterlayersaveasdialogbase.ui | 18 +++++++++++++
 9 files changed, 122 insertions(+), 2 deletions(-)

diff --git a/python/gui/qgscollapsiblegroupbox.sip b/python/gui/qgscollapsiblegroupbox.sip
index 93b909d..f384f03 100644
--- a/python/gui/qgscollapsiblegroupbox.sip
+++ b/python/gui/qgscollapsiblegroupbox.sip
@@ -1,3 +1,17 @@
+/**
+ * \class QgsCollapsibleGroupBox
+ * \brief A groupbox that collapses/expands when toggled.
+ * It is capable of saving it's collapsed and/or checked state.
+ * Those states are saved using the widget's and it's parent names.
+ *
+ * To add Collapsible properties in promoted QtDesigner widgets,
+ * you can add the following "Dynamic properties" by clicking
+ * on the green + in the propreties palette :
+ * bool collapsed,
+ * bool saveCollapsedState,
+ * bool saveCheckedState
+ */
+
 class QgsCollapsibleGroupBox : QGroupBox
 {
 %TypeHeaderCode
diff --git a/src/gui/qgscollapsiblegroupbox.cpp b/src/gui/qgscollapsiblegroupbox.cpp
index 7680564..a39d2e7 100644
--- a/src/gui/qgscollapsiblegroupbox.cpp
+++ b/src/gui/qgscollapsiblegroupbox.cpp
@@ -71,7 +71,7 @@ void QgsCollapsibleGroupBox::init()
   }
   // variables
   mCollapsed = false;
-  mSaveCollapsedState = true;
+  mSaveCollapsedState = false;
   // NOTE: only turn on mSaveCheckedState for groupboxes NOT used
   // in multiple places or used as options for different parent objects
   mSaveCheckedState = false;
diff --git a/src/gui/qgscollapsiblegroupbox.h b/src/gui/qgscollapsiblegroupbox.h
index 0977ad3..475c907 100644
--- a/src/gui/qgscollapsiblegroupbox.h
+++ b/src/gui/qgscollapsiblegroupbox.h
@@ -22,7 +22,16 @@
 
 /** \ingroup gui
  * A groupbox that collapses/expands when toggled.
- * @note Collapsible function not shown in promoted QtDesigner widgets.
+ * A groupbox that collapses/expands when toggled.
+ * It is capable of saving it's collapsed and/or checked state.
+ * Those states are saved using the widget's and it's parent names.
+ *
+ * To add Collapsible properties in promoted QtDesigner widgets,
+ * you can add the following "Dynamic properties" by clicking
+ * on the green + in the propreties palette :
+ * bool collapsed,
+ * bool saveCollapsedState,
+ * bool saveCheckedState
  */
 
 #include <QGroupBox>
@@ -36,6 +45,10 @@ class GUI_EXPORT QgsCollapsibleGroupBox : public QGroupBox
 {
     Q_OBJECT
 
+    Q_PROPERTY(bool collapsed READ isCollapsed WRITE setCollapsed USER true)
+    Q_PROPERTY(bool saveCollapsedState READ saveCollapsedState WRITE setSaveCollapsedState USER true)
+    Q_PROPERTY(bool saveCheckedState READ saveCheckedState WRITE setSaveCheckedState USER true)
+
   public:
     QgsCollapsibleGroupBox( QWidget *parent = 0, QSettings* settings = 0 );
     QgsCollapsibleGroupBox( const QString &title, QWidget *parent = 0, QSettings* settings = 0 );
diff --git a/src/ui/qgscomposeritemwidgetbase.ui b/src/ui/qgscomposeritemwidgetbase.ui
index 720bba5..a65955c 100644
--- a/src/ui/qgscomposeritemwidgetbase.ui
+++ b/src/ui/qgscomposeritemwidgetbase.ui
@@ -26,6 +26,9 @@
    </item>
    <item row="1" column="0" colspan="2">
     <widget class="QgsCollapsibleGroupBox" name="mFrameGroupBox">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
      <property name="title">
       <string>Show frame</string>
      </property>
@@ -61,6 +64,9 @@
    </item>
    <item row="2" column="0" colspan="2">
     <widget class="QgsCollapsibleGroupBox" name="mBackgroundGroupBox">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
      <property name="title">
       <string>Show background</string>
      </property>
diff --git a/src/ui/qgslabelingguibase.ui b/src/ui/qgslabelingguibase.ui
index 82d7461..10b538a 100644
--- a/src/ui/qgslabelingguibase.ui
+++ b/src/ui/qgslabelingguibase.ui
@@ -170,6 +170,9 @@
           <bool>false</bool>
          </property>
          <widget class="QgsCollapsibleGroupBox" name="groupBox_mPreview">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
           <property name="sizePolicy">
            <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
             <horstretch>0</horstretch>
@@ -463,6 +466,9 @@
             </property>
             <item row="9" column="0">
              <widget class="QgsCollapsibleGroupBox" name="chkFormattedNumbers">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
               <property name="sizePolicy">
                <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
                 <horstretch>0</horstretch>
@@ -530,6 +536,9 @@
             </item>
             <item row="7" column="0">
              <widget class="QgsCollapsibleGroupBox" name="mFontMultiLineGroupBox">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
               <property name="minimumSize">
                <size>
                 <width>0</width>
@@ -678,6 +687,9 @@
             </item>
             <item row="2" column="0">
              <widget class="QgsCollapsibleGroupBox" name="mFontStyleGroupBox">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
               <property name="sizePolicy">
                <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
                 <horstretch>0</horstretch>
@@ -1162,6 +1174,9 @@
             </item>
             <item row="4" column="0">
              <widget class="QgsCollapsibleGroupBox" name="chkBuffer">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
               <property name="sizePolicy">
                <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
                 <horstretch>0</horstretch>
@@ -1413,6 +1428,9 @@
             </item>
             <item row="6" column="0">
              <widget class="QgsCollapsibleGroupBox" name="mFontLimitPixelGroupBox">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
               <property name="title">
                <string>Pixel size-based visibility</string>
               </property>
@@ -1551,6 +1569,9 @@
             </item>
             <item row="5" column="0">
              <widget class="QgsCollapsibleGroupBox" name="chkScaleBasedVisibility">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
               <property name="sizePolicy">
                <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
                 <horstretch>0</horstretch>
@@ -1692,6 +1713,9 @@
             </item>
             <item row="8" column="0">
              <widget class="QgsCollapsibleGroupBox" name="mDirectSymbGroupBox">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
               <property name="title">
                <string>Line direction symbols</string>
               </property>
@@ -1930,6 +1954,9 @@
            </property>
            <item row="1" column="0">
             <widget class="QgsCollapsibleGroupBox" name="mPriorityGroupBox">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
              <property name="maximumSize">
               <size>
                <width>16777215</width>
@@ -1978,6 +2005,9 @@
            </item>
            <item row="0" column="0">
             <widget class="QgsCollapsibleGroupBox" name="mPlacementGroupBox">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
              <property name="sizePolicy">
               <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
                <horstretch>0</horstretch>
@@ -2732,6 +2762,9 @@
            </item>
            <item row="2" column="0">
             <widget class="QgsCollapsibleGroupBox" name="mOptionsGroupBox">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
              <property name="maximumSize">
               <size>
                <width>16777215</width>
@@ -3004,6 +3037,9 @@
            </property>
            <item row="3" column="0">
             <widget class="QgsCollapsibleGroupBox" name="mBufferAttributesPropertiesGroupBox">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
              <property name="title">
               <string>Buffer properties</string>
              </property>
@@ -3050,6 +3086,9 @@
            </item>
            <item row="4" column="0">
             <widget class="QgsCollapsibleGroupBox" name="mPositionAttributeGroupBox">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
              <property name="title">
               <string>Position</string>
              </property>
@@ -3148,6 +3187,9 @@
            </item>
            <item row="1" column="0">
             <widget class="QgsCollapsibleGroupBox" name="mDisplayAttributesPropertiesGroupBox">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
              <property name="title">
               <string>Display properties</string>
              </property>
@@ -3212,6 +3254,9 @@
            </item>
            <item row="2" column="0">
             <widget class="QgsCollapsibleGroupBox" name="mFontAttributePropertiesGroupBox">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
              <property name="sizePolicy">
               <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
                <horstretch>0</horstretch>
diff --git a/src/ui/qgsoptionsbase.ui b/src/ui/qgsoptionsbase.ui
index b7da26a..1047ddc 100644
--- a/src/ui/qgsoptionsbase.ui
+++ b/src/ui/qgsoptionsbase.ui
@@ -998,6 +998,9 @@
                   </item>
                   <item row="2" column="0" colspan="4">
                    <widget class="QgsCollapsibleGroupBox" name="mCurrentVariablesGrpBx">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
                     <property name="minimumSize">
                      <size>
                       <width>0</width>
@@ -3748,6 +3751,9 @@
                </item>
                <item>
                 <widget class="QgsCollapsibleGroupBox" name="grpProxy">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
                  <property name="title">
                   <string>Use proxy for web access</string>
                  </property>
diff --git a/src/ui/qgsprojectpropertiesbase.ui b/src/ui/qgsprojectpropertiesbase.ui
index f963ddc..6988df5 100644
--- a/src/ui/qgsprojectpropertiesbase.ui
+++ b/src/ui/qgsprojectpropertiesbase.ui
@@ -844,6 +844,9 @@
           <layout class="QGridLayout" name="gridLayout_15">
            <item row="0" column="0">
             <widget class="QgsCollapsibleGroupBox" name="grpOWSServiceCapabilities">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
              <property name="title">
               <string>Service Capabilitities</string>
              </property>
@@ -980,6 +983,9 @@
              <layout class="QGridLayout" name="gridLayout_14">
               <item row="0" column="0">
                <widget class="QgsCollapsibleGroupBox" name="grpWMSExt">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
                 <property name="title">
                  <string>Advertised Extent</string>
                 </property>
@@ -1083,6 +1089,9 @@
               </item>
               <item row="0" column="1" colspan="2">
                <widget class="QgsCollapsibleGroupBox" name="grpWMSList">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
                 <property name="title">
                  <string>Coordinate Systems Restrictions</string>
                 </property>
@@ -1122,6 +1131,9 @@
               </item>
               <item row="1" column="0">
                <widget class="QgsCollapsibleGroupBox" name="mWMSComposerGroupBox">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
                 <property name="title">
                  <string>Exclude composers</string>
                 </property>
@@ -1175,6 +1187,9 @@
               </item>
               <item row="1" column="2">
                <widget class="QgsCollapsibleGroupBox" name="mLayerRestrictionsGroupBox">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
                 <property name="title">
                  <string>Exclude layers</string>
                 </property>
diff --git a/src/ui/qgsrasterlayerpropertiesbase.ui b/src/ui/qgsrasterlayerpropertiesbase.ui
index 990e8db..323df38 100644
--- a/src/ui/qgsrasterlayerpropertiesbase.ui
+++ b/src/ui/qgsrasterlayerpropertiesbase.ui
@@ -159,6 +159,9 @@
        </item>
        <item>
         <widget class="QgsCollapsibleGroupBox" name="mResamplingGroupBox">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
          <property name="title">
           <string>Resampling</string>
          </property>
diff --git a/src/ui/qgsrasterlayersaveasdialogbase.ui b/src/ui/qgsrasterlayersaveasdialogbase.ui
index cc5b759..fc453a0 100644
--- a/src/ui/qgsrasterlayersaveasdialogbase.ui
+++ b/src/ui/qgsrasterlayersaveasdialogbase.ui
@@ -223,6 +223,9 @@ datasets with maximum width and height specified below.</string>
        </property>
        <item>
         <widget class="QgsCollapsibleGroupBox" name="mExtentGroupBox">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
          <property name="sizePolicy">
           <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
            <horstretch>0</horstretch>
@@ -381,6 +384,9 @@ datasets with maximum width and height specified below.</string>
        </item>
        <item>
         <widget class="QgsCollapsibleGroupBox" name="mResolutionGroupBox">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
          <property name="sizePolicy">
           <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
            <horstretch>0</horstretch>
@@ -466,6 +472,9 @@ datasets with maximum width and height specified below.</string>
        </item>
        <item>
         <widget class="QgsCollapsibleGroupBox" name="mTilesGroupBox">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
          <property name="sizePolicy">
           <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
            <horstretch>0</horstretch>
@@ -521,6 +530,9 @@ datasets with maximum width and height specified below.</string>
        </item>
        <item>
         <widget class="QgsCollapsibleGroupBox" name="mCreateOptionsGroupBox">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
          <property name="sizePolicy">
           <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
            <horstretch>0</horstretch>
@@ -545,6 +557,9 @@ datasets with maximum width and height specified below.</string>
        </item>
        <item>
         <widget class="QgsCollapsibleGroupBox" name="mPyramidsGroupBox">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
          <property name="sizePolicy">
           <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
            <horstretch>0</horstretch>
@@ -629,6 +644,9 @@ datasets with maximum width and height specified below.</string>
        </item>
        <item>
         <widget class="QgsCollapsibleGroupBox" name="mNoDataGroupBox">
+               <property name="collapsed" stdset="0"><bool>false</bool></property>
+               <property name="saveCheckedState" stdset="0"><bool>false</bool></property>
+               <property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
          <property name="sizePolicy">
           <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
            <horstretch>0</horstretch>
-- 
1.7.11.msysgit.0

