Skip to content

Commit

Permalink
attribute table now shows either all features (default), all selected…
Browse files Browse the repository at this point in the history
… features or all features in the current canvas.

(applies #1306)



git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9689 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Nov 24, 2008
1 parent 9a0b259 commit 7a733aa
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/app/qgsattributetable.cpp
Expand Up @@ -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 )
Expand Down Expand Up @@ -477,18 +480,29 @@ void QgsAttributeTable::fillTable( QgsVectorLayer *layer )
}

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() );

Expand Down
9 changes: 9 additions & 0 deletions src/app/qgsoptions.cpp
Expand Up @@ -64,6 +64,14 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
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
Expand Down Expand Up @@ -257,6 +265,7 @@ void QgsOptions::saveOptions()
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() ) );
Expand Down
28 changes: 28 additions & 0 deletions src/ui/qgsoptionsbase.ui
Expand Up @@ -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>
Expand Down

0 comments on commit 7a733aa

Please sign in to comment.