Skip to content

Commit cc1f24e

Browse files
committedJun 13, 2014
identify results dialog: use combo box instead of tabbed widget for view mode (rasters only) and add tooltips for identify mode and view mode (#10376)
1 parent cf7e016 commit cc1f24e

File tree

4 files changed

+67
-38
lines changed

4 files changed

+67
-38
lines changed
 

‎src/app/qgsidentifyresultsdialog.cpp

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,10 @@ 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 );
303+
// view modes
304+
cmbViewMode->addItem( tr( "Tree" ), 0 );
305+
cmbViewMode->addItem( tr( "Table" ), 0 );
306+
cmbViewMode->addItem( tr( "Graph" ), 0 );
305307

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

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

658-
if ( tabWidget->indexOf( tableTab ) < 0 )
659-
{
660-
tabWidget->addTab( tableTab, tr( "Table" ) );
661-
tabWidget->addTab( plotTab, tr( "Graph" ) );
662-
}
663-
664660
if ( layItem == 0 )
665661
{
666662
layItem = new QTreeWidgetItem( QStringList() << QString::number( lstResults->topLevelItemCount() ) << layer->name() );
@@ -907,7 +903,7 @@ void QgsIdentifyResultsDialog::contextMenuEvent( QContextMenuEvent* event )
907903
QgsDebugMsg( "Entered" );
908904

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

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

1079-
void QgsIdentifyResultsDialog::clearTabs()
1075+
void QgsIdentifyResultsDialog::updateViewModes()
10801076
{
1081-
tabWidget->removeTab( 1 );
1082-
tabWidget->removeTab( 1 );
1077+
// get # of identified vector and raster layers - there must be a better way involving caching
1078+
int vectorCount = 0, rasterCount = 0;
1079+
for ( int i = 0; i < lstResults->topLevelItemCount(); i++ )
1080+
{
1081+
QTreeWidgetItem *item = lstResults->topLevelItem( i );
1082+
if ( vectorLayer( item ) ) vectorCount++;
1083+
else if ( rasterLayer( item ) ) rasterCount++;
1084+
}
1085+
1086+
lblViewMode->setEnabled( rasterCount > 0 );
1087+
cmbViewMode->setEnabled( rasterCount > 0 );
1088+
if ( rasterCount == 0 )
1089+
cmbViewMode->setCurrentIndex( 0 );
1090+
10831091
}
10841092

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

1753+
void QgsIdentifyResultsDialog::on_cmbViewMode_currentIndexChanged( int index )
1754+
{
1755+
stackedWidget->setCurrentIndex( index );
1756+
}
1757+
17451758
void QgsIdentifyResultsDialog::on_cbxAutoFeatureForm_toggled( bool checked )
17461759
{
17471760
QSettings settings;

‎src/app/qgsidentifyresultsdialog.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti
155155
public slots:
156156
/** Remove results */
157157
void clear();
158-
void clearTabs();
158+
159+
void updateViewModes();
159160

160161
void show();
161162

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

197198
void on_cmbIdentifyMode_currentIndexChanged( int index );
198199

200+
void on_cmbViewMode_currentIndexChanged( int index );
201+
199202
void on_mExpandNewToolButton_toggled( bool checked );
200203

201204
void on_cbxAutoFeatureForm_toggled( bool checked );

‎src/app/qgsmaptoolidentifyaction.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ void QgsMapToolIdentifyAction::canvasReleaseEvent( QMouseEvent *e )
9595
disconnect( this, SIGNAL( identifyProgress( int, int ) ), QgisApp::instance(), SLOT( showProgress( int, int ) ) );
9696
disconnect( this, SIGNAL( identifyMessage( QString ) ), QgisApp::instance(), SLOT( showStatusMessage( QString ) ) );
9797

98-
bool identifiedRaster = false;
99-
10098
if ( !results.isEmpty() )
10199
{
102100
// Show the dialog before items are inserted so that items can resize themselves
@@ -108,8 +106,6 @@ void QgsMapToolIdentifyAction::canvasReleaseEvent( QMouseEvent *e )
108106
for ( result = results.begin(); result != results.end(); ++result )
109107
{
110108
resultsDialog()->addFeature( *result );
111-
if ( result->mLayer->type() == QgsMapLayer::RasterLayer )
112-
identifiedRaster = true;
113109
}
114110

115111
// Call QgsIdentifyResultsDialog::show() to adjust with items
@@ -120,9 +116,9 @@ void QgsMapToolIdentifyAction::canvasReleaseEvent( QMouseEvent *e )
120116
resultsDialog()->clear();
121117
QgisApp::instance()->statusBar()->showMessage( tr( "No features at this position found." ) );
122118
}
123-
// remove table and graph tabs if there are no rasters
124-
if ( ! identifiedRaster )
125-
resultsDialog()->clearTabs();
119+
120+
// update possible view modes
121+
resultsDialog()->updateViewModes();
126122
}
127123

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

‎src/ui/qgsidentifyresultsbase.ui

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>341</width>
9+
<width>394</width>
1010
<height>409</height>
1111
</rect>
1212
</property>
@@ -18,14 +18,8 @@
1818
<number>2</number>
1919
</property>
2020
<item>
21-
<widget class="QTabWidget" name="tabWidget">
22-
<property name="currentIndex">
23-
<number>0</number>
24-
</property>
25-
<widget class="QWidget" name="treeTab">
26-
<attribute name="title">
27-
<string>Tree</string>
28-
</attribute>
21+
<widget class="QStackedWidget" name="stackedWidget">
22+
<widget class="QWidget" name="stackedWidgetPage1" native="true">
2923
<layout class="QVBoxLayout" name="verticalLayout">
3024
<property name="spacing">
3125
<number>0</number>
@@ -53,10 +47,7 @@
5347
</item>
5448
</layout>
5549
</widget>
56-
<widget class="QWidget" name="tableTab">
57-
<attribute name="title">
58-
<string>Table</string>
59-
</attribute>
50+
<widget class="QWidget" name="stackedWidgetPage2" native="true">
6051
<layout class="QVBoxLayout" name="verticalLayout_2">
6152
<property name="spacing">
6253
<number>0</number>
@@ -96,10 +87,7 @@
9687
</item>
9788
</layout>
9889
</widget>
99-
<widget class="QWidget" name="plotTab">
100-
<attribute name="title">
101-
<string>Graph</string>
102-
</attribute>
90+
<widget class="QWidget" name="stackedWidgetPage3" native="true">
10391
<layout class="QVBoxLayout" name="verticalLayout_3">
10492
<item>
10593
<widget class="QwtPlot" name="mPlot"/>
@@ -251,7 +239,10 @@
251239
<item>
252240
<layout class="QHBoxLayout" name="mIdentifyModeHorizontalLayout">
253241
<item>
254-
<widget class="QLabel" name="label_4">
242+
<widget class="QLabel" name="lblIdentifyMode">
243+
<property name="toolTip">
244+
<string>Select identify mode</string>
245+
</property>
255246
<property name="text">
256247
<string>Mode</string>
257248
</property>
@@ -273,6 +264,32 @@
273264
</property>
274265
</spacer>
275266
</item>
267+
<item>
268+
<widget class="QLabel" name="lblViewMode">
269+
<property name="toolTip">
270+
<string>Select view mode for raster layers</string>
271+
</property>
272+
<property name="text">
273+
<string>View</string>
274+
</property>
275+
</widget>
276+
</item>
277+
<item>
278+
<widget class="QComboBox" name="cmbViewMode"/>
279+
</item>
280+
<item>
281+
<spacer name="horizontalSpacer_2">
282+
<property name="orientation">
283+
<enum>Qt::Horizontal</enum>
284+
</property>
285+
<property name="sizeHint" stdset="0">
286+
<size>
287+
<width>40</width>
288+
<height>20</height>
289+
</size>
290+
</property>
291+
</spacer>
292+
</item>
276293
<item>
277294
<widget class="QCheckBox" name="cbxAutoFeatureForm">
278295
<property name="text">

0 commit comments

Comments
 (0)
Please sign in to comment.