Skip to content

Commit 0c52039

Browse files
committed
identify results:
* restore identify dock (implements #10152) * add clear button (implements #10149) * automatically set only item current * move controls to bottom
1 parent 366fdbc commit 0c52039

File tree

4 files changed

+98
-153
lines changed

4 files changed

+98
-153
lines changed

src/app/qgisapp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
635635
* @note added in 2.1 */
636636
void refreshActionFeatureAction();
637637

638+
QMenu *panelMenu() { return mPanelMenu; }
639+
638640
protected:
639641

640642
//! Handle state changes (WindowTitleChange)

src/app/qgsidentifyresultsdialog.cpp

Lines changed: 25 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -177,22 +177,6 @@ QSize QgsIdentifyResultsWebView::sizeHint() const
177177
return s;
178178
}
179179

180-
class QgsIdentifyResultsDock : public QDockWidget
181-
{
182-
public:
183-
QgsIdentifyResultsDock( const QString & title, QWidget * parent = 0, Qt::WindowFlags flags = 0 )
184-
: QDockWidget( title, parent, flags )
185-
{
186-
setObjectName( "IdentifyResultsTableDock" ); // set object name so the position can be saved
187-
}
188-
189-
virtual void closeEvent( QCloseEvent *e )
190-
{
191-
Q_UNUSED( e );
192-
deleteLater();
193-
}
194-
};
195-
196180
QgsIdentifyResultsFeatureItem::QgsIdentifyResultsFeatureItem( const QgsFields &fields, const QgsFeature &feature, const QgsCoordinateReferenceSystem &crs, const QStringList & strings )
197181
: QTreeWidgetItem( strings )
198182
, mFields( fields )
@@ -271,11 +255,14 @@ QgsIdentifyResultsDialog::QgsIdentifyResultsDialog( QgsMapCanvas *canvas, QWidge
271255
mOpenFormButton->setDisabled( true );
272256

273257
QSettings mySettings;
274-
restoreGeometry( mySettings.value( "/Windows/Identify/geometry" ).toByteArray() );
275-
mDock = new QgsIdentifyResultsDock( tr( "Identify Results" ) , QgisApp::instance() );
258+
mDock = new QDockWidget( tr( "Identify Results" ) , QgisApp::instance() );
259+
mDock->setObjectName( "IdentifyResultsDock" );
276260
mDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
277261
mDock->setWidget( this );
278-
QgisApp::instance()->addDockWidget( Qt::LeftDockWidgetArea, mDock );
262+
if ( !QgisApp::instance()->restoreDockWidget( mDock ) )
263+
QgisApp::instance()->addDockWidget( Qt::LeftDockWidgetArea, mDock );
264+
else
265+
QgisApp::instance()->panelMenu()->addAction( mDock->toggleViewAction() );
279266

280267
mExpandNewToolButton->setChecked( mySettings.value( "/Map/identifyExpand", false ).toBool() );
281268
mCopyToolButton->setEnabled( false );
@@ -299,8 +286,6 @@ QgsIdentifyResultsDialog::QgsIdentifyResultsDialog( QgsMapCanvas *canvas, QWidge
299286
cmbIdentifyMode->setCurrentIndex( cmbIdentifyMode->findData( identifyMode ) );
300287
cbxAutoFeatureForm->setChecked( mySettings.value( "/Map/identifyAutoFeatureForm", false ).toBool() );
301288

302-
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( close() ) );
303-
304289
connect( lstResults, SIGNAL( itemExpanded( QTreeWidgetItem* ) ),
305290
this, SLOT( itemExpanded( QTreeWidgetItem* ) ) );
306291

@@ -310,17 +295,19 @@ QgsIdentifyResultsDialog::QgsIdentifyResultsDialog( QgsMapCanvas *canvas, QWidge
310295
connect( lstResults, SIGNAL( itemClicked( QTreeWidgetItem*, int ) ),
311296
this, SLOT( itemClicked( QTreeWidgetItem*, int ) ) );
312297

313-
connect( mPrintToolButton, SIGNAL( clicked() ),
314-
this, SLOT( printCurrentItem() ) );
315-
316-
connect( mOpenFormButton, SIGNAL( clicked() ),
317-
this, SLOT( featureForm() ) );
318-
298+
connect( mPrintToolButton, SIGNAL( clicked() ), this, SLOT( printCurrentItem() ) );
299+
connect( mOpenFormButton, SIGNAL( clicked() ), this, SLOT( featureForm() ) );
300+
connect( mClearToolButton, SIGNAL( clicked() ), this, SLOT( clear() ) );
301+
connect( mHelpToolButton, SIGNAL( clicked() ), this, SLOT( helpRequested() ) );
319302
}
320303

321304
QgsIdentifyResultsDialog::~QgsIdentifyResultsDialog()
322305
{
323306
clearHighlights();
307+
308+
QSettings settings;
309+
settings.setValue( "/Windows/Identify/columnWidth", lstResults->columnWidth( 0 ) );
310+
324311
if ( mActionPopup )
325312
delete mActionPopup;
326313
}
@@ -653,17 +640,19 @@ void QgsIdentifyResultsDialog::show()
653640
QTreeWidgetItem *layItem = lstResults->topLevelItem( 0 );
654641
QTreeWidgetItem *featItem = layItem->child( 0 );
655642

656-
if ( lstResults->topLevelItemCount() == 1 &&
657-
layItem->childCount() == 1 &&
658-
QSettings().value( "/Map/identifyAutoFeatureForm", false ).toBool() )
643+
if ( lstResults->topLevelItemCount() == 1 && layItem->childCount() == 1 )
659644
{
660-
QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( layItem->data( 0, Qt::UserRole ).value<QObject *>() );
661-
if ( layer )
645+
lstResults->setCurrentItem( featItem );
646+
647+
if ( QSettings().value( "/Map/identifyAutoFeatureForm", false ).toBool() )
662648
{
663-
// if this is the only feature and it's on a vector layer
664-
// don't show the form dialog instead of the results window
665-
lstResults->setCurrentItem( featItem );
666-
featureForm();
649+
QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( layItem->data( 0, Qt::UserRole ).value<QObject *>() );
650+
if ( layer )
651+
{
652+
// if this is the only feature and it's on a vector layer
653+
// don't show the form dialog instead of the results window
654+
featureForm();
655+
}
667656
}
668657
}
669658

@@ -682,30 +671,6 @@ void QgsIdentifyResultsDialog::show()
682671
raise();
683672
}
684673

685-
// Slot called when user clicks the Close button
686-
// (saves the current window size/position)
687-
void QgsIdentifyResultsDialog::close()
688-
{
689-
clear();
690-
691-
delete mActionPopup;
692-
mActionPopup = 0;
693-
694-
saveWindowLocation();
695-
done( 0 );
696-
697-
mDock->close();
698-
}
699-
700-
// Save the current window size/position before closing
701-
// from window menu or X in titlebar
702-
void QgsIdentifyResultsDialog::closeEvent( QCloseEvent *e )
703-
{
704-
// We'll close in our own good time thanks...
705-
e->ignore();
706-
close();
707-
}
708-
709674
void QgsIdentifyResultsDialog::itemClicked( QTreeWidgetItem *item, int column )
710675
{
711676
Q_UNUSED( column );
@@ -852,15 +817,6 @@ void QgsIdentifyResultsDialog::contextMenuEvent( QContextMenuEvent* event )
852817
mActionPopup->popup( event->globalPos() );
853818
}
854819

855-
// Save the current window location (store in ~/.qt/qgisrc)
856-
void QgsIdentifyResultsDialog::saveWindowLocation()
857-
{
858-
QSettings settings;
859-
settings.setValue( "/Windows/Identify/geometry", saveGeometry() );
860-
// first column width
861-
settings.setValue( "/Windows/Identify/columnWidth", lstResults->columnWidth( 0 ) );
862-
}
863-
864820
void QgsIdentifyResultsDialog::setColumnText( int column, const QString & label )
865821
{
866822
QTreeWidgetItem* header = lstResults->headerItem();
@@ -1154,11 +1110,6 @@ void QgsIdentifyResultsDialog::layerDestroyed()
11541110

11551111
disconnectLayer( theSender );
11561112
delete layerItem( theSender );
1157-
1158-
if ( lstResults->topLevelItemCount() == 0 )
1159-
{
1160-
close();
1161-
}
11621113
}
11631114

11641115
void QgsIdentifyResultsDialog::disconnectLayer( QObject *layer )
@@ -1205,11 +1156,6 @@ void QgsIdentifyResultsDialog::featureDeleted( QgsFeatureId fid )
12051156
{
12061157
delete layItem;
12071158
}
1208-
1209-
if ( lstResults->topLevelItemCount() == 0 )
1210-
{
1211-
close();
1212-
}
12131159
}
12141160

12151161
void QgsIdentifyResultsDialog::attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &val )

src/app/qgsidentifyresultsdialog.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti
127127
/** map tool was activated */
128128
void activate();
129129

130-
void closeEvent( QCloseEvent *e );
131-
132130
signals:
133131
void selectedFeatureChanged( QgsVectorLayer *, QgsFeatureId featureId );
134132

@@ -145,7 +143,6 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti
145143

146144
void show();
147145

148-
void close();
149146
void contextMenuEvent( QContextMenuEvent* );
150147

151148
void layerDestroyed();
@@ -178,7 +175,7 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti
178175

179176
QTreeWidgetItem *retrieveAttributes( QTreeWidgetItem *item, QgsAttributeMap &attributes, int &currentIdx );
180177

181-
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
178+
void helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
182179

183180
void on_cmbIdentifyMode_currentIndexChanged( int index );
184181

@@ -221,7 +218,6 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti
221218

222219
void setColumnText( int column, const QString & label );
223220
void expandColumnsToFit();
224-
void saveWindowLocation();
225221

226222
void highlightFeature( QTreeWidgetItem *item );
227223

src/ui/qgsidentifyresultsbase.ui

Lines changed: 70 additions & 69 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>317</width>
9+
<width>341</width>
1010
<height>409</height>
1111
</rect>
1212
</property>
@@ -17,47 +17,6 @@
1717
<property name="margin">
1818
<number>2</number>
1919
</property>
20-
<item>
21-
<layout class="QHBoxLayout" name="mIdentifyModeHorizontalLayout">
22-
<item>
23-
<widget class="QLabel" name="label_4">
24-
<property name="text">
25-
<string>Mode</string>
26-
</property>
27-
</widget>
28-
</item>
29-
<item>
30-
<widget class="QComboBox" name="cmbIdentifyMode"/>
31-
</item>
32-
<item>
33-
<spacer name="horizontalSpacer_43">
34-
<property name="orientation">
35-
<enum>Qt::Horizontal</enum>
36-
</property>
37-
<property name="sizeHint" stdset="0">
38-
<size>
39-
<width>40</width>
40-
<height>20</height>
41-
</size>
42-
</property>
43-
</spacer>
44-
</item>
45-
<item>
46-
<widget class="QToolButton" name="mOpenFormButton">
47-
<property name="text">
48-
<string>...</string>
49-
</property>
50-
</widget>
51-
</item>
52-
<item>
53-
<widget class="QCheckBox" name="cbxAutoFeatureForm">
54-
<property name="text">
55-
<string>Auto open form</string>
56-
</property>
57-
</widget>
58-
</item>
59-
</layout>
60-
</item>
6120
<item>
6221
<widget class="QTreeWidget" name="lstResults">
6322
<property name="lineWidth">
@@ -123,6 +82,34 @@
12382
</property>
12483
</widget>
12584
</item>
85+
<item>
86+
<widget class="QToolButton" name="mOpenFormButton">
87+
<property name="text">
88+
<string>...</string>
89+
</property>
90+
<property name="icon">
91+
<iconset resource="../../images/images.qrc">
92+
<normaloff>:/images/themes/default/mActionPropertyItem.png</normaloff>:/images/themes/default/mActionPropertyItem.png</iconset>
93+
</property>
94+
</widget>
95+
</item>
96+
<item>
97+
<widget class="QToolButton" name="mClearToolButton">
98+
<property name="toolTip">
99+
<string>Clear Results</string>
100+
</property>
101+
<property name="text">
102+
<string>...</string>
103+
</property>
104+
<property name="icon">
105+
<iconset resource="../../images/images.qrc">
106+
<normaloff>:/images/themes/default/mActionDeselectAll.svg</normaloff>:/images/themes/default/mActionDeselectAll.svg</iconset>
107+
</property>
108+
<property name="checkable">
109+
<bool>false</bool>
110+
</property>
111+
</widget>
112+
</item>
126113
<item>
127114
<widget class="QToolButton" name="mCopyToolButton">
128115
<property name="toolTip">
@@ -174,45 +161,59 @@
174161
</spacer>
175162
</item>
176163
<item>
177-
<widget class="QDialogButtonBox" name="buttonBox">
178-
<property name="sizePolicy">
179-
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
180-
<horstretch>0</horstretch>
181-
<verstretch>0</verstretch>
182-
</sizepolicy>
164+
<widget class="QToolButton" name="mHelpToolButton">
165+
<property name="enabled">
166+
<bool>true</bool>
183167
</property>
184-
<property name="standardButtons">
185-
<set>QDialogButtonBox::Help</set>
168+
<property name="text">
169+
<string>Help</string>
186170
</property>
187-
<property name="centerButtons">
171+
<property name="checkable">
188172
<bool>false</bool>
189173
</property>
190174
</widget>
191175
</item>
192176
</layout>
193177
</item>
178+
<item>
179+
<layout class="QHBoxLayout" name="mIdentifyModeHorizontalLayout">
180+
<item>
181+
<widget class="QLabel" name="label_4">
182+
<property name="text">
183+
<string>Mode</string>
184+
</property>
185+
</widget>
186+
</item>
187+
<item>
188+
<widget class="QComboBox" name="cmbIdentifyMode"/>
189+
</item>
190+
<item>
191+
<spacer name="horizontalSpacer_43">
192+
<property name="orientation">
193+
<enum>Qt::Horizontal</enum>
194+
</property>
195+
<property name="sizeHint" stdset="0">
196+
<size>
197+
<width>40</width>
198+
<height>20</height>
199+
</size>
200+
</property>
201+
</spacer>
202+
</item>
203+
<item>
204+
<widget class="QCheckBox" name="cbxAutoFeatureForm">
205+
<property name="text">
206+
<string>Auto open form</string>
207+
</property>
208+
</widget>
209+
</item>
210+
</layout>
211+
</item>
194212
</layout>
195213
</widget>
196214
<layoutdefault spacing="6" margin="11"/>
197215
<resources>
198216
<include location="../../images/images.qrc"/>
199217
</resources>
200-
<connections>
201-
<connection>
202-
<sender>buttonBox</sender>
203-
<signal>rejected()</signal>
204-
<receiver>QgsIdentifyResultsBase</receiver>
205-
<slot>reject()</slot>
206-
<hints>
207-
<hint type="sourcelabel">
208-
<x>261</x>
209-
<y>298</y>
210-
</hint>
211-
<hint type="destinationlabel">
212-
<x>204</x>
213-
<y>313</y>
214-
</hint>
215-
</hints>
216-
</connection>
217-
</connections>
218+
<connections/>
218219
</ui>

0 commit comments

Comments
 (0)