[QGIS Commit] r13510 - in trunk/qgis: python/core src/app src/core src/ui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sun May 16 17:00:02 EDT 2010


Author: jef
Date: 2010-05-16 17:00:01 -0400 (Sun, 16 May 2010)
New Revision: 13510

Modified:
   trunk/qgis/python/core/qgslabelattributes.sip
   trunk/qgis/src/app/qgslabeldialog.cpp
   trunk/qgis/src/core/qgslabel.cpp
   trunk/qgis/src/core/qgslabel.h
   trunk/qgis/src/core/qgslabelattributes.cpp
   trunk/qgis/src/core/qgslabelattributes.h
   trunk/qgis/src/ui/qgslabeldialogbase.ui
Log:
[FEATURE] label only selected features (implements #2717)

Modified: trunk/qgis/python/core/qgslabelattributes.sip
===================================================================
--- trunk/qgis/python/core/qgslabelattributes.sip	2010-05-16 20:30:17 UTC (rev 13509)
+++ trunk/qgis/python/core/qgslabelattributes.sip	2010-05-16 21:00:01 UTC (rev 13510)
@@ -112,5 +112,11 @@
 
     bool  multilineEnabled() const;
     void  setMultilineEnabled( bool useMultiline );
+  
+    /* label only selected features
+     * added in 1.5
+     */
+    bool  selectedOnly() const;
+    void  setSelectedOnly( bool selectedonly );
 };
 

Modified: trunk/qgis/src/app/qgslabeldialog.cpp
===================================================================
--- trunk/qgis/src/app/qgslabeldialog.cpp	2010-05-16 20:30:17 UTC (rev 13509)
+++ trunk/qgis/src/app/qgslabeldialog.cpp	2010-05-16 21:00:01 UTC (rev 13510)
@@ -264,6 +264,8 @@
   }
   //set the state of the multiline enabled checkbox
   chkUseMultiline->setChecked( myLabelAttributes->multilineEnabled() );
+  //set the state of the selected features only checkbox
+  chkSelectedOnly->setChecked( myLabelAttributes->selectedOnly() );
   //set the state of the buffer enabled checkbox
   chkUseBuffer->setChecked( myLabelAttributes->bufferEnabled() );
 
@@ -373,6 +375,7 @@
   if ( radioOver->isChecked() )        myLabelAttributes->setAlignment( Qt::AlignCenter );
 
   myLabelAttributes->setMultilineEnabled( chkUseMultiline->isChecked() );
+  myLabelAttributes->setSelectedOnly( chkSelectedOnly->isChecked() );
   myLabelAttributes->setBufferEnabled( chkUseBuffer->isChecked() );
   myLabelAttributes->setBufferColor( mBufferColor );
   myTypeInt = cboBufferSizeUnits->currentIndex() == 0 ? QgsLabelAttributes::PointUnits : QgsLabelAttributes::MapUnits;

Modified: trunk/qgis/src/core/qgslabel.cpp
===================================================================
--- trunk/qgis/src/core/qgslabel.cpp	2010-05-16 20:30:17 UTC (rev 13509)
+++ trunk/qgis/src/core/qgslabel.cpp	2010-05-16 21:00:01 UTC (rev 13510)
@@ -90,6 +90,9 @@
                             QgsFeature &feature, bool selected,
                             QgsLabelAttributes *classAttributes )
 {
+  if ( mLabelAttributes->selectedOnly() && !selected )
+    return;
+
   QPen pen;
   QFont font;
   QString value;
@@ -414,7 +417,6 @@
   x = x + xoffset * cos( rad ) - yoffset * sin( rad );
   y = y - xoffset * sin( rad ) - yoffset * cos( rad );
 
-
   painter->save();
   painter->setFont( font );
   painter->translate( x, y );
@@ -1017,6 +1019,18 @@
     readLabelField( el, MultilineEnabled );
   }
 
+  scratchNode = node.namedItem( "selectedonly" );
+
+  if ( scratchNode.isNull() )
+  {
+    QgsDebugMsg( "couldn't find QgsLabel ``selectedonly'' attribute" );
+  }
+  else
+  {
+    el = scratchNode.toElement();
+    mLabelAttributes->setSelectedOnly(( bool )el.attribute( "on", "0" ).toInt() );
+  }
+
 } // QgsLabel::readXML()
 
 
@@ -1357,6 +1371,17 @@
   }
   labelattributes.appendChild( multilineenabled );
 
+  QDomElement selectedonly = document.createElement( "selectedonly" );
+  if ( mLabelAttributes->selectedOnly() )
+  {
+    selectedonly.setAttribute( "on", mLabelAttributes->selectedOnly() );
+  }
+  else
+  {
+    selectedonly.setAttribute( "on", "" );
+  }
+  labelattributes.appendChild( selectedonly );
+
   layer_node.appendChild( labelattributes );
 }
 

Modified: trunk/qgis/src/core/qgslabel.h
===================================================================
--- trunk/qgis/src/core/qgslabel.h	2010-05-16 20:30:17 UTC (rev 13509)
+++ trunk/qgis/src/core/qgslabel.h	2010-05-16 21:00:01 UTC (rev 13510)
@@ -81,7 +81,7 @@
       BorderColor,
       BorderStyle,
       MultilineEnabled,
-      StrikeOut,  // added in 1.5
+      StrikeOut,     // added in 1.5
       LabelFieldCount
     };
 

Modified: trunk/qgis/src/core/qgslabelattributes.cpp
===================================================================
--- trunk/qgis/src/core/qgslabelattributes.cpp	2010-05-16 20:30:17 UTC (rev 13509)
+++ trunk/qgis/src/core/qgslabelattributes.cpp	2010-05-16 21:00:01 UTC (rev 13510)
@@ -26,35 +26,36 @@
 #include "qgslogger.h"
 
 QgsLabelAttributes::QgsLabelAttributes( bool def )
-    : mTextIsSet( false ),
-    mFamilyIsSet( false ),
-    mBoldIsSet( false ),
-    mItalicIsSet( false ),
-    mUnderlineIsSet( false ),
-    mStrikeOutIsSet( false ),
-    mSizeType( 0 ),
-    mSize( 0.0 ),
-    mSizeIsSet( false ),
-    mColorIsSet( false ),
-    mOffsetType( 0 ),
-    mXOffset( 0 ),
-    mYOffset( 0 ),
-    mOffsetIsSet( false ),
-    mAngle( 0.0 ),
-    mAngleIsSet( false ),
-    mAngleIsAuto( false ),
-    mAlignment( 0 ),
-    mAlignmentIsSet( false ),
-    mBufferEnabledFlag( false ),
-    mBufferSizeType( 0 ),
-    mBufferSize( 0.0 ),
-    mBufferSizeIsSet( false ),
-    mBufferColorIsSet( false ),
-    mBufferStyleIsSet( false ),
-    mBorderColorIsSet( false ),
-    mBorderWidthIsSet( false ),
-    mBorderStyleIsSet( false ),
-    mMultilineEnabledFlag( false )
+    : mTextIsSet( false )
+    , mFamilyIsSet( false )
+    , mBoldIsSet( false )
+    , mItalicIsSet( false )
+    , mUnderlineIsSet( false )
+    , mStrikeOutIsSet( false )
+    , mSizeType( 0 )
+    , mSize( 0.0 )
+    , mSizeIsSet( false )
+    , mColorIsSet( false )
+    , mOffsetType( 0 )
+    , mXOffset( 0 )
+    , mYOffset( 0 )
+    , mOffsetIsSet( false )
+    , mAngle( 0.0 )
+    , mAngleIsSet( false )
+    , mAngleIsAuto( false )
+    , mAlignment( 0 )
+    , mAlignmentIsSet( false )
+    , mBufferEnabledFlag( false )
+    , mBufferSizeType( 0 )
+    , mBufferSize( 0.0 )
+    , mBufferSizeIsSet( false )
+    , mBufferColorIsSet( false )
+    , mBufferStyleIsSet( false )
+    , mBorderColorIsSet( false )
+    , mBorderWidthIsSet( false )
+    , mBorderStyleIsSet( false )
+    , mMultilineEnabledFlag( false )
+    , mSelectedOnly( false )
 {
 
   if ( def )   // set defaults
@@ -429,6 +430,16 @@
   mMultilineEnabledFlag = useMultilineFlag;
 }
 
+/* selected only */
+bool QgsLabelAttributes::selectedOnly() const
+{
+  return mSelectedOnly;
+}
+void QgsLabelAttributes::setSelectedOnly( bool selectedOnly )
+{
+  mSelectedOnly = selectedOnly;
+}
+
 /* units */
 QString QgsLabelAttributes::unitsName( int units )
 {

Modified: trunk/qgis/src/core/qgslabelattributes.h
===================================================================
--- trunk/qgis/src/core/qgslabelattributes.h	2010-05-16 20:30:17 UTC (rev 13509)
+++ trunk/qgis/src/core/qgslabelattributes.h	2010-05-16 21:00:01 UTC (rev 13510)
@@ -185,6 +185,12 @@
     bool  multilineEnabled() const;
     void  setMultilineEnabled( bool useMultiline );
 
+    /* label only selected features
+     * added in 1.5
+     */
+    bool  selectedOnly() const;
+    void  setSelectedOnly( bool selectedonly );
+
   protected:
     /* Text */
     QString mText;
@@ -242,6 +248,9 @@
 
     /** Multiline enablement */
     bool mMultilineEnabledFlag;
+
+    /** Label only selected */
+    bool mSelectedOnly;
 };
 
 #endif

Modified: trunk/qgis/src/ui/qgslabeldialogbase.ui
===================================================================
--- trunk/qgis/src/ui/qgslabeldialogbase.ui	2010-05-16 20:30:17 UTC (rev 13509)
+++ trunk/qgis/src/ui/qgslabeldialogbase.ui	2010-05-16 21:00:01 UTC (rev 13510)
@@ -44,7 +44,7 @@
             <x>0</x>
             <y>0</y>
             <width>525</width>
-            <height>512</height>
+            <height>510</height>
            </rect>
           </property>
           <layout class="QGridLayout" name="gridLayout_2">
@@ -420,16 +420,6 @@
                 </item>
                </widget>
               </item>
-              <item row="6" column="2">
-               <widget class="QCheckBox" name="chkUseMultiline">
-                <property name="text">
-                 <string>Multiline labels?</string>
-                </property>
-                <property name="checked">
-                 <bool>true</bool>
-                </property>
-               </widget>
-              </item>
               <item row="3" column="3">
                <widget class="QPushButton" name="btnDefaultFont">
                 <property name="sizePolicy">
@@ -456,6 +446,23 @@
                 </property>
                </widget>
               </item>
+              <item row="7" column="0" colspan="2">
+               <widget class="QCheckBox" name="chkUseMultiline">
+                <property name="text">
+                 <string>Multiline labels?</string>
+                </property>
+                <property name="checked">
+                 <bool>true</bool>
+                </property>
+               </widget>
+              </item>
+              <item row="7" column="2" colspan="2">
+               <widget class="QCheckBox" name="chkSelectedOnly">
+                <property name="text">
+                 <string>Label only selected features</string>
+                </property>
+               </widget>
+              </item>
              </layout>
             </widget>
            </item>
@@ -484,7 +491,7 @@
             <x>0</x>
             <y>0</y>
             <width>525</width>
-            <height>623</height>
+            <height>592</height>
            </rect>
           </property>
           <layout class="QGridLayout" name="gridLayout_7">
@@ -886,7 +893,6 @@
   <tabstop>cboFontSizeUnits</tabstop>
   <tabstop>btnDefaultFont</tabstop>
   <tabstop>spinAngle</tabstop>
-  <tabstop>chkUseMultiline</tabstop>
   <tabstop>pbnDefaultFontColor</tabstop>
   <tabstop>radioOver</tabstop>
   <tabstop>radioAboveLeft</tabstop>



More information about the QGIS-commit mailing list