Skip to content

Commit 0a3313d

Browse files
committedSep 5, 2013
added change signal to clipboard
1 parent 250df51 commit 0a3313d

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed
 

‎src/app/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ SET (QGIS_APP_MOC_HDRS
171171
qgsattributetabledialog.h
172172
qgsbookmarks.h
173173
qgsbrowserdockwidget.h
174+
qgsclipboard.h
174175
qgsconfigureshortcutsdialog.h
175176
qgscustomization.h
176177
qgscustomprojectiondialog.h

‎src/app/qgisapp.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
573573
mLogDock->hide();
574574

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

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

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

55005500
// Test for feature support in this layer
55015501
clipboard()->replaceWithCopyOf( selectionVectorLayer );
5502-
activateDeactivateLayerRelatedActions( activeLayer() );
55035502
}
55045503

5504+
void QgisApp::clipboardChanged()
5505+
{
5506+
activateDeactivateLayerRelatedActions( activeLayer() );
5507+
}
55055508

55065509
void QgisApp::editPaste( QgsMapLayer *destinationLayer )
55075510
{

‎src/app/qgisapp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,8 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
11291129
void osmImportDialog();
11301130
void osmExportDialog();
11311131

1132+
void clipboardChanged();
1133+
11321134
signals:
11331135
/** emitted when a key is pressed and we want non widget sublasses to be able
11341136
to pick up on this (e.g. maplayer) */

‎src/app/qgsclipboard.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <fstream>
1919

2020
#include <QApplication>
21+
#include <QObject>
2122
#include <QString>
2223
#include <QStringList>
2324
#include <QClipboard>
@@ -33,7 +34,8 @@
3334
#include "qgsvectorlayer.h"
3435

3536
QgsClipboard::QgsClipboard()
36-
: mFeatureClipboard()
37+
: QObject()
38+
, mFeatureClipboard()
3739
, mFeatureFields()
3840
{
3941
}
@@ -55,6 +57,7 @@ void QgsClipboard::replaceWithCopyOf( QgsVectorLayer *src )
5557
QgsDebugMsg( "replaced QGis clipboard." );
5658

5759
setSystemClipboard();
60+
emit changed();
5861
}
5962

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

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

151155
QgsDebugMsg( "cleared clipboard." );
156+
emit changed();
152157
}
153158

154159
void QgsClipboard::insert( QgsFeature& feature )
155160
{
156161
mFeatureClipboard.push_back( feature );
157162

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

161167
bool QgsClipboard::empty()

‎src/app/qgsclipboard.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <QList>
2222
#include <QMap>
23+
#include <QObject>
2324

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

52-
class QgsClipboard
53+
class QgsClipboard : public QObject
5354
{
55+
Q_OBJECT
5456
public:
5557
/**
5658
* Constructor for the clipboard.
@@ -139,6 +141,10 @@ class QgsClipboard
139141
*/
140142
const QgsFields &fields() { return mFeatureFields; }
141143

144+
signals:
145+
/** Emited when content changed */
146+
void changed();
147+
142148
private:
143149
/*
144150
* Set system clipboard from previously set features.

0 commit comments

Comments
 (0)
Please sign in to comment.