Skip to content
Permalink
Browse files

identify shows a non-modal feature form

  • Loading branch information
3nids committed Aug 18, 2014
1 parent 4588d9b commit bc187ba95309a8eee70e07070b412cb9e581c344
@@ -515,7 +515,7 @@ class QgisInterface : QObject
* @return true when dialog was accepted
* @note added in 1.6
*/
virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false ) = 0;
virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;

virtual QgsAttributeDialog* getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;

@@ -572,7 +572,7 @@ QAction *QgisAppInterface::actionQgisHomePage() { return qgis->actionQgisHomePag
QAction *QgisAppInterface::actionCheckQgisVersion() { return qgis->actionCheckQgisVersion(); }
QAction *QgisAppInterface::actionAbout() { return qgis->actionAbout(); }

bool QgisAppInterface::openFeatureForm( QgsVectorLayer *vlayer, QgsFeature &f, bool updateFeatureOnly )
bool QgisAppInterface::openFeatureForm( QgsVectorLayer *vlayer, QgsFeature &f, bool updateFeatureOnly, bool showModal )
{
Q_UNUSED( updateFeatureOnly );
if ( !vlayer )
@@ -581,11 +581,12 @@ bool QgisAppInterface::openFeatureForm( QgsVectorLayer *vlayer, QgsFeature &f, b
QgsFeatureAction action( tr( "Attributes changed" ), f, vlayer, -1, -1, QgisApp::instance() );
if ( vlayer->isEditable() )
{
return action.editFeature();
return action.editFeature( showModal );
}
else
{
return action.viewFeatureForm();
action.viewFeatureForm();
return true;
}
}

@@ -434,13 +434,14 @@ class APP_EXPORT QgisAppInterface : public QgisInterface

/**
* Open feature form
* returns true when dialog was accepted
* returns true when dialog was accepted (if shown modal, true otherwise)
* @param l vector layer
* @param f feature to show/modify
* @param updateFeatureOnly only update the feature update (don't change any attributes of the layer)
* @param showModal if true, will wait for the dialog to be executed (only shown otherwise)
* @note added in 1.6
*/
virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false );
virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false , bool showModal = true );

/**
* Returns a feature form for a given feature
@@ -102,49 +102,27 @@ bool QgsFeatureAction::viewFeatureForm( QgsHighlight *h )
return true;
}

bool QgsFeatureAction::editFeature()
bool QgsFeatureAction::editFeature( bool showModal )
{
bool res = false;

if ( !mLayer )
return res;
return false;

QgsAttributeDialog *dialog = newDialog( false );

if ( !mLayer->isEditable() )
if ( !mFeature.isValid() )
dialog->setIsAddDialog( true );

if ( showModal )
{
res = dialog->exec();
dialog->setAttribute( Qt::WA_DeleteOnClose );
return dialog->exec();
}
else
{
QgsAttributes src = mFeature.attributes();
if ( !mFeature.isValid() )
dialog->setIsAddDialog( true );

if ( dialog->exec() )
{
mLayer->beginEditCommand( text() );

const QgsAttributes &dst = mFeature.attributes();
for ( int i = 0; i < dst.count(); ++i )
{
if ( dst[i] != src[i] )
{
mLayer->changeAttributeValue( mFeature.id(), i, dst[i], src[i] );
}
}

mLayer->endEditCommand();
res = true;
}
else
{
res = false;
}
dialog->show();
}

delete dialog;
return res;
return true;
}

bool QgsFeatureAction::addFeature( const QgsAttributeMap& defaultAttributes )
@@ -39,7 +39,7 @@ class APP_EXPORT QgsFeatureAction : public QAction
public slots:
void execute();
bool viewFeatureForm( QgsHighlight *h = 0 );
bool editFeature();
bool editFeature( bool showModal = true );

/**
* Add a new feature to the layer.
@@ -1585,10 +1585,7 @@ void QgsIdentifyResultsDialog::featureForm()
QgsFeatureAction action( tr( "Attributes changed" ), f, vlayer, idx, -1, this );
if ( vlayer->isEditable() )
{
if ( action.editFeature() )
{
mCanvas->refresh();
}
action.editFeature( false );
}
else
{
@@ -570,7 +570,7 @@ class GUI_EXPORT QgisInterface : public QObject
* @return true when dialog was accepted
* @note added in 1.6
*/
virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false ) = 0;
virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;

/**
* Returns a feature form for a given feature
@@ -230,6 +230,8 @@ bool QgsAttributeForm::save()

emit featureSaved( updatedFeature );

mLayer->triggerRepaint();

mIsSaving = false;

return success;

0 comments on commit bc187ba

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