Skip to content

Commit af4c4be

Browse files
committed
Properly show feature count in attribute table title
Total # of features Filtered features Selected features
1 parent 082c6ba commit af4c4be

File tree

4 files changed

+16
-19
lines changed

4 files changed

+16
-19
lines changed

src/app/qgsattributetabledialog.cpp

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid
109109
connect( mLayer, SIGNAL( editingStarted() ), this, SLOT( editingToggled() ) );
110110
connect( mLayer, SIGNAL( editingStopped() ), this, SLOT( editingToggled() ) );
111111
connect( mLayer, SIGNAL( layerDeleted() ), this, SLOT( close() ) );
112+
connect( mLayer, SIGNAL( selectionChanged() ), this, SLOT( updateTitle() ) );
113+
114+
// connect table info to window
115+
connect( mMainView, SIGNAL( filterChanged() ), this, SLOT( updateTitle() ) );
112116

113117
// info from table to application
114118
connect( this, SIGNAL( saveEdits( QgsMapLayer * ) ), QgisApp::instance(), SLOT( saveEdits( QgsMapLayer * ) ) );
@@ -193,12 +197,11 @@ QgsAttributeTableDialog::~QgsAttributeTableDialog()
193197
void QgsAttributeTableDialog::updateTitle()
194198
{
195199
QWidget *w = mDock ? qobject_cast<QWidget*>( mDock ) : qobject_cast<QWidget*>( this );
196-
w->setWindowTitle( tr( "Attribute table - %1 :: %n / %2 feature(s) filtered",
197-
"feature count",
198-
mMainView->filteredFeatureCount()
199-
)
200+
w->setWindowTitle( tr( "Attribute table - %1 :: Features total: %2, filtered: %3, selected: %4" )
200201
.arg( mLayer->name() )
201202
.arg( mMainView->featureCount() )
203+
.arg( mMainView->filteredFeatureCount() )
204+
.arg( mLayer->selectedFeatureCount() )
202205
);
203206
}
204207

@@ -610,14 +613,4 @@ void QgsAttributeTableDialog::setFilterExpression( QString filterString )
610613
QgisApp::instance()->messageBar()->pushMessage( tr( "Error filtering" ), filterExpression.evalErrorString(), QgsMessageBar::WARNING, QgisApp::instance()->messageTimeout() );
611614
return;
612615
}
613-
614-
QWidget *w = mDock ? qobject_cast<QWidget*>( mDock ) : qobject_cast<QWidget*>( this );
615-
if ( mMainView->filteredFeatureCount() )
616-
{
617-
w->setWindowTitle( tr( "Attribute table - %1 (%n matching features)", "matching features", mMainView->filteredFeatureCount() ).arg( mMainView->filteredFeatureCount() ) );
618-
}
619-
else
620-
{
621-
w->setWindowTitle( tr( "Attribute table - %1 (No matching features)" ).arg( mLayer->name() ) );
622-
}
623616
}

src/app/qgsattributetabledialog.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ class QgsAttributeTableDialog : public QDialog, private Ui::QgsAttributeTableDia
138138
void filterQueryChanged( const QString& query );
139139
void filterQueryAccepted();
140140

141+
/**
142+
* update window title
143+
*/
144+
void updateTitle();
145+
141146
signals:
142147
/**
143148
* Informs that editing mode has been toggled
@@ -164,11 +169,6 @@ class QgsAttributeTableDialog : public QDialog, private Ui::QgsAttributeTableDia
164169
*/
165170
void columnBoxInit();
166171

167-
/**
168-
* update window title
169-
*/
170-
void updateTitle();
171-
172172
QMenu* mMenuActions;
173173
QAction* mActionToggleEditing;
174174

src/gui/attributetable/qgsdualview.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ void QgsDualView::initModels( QgsMapCanvas* mapCanvas )
191191
mMasterModel->loadLayer();
192192

193193
mFilterModel = new QgsAttributeTableFilterModel( mapCanvas, mMasterModel, mMasterModel );
194+
195+
connect( mFilterModel, SIGNAL( filterInvalidated() ), this, SIGNAL( filterChanged() ) );
196+
194197
mFeatureListModel = new QgsFeatureListModel( mFilterModel, mFilterModel );
195198
}
196199

src/gui/attributetable/qgsdualview.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBas
9898
void setCurrentEditSelection( const QgsFeatureIds& fids );
9999

100100
signals:
101+
void filterChanged();
101102

102103
private slots:
103104
/**

0 commit comments

Comments
 (0)