Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add "Result Features" as new row; Change "selected" to "identified" i…
…n tooltips
  • Loading branch information
suricactus authored and nyalldawson committed Mar 25, 2020
1 parent f0e74df commit d40ab03
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
32 changes: 30 additions & 2 deletions src/app/qgsidentifyresultsdialog.cpp
Expand Up @@ -481,6 +481,19 @@ QTreeWidgetItem *QgsIdentifyResultsDialog::layerItem( QObject *object )
return nullptr;
}

QTreeWidgetItem *QgsIdentifyResultsDialog::findResultFeaturesItem( QTreeWidgetItem *layerItem )
{
for ( int i = 0; i < layerItem->childCount(); i++ )
{
QTreeWidgetItem *item = layerItem->child( i );

if ( item->data( 0, Qt::UserRole ).toString() == QLatin1String( "count" ) )
return item;
}

return nullptr;
}

void QgsIdentifyResultsDialog::addFeature( const QgsMapToolIdentify::IdentifyResult &result )
{
switch ( result.mLayer->type() )
Expand Down Expand Up @@ -508,7 +521,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat

if ( !layItem )
{
layItem = new QTreeWidgetItem( QStringList() << vlayer->name() << tr( "Selected features: %1" ).arg( 0 ) );
layItem = new QTreeWidgetItem( QStringList() << vlayer->name() );
layItem->setData( 0, Qt::UserRole, QVariant::fromValue( qobject_cast<QObject *>( vlayer ) ) );
lstResults->addTopLevelItem( layItem );

Expand All @@ -526,7 +539,19 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat
featItem->setData( 0, Qt::UserRole + 1, mFeatures.size() );
mFeatures << f;
layItem->addChild( featItem );
layItem->setText( 1, tr( "Selected features: %1" ).arg( layItem->childCount() ) );

QTreeWidgetItem *resultFeaturesCountItem = findResultFeaturesItem( layItem );
if ( ! resultFeaturesCountItem )
{
resultFeaturesCountItem = new QTreeWidgetItem( QStringList() << tr( "(Count Results)" ) );
resultFeaturesCountItem->setData( 0, Qt::UserRole, QLatin1String( "count" ) );
layItem->insertChild( 0, resultFeaturesCountItem );
}

if ( resultFeaturesCountItem )
{
resultFeaturesCountItem->setText( 1, QString::number( layItem->childCount() - 1 ) );
}

if ( derivedAttributes.size() >= 0 )
{
Expand Down Expand Up @@ -1107,6 +1132,9 @@ void QgsIdentifyResultsDialog::editingToggled()
{
QTreeWidgetItem *featItem = layItem->child( i );

if ( featItem->data( 0, Qt::UserRole ).toString() == QLatin1String( "result features" ) )
continue;

int j;
for ( j = 0; j < featItem->childCount() && featItem->child( j )->data( 0, Qt::UserRole ).toString() != QLatin1String( "actions" ); j++ )
{
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsidentifyresultsdialog.h
Expand Up @@ -278,6 +278,7 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti
QTreeWidgetItem *featureItem( QTreeWidgetItem *item );
QTreeWidgetItem *layerItem( QTreeWidgetItem *item );
QTreeWidgetItem *layerItem( QObject *layer );
QTreeWidgetItem *findResultFeaturesItem( QTreeWidgetItem *layerItem );


void highlightLayer( QTreeWidgetItem *object );
Expand Down
2 changes: 1 addition & 1 deletion src/ui/qgsidentifyresultsbase.ui
Expand Up @@ -311,7 +311,7 @@
<string>Copy Feature</string>
</property>
<property name="toolTip">
<string>Copy Selected Feature to Clipboard</string>
<string>Copy the Identified Feature to Clipboard</string>
</property>
</action>
<action name="mActionPrint">
Expand Down

0 comments on commit d40ab03

Please sign in to comment.