Skip to content
Permalink
Browse files

added change signal to clipboard

  • Loading branch information
blazek committed Sep 5, 2013
1 parent 250df51 commit 0a3313d317a7f2f1c48cf4ed2dc6faa26e23d9b7
Showing with 22 additions and 4 deletions.
  1. +1 −0 src/app/CMakeLists.txt
  2. +5 −2 src/app/qgisapp.cpp
  3. +2 −0 src/app/qgisapp.h
  4. +7 −1 src/app/qgsclipboard.cpp
  5. +7 −1 src/app/qgsclipboard.h
@@ -171,6 +171,7 @@ SET (QGIS_APP_MOC_HDRS
qgsattributetabledialog.h
qgsbookmarks.h
qgsbrowserdockwidget.h
qgsclipboard.h
qgsconfigureshortcutsdialog.h
qgscustomization.h
qgscustomprojectiondialog.h
@@ -573,6 +573,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
mLogDock->hide();

mInternalClipboard = new QgsClipboard; // create clipboard
connect( mInternalClipboard, SIGNAL( changed() ), this, SLOT( clipboardChanged() ) );
mQgisInterface = new QgisAppInterface( this ); // create the interfce

#ifdef Q_WS_MAC
@@ -5483,7 +5484,6 @@ void QgisApp::editCut( QgsMapLayer * layerContainingSelection )
selectionVectorLayer->beginEditCommand( tr( "Features cut" ) );
selectionVectorLayer->deleteSelectedFeatures();
selectionVectorLayer->endEditCommand();
activateDeactivateLayerRelatedActions( activeLayer() );
}

void QgisApp::editCopy( QgsMapLayer * layerContainingSelection )
@@ -5499,9 +5499,12 @@ void QgisApp::editCopy( QgsMapLayer * layerContainingSelection )

// Test for feature support in this layer
clipboard()->replaceWithCopyOf( selectionVectorLayer );
activateDeactivateLayerRelatedActions( activeLayer() );
}

void QgisApp::clipboardChanged()
{
activateDeactivateLayerRelatedActions( activeLayer() );
}

void QgisApp::editPaste( QgsMapLayer *destinationLayer )
{
@@ -1129,6 +1129,8 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
void osmImportDialog();
void osmExportDialog();

void clipboardChanged();

signals:
/** emitted when a key is pressed and we want non widget sublasses to be able
to pick up on this (e.g. maplayer) */
@@ -18,6 +18,7 @@
#include <fstream>

#include <QApplication>
#include <QObject>
#include <QString>
#include <QStringList>
#include <QClipboard>
@@ -33,7 +34,8 @@
#include "qgsvectorlayer.h"

QgsClipboard::QgsClipboard()
: mFeatureClipboard()
: QObject()
, mFeatureClipboard()
, mFeatureFields()
{
}
@@ -55,6 +57,7 @@ void QgsClipboard::replaceWithCopyOf( QgsVectorLayer *src )
QgsDebugMsg( "replaced QGis clipboard." );

setSystemClipboard();
emit changed();
}

void QgsClipboard::replaceWithCopyOf( QgsFeatureStore & featureStore )
@@ -64,6 +67,7 @@ void QgsClipboard::replaceWithCopyOf( QgsFeatureStore & featureStore )
mFeatureClipboard = featureStore.features();
mCRS = featureStore.crs();
setSystemClipboard();
emit changed();
}

void QgsClipboard::setSystemClipboard()
@@ -149,13 +153,15 @@ void QgsClipboard::clear()
mFeatureClipboard.clear();

QgsDebugMsg( "cleared clipboard." );
emit changed();
}

void QgsClipboard::insert( QgsFeature& feature )
{
mFeatureClipboard.push_back( feature );

QgsDebugMsg( "inserted " + feature.geometry()->exportToWkt() );
emit changed();
}

bool QgsClipboard::empty()
@@ -20,6 +20,7 @@

#include <QList>
#include <QMap>
#include <QObject>

#include "qgsfield.h"
#include "qgsfeature.h"
@@ -49,8 +50,9 @@ class QgsVectorLayer;
*/
#define QGSCLIPBOARD_STYLE_MIME "application/qgis.style"

class QgsClipboard
class QgsClipboard : public QObject
{
Q_OBJECT
public:
/**
* Constructor for the clipboard.
@@ -139,6 +141,10 @@ class QgsClipboard
*/
const QgsFields &fields() { return mFeatureFields; }

signals:
/** Emited when content changed */
void changed();

private:
/*
* Set system clipboard from previously set features.

0 comments on commit 0a3313d

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