Skip to content

Commit 28ba4f6

Browse files
author
jef
committedJan 20, 2010
[FEATURE] identify tool update
- attribute form now non-modal in view mode (since r12796) - highlight disappear when window is deactivate or closed and reappears when reactivated. git-svn-id: http://svn.osgeo.org/qgis/trunk@12806 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent ac98204 commit 28ba4f6

File tree

3 files changed

+63
-9
lines changed

3 files changed

+63
-9
lines changed
 

‎src/app/qgsattributedialog.cpp

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "qgsuniquevaluerenderer.h"
2525
#include "qgssymbol.h"
2626
#include "qgsattributeeditor.h"
27+
#include "qgsrubberband.h"
2728

2829
#include "qgisapp.h"
2930

@@ -44,7 +45,8 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat
4445
: mDialog( 0 ),
4546
mSettingsPath( "/Windows/AttributeDialog/" ),
4647
mLayer( vl ),
47-
mpFeature( thepFeature )
48+
mpFeature( thepFeature ),
49+
mRubberBand( 0 )
4850
{
4951
if ( mpFeature == NULL || vl->dataProvider() == NULL )
5052
return;
@@ -237,6 +239,17 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat
237239

238240
QgsAttributeDialog::~QgsAttributeDialog()
239241
{
242+
if ( mRubberBand )
243+
{
244+
mRubberBand->hide();
245+
delete mRubberBand;
246+
}
247+
248+
if ( mDialog )
249+
{
250+
delete mDialog;
251+
}
252+
240253
saveGeometry();
241254
}
242255

@@ -275,12 +288,11 @@ int QgsAttributeDialog::exec()
275288

276289
void QgsAttributeDialog::show()
277290
{
278-
if ( mDialog )
279-
{
280-
mDialog->setAttribute( Qt::WA_DeleteOnClose );
281-
mDialog->show();
282-
mDialog = 0;
283-
}
291+
mDialog->setAttribute( Qt::WA_DeleteOnClose );
292+
mDialog->show();
293+
mDialog->raise();
294+
mDialog->activateWindow();
295+
mDialog->installEventFilter( this );
284296
}
285297

286298
void QgsAttributeDialog::saveGeometry()
@@ -301,12 +313,45 @@ void QgsAttributeDialog::restoreGeometry()
301313
}
302314
}
303315

316+
void QgsAttributeDialog::setHighlight( QgsRubberBand *rb )
317+
{
318+
if ( mRubberBand )
319+
{
320+
delete mRubberBand;
321+
}
322+
323+
mRubberBand = rb;
324+
}
325+
326+
304327
void QgsAttributeDialog::dialogDestroyed()
305328
{
306329
#if 0
307330
mLayer->setProperty( "featureForm.dialog", QVariant() );
308331
mLayer->setProperty( "featureForm.id", QVariant() );
309332
#endif
310333
QgisApp::instance()->runPythonString( QString( "del _qgis_featureform_%1" ).arg( mLayer->getLayerID() ) );
334+
311335
mDialog = NULL;
336+
deleteLater();
337+
}
338+
339+
bool QgsAttributeDialog::eventFilter( QObject *obj, QEvent *e )
340+
{
341+
if ( mRubberBand && obj == mDialog )
342+
{
343+
switch ( e->type() )
344+
{
345+
case QEvent::WindowActivate:
346+
mRubberBand->show();
347+
break;
348+
case QEvent::WindowDeactivate:
349+
mRubberBand->hide();
350+
break;
351+
default:
352+
break;
353+
}
354+
}
355+
356+
return false;
312357
}

‎src/app/qgsattributedialog.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class QgsFeature;
2525
class QLayout;
2626
class QgsField;
2727
class QgsVectorLayer;
28+
class QgsRubberBand;
2829

2930
class QgsAttributeDialog : public QObject
3031
{
@@ -45,6 +46,8 @@ class QgsAttributeDialog : public QObject
4546
*/
4647
void restoreGeometry();
4748

49+
void setHighlight( QgsRubberBand *rb );
50+
4851
QDialog *dialog() { return mDialog; }
4952

5053
public slots:
@@ -59,13 +62,15 @@ class QgsAttributeDialog : public QObject
5962
void dialogDestroyed();
6063

6164
private:
65+
bool eventFilter( QObject *obj, QEvent *event );
6266

6367
QDialog *mDialog;
6468
QString mSettingsPath;
6569
QList<QWidget *> mpWidgets;
6670
QList<int> mpIndizes;
6771
QgsVectorLayer *mLayer;
6872
QgsFeature *mpFeature;
73+
QgsRubberBand *mRubberBand;
6974
};
7075

7176
#endif

‎src/app/qgsidentifyresults.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,9 @@ void QgsIdentifyResults::show()
268268
QTreeWidgetItem *layItem = lstResults->topLevelItem( 0 );
269269
QTreeWidgetItem *featItem = layItem->child( 0 );
270270

271-
if ( lstResults->topLevelItemCount() == 1 && layItem->childCount() == 1 && QSettings().value( "/Map/identifyAutoFeatureForm", false ).toBool() )
271+
if ( lstResults->topLevelItemCount() == 1 &&
272+
layItem->childCount() == 1 &&
273+
QSettings().value( "/Map/identifyAutoFeatureForm", false ).toBool() )
272274
{
273275
QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( layItem->data( 0, Qt::UserRole ).value<QObject *>() );
274276
if ( layer )
@@ -682,7 +684,7 @@ void QgsIdentifyResults::highlightFeature( QTreeWidgetItem *item )
682684
int fid = featItem->data( 0, Qt::UserRole ).toInt();
683685

684686
QgsFeature feat;
685-
if ( ! layer->featureAtId( fid, feat, true, false ) )
687+
if ( !layer->featureAtId( fid, feat, true, false ) )
686688
{
687689
return;
688690
}
@@ -816,6 +818,8 @@ void QgsIdentifyResults::featureForm()
816818
}
817819
else
818820
{
821+
QgsRubberBand *rb = mRubberBands.take( featItem );
822+
ad->setHighlight( rb );
819823
ad->show();
820824
}
821825
}

0 commit comments

Comments
 (0)
Please sign in to comment.