File tree 2 files changed +11
-1
lines changed
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -141,7 +141,7 @@ class CORE_EXPORT QgsDataItem : public QObject
141
141
/* * Returns the list of actions available for this item. This is usually used for the popup menu on right-clicking
142
142
* the item. Subclasses should override this to provide actions.
143
143
*/
144
- virtual QList<QAction *> actions () { return QList<QAction *>() ; }
144
+ virtual QList<QAction *> actions () { return mActions ; }
145
145
146
146
/* * Returns whether the item accepts drag and dropped layers - e.g. for importing a dataset to a provider.
147
147
* Subclasses should override this and handleDrop() to accept dropped layers.
@@ -228,6 +228,8 @@ class CORE_EXPORT QgsDataItem : public QObject
228
228
void setToolTip ( const QString &msg ) { mToolTip = msg; }
229
229
QString toolTip () const { return mToolTip ; }
230
230
231
+ void setActions ( QList<QAction *> actions ) { mActions = actions; }
232
+
231
233
// deleteLater() items anc clear the vector
232
234
static void deleteLater ( QVector<QgsDataItem *> &items );
233
235
@@ -265,6 +267,7 @@ class CORE_EXPORT QgsDataItem : public QObject
265
267
QString mIconName ;
266
268
QIcon mIcon ;
267
269
QMap<QString, QIcon> mIconMap ;
270
+ QList<QAction *> mActions ;
268
271
269
272
public slots:
270
273
Original file line number Diff line number Diff line change @@ -176,6 +176,12 @@ QVector<QgsDataItem *> QgsGeoNodeServiceItem::createChildren()
176
176
skipProvider = true ;
177
177
}
178
178
179
+ // add new action menus to the layer item
180
+ QAction *actionCopyStyle = new QAction ( tr ( " Copy Style" ), this );
181
+ QAction *actionPasteStyle = new QAction ( tr ( " Paste Style" ), this );
182
+ QList<QAction *> actions;
183
+ actions << actionCopyStyle << actionPasteStyle;
184
+
179
185
Q_FOREACH ( QgsDataItem *item, serviceItems.keys () )
180
186
{
181
187
QString providerKey = serviceItems.value ( item );
@@ -190,6 +196,7 @@ QVector<QgsDataItem *> QgsGeoNodeServiceItem::createChildren()
190
196
item->removeChildItem ( subItem );
191
197
subItem->setParent ( this );
192
198
replacePath ( subItem, providerKey.toLower () + " :/" , pathPrefix );
199
+ subItem->setActions ( actions );
193
200
children.append ( subItem );
194
201
}
195
202
You can’t perform that action at this time.
0 commit comments