Skip to content

Commit bdc3d36

Browse files
myarjunarnyalldawson
authored andcommitted
add copy and paste style actions to the layer node
1 parent 3d3ff70 commit bdc3d36

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/core/qgsdataitem.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class CORE_EXPORT QgsDataItem : public QObject
141141
/** Returns the list of actions available for this item. This is usually used for the popup menu on right-clicking
142142
* the item. Subclasses should override this to provide actions.
143143
*/
144-
virtual QList<QAction *> actions() { return QList<QAction *>(); }
144+
virtual QList<QAction *> actions() { return mActions; }
145145

146146
/** Returns whether the item accepts drag and dropped layers - e.g. for importing a dataset to a provider.
147147
* Subclasses should override this and handleDrop() to accept dropped layers.
@@ -228,6 +228,8 @@ class CORE_EXPORT QgsDataItem : public QObject
228228
void setToolTip( const QString &msg ) { mToolTip = msg; }
229229
QString toolTip() const { return mToolTip; }
230230

231+
void setActions( QList<QAction *> actions ) { mActions = actions; }
232+
231233
// deleteLater() items anc clear the vector
232234
static void deleteLater( QVector<QgsDataItem *> &items );
233235

@@ -265,6 +267,7 @@ class CORE_EXPORT QgsDataItem : public QObject
265267
QString mIconName;
266268
QIcon mIcon;
267269
QMap<QString, QIcon> mIconMap;
270+
QList<QAction *> mActions;
268271

269272
public slots:
270273

src/providers/ows/qgsgeonodedataitems.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,12 @@ QVector<QgsDataItem *> QgsGeoNodeServiceItem::createChildren()
176176
skipProvider = true;
177177
}
178178

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+
179185
Q_FOREACH ( QgsDataItem *item, serviceItems.keys() )
180186
{
181187
QString providerKey = serviceItems.value( item );
@@ -190,6 +196,7 @@ QVector<QgsDataItem *> QgsGeoNodeServiceItem::createChildren()
190196
item->removeChildItem( subItem );
191197
subItem->setParent( this );
192198
replacePath( subItem, providerKey.toLower() + ":/", pathPrefix );
199+
subItem->setActions( actions );
193200
children.append( subItem );
194201
}
195202

0 commit comments

Comments
 (0)