24 , mFeatureId( feature->id() )
25 , mOwnsFeature( false )
36 , mOwnsFeature( false )
41 void QgsActionMenu::init()
43 setTitle(
tr(
"&Actions" ) );
52 if ( !mFeature || !mFeature->
isValid() )
85 void QgsActionMenu::triggerAction()
90 QAction* action = qobject_cast<QAction*>( sender() );
94 if ( !action->data().isValid() || !action->data().canConvert<ActionData>() )
97 ActionData data = action->data().value<ActionData>();
99 if ( data.actionType ==
Invalid )
109 mActions->
doAction( data.actionId.id, *feature() );
113 void QgsActionMenu::reloadActions()
120 for (
int idx = 0; idx < mActions->
size(); ++idx )
124 QAction* action =
new QAction( qaction.icon(), qaction.name(), this );
125 action->setData( QVariant::fromValue<ActionData>( ActionData( idx, mFeatureId, mLayer ) ) );
126 action->setIcon( qaction.icon() );
129 if ( !qaction.runable() )
131 action->setEnabled(
false );
132 action->setToolTip(
tr(
"Not supported on your platform" ) );
136 action->setToolTip( qaction.action() );
138 connect( action, SIGNAL( triggered() ),
this, SLOT( triggerAction() ) );
144 if ( mapLayerActions.size() > 0 )
149 for (
int i = 0; i < mapLayerActions.size(); ++i )
152 QAction* action =
new QAction( qaction->icon(), qaction->text(), this );
153 action->setData( QVariant::fromValue<ActionData>( ActionData( qaction, mFeatureId, mLayer ) ) );
155 connect( action, SIGNAL( triggered() ),
this, SLOT( triggerAction() ) );