Skip to content
Permalink
Browse files

Update for QgsSettings

  • Loading branch information
nyalldawson committed Mar 5, 2017
1 parent d4b1655 commit 346bfe499f568dd2cc17fcd504ed7c4dc69a695c
Showing with 5 additions and 3 deletions.
  1. +5 −3 tests/src/app/testqgsattributetable.cpp
@@ -24,7 +24,7 @@
#include "qgsproject.h"
#include "qgsmapcanvas.h"
#include "qgsunittypes.h"
#include <QSettings>
#include "qgssettings.h"

#include "qgstest.h"

@@ -178,19 +178,21 @@ void TestQgsAttributeTable::testFieldCalculationArea()

void TestQgsAttributeTable::testNoGeom()
{
QgsSettings s;

//test that by default the attribute table DOESN'T fetch geometries (because performance)
std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) );
QVERIFY( tempLayer->isValid() );

QSettings().setValue( QStringLiteral( "/qgis/attributeTableBehavior" ), QgsAttributeTableFilterModel::ShowAll );
s.setValue( QStringLiteral( "/qgis/attributeTableBehavior" ), QgsAttributeTableFilterModel::ShowAll );
std::unique_ptr< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( tempLayer.get() ) );

QVERIFY( !dlg->mMainView->masterModel()->layerCache()->cacheGeometry() );
QVERIFY( dlg->mMainView->masterModel()->request().flags() & QgsFeatureRequest::NoGeometry );

// but if we are requesting only visible features, then geometry must be fetched...

QSettings().setValue( QStringLiteral( "/qgis/attributeTableBehavior" ), QgsAttributeTableFilterModel::ShowVisible );
s.setValue( QStringLiteral( "/qgis/attributeTableBehavior" ), QgsAttributeTableFilterModel::ShowVisible );
dlg.reset( new QgsAttributeTableDialog( tempLayer.get() ) );
QVERIFY( dlg->mMainView->masterModel()->layerCache()->cacheGeometry() );
QVERIFY( !( dlg->mMainView->masterModel()->request().flags() & QgsFeatureRequest::NoGeometry ) );

0 comments on commit 346bfe4

Please sign in to comment.
You can’t perform that action at this time.