Skip to content

Commit 4ff233e

Browse files
committed
identify results: hide highlights on deactivation and hide table/plot tab meant
for rasters when there are only vector features (fixes #10376)
1 parent 4a890b9 commit 4ff233e

File tree

2 files changed

+30
-22
lines changed

2 files changed

+30
-22
lines changed

src/app/qgsidentifyresultsdialog.cpp

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,9 @@ QgsIdentifyResultsDialog::QgsIdentifyResultsDialog( QgsMapCanvas *canvas, QWidge
300300
cmbIdentifyMode->setCurrentIndex( cmbIdentifyMode->findData( identifyMode ) );
301301
cbxAutoFeatureForm->setChecked( mySettings.value( "/Map/identifyAutoFeatureForm", false ).toBool() );
302302

303+
tabWidget->removeTab( 1 );
304+
tabWidget->removeTab( 1 );
305+
303306
// graph
304307
mPlot->setVisible( false );
305308
mPlot->setAutoFillBackground( false );
@@ -652,6 +655,12 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer,
652655

653656
QgsRaster::IdentifyFormat currentFormat = QgsRasterDataProvider::identifyFormatFromName( layer->customProperty( "identify/format" ).toString() );
654657

658+
if ( tabWidget->indexOf( tableTab ) < 0 )
659+
{
660+
tabWidget->addTab( tableTab, tr( "Table" ) );
661+
tabWidget->addTab( plotTab, tr( "Graph" ) );
662+
}
663+
655664
if ( layItem == 0 )
656665
{
657666
layItem = new QTreeWidgetItem( QStringList() << QString::number( lstResults->topLevelItemCount() ) << layer->name() );
@@ -885,7 +894,7 @@ void QgsIdentifyResultsDialog::contextMenuEvent( QContextMenuEvent* event )
885894
QgsDebugMsg( "Entered" );
886895

887896
// only handle context menu event if showing tree widget
888-
if ( tabWidget->currentIndex() != 0 )
897+
if ( tabWidget->currentWidget() != treeTab )
889898
return;
890899

891900
QTreeWidgetItem *item = lstResults->itemAt( lstResults->viewport()->mapFrom( this, event->pos() ) );
@@ -1030,16 +1039,6 @@ void QgsIdentifyResultsDialog::expandColumnsToFit()
10301039
lstResults->resizeColumnToContents( 1 );
10311040
}
10321041

1033-
void QgsIdentifyResultsDialog::clearHighlights()
1034-
{
1035-
foreach ( QgsHighlight *h, mHighlights )
1036-
{
1037-
delete h;
1038-
}
1039-
1040-
mHighlights.clear();
1041-
}
1042-
10431042
void QgsIdentifyResultsDialog::clear()
10441043
{
10451044
for ( int i = 0; i < lstResults->topLevelItemCount(); i++ )
@@ -1053,6 +1052,9 @@ void QgsIdentifyResultsDialog::clear()
10531052
tblResults->clearContents();
10541053
tblResults->setRowCount( 0 );
10551054

1055+
tabWidget->removeTab( 1 );
1056+
tabWidget->removeTab( 1 );
1057+
10561058
mPlot->setVisible( false );
10571059
foreach ( QgsIdentifyPlotCurve *curve, mPlotCurves )
10581060
delete curve;
@@ -1063,14 +1065,22 @@ void QgsIdentifyResultsDialog::clear()
10631065
mPrintToolButton->setDisabled( true );
10641066
}
10651067

1068+
void QgsIdentifyResultsDialog::clearHighlights()
1069+
{
1070+
foreach ( QgsHighlight *h, mHighlights )
1071+
{
1072+
delete h;
1073+
}
1074+
1075+
mHighlights.clear();
1076+
}
1077+
10661078
void QgsIdentifyResultsDialog::activate()
10671079
{
1068-
#if 0
1069-
foreach ( QgsRubberBand *rb, mRubberBands )
1080+
foreach ( QgsHighlight *h, mHighlights )
10701081
{
1071-
rb->show();
1082+
h->show();
10721083
}
1073-
#endif
10741084

10751085
if ( lstResults->topLevelItemCount() > 0 )
10761086
{
@@ -1081,12 +1091,10 @@ void QgsIdentifyResultsDialog::activate()
10811091

10821092
void QgsIdentifyResultsDialog::deactivate()
10831093
{
1084-
#if 0
1085-
foreach ( QgsRubberBand *rb, mRubberBands )
1094+
foreach ( QgsHighlight *h, mHighlights )
10861095
{
1087-
rb->hide();
1096+
h->hide();
10881097
}
1089-
#endif
10901098
}
10911099

10921100
void QgsIdentifyResultsDialog::doAction( QTreeWidgetItem *item, int action )

src/ui/qgsidentifyresultsbase.ui

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<property name="currentIndex">
2323
<number>0</number>
2424
</property>
25-
<widget class="QWidget" name="tab">
25+
<widget class="QWidget" name="treeTab">
2626
<attribute name="title">
2727
<string>Tree</string>
2828
</attribute>
@@ -53,7 +53,7 @@
5353
</item>
5454
</layout>
5555
</widget>
56-
<widget class="QWidget" name="tab_2">
56+
<widget class="QWidget" name="tableTab">
5757
<attribute name="title">
5858
<string>Table</string>
5959
</attribute>
@@ -96,7 +96,7 @@
9696
</item>
9797
</layout>
9898
</widget>
99-
<widget class="QWidget" name="tab_3">
99+
<widget class="QWidget" name="plotTab">
100100
<attribute name="title">
101101
<string>Graph</string>
102102
</attribute>

0 commit comments

Comments
 (0)