Skip to content

Commit

Permalink
[FEATURE] identify tool update
Browse files Browse the repository at this point in the history
- 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/qgis@12806 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Jan 20, 2010
1 parent 9320cee commit ee4bd0f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 9 deletions.
59 changes: 52 additions & 7 deletions src/app/qgsattributedialog.cpp
Expand Up @@ -24,6 +24,7 @@
#include "qgsuniquevaluerenderer.h"
#include "qgssymbol.h"
#include "qgsattributeeditor.h"
#include "qgsrubberband.h"

#include "qgisapp.h"

Expand All @@ -44,7 +45,8 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat
: mDialog( 0 ),
mSettingsPath( "/Windows/AttributeDialog/" ),
mLayer( vl ),
mpFeature( thepFeature )
mpFeature( thepFeature ),
mRubberBand( 0 )
{
if ( mpFeature == NULL || vl->dataProvider() == NULL )
return;
Expand Down Expand Up @@ -237,6 +239,17 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat

QgsAttributeDialog::~QgsAttributeDialog()
{
if ( mRubberBand )
{
mRubberBand->hide();
delete mRubberBand;
}

if ( mDialog )
{
delete mDialog;
}

saveGeometry();
}

Expand Down Expand Up @@ -275,12 +288,11 @@ int QgsAttributeDialog::exec()

void QgsAttributeDialog::show()
{
if ( mDialog )
{
mDialog->setAttribute( Qt::WA_DeleteOnClose );
mDialog->show();
mDialog = 0;
}
mDialog->setAttribute( Qt::WA_DeleteOnClose );
mDialog->show();
mDialog->raise();
mDialog->activateWindow();
mDialog->installEventFilter( this );
}

void QgsAttributeDialog::saveGeometry()
Expand All @@ -301,12 +313,45 @@ void QgsAttributeDialog::restoreGeometry()
}
}

void QgsAttributeDialog::setHighlight( QgsRubberBand *rb )
{
if ( mRubberBand )
{
delete mRubberBand;
}

mRubberBand = rb;
}


void QgsAttributeDialog::dialogDestroyed()
{
#if 0
mLayer->setProperty( "featureForm.dialog", QVariant() );
mLayer->setProperty( "featureForm.id", QVariant() );
#endif
QgisApp::instance()->runPythonString( QString( "del _qgis_featureform_%1" ).arg( mLayer->getLayerID() ) );

mDialog = NULL;
deleteLater();
}

bool QgsAttributeDialog::eventFilter( QObject *obj, QEvent *e )
{
if ( mRubberBand && obj == mDialog )
{
switch ( e->type() )
{
case QEvent::WindowActivate:
mRubberBand->show();
break;
case QEvent::WindowDeactivate:
mRubberBand->hide();
break;
default:
break;
}
}

return false;
}
5 changes: 5 additions & 0 deletions src/app/qgsattributedialog.h
Expand Up @@ -25,6 +25,7 @@ class QgsFeature;
class QLayout;
class QgsField;
class QgsVectorLayer;
class QgsRubberBand;

class QgsAttributeDialog : public QObject
{
Expand All @@ -45,6 +46,8 @@ class QgsAttributeDialog : public QObject
*/
void restoreGeometry();

void setHighlight( QgsRubberBand *rb );

QDialog *dialog() { return mDialog; }

public slots:
Expand All @@ -59,13 +62,15 @@ class QgsAttributeDialog : public QObject
void dialogDestroyed();

private:
bool eventFilter( QObject *obj, QEvent *event );

QDialog *mDialog;
QString mSettingsPath;
QList<QWidget *> mpWidgets;
QList<int> mpIndizes;
QgsVectorLayer *mLayer;
QgsFeature *mpFeature;
QgsRubberBand *mRubberBand;
};

#endif
8 changes: 6 additions & 2 deletions src/app/qgsidentifyresults.cpp
Expand Up @@ -268,7 +268,9 @@ void QgsIdentifyResults::show()
QTreeWidgetItem *layItem = lstResults->topLevelItem( 0 );
QTreeWidgetItem *featItem = layItem->child( 0 );

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

QgsFeature feat;
if ( ! layer->featureAtId( fid, feat, true, false ) )
if ( !layer->featureAtId( fid, feat, true, false ) )
{
return;
}
Expand Down Expand Up @@ -816,6 +818,8 @@ void QgsIdentifyResults::featureForm()
}
else
{
QgsRubberBand *rb = mRubberBands.take( featItem );
ad->setHighlight( rb );
ad->show();
}
}
Expand Down

0 comments on commit ee4bd0f

Please sign in to comment.