Skip to content

Commit 7508fcc

Browse files
committed
Add switch for handling pasting WKT from clipboard
1 parent 226c006 commit 7508fcc

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/app/qgsclipboard.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ QgsClipboard::QgsClipboard()
3737
: QObject()
3838
, mFeatureClipboard()
3939
, mFeatureFields()
40+
, mUseSystemClipboard( false )
4041
{
41-
connect( QApplication::clipboard(), SIGNAL( dataChanged() ), this, SIGNAL( changed() ) );
42+
connect( QApplication::clipboard(), SIGNAL( dataChanged() ), this, SLOT( systemClipboardChanged() ) );
4243
}
4344

4445
QgsClipboard::~QgsClipboard()
@@ -58,6 +59,7 @@ void QgsClipboard::replaceWithCopyOf( QgsVectorLayer *src )
5859
QgsDebugMsg( "replaced QGis clipboard." );
5960

6061
setSystemClipboard();
62+
mUseSystemClipboard = false;
6163
emit changed();
6264
}
6365

@@ -68,6 +70,7 @@ void QgsClipboard::replaceWithCopyOf( QgsFeatureStore & featureStore )
6870
mFeatureClipboard = featureStore.features();
6971
mCRS = featureStore.crs();
7072
setSystemClipboard();
73+
mUseSystemClipboard = false;
7174
emit changed();
7275
}
7376

@@ -143,6 +146,9 @@ void QgsClipboard::setSystemClipboard()
143146
QgsFeatureList QgsClipboard::copyOf( const QgsFields &fields )
144147
{
145148
QgsDebugMsg( "returning clipboard." );
149+
if ( !mUseSystemClipboard )
150+
return mFeatureClipboard;
151+
146152
QClipboard *cb = QApplication::clipboard();
147153

148154
#ifndef Q_OS_WIN
@@ -193,6 +199,7 @@ void QgsClipboard::insert( QgsFeature& feature )
193199
mFeatureClipboard.push_back( feature );
194200

195201
QgsDebugMsg( "inserted " + feature.geometry()->exportToWkt() );
202+
mUseSystemClipboard = false;
196203
emit changed();
197204
}
198205

@@ -260,3 +267,9 @@ QByteArray QgsClipboard::data( const QString& mimeType )
260267
{
261268
return QApplication::clipboard()->mimeData()->data( mimeType );
262269
}
270+
271+
void QgsClipboard::systemClipboardChanged()
272+
{
273+
mUseSystemClipboard = true;
274+
emit changed();
275+
}

src/app/qgsclipboard.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ class APP_EXPORT QgsClipboard : public QObject
141141
*/
142142
const QgsFields &fields() { return mFeatureFields; }
143143

144+
private slots:
145+
146+
void systemClipboardChanged();
147+
144148
signals:
145149
/** Emitted when content changed */
146150
void changed();
@@ -158,6 +162,9 @@ class APP_EXPORT QgsClipboard : public QObject
158162
QgsFeatureList mFeatureClipboard;
159163
QgsFields mFeatureFields;
160164
QgsCoordinateReferenceSystem mCRS;
165+
166+
/** True when the data from the system clipboard should be read */
167+
bool mUseSystemClipboard;
161168
};
162169

163170
#endif

0 commit comments

Comments
 (0)