Skip to content

Commit ea2a434

Browse files
jef-nalexbruy
authored andcommittedDec 25, 2011
fix #4478
1 parent ded240e commit ea2a434

File tree

8 files changed

+16
-11
lines changed

8 files changed

+16
-11
lines changed
 

‎src/app/attributetable/qgsattributetabledialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ void QgsAttributeTableDialog::addFeature()
815815
return;
816816

817817
QgsFeature f;
818-
QgsFeatureAction action( tr( "Geometryless feature added" ), f, mLayer, -1, this );
818+
QgsFeatureAction action( tr( "Geometryless feature added" ), f, mLayer, -1, -1, this );
819819
if ( action.addFeature() )
820820
{
821821
mModel->reload( mModel->index( 0, 0 ), mModel->index( mModel->rowCount(), mModel->columnCount() ) );

‎src/app/gps/qgsgpsinformationwidget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ void QgsGPSInformationWidget::on_mBtnCloseFeature_clicked( )
672672

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

675-
QgsFeatureAction action( tr( "Feature added" ), *f, vlayer, -1, this );
675+
QgsFeatureAction action( tr( "Feature added" ), *f, vlayer, -1, -1, this );
676676
if ( action.addFeature() )
677677
mpCanvas->refresh();
678678

@@ -784,7 +784,7 @@ void QgsGPSInformationWidget::on_mBtnCloseFeature_clicked( )
784784
return; //unknown wkbtype
785785
}
786786

787-
QgsFeatureAction action( tr( "Feature added" ), *f, vlayer, -1, this );
787+
QgsFeatureAction action( tr( "Feature added" ), *f, vlayer, -1, -1, this );
788788
if ( action.addFeature() )
789789
mpCanvas->refresh();
790790

‎src/app/qgisappinterface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,6 @@ bool QgisAppInterface::openFeatureForm( QgsVectorLayer *vlayer, QgsFeature &f, b
407407
if ( !vlayer )
408408
return false;
409409

410-
QgsFeatureAction action( tr( "Attributes changed" ), f, vlayer, -1, QgisApp::instance() );
410+
QgsFeatureAction action( tr( "Attributes changed" ), f, vlayer, -1, -1, QgisApp::instance() );
411411
return action.editFeature();
412412
}

‎src/app/qgsfeatureaction.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@
2626
#include <QPushButton>
2727
#include <QSettings>
2828

29-
QgsFeatureAction::QgsFeatureAction( const QString &name, QgsFeature &f, QgsVectorLayer *layer, int action, QObject *parent )
29+
QgsFeatureAction::QgsFeatureAction( const QString &name, QgsFeature &f, QgsVectorLayer *layer, int action, int defaultAttr, QObject *parent )
3030
: QAction( name, parent )
3131
, mLayer( layer )
3232
, mFeature( f )
3333
, mAction( action )
34+
, mIdx( defaultAttr )
3435
{
3536
}
3637

@@ -59,7 +60,7 @@ QgsAttributeDialog *QgsFeatureAction::newDialog( bool cloneFeature )
5960
if ( !action.runable() )
6061
continue;
6162

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

‎src/app/qgsfeatureaction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class QgsFeatureAction : public QAction
3434
Q_OBJECT
3535

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

3939
public slots:
4040
void execute();

‎src/app/qgsidentifyresults.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ void QgsIdentifyResults::contextMenuEvent( QContextMenuEvent* event )
418418
if ( !item )
419419
return;
420420

421+
int idx = 0;
421422
QgsVectorLayer *vlayer = vectorLayer( item );
422423
if ( vlayer == 0 )
423424
return;
@@ -438,6 +439,10 @@ void QgsIdentifyResults::contextMenuEvent( QContextMenuEvent* event )
438439
mActionPopup->addAction( tr( "Copy attribute value" ), this, SLOT( copyAttributeValue() ) );
439440
mActionPopup->addAction( tr( "Copy feature attributes" ), this, SLOT( copyFeatureAttributes() ) );
440441
mActionPopup->addSeparator();
442+
if ( item->parent() == featItem && item->childCount() == 0 )
443+
{
444+
idx = item->data( 0, Qt::UserRole + 1 ).toInt();
445+
}
441446
}
442447

443448
mActionPopup->addAction( tr( "Clear results" ), this, SLOT( clear() ) );
@@ -464,7 +469,7 @@ void QgsIdentifyResults::contextMenuEvent( QContextMenuEvent* event )
464469
continue;
465470

466471
int idx = featItem->data( 0, Qt::UserRole + 1 ).toInt();
467-
QgsFeatureAction *a = new QgsFeatureAction( action.name(), mFeatures[ idx ], vlayer, i, this );
472+
QgsFeatureAction *a = new QgsFeatureAction( action.name(), mFeatures[ idx ], vlayer, i, idx, this );
468473
mActionPopup->addAction( QgisApp::getThemeIcon( "/mAction.png" ), action.name(), a, SLOT( execute() ) );
469474
}
470475
}
@@ -877,7 +882,7 @@ void QgsIdentifyResults::featureForm()
877882
if ( !vlayer->featureAtId( fid, f ) )
878883
return;
879884

880-
QgsFeatureAction action( tr( "Attribute changes" ), f, vlayer, idx, this );
885+
QgsFeatureAction action( tr( "Attribute changes" ), f, vlayer, idx, -1, this );
881886
if ( vlayer->isEditable() )
882887
{
883888
if ( action.editFeature() )

‎src/app/qgsmaptooladdfeature.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ QgsMapToolAddFeature::~QgsMapToolAddFeature()
4343

4444
bool QgsMapToolAddFeature::addFeature( QgsVectorLayer *vlayer, QgsFeature *f )
4545
{
46-
QgsFeatureAction action( tr( "add feature" ), *f, vlayer, -1, this );
46+
QgsFeatureAction action( tr( "add feature" ), *f, vlayer, -1, -1, this );
4747
return action.addFeature();
4848
}
4949

‎src/core/qgsattributeaction.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ QString QgsAttributeAction::expandAction( QString action, const QgsAttributeMap
127127
}
128128
}
129129

130-
131130
return expanded_action;
132131
}
133132

0 commit comments

Comments
 (0)
Please sign in to comment.