Skip to content
Permalink
Browse files

Add switch for handling pasting WKT from clipboard

  • Loading branch information
NathanW2 committed Oct 26, 2013
1 parent 226c006 commit 7508fcc1ed40e641b4b25225cb180b17bc05be08
Showing with 21 additions and 1 deletion.
  1. +14 −1 src/app/qgsclipboard.cpp
  2. +7 −0 src/app/qgsclipboard.h
@@ -37,8 +37,9 @@ QgsClipboard::QgsClipboard()
: QObject()
, mFeatureClipboard()
, mFeatureFields()
, mUseSystemClipboard( false )
{
connect( QApplication::clipboard(), SIGNAL( dataChanged() ), this, SIGNAL( changed() ) );
connect( QApplication::clipboard(), SIGNAL( dataChanged() ), this, SLOT( systemClipboardChanged() ) );
}

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

setSystemClipboard();
mUseSystemClipboard = false;
emit changed();
}

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

@@ -143,6 +146,9 @@ void QgsClipboard::setSystemClipboard()
QgsFeatureList QgsClipboard::copyOf( const QgsFields &fields )
{
QgsDebugMsg( "returning clipboard." );
if ( !mUseSystemClipboard )
return mFeatureClipboard;

QClipboard *cb = QApplication::clipboard();

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

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

@@ -260,3 +267,9 @@ QByteArray QgsClipboard::data( const QString& mimeType )
{
return QApplication::clipboard()->mimeData()->data( mimeType );
}

void QgsClipboard::systemClipboardChanged()
{
mUseSystemClipboard = true;
emit changed();
}
@@ -141,6 +141,10 @@ class APP_EXPORT QgsClipboard : public QObject
*/
const QgsFields &fields() { return mFeatureFields; }

private slots:

void systemClipboardChanged();

signals:
/** Emitted when content changed */
void changed();
@@ -158,6 +162,9 @@ class APP_EXPORT QgsClipboard : public QObject
QgsFeatureList mFeatureClipboard;
QgsFields mFeatureFields;
QgsCoordinateReferenceSystem mCRS;

/** True when the data from the system clipboard should be read */
bool mUseSystemClipboard;
};

#endif

0 comments on commit 7508fcc

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