[QGIS Commit] r9689 - in trunk/qgis/src: app ui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Nov 24 04:26:02 EST 2008


Author: jef
Date: 2008-11-24 04:26:02 -0500 (Mon, 24 Nov 2008)
New Revision: 9689

Modified:
   trunk/qgis/src/app/qgsattributetable.cpp
   trunk/qgis/src/app/qgsoptions.cpp
   trunk/qgis/src/ui/qgsoptionsbase.ui
Log:
attribute table now shows either all features (default), all selected features or all features in the current canvas.
(applies #1306)



Modified: trunk/qgis/src/app/qgsattributetable.cpp
===================================================================
--- trunk/qgis/src/app/qgsattributetable.cpp	2008-11-23 22:58:53 UTC (rev 9688)
+++ trunk/qgis/src/app/qgsattributetable.cpp	2008-11-24 09:26:02 UTC (rev 9689)
@@ -24,12 +24,15 @@
 #include "qgslogger.h"
 #include "qgsvectordataprovider.h"
 #include "qgsvectorlayer.h"
+#include "qgisapp.h"
+#include "qgsmapcanvas.h"
 
 #include <QApplication>
 #include <QClipboard>
 #include <QHeaderView>
 #include <QKeyEvent>
 #include <QMenu>
+#include <QSettings>
 
 
 QgsAttributeTableItemDelegate::QgsAttributeTableItemDelegate( QgsAttributeTable *table, QObject *parent )
@@ -477,18 +480,29 @@
   }
 
   QgsFeatureList features;
-  if ( layer->selectedFeatureCount() == 0 )
+
+  QSettings settings;
+  int behaviour = settings.value( "/qgis/attributeTableBehaviour", 0 ).toInt();
+
+  if ( behaviour == 1 )
   {
-    layer->select( layer->pendingAllAttributesList(), QgsRectangle(), false );
+    features = layer->selectedFeatures();
+  }
+  else
+  {
+    QgsRectangle rect;
+    if( behaviour == 2 ) 
+    {
+      // current canvas only
+      rect = QgisApp::instance()->mapCanvas()->extent();
+    }
 
+    layer->select( layer->pendingAllAttributesList(), rect, false );
+
     QgsFeature f;
     while ( layer->nextFeature( f ) )
       features << f;
   }
-  else
-  {
-    features = layer->selectedFeatures();
-  }
 
   setRowCount( features.size() );
 

Modified: trunk/qgis/src/app/qgsoptions.cpp
===================================================================
--- trunk/qgis/src/app/qgsoptions.cpp	2008-11-23 22:58:53 UTC (rev 9688)
+++ trunk/qgis/src/app/qgsoptions.cpp	2008-11-24 09:26:02 UTC (rev 9689)
@@ -64,6 +64,14 @@
   leProxyPassword->setText( settings.value( "proxy/proxyPassword", "" ).toString() );
   // set the current theme
   cmbTheme->setItemText( cmbTheme->currentIndex(), settings.value( "/Themes" ).toString() );
+
+  // set the attribute table behaviour
+  cmbAttrTableBehaviour->clear();
+  cmbAttrTableBehaviour->addItem( tr( "Show all features" ) );
+  cmbAttrTableBehaviour->addItem( tr( "Show selected features" ) );
+  cmbAttrTableBehaviour->addItem( tr( "Show features in current canvas" ) );
+  cmbAttrTableBehaviour->setCurrentIndex( settings.value( "/qgis/attributeTableBehaviour", 0 ).toInt() );
+
   // set the display update threshold
   spinBoxUpdateThreshold->setValue( settings.value( "/Map/updateThreshold" ).toInt() );
   //set the default projection behaviour radio buttongs
@@ -257,6 +265,7 @@
   settings.setValue( "/qgis/showLegendClassifiers", cbxLegendClassifiers->isChecked() );
   settings.setValue( "/qgis/hideSplash", cbxHideSplash->isChecked() );
   settings.setValue( "/qgis/dockAttributeTable", cbxAttributeTableDocked->isChecked() );
+  settings.setValue( "/qgis/attributeTableBehaviour", cmbAttrTableBehaviour->currentIndex() );
   settings.setValue( "/qgis/new_layers_visible", chkAddedVisibility->isChecked() );
   settings.setValue( "/qgis/enable_anti_aliasing", chkAntiAliasing->isChecked() );
   settings.setValue( "/qgis/use_qimage_to_render", !( chkUseQPixmap->isChecked() ) );

Modified: trunk/qgis/src/ui/qgsoptionsbase.ui
===================================================================
--- trunk/qgis/src/ui/qgsoptionsbase.ui	2008-11-23 22:58:53 UTC (rev 9688)
+++ trunk/qgis/src/ui/qgsoptionsbase.ui	2008-11-24 09:26:02 UTC (rev 9689)
@@ -220,6 +220,34 @@
             </property>
            </widget>
           </item>
+          <item row="6" column="0" >
+           <widget class="QLabel" name="textLabel1_6" >
+            <property name="sizePolicy" >
+             <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
+            <property name="text" >
+             <string>Attribute table behaviour</string>
+            </property>
+            <property name="buddy" >
+             <cstring>cmbAttrTableBehaviour</cstring>
+            </property>
+           </widget>
+          </item>
+          <item row="6" column="1" >
+           <widget class="QComboBox" name="cmbAttrTableBehaviour" >
+            <property name="duplicatesEnabled" >
+             <bool>false</bool>
+            </property>
+            <item>
+             <property name="text" >
+              <string/>
+             </property>
+            </item>
+           </widget>
+          </item>
          </layout>
         </widget>
        </item>



More information about the QGIS-commit mailing list