Skip to content

Commit

Permalink
remove table and graph tabs only if there are no raster layers identi…
Browse files Browse the repository at this point in the history
…fied (qgis#10376)
  • Loading branch information
etiennesky committed Jun 10, 2014
1 parent f97fa90 commit 7f30ad2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/app/qgsidentifyresultsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,7 @@ void QgsIdentifyResultsDialog::expandColumnsToFit()

void QgsIdentifyResultsDialog::clear()
{
QgsDebugMsg( "Entered" );
for ( int i = 0; i < lstResults->topLevelItemCount(); i++ )
{
disconnectLayer( lstResults->topLevelItem( i )->data( 0, Qt::UserRole ).value<QObject *>() );
Expand All @@ -1052,9 +1053,6 @@ void QgsIdentifyResultsDialog::clear()
tblResults->clearContents();
tblResults->setRowCount( 0 );

tabWidget->removeTab( 1 );
tabWidget->removeTab( 1 );

mPlot->setVisible( false );
foreach ( QgsIdentifyPlotCurve *curve, mPlotCurves )
delete curve;
Expand All @@ -1065,6 +1063,12 @@ void QgsIdentifyResultsDialog::clear()
mPrintToolButton->setDisabled( true );
}

void QgsIdentifyResultsDialog::clearTabs()
{
tabWidget->removeTab( 1 );
tabWidget->removeTab( 1 );
}

void QgsIdentifyResultsDialog::clearHighlights()
{
foreach ( QgsHighlight *h, mHighlights )
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsidentifyresultsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti
public slots:
/** Remove results */
void clear();
void clearTabs();

void show();

Expand Down
7 changes: 7 additions & 0 deletions src/app/qgsmaptoolidentifyaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ void QgsMapToolIdentifyAction::canvasReleaseEvent( QMouseEvent *e )
disconnect( this, SIGNAL( identifyProgress( int, int ) ), QgisApp::instance(), SLOT( showProgress( int, int ) ) );
disconnect( this, SIGNAL( identifyMessage( QString ) ), QgisApp::instance(), SLOT( showStatusMessage( QString ) ) );

bool identifiedRaster = false;

if ( !results.isEmpty() )
{
// Show the dialog before items are inserted so that items can resize themselves
Expand All @@ -106,6 +108,8 @@ void QgsMapToolIdentifyAction::canvasReleaseEvent( QMouseEvent *e )
for ( result = results.begin(); result != results.end(); ++result )
{
resultsDialog()->addFeature( *result );
if ( result->mLayer->type() == QgsMapLayer::RasterLayer )
identifiedRaster = true;
}

// Call QgsIdentifyResultsDialog::show() to adjust with items
Expand All @@ -116,6 +120,9 @@ void QgsMapToolIdentifyAction::canvasReleaseEvent( QMouseEvent *e )
resultsDialog()->clear();
QgisApp::instance()->statusBar()->showMessage( tr( "No features at this position found." ) );
}
// remove table and graph tabs if there are no rasters
if ( ! identifiedRaster )
resultsDialog()->clearTabs();
}

void QgsMapToolIdentifyAction::handleChangedRasterResults( QList<IdentifyResult> &results )
Expand Down

0 comments on commit 7f30ad2

Please sign in to comment.