Skip to content
Permalink
Browse files

[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
  • Loading branch information
jef
jef committed Jan 20, 2010
1 parent ac98204 commit 28ba4f63d6dc94784a45f9757038e80c9c326b8f
Showing with 63 additions and 9 deletions.
  1. +52 −7 src/app/qgsattributedialog.cpp
  2. +5 −0 src/app/qgsattributedialog.h
  3. +6 −2 src/app/qgsidentifyresults.cpp
@@ -24,6 +24,7 @@
#include "qgsuniquevaluerenderer.h"
#include "qgssymbol.h"
#include "qgsattributeeditor.h"
#include "qgsrubberband.h"

#include "qgisapp.h"

@@ -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;
@@ -237,6 +239,17 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat

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

if ( mDialog )
{
delete mDialog;
}

saveGeometry();
}

@@ -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()
@@ -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;
}
@@ -25,6 +25,7 @@ class QgsFeature;
class QLayout;
class QgsField;
class QgsVectorLayer;
class QgsRubberBand;

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

void setHighlight( QgsRubberBand *rb );

QDialog *dialog() { return mDialog; }

public slots:
@@ -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
@@ -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 )
@@ -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;
}
@@ -816,6 +818,8 @@ void QgsIdentifyResults::featureForm()
}
else
{
QgsRubberBand *rb = mRubberBands.take( featItem );
ad->setHighlight( rb );
ad->show();
}
}

0 comments on commit 28ba4f6

Please sign in to comment.
You can’t perform that action at this time.