Skip to content
Permalink
Browse files

Fix pasting features to new layer doesn't paste fields

Fixes #17702
  • Loading branch information
nyalldawson committed Jan 3, 2018
1 parent 611ae95 commit 7febd1e461359e819ede33f54f1bdca9970f96f9
Showing with 24 additions and 1 deletion.
  1. +20 −0 src/app/qgsclipboard.cpp
  2. +4 −1 src/app/qgsclipboard.h
@@ -148,6 +148,12 @@ QString QgsClipboard::generateClipboardText() const

void QgsClipboard::setSystemClipboard()
{
// avoid overwriting internal clipboard - note that on Windows, the call to QClipboard::setText
// below doesn't immediately trigger QClipboard::dataChanged, and accordingly the call to
// systemClipboardChanged() is delayed. So by setting mIgnoreNextSystemClipboardChange we indicate
// that just the next call to systemClipboardChanged() should be ignored
mIgnoreNextSystemClipboardChange = true;

QString textCopy = generateClipboardText();

QClipboard *cb = QApplication::clipboard();
@@ -323,8 +329,22 @@ QByteArray QgsClipboard::data( const QString &mimeType ) const
return QApplication::clipboard()->mimeData()->data( mimeType );
}

QgsFields QgsClipboard::fields() const
{
if ( !mUseSystemClipboard )
return mFeatureFields;
else
return retrieveFields();
}

void QgsClipboard::systemClipboardChanged()
{
if ( mIgnoreNextSystemClipboardChange )
{
mIgnoreNextSystemClipboardChange = false;
return;
}

mUseSystemClipboard = true;
emit changed();
}
@@ -132,7 +132,7 @@ class APP_EXPORT QgsClipboard : public QObject
/**
* Source fields
*/
QgsFields fields() const { return !mUseSystemClipboard ? mFeatureFields : retrieveFields(); }
QgsFields fields() const;

private slots:

@@ -180,6 +180,9 @@ class APP_EXPORT QgsClipboard : public QObject
QgsCoordinateReferenceSystem mCRS;
QPointer<QgsVectorLayer> mSrcLayer;

//! True if next system clipboard change should be ignored
bool mIgnoreNextSystemClipboardChange = false;

//! True when the data from the system clipboard should be read
bool mUseSystemClipboard = false;

0 comments on commit 7febd1e

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