@@ -154,22 +154,50 @@ void QgsClipboard::setSystemClipboard()
154
154
// that just the next call to systemClipboardChanged() should be ignored
155
155
mIgnoreNextSystemClipboardChange = true ;
156
156
157
- QString textCopy = generateClipboardText ();
158
-
159
157
QClipboard *cb = QApplication::clipboard ();
160
158
161
159
// Copy text into the clipboard
160
+ QString textCopy = generateClipboardText ();
161
+ QMimeData *m = new QMimeData ();
162
+ m->setText ( textCopy );
163
+
164
+ if ( mFeatureClipboard .count () < 1000 )
165
+ {
166
+ QgsSettings settings;
167
+ CopyFormat format = AttributesWithWKT;
168
+ if ( settings.contains ( QStringLiteral ( " /qgis/copyFeatureFormat" ) ) )
169
+ {
170
+ format = static_cast < CopyFormat >( settings.value ( QStringLiteral ( " qgis/copyFeatureFormat" ), true ).toInt () );
171
+ }
172
+
173
+ QString htmlCopy;
174
+ switch ( format )
175
+ {
176
+ case AttributesOnly:
177
+ case AttributesWithWKT:
178
+ htmlCopy = textCopy;
179
+ htmlCopy.replace ( ' \n ' , QStringLiteral ( " </td></tr><tr><td>" ) );
180
+ htmlCopy.replace ( ' \t ' , QStringLiteral ( " </td><td>" ) );
181
+ htmlCopy = QStringLiteral ( " <!DOCTYPE HTML PUBLIC \" -//W3C//DTD HTML 4.0 Transitional//EN\" ><html><head><meta http-equiv=\" content-type\" content=\" text/html; charset=utf-8\" /></head><body><table border=\" 1\" ><tr><td>" ) + htmlCopy + QStringLiteral ( " </td></tr></table></body></html>" );
182
+ break ;
183
+ case GeoJSON:
184
+ break ;
185
+ }
186
+ if ( !htmlCopy.isEmpty () )
187
+ {
188
+ m->setHtml ( htmlCopy );
189
+ }
190
+ }
162
191
163
192
// With qgis running under Linux, but with a Windows based X
164
193
// server (Xwin32), ::Selection was necessary to get the data into
165
194
// the Windows clipboard (which seems contrary to the Qt
166
195
// docs). With a Linux X server, ::Clipboard was required.
167
196
// The simple solution was to put the text into both clipboards.
168
-
169
197
#ifdef Q_OS_LINUX
170
- cb->setText ( textCopy , QClipboard::Selection );
198
+ cb->setMimeData ( m , QClipboard::Selection );
171
199
#endif
172
- cb->setText ( textCopy , QClipboard::Clipboard );
200
+ cb->setMimeData ( m , QClipboard::Clipboard );
173
201
174
202
QgsDebugMsgLevel ( QString ( " replaced system clipboard with: %1." ).arg ( textCopy ), 4 );
175
203
}
0 commit comments