Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
identify results dialog: use combo box instead of tabbed widget for v…
…iew mode (rasters only) and add tooltips for identify mode and view mode (#10376)
  • Loading branch information
etiennesky committed Jun 13, 2014
1 parent cf7e016 commit cc1f24e
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 38 deletions.
37 changes: 25 additions & 12 deletions src/app/qgsidentifyresultsdialog.cpp
Expand Up @@ -300,8 +300,10 @@ QgsIdentifyResultsDialog::QgsIdentifyResultsDialog( QgsMapCanvas *canvas, QWidge
cmbIdentifyMode->setCurrentIndex( cmbIdentifyMode->findData( identifyMode ) );
cbxAutoFeatureForm->setChecked( mySettings.value( "/Map/identifyAutoFeatureForm", false ).toBool() );

tabWidget->removeTab( 1 );
tabWidget->removeTab( 1 );
// view modes
cmbViewMode->addItem( tr( "Tree" ), 0 );
cmbViewMode->addItem( tr( "Table" ), 0 );
cmbViewMode->addItem( tr( "Graph" ), 0 );

// graph
mPlot->setVisible( false );
Expand Down Expand Up @@ -655,12 +657,6 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer,

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

if ( tabWidget->indexOf( tableTab ) < 0 )
{
tabWidget->addTab( tableTab, tr( "Table" ) );
tabWidget->addTab( plotTab, tr( "Graph" ) );
}

if ( layItem == 0 )
{
layItem = new QTreeWidgetItem( QStringList() << QString::number( lstResults->topLevelItemCount() ) << layer->name() );
Expand Down Expand Up @@ -907,7 +903,7 @@ void QgsIdentifyResultsDialog::contextMenuEvent( QContextMenuEvent* event )
QgsDebugMsg( "Entered" );

// only handle context menu event if showing tree widget
if ( tabWidget->currentWidget() != treeTab )
if ( stackedWidget->currentIndex() != 0 )
return;

QTreeWidgetItem *item = lstResults->itemAt( lstResults->viewport()->mapFrom( this, event->pos() ) );
Expand Down Expand Up @@ -1076,10 +1072,22 @@ void QgsIdentifyResultsDialog::clear()
mPrintToolButton->setDisabled( true );
}

void QgsIdentifyResultsDialog::clearTabs()
void QgsIdentifyResultsDialog::updateViewModes()
{
tabWidget->removeTab( 1 );
tabWidget->removeTab( 1 );
// get # of identified vector and raster layers - there must be a better way involving caching
int vectorCount = 0, rasterCount = 0;
for ( int i = 0; i < lstResults->topLevelItemCount(); i++ )
{
QTreeWidgetItem *item = lstResults->topLevelItem( i );
if ( vectorLayer( item ) ) vectorCount++;
else if ( rasterLayer( item ) ) rasterCount++;
}

lblViewMode->setEnabled( rasterCount > 0 );
cmbViewMode->setEnabled( rasterCount > 0 );
if ( rasterCount == 0 )
cmbViewMode->setCurrentIndex( 0 );

}

void QgsIdentifyResultsDialog::clearHighlights()
Expand Down Expand Up @@ -1742,6 +1750,11 @@ void QgsIdentifyResultsDialog::on_cmbIdentifyMode_currentIndexChanged( int index
settings.setValue( "/Map/identifyMode", cmbIdentifyMode->itemData( index ).toInt() );
}

void QgsIdentifyResultsDialog::on_cmbViewMode_currentIndexChanged( int index )
{
stackedWidget->setCurrentIndex( index );
}

void QgsIdentifyResultsDialog::on_cbxAutoFeatureForm_toggled( bool checked )
{
QSettings settings;
Expand Down
5 changes: 4 additions & 1 deletion src/app/qgsidentifyresultsdialog.h
Expand Up @@ -155,7 +155,8 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti
public slots:
/** Remove results */
void clear();
void clearTabs();

void updateViewModes();

void show();

Expand Down Expand Up @@ -196,6 +197,8 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti

void on_cmbIdentifyMode_currentIndexChanged( int index );

void on_cmbViewMode_currentIndexChanged( int index );

void on_mExpandNewToolButton_toggled( bool checked );

void on_cbxAutoFeatureForm_toggled( bool checked );
Expand Down
10 changes: 3 additions & 7 deletions src/app/qgsmaptoolidentifyaction.cpp
Expand Up @@ -95,8 +95,6 @@ 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 @@ -108,8 +106,6 @@ 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 @@ -120,9 +116,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();

// update possible view modes
resultsDialog()->updateViewModes();
}

void QgsMapToolIdentifyAction::handleChangedRasterResults( QList<IdentifyResult> &results )
Expand Down
53 changes: 35 additions & 18 deletions src/ui/qgsidentifyresultsbase.ui
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>341</width>
<width>394</width>
<height>409</height>
</rect>
</property>
Expand All @@ -18,14 +18,8 @@
<number>2</number>
</property>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="treeTab">
<attribute name="title">
<string>Tree</string>
</attribute>
<widget class="QStackedWidget" name="stackedWidget">
<widget class="QWidget" name="stackedWidgetPage1" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
Expand Down Expand Up @@ -53,10 +47,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tableTab">
<attribute name="title">
<string>Table</string>
</attribute>
<widget class="QWidget" name="stackedWidgetPage2" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
Expand Down Expand Up @@ -96,10 +87,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="plotTab">
<attribute name="title">
<string>Graph</string>
</attribute>
<widget class="QWidget" name="stackedWidgetPage3" native="true">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QwtPlot" name="mPlot"/>
Expand Down Expand Up @@ -251,7 +239,10 @@
<item>
<layout class="QHBoxLayout" name="mIdentifyModeHorizontalLayout">
<item>
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="lblIdentifyMode">
<property name="toolTip">
<string>Select identify mode</string>
</property>
<property name="text">
<string>Mode</string>
</property>
Expand All @@ -273,6 +264,32 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lblViewMode">
<property name="toolTip">
<string>Select view mode for raster layers</string>
</property>
<property name="text">
<string>View</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cmbViewMode"/>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="cbxAutoFeatureForm">
<property name="text">
Expand Down

0 comments on commit cc1f24e

Please sign in to comment.