Skip to content

Commit

Permalink
Add switch for handling pasting WKT from clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Oct 26, 2013
1 parent 226c006 commit 7508fcc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/app/qgsclipboard.cpp
Expand Up @@ -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()
Expand All @@ -58,6 +59,7 @@ void QgsClipboard::replaceWithCopyOf( QgsVectorLayer *src )
QgsDebugMsg( "replaced QGis clipboard." );

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

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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -193,6 +199,7 @@ void QgsClipboard::insert( QgsFeature& feature )
mFeatureClipboard.push_back( feature );

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

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

void QgsClipboard::systemClipboardChanged()
{
mUseSystemClipboard = true;
emit changed();
}
7 changes: 7 additions & 0 deletions src/app/qgsclipboard.h
Expand Up @@ -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();
Expand All @@ -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.