@@ -83,7 +83,6 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QWidget
83
83
: QDialog( parent, flags )
84
84
, mDock( nullptr )
85
85
, mLayer( layer )
86
- , mRubberBand( nullptr )
87
86
, mCurrentSearchWidgetWrapper( nullptr )
88
87
{
89
88
setObjectName ( QStringLiteral ( " QgsAttributeTableDialog/" ) + layer->id () );
@@ -133,21 +132,26 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QWidget
133
132
mEditorContext .setVectorLayerTools ( QgisApp::instance ()->vectorLayerTools () );
134
133
135
134
QgsFeatureRequest r;
135
+ bool needsGeom = false ;
136
+ QgsAttributeTableFilterModel::FilterMode initialMode = static_cast < QgsAttributeTableFilterModel::FilterMode>( settings.value ( QStringLiteral ( " /qgis/attributeTableBehavior" ), QgsAttributeTableFilterModel::ShowAll ).toInt () );
136
137
if ( mLayer ->geometryType () != QgsWkbTypes::NullGeometry &&
137
- settings. value ( QStringLiteral ( " /qgis/attributeTableBehavior " ), QgsAttributeTableFilterModel::ShowAll ). toInt () == QgsAttributeTableFilterModel::ShowVisible )
138
+ initialMode == QgsAttributeTableFilterModel::ShowVisible )
138
139
{
139
140
QgsMapCanvas *mc = QgisApp::instance ()->mapCanvas ();
140
141
QgsRectangle extent ( mc->mapSettings ().mapToLayerCoordinates ( layer, mc->extent () ) );
141
142
r.setFilterRect ( extent );
142
-
143
- mRubberBand = new QgsRubberBand ( mc, QgsWkbTypes::PolygonGeometry );
144
- mRubberBand ->setToGeometry ( QgsGeometry::fromRect ( extent ), layer );
145
-
146
- mActionShowAllFilter ->setText ( tr ( " Show All Features In Initial Canvas Extent" ) );
143
+ needsGeom = true ;
144
+ }
145
+ else if ( initialMode == QgsAttributeTableFilterModel::ShowSelected )
146
+ {
147
+ if ( layer->selectedFeatureCount () > 0 )
148
+ r.setFilterFids ( layer->selectedFeatureIds () );
147
149
}
150
+ if ( !needsGeom )
151
+ r.setFlags ( QgsFeatureRequest::NoGeometry );
148
152
149
153
// Initialize dual view
150
- mMainView ->init ( mLayer , QgisApp::instance ()->mapCanvas (), r, mEditorContext );
154
+ mMainView ->init ( mLayer , QgisApp::instance ()->mapCanvas (), r, mEditorContext , false );
151
155
152
156
QgsAttributeTableConfig config = mLayer ->attributeTableConfig ();
153
157
mMainView ->setAttributeTableConfig ( config );
@@ -334,18 +338,16 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QWidget
334
338
QgsAttributeTableDialog::~QgsAttributeTableDialog ()
335
339
{
336
340
delete myDa;
337
- delete mRubberBand ;
338
341
}
339
342
340
343
void QgsAttributeTableDialog::updateTitle ()
341
344
{
342
345
QWidget *w = mDock ? qobject_cast<QWidget *>( mDock ) : qobject_cast<QWidget *>( this );
343
- w->setWindowTitle ( tr ( " %1 :: Features total: %2, filtered: %3, selected: %4%5 " )
346
+ w->setWindowTitle ( tr ( " %1 :: Features total: %2, filtered: %3, selected: %4" )
344
347
.arg ( mLayer ->name () )
345
- .arg ( mMainView ->featureCount () )
348
+ .arg ( qMax ( static_cast < long >( mMainView ->featureCount () ), mLayer -> featureCount () ) ) // layer count may be estimated, so use larger of the two
346
349
.arg ( mMainView ->filteredFeatureCount () )
347
350
.arg ( mLayer ->selectedFeatureCount () )
348
- .arg ( mRubberBand ? tr ( " , spatially limited" ) : QLatin1String ( " " ) )
349
351
);
350
352
351
353
if ( mMainView ->filterMode () == QgsAttributeTableFilterModel::ShowAll )
0 commit comments