Skip to content
Permalink
Browse files

add copy and paste style actions to the layer node

  • Loading branch information
myarjunar authored and nyalldawson committed Aug 25, 2017
1 parent 3d3ff70 commit bdc3d366012b133d2a1152eb3c0438fad2c70621
Showing with 11 additions and 1 deletion.
  1. +4 −1 src/core/qgsdataitem.h
  2. +7 −0 src/providers/ows/qgsgeonodedataitems.cpp
@@ -141,7 +141,7 @@ class CORE_EXPORT QgsDataItem : public QObject
/** Returns the list of actions available for this item. This is usually used for the popup menu on right-clicking
* the item. Subclasses should override this to provide actions.
*/
virtual QList<QAction *> actions() { return QList<QAction *>(); }
virtual QList<QAction *> actions() { return mActions; }

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

void setActions( QList<QAction *> actions ) { mActions = actions; }

// deleteLater() items anc clear the vector
static void deleteLater( QVector<QgsDataItem *> &items );

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

public slots:

@@ -176,6 +176,12 @@ QVector<QgsDataItem *> QgsGeoNodeServiceItem::createChildren()
skipProvider = true;
}

// add new action menus to the layer item
QAction *actionCopyStyle = new QAction( tr( "Copy Style" ), this );
QAction *actionPasteStyle = new QAction( tr( "Paste Style" ), this );
QList<QAction *> actions;
actions << actionCopyStyle << actionPasteStyle;

Q_FOREACH ( QgsDataItem *item, serviceItems.keys() )
{
QString providerKey = serviceItems.value( item );
@@ -190,6 +196,7 @@ QVector<QgsDataItem *> QgsGeoNodeServiceItem::createChildren()
item->removeChildItem( subItem );
subItem->setParent( this );
replacePath( subItem, providerKey.toLower() + ":/", pathPrefix );
subItem->setActions( actions );
children.append( subItem );
}

0 comments on commit bdc3d36

Please sign in to comment.
You can’t perform that action at this time.