Skip to content
Permalink
Browse files

Add "Result Features" as new row; Change "selected" to "identified" i…

…n tooltips
  • Loading branch information
suricactus authored and nyalldawson committed Mar 20, 2020
1 parent f0e74df commit d40ab0307ebc3f118314242fe43988591dbec2ac
Showing with 32 additions and 3 deletions.
  1. +30 −2 src/app/qgsidentifyresultsdialog.cpp
  2. +1 −0 src/app/qgsidentifyresultsdialog.h
  3. +1 −1 src/ui/qgsidentifyresultsbase.ui
@@ -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() )
@@ -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 );

@@ -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 )
{
@@ -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++ )
{
@@ -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 );
@@ -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">

0 comments on commit d40ab03

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