Skip to content
Permalink
Browse files

[FEATURE] option to avoid WKT copying from attribute table (fix 4591)

  • Loading branch information
alexbruy committed Mar 24, 2012
1 parent 54769b3 commit 0ee37699a7d87e0d260f14e7b89db70662245ecf
Showing with 39 additions and 46 deletions.
  1. +14 −18 src/app/qgsclipboard.cpp
  2. +0 −12 src/app/qgsclipboard.h
  3. +2 −0 src/app/qgsoptions.cpp
  4. +23 −16 src/ui/qgsoptionsbase.ui
@@ -15,7 +15,6 @@
* *
***************************************************************************/


#include <fstream>

#include <QApplication>
@@ -31,7 +30,6 @@
#include "qgscoordinatereferencesystem.h"
#include "qgslogger.h"


QgsClipboard::QgsClipboard()
: mFeatureClipboard()
{
@@ -43,44 +41,47 @@ QgsClipboard::~QgsClipboard()

void QgsClipboard::replaceWithCopyOf( const QgsFieldMap& fields, QgsFeatureList& features )
{
QSettings settings;
bool copyWKT = settings.value( "qgis/copyGeometryAsWKT", true ).toBool();

// Replace the QGis clipboard.
mFeatureClipboard = features;
QgsDebugMsg( "replaced QGis clipboard." );

// Replace the system clipboard.

QStringList textLines;
QStringList textFields;

// first do the field names
textFields += "wkt_geom";
if ( copyWKT )
{
textFields += "wkt_geom";
}

for ( QgsFieldMap::const_iterator fit = fields.begin(); fit != fields.end(); ++fit )
{
textFields += fit->name();
}
textLines += textFields.join( "\t" );
textFields.clear();


// then the field contents
for ( QgsFeatureList::iterator it = features.begin(); it != features.end(); ++it )
{
QgsAttributeMap attributes = it->attributeMap();


// TODO: Set up Paste Transformations to specify the order in which fields are added.

if ( it->geometry() )
textFields += it->geometry()->exportToWkt();
else
if ( copyWKT )
{
QSettings settings;
textFields += settings.value( "qgis/nullValue", "NULL" ).toString();
if ( it->geometry() )
textFields += it->geometry()->exportToWkt();
else
{
textFields += settings.value( "qgis/nullValue", "NULL" ).toString();
}
}

// QgsDebugMsg("about to traverse fields.");
//
for ( QgsAttributeMap::iterator it2 = attributes.begin(); it2 != attributes.end(); ++it2 )
{
// QgsDebugMsg(QString("inspecting field '%1'.").arg(it2->toString()));
@@ -113,15 +114,11 @@ void QgsClipboard::replaceWithCopyOf( const QgsFieldMap& fields, QgsFeatureList&

QgsFeatureList QgsClipboard::copyOf()
{

QgsDebugMsg( "returning clipboard." );

//TODO: Slurp from the system clipboard as well.

return mFeatureClipboard;

// return mFeatureClipboard;

}

void QgsClipboard::clear()
@@ -145,7 +142,6 @@ bool QgsClipboard::empty()

QgsFeatureList QgsClipboard::transformedCopyOf( QgsCoordinateReferenceSystem destCRS )
{

QgsFeatureList featureList = copyOf();
QgsCoordinateTransform ct( crs(), destCRS );

@@ -15,7 +15,6 @@
* *
***************************************************************************/


#ifndef QGSCLIPBOARD_H
#define QGSCLIPBOARD_H

@@ -26,9 +25,7 @@
#include "qgsfeature.h"
#include "qgscoordinatereferencesystem.h"


/**
\brief QGIS internal clipboard for features.
An internal clipboard is required so that features can be retained in
@@ -42,16 +39,11 @@
of features in and out of the system clipboard (QClipboard).
TODO: Make it work
*/

class QgsClipboard
{


public:


/**
* Constructor for the clipboard.
*/
@@ -83,7 +75,6 @@ class QgsClipboard
*/
void insert( QgsFeature& feature );


/*
* Returns true if the internal clipboard is empty, else false.
*/
@@ -102,7 +93,6 @@ class QgsClipboard
*/
void setCRS( QgsCoordinateReferenceSystem crs );


/*
* Get the clipboard CRS
*/
@@ -117,8 +107,6 @@ class QgsClipboard
QgsFeatureList mFeatureClipboard;

QgsCoordinateReferenceSystem mCRS;


};

#endif
@@ -316,6 +316,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
cbxAddPostgisDC->setChecked( settings.value( "/qgis/addPostgisDC", false ).toBool() );
cbxAddNewLayersToCurrentGroup->setChecked( settings.value( "/qgis/addNewLayersToCurrentGroup", false ).toBool() );
cbxCreateRasterLegendIcons->setChecked( settings.value( "/qgis/createRasterLegendIcons", true ).toBool() );
cbxCopyWKTGeomFromTable->setChecked( settings.value( "/qgis/copyGeometryAsWKT", true ).toBool() );
leNullValue->setText( settings.value( "qgis/nullValue", "NULL" ).toString() );

cmbLegendDoubleClickAction->setCurrentIndex( settings.value( "/qgis/legendDoubleClickAction", 0 ).toInt() );
@@ -626,6 +627,7 @@ void QgsOptions::saveOptions()
settings.setValue( "/qgis/addPostgisDC", cbxAddPostgisDC->isChecked() );
settings.setValue( "/qgis/addNewLayersToCurrentGroup", cbxAddNewLayersToCurrentGroup->isChecked() );
settings.setValue( "/qgis/createRasterLegendIcons", cbxCreateRasterLegendIcons->isChecked() );
settings.setValue( "/qgis/copyGeometryAsWKT", cbxCopyWKTGeomFromTable->isChecked() );
settings.setValue( "/qgis/new_layers_visible", chkAddedVisibility->isChecked() );
settings.setValue( "/qgis/enable_anti_aliasing", chkAntiAliasing->isChecked() );
settings.setValue( "/qgis/enable_render_caching", chkUseRenderCaching->isChecked() );
@@ -66,8 +66,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>809</width>
<height>778</height>
<width>787</width>
<height>823</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
@@ -438,6 +438,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbxCopyWKTGeomFromTable">
<property name="text">
<string>Copy geometry in WKT representation from attribute table</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
@@ -726,8 +733,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>809</width>
<height>778</height>
<width>614</width>
<height>523</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_8">
@@ -900,8 +907,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>809</width>
<height>778</height>
<width>539</width>
<height>502</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_4">
@@ -1186,8 +1193,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>809</width>
<height>778</height>
<width>270</width>
<height>93</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_10">
@@ -1261,8 +1268,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>795</width>
<height>764</height>
<width>571</width>
<height>620</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_13">
@@ -1637,8 +1644,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>809</width>
<height>778</height>
<width>425</width>
<height>417</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_15">
@@ -1811,8 +1818,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>809</width>
<height>778</height>
<width>519</width>
<height>584</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_17">
@@ -1908,8 +1915,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>809</width>
<height>778</height>
<width>355</width>
<height>572</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_20">

0 comments on commit 0ee3769

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