Skip to content
Permalink
Browse files

Fix #8590 - Copy and paste for rules

  • Loading branch information
NathanW2 committed Sep 12, 2013
1 parent 02ed712 commit 4a95d35606c087580f4737126b1a4c79e3361ea8
@@ -121,7 +121,6 @@ class GUI_EXPORT QgsGraduatedSymbolRendererV2Widget : public QgsRendererV2Widget
QgsSymbolV2* findSymbolForRange( double lowerBound, double upperBound, const QgsRangeList& ranges ) const;
void refreshSymbolView();


protected:
QgsGraduatedSymbolRendererV2* mRenderer;

@@ -27,6 +27,9 @@ QgsRendererV2Widget::QgsRendererV2Widget( QgsVectorLayer* layer, QgsStyleV2* sty
{
contextMenu = new QMenu( "Renderer Options " );

contextMenu->addAction( tr( "Copy" ), this, SLOT( copy() ) );
contextMenu->addAction( tr( "Paste" ), this, SLOT( paste() ) );

contextMenu->addAction( tr( "Change color" ), this, SLOT( changeSymbolColor( ) ) );
contextMenu->addAction( tr( "Change transparency" ), this, SLOT( changeSymbolTransparency() ) );
contextMenu->addAction( tr( "Change output unit" ), this, SLOT( changeSymbolUnit() ) );
@@ -71,6 +71,10 @@ class GUI_EXPORT QgsRendererV2Widget : public QWidget
void changeSymbolWidth();
/**Change marker sizes of selected symbols*/
void changeSymbolSize();

virtual void copy() {}
virtual void paste() {}

};


@@ -197,6 +197,8 @@ void QgsRuleBasedRendererV2Widget::currentRuleChanged( const QModelIndex& curren
#include "qgsexpressionbuilderdialog.h"
#include <QDialogButtonBox>
#include <QInputDialog>
#include <QKeyEvent>
#include <QClipboard>

void QgsRuleBasedRendererV2Widget::refineRule( int type )
{
@@ -403,6 +405,26 @@ void QgsRuleBasedRendererV2Widget::restoreSectionWidths()
head->resizeSection( 5, settings.value( path + QString::number( 5 ), 50 ).toInt() );
}

void QgsRuleBasedRendererV2Widget::copy()
{
QModelIndexList indexlist = viewRules->selectionModel()->selectedRows();
QgsDebugMsg(QString("%1").arg(indexlist.count()));

if ( indexlist.isEmpty() )
return;

QMimeData* mime = mModel->mimeData( indexlist );
QApplication::clipboard()->setMimeData(mime);
}

void QgsRuleBasedRendererV2Widget::paste()
{
const QMimeData* mime = QApplication::clipboard()->mimeData();
QModelIndex index = viewRules->selectionModel()->selectedRows().first();
mModel->dropMimeData( mime, Qt::CopyAction, index.row(), index.column(), index.parent() );
}


void QgsRuleBasedRendererV2Widget::countFeatures()
{
if ( !mLayer || !mRenderer || !mRenderer->rootRule() )
@@ -128,7 +128,6 @@ class GUI_EXPORT QgsRuleBasedRendererV2Widget : public QgsRendererV2Widget, priv
void restoreSectionWidths();

protected:

void refineRule( int type );
void refineRuleCategoriesGui( const QModelIndexList& index );
void refineRuleRangesGui( const QModelIndexList& index );
@@ -143,6 +142,10 @@ class GUI_EXPORT QgsRuleBasedRendererV2Widget : public QgsRendererV2Widget, priv
QgsRuleBasedRendererV2Model* mModel;

QMenu* mRefineMenu;

protected slots:
void copy();
void paste();
};

///////

0 comments on commit 4a95d35

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