@@ -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-
196180QgsIdentifyResultsFeatureItem::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
321304QgsIdentifyResultsDialog::~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-
709674void 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-
864820void 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
11641115void 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
12151161void QgsIdentifyResultsDialog::attributeValueChanged ( QgsFeatureId fid, int idx, const QVariant &val )
0 commit comments