Skip to content

Commit

Permalink
fix #4478
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Dec 23, 2011
1 parent 07b5640 commit 9461465
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/app/attributetable/qgsattributetabledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ void QgsAttributeTableDialog::addFeature()
return;

QgsFeature f;
QgsFeatureAction action( tr( "Geometryless feature added" ), f, mLayer, -1, this );
QgsFeatureAction action( tr( "Geometryless feature added" ), f, mLayer, -1, -1, this );
if ( action.addFeature() )
{
mModel->reload( mModel->index( 0, 0 ), mModel->index( mModel->rowCount(), mModel->columnCount() ) );
Expand Down Expand Up @@ -839,7 +839,7 @@ void QgsAttributeTableAction::featureForm()
{
QgsFeature f = mModel->feature( mFieldIdx );

QgsFeatureAction action( tr( "Attributes changed" ), f, mModel->layer(), -1, this );
QgsFeatureAction action( tr( "Attributes changed" ), f, mModel->layer(), -1, -1, this );
if ( mModel->layer()->isEditable() )
action.editFeature();
else
Expand Down
4 changes: 2 additions & 2 deletions src/app/gps/qgsgpsinformationwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ void QgsGPSInformationWidget::on_mBtnCloseFeature_clicked( )

f->setGeometryAndOwnership( &wkb[0], size );

QgsFeatureAction action( tr( "Feature added" ), *f, vlayer, -1, this );
QgsFeatureAction action( tr( "Feature added" ), *f, vlayer, -1, -1, this );
if ( action.addFeature() )
{
if ( mCbxAutoCommit->isChecked() )
Expand Down Expand Up @@ -1060,7 +1060,7 @@ void QgsGPSInformationWidget::on_mBtnCloseFeature_clicked( )
return; //unknown wkbtype
} // layerWKBType == QGis::WKBPolygon

QgsFeatureAction action( tr( "Feature added" ), *f, vlayer, -1, this );
QgsFeatureAction action( tr( "Feature added" ), *f, vlayer, -1, -1, this );
if ( action.addFeature() )
{
if ( mCbxAutoCommit->isChecked() )
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisappinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,6 @@ bool QgisAppInterface::openFeatureForm( QgsVectorLayer *vlayer, QgsFeature &f, b
if ( !vlayer )
return false;

QgsFeatureAction action( tr( "Attributes changed" ), f, vlayer, -1, QgisApp::instance() );
QgsFeatureAction action( tr( "Attributes changed" ), f, vlayer, -1, -1, QgisApp::instance() );
return action.editFeature();
}
5 changes: 3 additions & 2 deletions src/app/qgsfeatureaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
#include <QPushButton>
#include <QSettings>

QgsFeatureAction::QgsFeatureAction( const QString &name, QgsFeature &f, QgsVectorLayer *layer, int action, QObject *parent )
QgsFeatureAction::QgsFeatureAction( const QString &name, QgsFeature &f, QgsVectorLayer *layer, int action, int defaultAttr, QObject *parent )
: QAction( name, parent )
, mLayer( layer )
, mFeature( f )
, mAction( action )
, mIdx( defaultAttr )
{
}

Expand Down Expand Up @@ -58,7 +59,7 @@ QgsAttributeDialog *QgsFeatureAction::newDialog( bool cloneFeature )
if ( !action.runable() )
continue;

QgsFeatureAction *a = new QgsFeatureAction( action.name(), *f, mLayer, i, dialog->dialog() );
QgsFeatureAction *a = new QgsFeatureAction( action.name(), *f, mLayer, i, -1, dialog->dialog() );
dialog->dialog()->addAction( a );
connect( a, SIGNAL( triggered() ), a, SLOT( execute() ) );

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsfeatureaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class QgsFeatureAction : public QAction
Q_OBJECT

public:
QgsFeatureAction( const QString &name, QgsFeature &f, QgsVectorLayer *vl, int action, QObject *parent );
QgsFeatureAction( const QString &name, QgsFeature &f, QgsVectorLayer *vl, int action, int defaultAttr, QObject *parent );

public slots:
void execute();
Expand Down
11 changes: 8 additions & 3 deletions src/app/qgsidentifyresults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ void QgsIdentifyResults::contextMenuEvent( QContextMenuEvent* event )

mActionPopup = new QMenu();

int idx = 0;
QTreeWidgetItem *featItem = featureItem( item );
if ( featItem )
{
Expand All @@ -440,6 +441,11 @@ void QgsIdentifyResults::contextMenuEvent( QContextMenuEvent* event )
mActionPopup->addAction( tr( "Copy attribute value" ), this, SLOT( copyAttributeValue() ) );
mActionPopup->addAction( tr( "Copy feature attributes" ), this, SLOT( copyFeatureAttributes() ) );
mActionPopup->addSeparator();

if ( item->parent() == featItem && item->childCount() == 0 )
{
idx = item->data( 0, Qt::UserRole + 1 ).toInt();
}
}

mActionPopup->addAction( tr( "Clear results" ), this, SLOT( clear() ) );
Expand All @@ -465,8 +471,7 @@ void QgsIdentifyResults::contextMenuEvent( QContextMenuEvent* event )
if ( !action.runable() )
continue;

int idx = featItem->data( 0, Qt::UserRole + 1 ).toInt();
QgsFeatureAction *a = new QgsFeatureAction( action.name(), mFeatures[ idx ], vlayer, i, this );
QgsFeatureAction *a = new QgsFeatureAction( action.name(), mFeatures[ idx ], vlayer, i, idx, this );
mActionPopup->addAction( QgisApp::getThemeIcon( "/mAction.png" ), action.name(), a, SLOT( execute() ) );
}
}
Expand Down Expand Up @@ -882,7 +887,7 @@ void QgsIdentifyResults::featureForm()
if ( !vlayer->featureAtId( fid, f ) )
return;

QgsFeatureAction action( tr( "Attribute changes" ), f, vlayer, idx, this );
QgsFeatureAction action( tr( "Attribute changes" ), f, vlayer, idx, -1, this );
if ( vlayer->isEditable() )
{
if ( action.editFeature() )
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptooladdfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ QgsMapToolAddFeature::~QgsMapToolAddFeature()

bool QgsMapToolAddFeature::addFeature( QgsVectorLayer *vlayer, QgsFeature *f )
{
QgsFeatureAction action( tr( "add feature" ), *f, vlayer, -1, this );
QgsFeatureAction action( tr( "add feature" ), *f, vlayer, -1, -1, this );
return action.addFeature();
}

Expand Down
1 change: 0 additions & 1 deletion src/core/qgsattributeaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ QString QgsAttributeAction::expandAction( QString action, const QgsAttributeMap
}
}


return expanded_action;
}

Expand Down

0 comments on commit 9461465

Please sign in to comment.