Continuation of coding for the new "Paste Transformations" feature. Bonus item: Doing a Copy now also puts attribute values on the system clipboard as well as geomteries.

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@3768 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
morb_au 2005-07-22 04:27:10 +00:00
parent f8fe954278
commit 8204253c4e
8 changed files with 573 additions and 300 deletions

View File

@ -3153,11 +3153,7 @@ void QgisApp::pasteTransformations()
mMapCanvas->freeze();
if (pt->exec())
{
// TODO: Save the new trnasformations state
pt->saveState();
}
pt->exec();
}

View File

@ -48,7 +48,6 @@ void QgsClipboard::replaceWithCopyOf( std::vector<QgsFeature> features )
#endif
// Replace the system clipboard.
// TODO: Add attributes as well.
QStringList textLines;
@ -56,7 +55,30 @@ void QgsClipboard::replaceWithCopyOf( std::vector<QgsFeature> features )
it != features.end();
++it)
{
textLines += it->geometry()->wkt();
QStringList textFields;
// TODO: Set up Paste Transformations to specify the order in which fields are added.
textFields += it->geometry()->wkt();
std::vector<QgsFeatureAttribute> attributes = it->attributeMap();
#ifdef QGISDEBUG
std::cout << "QgsClipboard::replaceWithCopyOf: about to traverse fields." << std::endl;
#endif
for (std::vector<QgsFeatureAttribute>::iterator it2 = attributes.begin();
it2 != attributes.end();
++it2)
{
#ifdef QGISDEBUG
std::cout << "QgsClipboard::replaceWithCopyOf: inspecting field '"
<< (it2->fieldName())
<< "'." << std::endl;
#endif
textFields += it2->fieldValue();
}
textLines += textFields.join(",");
}
QString textCopy = textLines.join("\n");

View File

@ -243,12 +243,30 @@ void QgsFeature::changeAttributeValue(const QString& name, const QString& newval
}
}
void QgsFeature::changeAttributeName(const QString& name, const QString& newname)
{
// TODO: This was added for Paste Transformations, but as this is called per transfer,
// per feature pasted, this can get inefficient. It may be worth calculating once per
// paste action and caching for each subsequent feature in that paste action.
for(std::vector<QgsFeatureAttribute>::iterator iter=attributes.begin();iter!=attributes.end();++iter)
{
if(iter->fieldName()==name)
{
iter->setFieldName(newname);
break;
}
}
}
/**
* Get the fields for this feature
* @return A std::map containing field position (index) and field name
*/
const std::map < int, QString > &QgsFeature::fields()
{
#ifdef QGISDEBUG
std::cout << "QgsFeature::fields: Returning fieldNames." << std::endl;
#endif
return fieldNames;
}

View File

@ -106,6 +106,11 @@ class QgsFeature {
@param newval new value*/
void changeAttributeValue(const QString& name, const QString& newval);
/**Changes an existing attribute name. The value is unchanged.
@param name attribute name
@param newname new name*/
void changeAttributeName(const QString& name, const QString& newname);
/**
* Get the fields for this feature
* @return A std::map containing field position (index) and field name

View File

@ -17,67 +17,298 @@
***************************************************************************/
/* $Id$ */
#include <iostream>
#include <qsettings.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qcombobox.h>
#include "qgspastetransformations.h"
#include "qgsmaplayerregistry.h"
QgsPasteTransformations::QgsPasteTransformations()
: QgsPasteTransformationsBase()
{
/*
if (!connName.isEmpty())
{
// populate the dialog with the information stored for the connection
// populate the fields with the stored setting parameters
QSettings settings;
QString key = "/Qgis/connections-wms/" + connName;
txtName->setText (connName);
txtUrl->setText (settings.readEntry(key + "/url"));
txtProxyHost->setText(settings.readEntry(key + "/proxyhost"));
txtProxyPort->setText(settings.readEntry(key + "/proxyport"));
}
// Populate the dialog with the loaded layers
std::map<QString, QgsMapLayer*> mapLayers =
QgsMapLayerRegistry::instance()->mapLayers();
for (std::map<QString, QgsMapLayer*>::iterator it = mapLayers.begin();
it != mapLayers.end();
++it )
{
#ifdef QGISDEBUG
std::cerr << "QgsPasteTransformations::QgsPasteTransformations: QgsMapLayerRegistry has "
<< it->second->name() << "."
<< std::endl;
#endif
// TODO: Test if a VECTOR or DATABASE layer only (not RASTER)
sourceLayerComboBox ->insertItem( it->second->name() );
destinationLayerComboBox->insertItem( it->second->name() );
// store the lookup from the name to the map layer object
mMapNameLookup[ it->second->name() ] = it->second;
}
QWidget::setTabOrder(txtName, txtUrl);
QWidget::setTabOrder(txtUrl, (QWidget*)btnOk);
QWidget::setTabOrder((QWidget*)btnOk, (QWidget*)btnCancel);
QWidget::setTabOrder((QWidget*)btnCancel, (QWidget*)btnHelp);
QWidget::setTabOrder((QWidget*)btnHelp, txtName);
*/
}
QgsPasteTransformations::~QgsPasteTransformations()
{
// TODO: Save settings here?
/*
QSettings settings;
QString baseKey = "/Qgis/connections-wms/";
baseKey += txtName->text();
settings.writeEntry(baseKey + "/url", txtUrl->text());
settings.writeEntry(baseKey + "/proxyhost", txtProxyHost->text());
settings.writeEntry(baseKey + "/proxyport", txtProxyPort->text());
accept();
*/
}
void QgsPasteTransformations::saveState()
void QgsPasteTransformations::accept()
{
QSettings settings;
QString baseKey = "/Qgis/paste-transformations/";
QSettings settings;
QString baseKey = "/Qgis/paste-transformations"; // TODO: promote to static member
QString sourceKey = sourceLayerComboBox ->currentText();
QString destinationKey = destinationLayerComboBox->currentText();
/*
baseKey += txtName->text();
settings.writeEntry(baseKey + "/url", txtUrl->text());
settings.writeEntry(baseKey + "/proxyhost", txtProxyHost->text());
settings.writeEntry(baseKey + "/proxyport", txtProxyPort->text());
*/
for (int i = 0; i < mSourceTransfers.size(); i++)
{
settings.writeEntry(
baseKey + "/" + sourceKey + "/" + destinationKey + "/" +
mSourceTransfers[i] ->currentText(),
mDestinationTransfers[i]->currentText()
);
}
QDialog::accept();
}
void QgsPasteTransformations::addNewTransfer()
{
// This ends up being a wrapper for addTransfer, but with no preselected fields
addTransfer();
}
void QgsPasteTransformations::sourceChanged(const QString& layerName)
{
#ifdef QGISDEBUG
std::cerr << "QgsPasteTransformations::sourceChanged: Source changed to "
<< layerName << "."
<< std::endl;
#endif
layerChanged(layerName, &mSourceFields);
}
void QgsPasteTransformations::destinationChanged(const QString& layerName)
{
#ifdef QGISDEBUG
std::cerr << "QgsPasteTransformations::destinationChanged: Destination changed to "
<< layerName << "."
<< std::endl;
#endif
layerChanged(layerName, &mDestinationFields);
}
void QgsPasteTransformations::addTransfer(const QString& sourceSelectedFieldName,
const QString& destinationSelectedFieldName)
{
#ifdef QGISDEBUG
std::cerr << "QgsPasteTransformations::addTransfer: From " << sourceSelectedFieldName
<< " to " << destinationSelectedFieldName << "."
<< std::endl;
#endif
int newRow = transferLayout->numRows();
// TODO: Do not add the transfer if neither the sourceSelectedFieldName nor the destinationSelectedFieldName could be found.
// Build a Transfer row at the end of the grid layout.
QComboBox* newSourceFields = new QComboBox(FALSE, transferLayout->mainWidget() );
QComboBox* newDestinationFields = new QComboBox(FALSE, transferLayout->mainWidget() );
int count = 0;
// Populate source fields
for (std::vector<QString>::iterator it = mSourceFields.begin();
it != mSourceFields.end();
++it )
{
newSourceFields->insertItem( (*it) );
// highlight this item if appropriate
if (sourceSelectedFieldName == (*it))
{
newSourceFields->setCurrentItem(count);
}
count++;
}
count = 0;
// Populate destination fields
for (std::vector<QString>::iterator it = mDestinationFields.begin();
it != mDestinationFields.end();
++it )
{
newDestinationFields->insertItem( (*it) );
// highlight this item if appropriate
if (destinationSelectedFieldName == (*it))
{
newDestinationFields->setCurrentItem(count);
}
count++;
}
// Append to dialog layout
transferLayout->addWidget(newSourceFields, newRow, 0);
transferLayout->addWidget(newDestinationFields, newRow, 1);
// Keep a reference to them so that we can read from them
// when the dialog is dismissed
mSourceTransfers .push_back(newSourceFields);
mDestinationTransfers.push_back(newDestinationFields);
// Reveal the new sub-widgets
newSourceFields->show();
newDestinationFields->show();
}
void QgsPasteTransformations::layerChanged(const QString& layerName, std::vector<QString>* fields)
{
// Fetch the fields that will be populated into the Transfer rows.
#ifdef QGISDEBUG
std::cerr << "QgsPasteTransformations::layerChanged: Layer changed to "
<< layerName << "."
<< std::endl;
#endif
std::vector<QgsField> layerFields =
(mMapNameLookup[ layerName ])->fields();
fields->clear();
for (std::vector<QgsField>::iterator it = layerFields.begin();
it != layerFields.end();
++it )
{
#ifdef QGISDEBUG
std::cerr << "QgsPasteTransformations::layerChanged: Got field "
<< it->name() << "."
<< std::endl;
#endif
fields->push_back(it->name());
}
restoreTransfers( sourceLayerComboBox ->currentText(),
destinationLayerComboBox->currentText() );
}
void QgsPasteTransformations::restoreTransfers(const QString& sourceLayerName,
const QString& destinationLayerName)
{
#ifdef QGISDEBUG
std::cerr << "QgsPasteTransformations::restoreTransfers: Entered."
<< std::endl;
#endif
QSettings settings;
QString baseKey = "/Qgis/paste-transformations"; // TODO: promote to static member
QStringList sourceLayers = settings.subkeyList(baseKey);
for (QStringList::Iterator it = sourceLayers.begin();
it != sourceLayers.end();
++it )
{
#ifdef QGISDEBUG
std::cerr << "QgsPasteTransformations::restoreTransfers: Testing source '"
<< (*it) << "' with '"
<< sourceLayerName << "'."
<< std::endl;
#endif
if ((sourceLayerName == (*it)))
{
// Go through destination layers defined for this source layer.
QStringList destinationLayers = settings.subkeyList( baseKey + "/" + (*it) );
for (QStringList::Iterator it2 = destinationLayers.begin();
it2 != destinationLayers.end();
++it2 )
{
#ifdef QGISDEBUG
std::cerr << "QgsPasteTransformations::restoreTransfers: Testing destination '"
<< (*it2) << "' with '"
<< destinationLayerName << "'."
<< std::endl;
#endif
if ((destinationLayerName == (*it2)))
{
#ifdef QGISDEBUG
std::cerr << "QgsPasteTransformations::restoreTransfers:going through transfers."
<< std::endl;
#endif
// Go through Transfers for this source/destination layer pair.
QStringList transfers = settings.entryList( baseKey + "/" + (*it) + "/" + (*it2) );
for (QStringList::Iterator it3 = transfers.begin();
it3 != transfers.end();
++it3 )
{
#ifdef QGISDEBUG
std::cerr << "QgsPasteTransformations::restoreTransfers: setting transfer for "
<< (*it3) << "."
<< std::endl;
#endif
QString destinationField =
settings.readEntry( baseKey + "/" + (*it) + "/" + (*it2) + "/" + (*it3) );
addTransfer( (*it3), destinationField );
}
}
}
}
}
}
QString QgsPasteTransformations::pasteTo(const QString& sourceLayerName,
const QString& destinationLayerName,
const QString& sourceFieldName)
{
// TODO: Adjust QgsVectorLayer::addFeature to complete the usefulness of this function
// TODO: Cache previous results as this will be called once per pasted feature.
#ifdef QGISDEBUG
std::cerr << "QgsPasteTransformations::pasteTo: Entered."
<< std::endl;
#endif
QSettings settings;
QString baseKey = "/Qgis/paste-transformations"; // TODO: promote to static member
QString destinationField =
settings.readEntry( baseKey + "/" + sourceLayerName + "/" + destinationLayerName + "/" + sourceFieldName );
if (QString::null == destinationField)
{
destinationField = sourceFieldName;
}
#ifdef QGISDEBUG
std::cerr << "QgsPasteTransformations::pasteTo: Returning '" << destinationField << "'."
<< std::endl;
#endif
return destinationField;
}

View File

@ -23,6 +23,11 @@
#else
#include "qgspastetransformationsbase.uic.h"
#endif
#include <qstring.h>
#include "qgsmaplayer.h"
/*!
* \brief Dialog to allow the user to set up how source fields are transformed to destination fields in copy/paste operations
*/
@ -36,8 +41,51 @@ class QgsPasteTransformations : public QgsPasteTransformationsBase
//! Destructor
~QgsPasteTransformations();
//! Saves the state of the paste transformations
void saveState();
/**
Returns the destination field in destinationLayerName that
should be chosen for pastes from sourceLayerName & sourceFieldName.
Returns the sourceFieldName if there is no saved preference.
@note This non-GUI function is a bonus for this class. OO purists may insist that this function should be in its own class. If so, let them separate it.
*/
QString pasteTo(const QString& sourceLayerName,
const QString& destinationLayerName,
const QString& sourceFieldName);
public slots:
virtual void accept();
virtual void addNewTransfer();
virtual void sourceChanged(const QString& layerName);
virtual void destinationChanged(const QString& layerName);
private:
void addTransfer(const QString& sourceLayerName = QString::null,
const QString& destinationLayerName = QString::null);
//! Common subfunction to sourceChanged() and destinationChanged()
void layerChanged(const QString& layerName, std::vector<QString>* fields);
void QgsPasteTransformations::restoreTransfers(const QString& sourceSelectedFieldName,
const QString& destinationSelectedFieldName);
std::map<QString, QgsMapLayer*> mMapNameLookup;
std::vector<QString> mSourceFields;
std::vector<QString> mDestinationFields;
std::vector<QComboBox*> mSourceTransfers;
std::vector<QComboBox*> mDestinationTransfers;
};
#endif // QGSPASTETRANSFORMATIONS_H

View File

@ -8,18 +8,10 @@
<rect>
<x>0</x>
<y>0</y>
<width>614</width>
<height>222</height>
<width>564</width>
<height>426</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="caption">
<string>Paste Transformations</string>
</property>
@ -29,255 +21,176 @@
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
<widget class="QLayoutWidget">
<vbox>
<property name="name">
<cstring>layout5</cstring>
<cstring>unnamed</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>583</width>
<height>173</height>
</rect>
</property>
<vbox>
<widget class="QLabel">
<property name="name">
<cstring>unnamed</cstring>
<cstring>textLabel1_2</cstring>
</property>
<widget class="QLabel">
<property name="sizePolicy">
<sizepolicy>
<hsizetype>1</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;b&gt;Note: This function is not useful yet!&lt;/b&gt;</string>
</property>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>transferLayout</cstring>
</property>
<grid>
<property name="name">
<cstring>textLabel1_2</cstring>
<cstring>unnamed</cstring>
</property>
<property name="text">
<string>&lt;b&gt;Note: This function is not useful yet!&lt;/b&gt;</string>
</property>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout4</cstring>
</property>
<grid>
<widget class="QLabel" row="0" column="0">
<property name="name">
<cstring>unnamed</cstring>
<cstring>textLabel3</cstring>
</property>
<widget class="QLabel" row="3" column="0">
<property name="name">
<cstring>textLabel3_2</cstring>
</property>
<property name="text">
<string>transfer</string>
</property>
</widget>
<widget class="QComboBox" row="3" column="3">
<property name="name">
<cstring>comboBox4_2</cstring>
</property>
</widget>
<widget class="QComboBox" row="3" column="5">
<item>
<property name="text">
<string>copying</string>
</property>
</item>
<item>
<property name="text">
<string>multiplying</string>
</property>
</item>
<property name="name">
<cstring>comboBox5_2</cstring>
</property>
</widget>
<widget class="QLineEdit" row="3" column="7">
<property name="name">
<cstring>lineEdit1</cstring>
</property>
<property name="text">
<string>20</string>
</property>
</widget>
<widget class="QComboBox" row="2" column="3">
<property name="name">
<cstring>comboBox4</cstring>
</property>
</widget>
<widget class="QComboBox" row="2" column="1">
<property name="name">
<cstring>comboBox3</cstring>
</property>
</widget>
<widget class="QLabel" row="0" column="1">
<property name="name">
<cstring>textLabel1</cstring>
</property>
<property name="text">
<string>Source Layer</string>
</property>
</widget>
<widget class="QLabel" row="2" column="2">
<property name="name">
<cstring>textLabel4</cstring>
</property>
<property name="text">
<string>to</string>
</property>
</widget>
<widget class="QLabel" row="3" column="6">
<property name="name">
<cstring>textLabel6</cstring>
</property>
<property name="text">
<string>by</string>
</property>
</widget>
<widget class="QComboBox" row="2" column="5">
<item>
<property name="text">
<string>copying</string>
</property>
</item>
<property name="name">
<cstring>comboBox5</cstring>
</property>
</widget>
<widget class="QComboBox" row="1" column="3">
<property name="name">
<cstring>destinationLayerComboBox</cstring>
</property>
</widget>
<widget class="QLabel" row="2" column="4">
<property name="name">
<cstring>textLabel5</cstring>
</property>
<property name="text">
<string>by</string>
</property>
</widget>
<widget class="QLabel" row="0" column="3">
<property name="name">
<cstring>textLabel2</cstring>
</property>
<property name="text">
<string>Destination Layer</string>
</property>
</widget>
<widget class="QLabel" row="3" column="4">
<property name="name">
<cstring>textLabel5_2</cstring>
</property>
<property name="text">
<string>by</string>
</property>
</widget>
<widget class="QLabel" row="3" column="2">
<property name="name">
<cstring>textLabel4_2</cstring>
</property>
<property name="text">
<string>to</string>
</property>
</widget>
<widget class="QComboBox" row="1" column="1">
<property name="name">
<cstring>originLayerComboBox</cstring>
</property>
</widget>
<widget class="QLabel" row="2" column="0">
<property name="name">
<cstring>textLabel3</cstring>
</property>
<property name="text">
<string>transfer</string>
</property>
</widget>
<widget class="QComboBox" row="3" column="1">
<property name="name">
<cstring>comboBox3_2</cstring>
</property>
</widget>
</grid>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>Layout1</cstring>
</property>
<hbox>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Source</string>
</property>
</widget>
<widget class="QComboBox" row="1" column="1">
<property name="name">
<cstring>unnamed</cstring>
<cstring>destinationLayerComboBox</cstring>
</property>
<property name="margin">
<number>0</number>
</widget>
<widget class="QLabel" row="0" column="1">
<property name="name">
<cstring>textLabel4</cstring>
</property>
<property name="spacing">
<number>6</number>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QPushButton">
<property name="name">
<cstring>buttonHelp</cstring>
</property>
<property name="text">
<string>&amp;Help</string>
</property>
<property name="accel">
<string>F1</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
<spacer>
<property name="name">
<cstring>Horizontal Spacing2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget class="QPushButton">
<property name="name">
<cstring>buttonOk</cstring>
</property>
<property name="text">
<string>&amp;OK</string>
</property>
<property name="accel">
<string></string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>buttonCancel</cstring>
</property>
<property name="text">
<string>&amp;Cancel</string>
</property>
<property name="accel">
<string></string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</hbox>
</widget>
</vbox>
</widget>
<property name="text">
<string>Destination</string>
</property>
</widget>
<widget class="QComboBox" row="1" column="0">
<property name="name">
<cstring>sourceLayerComboBox</cstring>
</property>
</widget>
</grid>
</widget>
<spacer>
<property name="name">
<cstring>spacer2</cstring>
</property>
<property name="orientation">
<enum>Vertical</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>251</height>
</size>
</property>
</spacer>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout5</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QPushButton">
<property name="name">
<cstring>buttonHelp</cstring>
</property>
<property name="text">
<string>&amp;Help</string>
</property>
<property name="accel">
<string>F1</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
<spacer>
<property name="name">
<cstring>Horizontal Spacing2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
<widget class="QPushButton">
<property name="name">
<cstring>newTransferPushButton</cstring>
</property>
<property name="text">
<string>Add New Transfer</string>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>buttonOk</cstring>
</property>
<property name="text">
<string>&amp;OK</string>
</property>
<property name="accel">
<string></string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>buttonCancel</cstring>
</property>
<property name="text">
<string>&amp;Cancel</string>
</property>
<property name="accel">
<string></string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</hbox>
</widget>
</vbox>
</widget>
<connections>
<connection>
@ -292,6 +205,23 @@
<receiver>QgsPasteTransformationsBase</receiver>
<slot>reject()</slot>
</connection>
<connection>
<sender>sourceLayerComboBox</sender>
<signal>activated(const QString&amp;)</signal>
<receiver>QgsPasteTransformationsBase</receiver>
<slot>sourceChanged(const QString&amp;)</slot>
</connection>
<connection>
<sender>destinationLayerComboBox</sender>
<signal>activated(const QString&amp;)</signal>
<receiver>QgsPasteTransformationsBase</receiver>
<slot>destinationChanged(const QString&amp;)</slot>
</connection>
</connections>
<slots>
<slot>addNewTransfer(const QString&amp;, const QString&amp;)</slot>
<slot>sourceChanged(const QString&amp;)</slot>
<slot>destinationChanged(const QString&amp;)</slot>
</slots>
<layoutdefaults spacing="6" margin="11"/>
</UI>

View File

@ -1814,7 +1814,30 @@ bool QgsVectorLayer::addFeature(QgsFeature* f, bool alsoUpdateExtent)
#ifdef QGISDEBUG
qWarning("assigned feature id "+QString::number(addedIdLowWaterMark));
#endif
// Change the fields on the feature to suit the destination
// in the paste transformation transfer.
// TODO: Could be done more efficiently for large pastes
std::map<int, QString> fields = f->fields();
#ifdef QGISDEBUG
std::cout << "QgsVectorLayer::addFeature: about to traverse fields." << std::endl;
#endif
for (std::map<int, QString>::iterator it = fields.begin();
it != fields.end();
++it)
{
#ifdef QGISDEBUG
std::cout << "QgsVectorLayer::addFeature: inspecting field '"
<< (it->second)
<< "'." << std::endl;
#endif
}
// Force a feature ID (to keep other functions in QGIS happy,
// providers will use their own new feature ID when we commit the new feature)
// and add to the known added features.
f->setFeatureId(addedIdLowWaterMark);
mAddedFeatures.push_back(f);
mModified=true;
@ -2406,7 +2429,7 @@ bool QgsVectorLayer::setDataProvider( QString const & provider )
#endif
// adjust the display name for postgres layers
layerName = layerName.mid(layerName.find(".") + 1);
layerName = layerName.left(layerName.find("("));
layerName = layerName.left(layerName.find("(") - 1); // Take one away, to avoid a trailing space
#ifdef QGISDEBUG
std::cout << "Beautified name is " << layerName << std::endl;
#endif