24 changes: 11 additions & 13 deletions python/plugins/osm/OsmLoadDlg.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def showOpenFileDialog(self):
lastDir=settings.value("/OSM_Plugin/lastDir", QVariant(QString())).toString()

# display file open dialog and get absolute path to selected file
fileSelected=QFileDialog.getOpenFileName(self,"Choose an Open Street Map file",lastDir,"OSM Files (*.osm)");
fileSelected=QFileDialog.getOpenFileName(self,self.tr("Choose an Open Street Map file"),lastDir,self.tr("OSM Files (*.osm)"));
# insert OSM file path into line edit control
if not fileSelected.isNull():
self.OSMFileEdit.setText(fileSelected)
Expand All @@ -108,7 +108,7 @@ def onOK(self):
self.fname = self.OSMFileEdit.text()

if self.fname=='':
QMessageBox.information(self, "OSM Load", QString("Please enter path to OSM data file."))
QMessageBox.information(self, self.tr("OSM Load"),self.tr("Please enter path to OSM data file."))
self.buttonBox.setEnabled(True)
return

Expand All @@ -117,7 +117,7 @@ def onOK(self):
basename = osmfile.baseName()

if not osmfile.exists():
QMessageBox.information(self, "OSM Load", QString("Path to OSM file is invalid: %1.").arg(self.fname))
QMessageBox.information(self, self.tr("OSM Load"), self.tr("Path to OSM file is invalid: %1.").arg(self.fname))
return

fLoaded=self.filesLoaded()
Expand All @@ -126,11 +126,11 @@ def onOK(self):
curDB=self.dbm.currentKey

if basename in fLoaded and newDB<>curDB:
QMessageBox.information(self, "Error", QString("Layers of OSM file \"%1\" are loaded already.").arg(self.fname))
QMessageBox.information(self, self.tr("Error"), self.tr("Layers of OSM file \"%1\" are loaded already.").arg(self.fname))
return

if replacing:
# remove layers of current data first
if replacing:
# remove layers of current data first
QgsMapLayerRegistry.instance().removeMapLayer(self.canvas.currentLayer().id(),True)

if self.chkCustomRenderer.isChecked():
Expand Down Expand Up @@ -162,7 +162,7 @@ def onOK(self):
polygonLayer=None
return
if not polygonLayer.isValid():
QMessageBox.information(self,"Error",QString("Failed to load polygon layer."))
QMessageBox.information(self,self.tr("Error"),self.tr("Failed to load polygon layer."))
return

if self.chkCustomRenderer.isChecked():
Expand All @@ -176,7 +176,7 @@ def onOK(self):
lineLayer=None
return
if not lineLayer.isValid():
QMessageBox.information(self,"Error",QString("Failed to load line layer."))
QMessageBox.information(self,self.tr("Error"),self.tr("Failed to load line layer."))
return

if self.chkCustomRenderer.isChecked():
Expand All @@ -190,7 +190,7 @@ def onOK(self):
pointLayer=None
return
if not pointLayer.isValid():
QMessageBox.information(self,"Error",QString("Failed to load point layer."))
QMessageBox.information(self,self.tr("Error"),self.tr("Failed to load point layer."))
return

if self.chkCustomRenderer.isChecked():
Expand Down Expand Up @@ -231,7 +231,7 @@ def setCustomRenderer(self, layer):
self.emit( SIGNAL( "setRenderer(QgsVectorLayer *)" ), layer )
QObject.disconnect( self, SIGNAL( "setRenderer(QgsVectorLayer *)" ), layer.dataProvider(), SLOT( "setRenderer( QgsVectorLayer * )" ) )
else:
QMessageBox.information(self, "OSM Load", QString("Could not connect to setRenderer signal."))
QMessageBox.information(self, self.tr("OSM Load"), self.tr("Could not connect to setRenderer signal."))

def filesLoaded(self):
"""Function returns list of keys of all currently loaded vector layers.
Expand Down Expand Up @@ -303,11 +303,9 @@ def event(self, e):
QObject.disconnect(self.progress,SIGNAL("canceled()"),self.cancelLoading)
self.progress.close()
self.progress = None
QMessageBox.information(self,"Error",QString("Failed to load layers: %1")
QMessageBox.information(self,self.tr("Error"),self.tr("Failed to load layers: %1")
.arg(self.property("osm_failure").toString()))
self.buttonBox.setEnabled(True)

qApp.processEvents()
return QDialog.event(self,e)


59 changes: 31 additions & 28 deletions python/plugins/osm/OsmPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,28 +73,28 @@ def initGui(self):

# create action for loading OSM file
self.actionLoad=QAction(QIcon(":/plugins/osm_plugin/images/osm_load.png")
,"Load OSM from file", self.iface.mainWindow())
self.actionLoad.setWhatsThis("Load OpenStreetMap from file")
,QCoreApplication.translate( "OsmPlugin", "Load OSM from file"), self.iface.mainWindow())
self.actionLoad.setWhatsThis( QCoreApplication.translate( "OsmPlugin", "Load OpenStreetMap from file") )
# create action for import of a layer into OSM
self.actionImport=QAction(QIcon(":/plugins/osm_plugin/images/osm_import.png")
,"Import data from a layer", self.iface.mainWindow())
self.actionImport.setWhatsThis("Import data from a layer to OpenStreetMap")
,QCoreApplication.translate( "OsmPlugin", "Import data from a layer"), self.iface.mainWindow())
self.actionImport.setWhatsThis(QCoreApplication.translate( "OsmPlugin", "Import data from a layer to OpenStreetMap") )
# create action for saving OSM file
self.actionSave=QAction(QIcon(":/plugins/osm_plugin/images/osm_save.png")
,"Save OSM to file", self.iface.mainWindow())
self.actionSave.setWhatsThis("Save OpenStreetMap to file")
,QCoreApplication.translate( "OsmPlugin", "Save OSM to file"), self.iface.mainWindow())
self.actionSave.setWhatsThis(QCoreApplication.translate( "OsmPlugin", "Save OpenStreetMap to file") )
# create action for OSM data downloading
self.actionDownload=QAction(QIcon(":/plugins/osm_plugin/images/osm_download.png")
,"Download OSM data", self.iface.mainWindow())
self.actionDownload.setWhatsThis("Download OpenStreetMap data")
,QCoreApplication.translate( "OsmPlugin", "Download OSM data"), self.iface.mainWindow())
self.actionDownload.setWhatsThis(QCoreApplication.translate( "OsmPlugin", "Download OpenStreetMap data") )
# create action for OSM data downloading
self.actionUpload=QAction(QIcon(":/plugins/osm_plugin/images/osm_upload.png")
,"Upload OSM data", self.iface.mainWindow())
self.actionUpload.setWhatsThis("Upload OpenStreetMap data")
,QCoreApplication.translate( "OsmPlugin", "Upload OSM data"), self.iface.mainWindow())
self.actionUpload.setWhatsThis(QCoreApplication.translate( "OsmPlugin", "Upload OpenStreetMap data") )
# create action for OSM dockable window
self.actionDockWidget=QAction(QIcon(":/plugins/osm_plugin/images/osm_featureManager.png")
,"Show/Hide OSM Feature Manager",self.iface.mainWindow())
self.actionDockWidget.setWhatsThis("Show/Hide OpenStreetMap Feature Manager")
,QCoreApplication.translate( "OsmPlugin", "Show/Hide OSM Feature Manager"),self.iface.mainWindow())
self.actionDockWidget.setWhatsThis(QCoreApplication.translate( "OsmPlugin", "Show/Hide OpenStreetMap Feature Manager") )
self.actionDockWidget.setCheckable(True)

# connect new action to plugin function - when action is triggered
Expand Down Expand Up @@ -193,7 +193,8 @@ def loadOsmFromFile(self):

# sanity check whether we're able to load osm data
if 'osm' not in QgsProviderRegistry.instance().providerList():
QMessageBox.critical(None, "Sorry", "You don't have OSM provider installed!")
QMessageBox.critical(None, QCoreApplication.translate( "OsmPlugin", "Sorry" ),
QCoreApplication.translate( "OsmPlugin", "You don't have OSM provider installed!") )
return

# show modal dialog with OSM file selection
Expand Down Expand Up @@ -222,13 +223,14 @@ def saveOsmToFile(self):
"""

if 'osm' not in QgsProviderRegistry.instance().providerList():
QMessageBox.critical(None, "Sorry", "You don't have OSM provider installed!")
QMessageBox.critical(None, QCoreApplication.translate( "OsmPlugin", "Sorry" ),
QCoreApplication.translate( "OsmPlugin", "You don't have OSM provider installed!") )
return

if not self.dbm.currentKey:
QMessageBox.information(QWidget(), QString("OSM Save to file")
,"No OSM data are loaded/downloaded or no OSM layer is selected in Layers panel. \
Please change this situation first, because OSM Plugin doesn't know what to save.")
QMessageBox.information(QWidget(), QCoreApplication.translate( "OsmPlugin", "OSM Save to file"),
QCoreApplication.translate( "OsmPlugin", "No OSM data are loaded/downloaded or no OSM layer is selected in Layers panel. \
Please change this situation first, because OSM Plugin doesn't know what to save.") )
return

# show modal dialog with OSM file selection
Expand All @@ -247,7 +249,8 @@ def downloadOsmData(self):
"""

if 'osm' not in QgsProviderRegistry.instance().providerList():
QMessageBox.critical(None, "Sorry", "You don't have OSM provider installed!")
QMessageBox.critical(None, QCoreApplication.translate( "OsmPlugin", "Sorry" ),
QCoreApplication.translate( "OsmPlugin", "You don't have OSM provider installed!") )
return

self.dlgDownload=OsmDownloadDlg(self)
Expand Down Expand Up @@ -299,9 +302,9 @@ def uploadOsmData(self):

# first check if there are some data; if not upload doesn't have sense
if not self.dbm.currentKey:
QMessageBox.information(QWidget(), QString("OSM Upload")
,"No OSM data are loaded/downloaded or no OSM layer is selected in Layers panel. \
Please change this situation first, because OSM Plugin doesn't know what to upload.")
QMessageBox.information(QWidget(), QCoreApplication.translate( "OsmPlugin", "OSM Upload"),
QCoreApplication.translate( "OsmPlugin", "No OSM data are loaded/downloaded or no OSM layer is selected in Layers panel. \
Please change this situation first, because OSM Plugin doesn't know what to upload.") )
return

self.dlgUpload=OsmUploadDlg(self)
Expand All @@ -316,18 +319,20 @@ def importData(self):
"""

if 'osm' not in QgsProviderRegistry.instance().providerList():
QMessageBox.critical(None, "Sorry", "You don't have OSM provider installed!")
QMessageBox.critical(None, QCoreApplication.translate( "OsmPlugin", "Sorry"),
QCoreApplication.translate( "OsmPlugin", "You don't have OSM provider installed!") )
return

if self.dbm.currentKey is None:
QMessageBox.information(self.iface.mainWindow(), "OSM Import"
,"No OSM data are loaded/downloaded or no OSM layer is selected in Layers panel. \
Please change this situation first, because OSM Plugin doesn't know what layer will be destination of the import.")
QMessageBox.information(self.iface.mainWindow(), QCoreApplication.translate( "OsmPlugin", "OSM Import"),
QCoreApplication.translate( "OsmPlugin", "No OSM data are loaded/downloaded or no OSM layer is selected in Layers panel. \
Please change this situation first, because OSM Plugin doesn't know what layer will be destination of the import.") )
return

dlg=OsmImportDlg(self)
if dlg.cboLayer.count()==0:
QMessageBox.information(self.iface.mainWindow(), "OSM Import", "There are currently no available vector layers.")
QMessageBox.information(self.iface.mainWindow(), QCoreApplication.translate( "OsmPlugin", "OSM Import"),
QCoreApplication.translate( "OsmPlugin", "There are currently no available vector layers.") )
return

dlg.exec_()
Expand Down Expand Up @@ -367,5 +372,3 @@ def __ofVisibilityChanged(self):
self.actionDockWidget.setChecked(True)
else:
self.actionDockWidget.setChecked(False)


5 changes: 1 addition & 4 deletions python/plugins/osm/OsmSaveDlg.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def showSaveFileDialog(self):
lastDir = settings.value("/OSM_Plugin/lastDir", QVariant(QString())).toString()

# display file open dialog and get absolute path to selected file
fileSelected = QFileDialog.getSaveFileName(self,"Choose an Open Street Map file",lastDir,"OSM Files (*.osm)");
fileSelected = QFileDialog.getSaveFileName(self, self.tr("Choose an Open Street Map file"),lastDir,self.tr("OSM Files (*.osm)") );
# insert OSM file path into line edit control
if not fileSelected.isNull():
self.OSMFileEdit.setText(fileSelected)
Expand Down Expand Up @@ -457,6 +457,3 @@ def onOK(self):
if self.outFile and self.outFile.exists():
self.outFile.close()
self.close()



2 changes: 0 additions & 2 deletions python/plugins/osm/OsmUndoRedoDW.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,5 +437,3 @@ def redo(self,standAlone=True):
if self.redoCounter>0:
self.redoButton.setEnabled(True)
self.plugin.dockWidget.redoButton.setEnabled(True)


34 changes: 17 additions & 17 deletions python/plugins/osm/OsmUploadDlg.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(self,plugin):
self.ur=plugin.undoredo

self.urlHost = "api.openstreetmap.org"
self.uploadButton = self.buttonBox.addButton("Upload", QDialogButtonBox.ActionRole)
self.uploadButton = self.buttonBox.addButton(self.tr("Upload"), QDialogButtonBox.ActionRole)

self.uploadChangesTable.setColumnCount(5)
self.uploadChangesTable.setColumnWidth(0,80)
Expand Down Expand Up @@ -1079,7 +1079,7 @@ def __httpNodeAdditionReqFinished(self, requestId, error):
del self.pseudoId_map[requestId]

if error:
self.cancelUpload("Node addition failed.")
self.cancelUpload( self.tr("Node addition failed.") )
return

newNodeIdStr=QString(self.http.readAll().data())
Expand Down Expand Up @@ -1119,7 +1119,7 @@ def __httpNodeUpdateReqFinished(self, requestId, error):
del self.featureId_map[requestId]

if error:
self.cancelUpload("Node update failed.")
self.cancelUpload(self.tr("Node update failed."))
return

newVersionIdStr=QString(self.http.readAll().data())
Expand Down Expand Up @@ -1158,7 +1158,7 @@ def __httpNodeDeletionReqFinished(self, requestId, error):
del self.featureId_map[requestId]

if error:
self.cancelUpload("Node deletion failed.")
self.cancelUpload(self.tr("Node deletion failed."))
return

self.dbm.removePointRecord(pointId)
Expand Down Expand Up @@ -1194,7 +1194,7 @@ def __httpWayAdditionReqFinished(self, requestId, error):
del self.pseudoId_map[requestId]

if error:
self.cancelUpload("Way addition failed.")
self.cancelUpload(self.tr("Way addition failed."))
return

newWayIdStr = QString(self.http.readAll().data())
Expand Down Expand Up @@ -1234,7 +1234,7 @@ def __httpWayUpdateReqFinished(self, requestId, error):
del self.featureId_map[requestId]

if error:
self.cancelUpload("Way update failed.")
self.cancelUpload(self.tr("Way update failed."))
return

newVersionIdStr=QString(self.http.readAll().data())
Expand Down Expand Up @@ -1273,7 +1273,7 @@ def __httpWayDeletionReqFinished(self, requestId, error):
del self.featureId_map[requestId]

if error:
self.cancelUpload("Way deletion failed.")
self.cancelUpload(self.tr("Way deletion failed."))
return

self.dbm.removeWayRecord(wayId)
Expand Down Expand Up @@ -1309,7 +1309,7 @@ def __httpRelationAdditionReqFinished(self, requestId, error):
del self.pseudoId_map[requestId]

if error:
self.cancelUpload("Relation addition failed.")
self.cancelUpload(self.tr("Relation addition failed."))
return

newRelIdStr=QString(self.http.readAll().data())
Expand Down Expand Up @@ -1348,7 +1348,7 @@ def __httpRelationUpdateReqFinished(self, requestId, error):
del self.featureId_map[requestId]

if error:
self.cancelUpload("Relation update failed.")
self.cancelUpload(self.tr("Relation update failed."))
return

newVersionIdStr=QString(self.http.readAll().data())
Expand Down Expand Up @@ -1386,7 +1386,7 @@ def __httpRelationDeletionReqFinished(self, requestId, error):
del self.featureId_map[requestId]

if error:
self.cancelUpload("Relation deletion failed.")
self.cancelUpload(self.tr("Relation deletion failed."))
return

self.dbm.removeRelationRecord(relId)
Expand Down Expand Up @@ -1417,7 +1417,7 @@ def __httpChangesetCreationReqFinished(self, requestId, error):
self.disconnect(self.http, SIGNAL("requestFinished(int, bool)"), self.__httpChangesetCreationReqFinished)

if error:
self.cancelUpload("Connection to OpenStreetMap server cannot be established. Please check your proxy settings, firewall settings and try again.")
self.cancelUpload(self.tr("Connection to OpenStreetMap server cannot be established. Please check your proxy settings, firewall settings and try again."))
return

del self.qhttp_map[requestId]
Expand Down Expand Up @@ -1448,7 +1448,7 @@ def __httpChangesetClosingReqFinished(self, requestId, error):
self.disconnect(self.http, SIGNAL("requestFinished(int, bool)"), self.__httpChangesetClosingReqFinished)

if error:
self.cancelUpload("Changeset closing failed.")
self.cancelUpload(self.tr("Changeset closing failed."))
return

# call the next upload step
Expand All @@ -1468,7 +1468,7 @@ def __readResponseHeader(self, responseHeader):

if responseHeader.statusCode() != 200:

self.cancelUpload(QString("Upload process failed. OpenStreetMap server response: %1 - %2.")
self.cancelUpload(self.tr("Upload process failed. OpenStreetMap server response: %1 - %2.")
.arg(responseHeader.reasonPhrase())
.arg(responseHeader.value("Error")))

Expand All @@ -1480,7 +1480,7 @@ def __authRequired(self,s,a,b):
We are really not interested in function parameters - we just cancel the connection.
"""

self.cancelUpload("Authentication failed. Please try again with correct login and password.")
self.cancelUpload(self.tr("Authentication failed. Please try again with correct login and password."))


def __setProxy(self):
Expand Down Expand Up @@ -1536,13 +1536,13 @@ def __examineResponse(self,requestId,error):
return

if requestId==self.reqSetHost:
self.cancelUpload("Setting host failed.")
self.cancelUpload(self.tr("Setting host failed."))

elif requestId==self.reqSetUser:
self.cancelUpload("Setting user and password failed.")
self.cancelUpload(self.tr("Setting user and password failed."))

elif requestId==self.reqSetProxy:
self.cancelUpload("Setting proxy failed.")
self.cancelUpload(self.tr("Setting proxy failed."))



2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5722,7 +5722,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
else
{
mActionPasteFeatures->setEnabled( false );
mActionAddFeature->setEnabled( !vlayer->isEditable() );
mActionAddFeature->setEnabled( false );
}

//does provider allow deleting of features?
Expand Down
12 changes: 12 additions & 0 deletions src/app/qgscustomization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,10 @@ void QgsCustomization::updateMainWindow( QMenu * theToolBarMenu )
// hide individual toolbar actions
foreach( QAction* action, tb->actions() )
{
if ( action->objectName().isEmpty() )
{
continue;
}
visible = mSettings.value( action->objectName(), true ).toBool();
if ( !visible )
tb->removeAction( action );
Expand Down Expand Up @@ -708,6 +712,10 @@ void QgsCustomization::updateMainWindow( QMenu * theToolBarMenu )
if ( obj->inherits( "QWidget" ) )
{
QWidget* widget = qobject_cast<QWidget*>( obj );
if ( widget->objectName().isEmpty() )
{
continue;
}
bool visible = mSettings.value( widget->objectName(), true ).toBool();
if ( !visible )
{
Expand All @@ -732,6 +740,10 @@ void QgsCustomization::updateMenu( QMenu* menu, QSettings& settings )
foreach( QAction* action, menu->actions() )
{
QString objName = ( action->menu() ? action->menu()->objectName() : action->objectName() );
if ( objName.isEmpty() )
{
continue;
}
bool visible = settings.value( objName, true ).toBool();
if ( !visible )
menu->removeAction( action );
Expand Down
21 changes: 21 additions & 0 deletions src/app/qgsmergeattributesdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ QComboBox* QgsMergeAttributesDialog::createMergeComboBox( QVariant::Type columnT
newComboBox->addItem( tr( "Minimum" ) );
newComboBox->addItem( tr( "Maximum" ) );
newComboBox->addItem( tr( "Median" ) );
newComboBox->addItem( tr( "Sum" ) );
}
else if ( columnType == QVariant::String )
{
Expand Down Expand Up @@ -246,6 +247,10 @@ void QgsMergeAttributesDialog::refreshMergedValue( int col )
{
evalText = medianAttributeString( col );
}
else if ( mergeBehaviourString == tr( "Sum" ) )
{
evalText = sumAttributeString( col );
}
else if ( mergeBehaviourString == tr( "Concatenation" ) )
{
evalText = concatenationAttributeString( col );
Expand Down Expand Up @@ -390,6 +395,22 @@ QString QgsMergeAttributesDialog::medianAttributeString( int col )
return QString::number( medianValue, 'f' );
}

QString QgsMergeAttributesDialog::sumAttributeString( int col )
{
double sum = 0.0;
bool conversion = false;

for ( int i = 0; i < mFeatureList.size(); ++i )
{
double currentValue = mTableWidget->item( i + 1, col )->text().toDouble( &conversion );
if ( conversion )
{
sum += currentValue;
}
}
return QString::number( sum, 'f' );
}

QString QgsMergeAttributesDialog::concatenationAttributeString( int col )
{
QStringList concatString;
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsmergeattributesdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class QgsMergeAttributesDialog: public QDialog, private Ui::QgsMergeAttributesDi
QString meanAttributeString( int col );
/**Calculates and inserts the median value of a column*/
QString medianAttributeString( int col );
/**Calculates and inserts the sum of a column*/
QString sumAttributeString( int col );
/**Appends the values of the features for the final value*/
QString concatenationAttributeString( int col );
/**Sets mSelectionRubberBand to a new feature*/
Expand Down
2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ SET(QGIS_CORE_SRCS
qgsvectordataprovider.cpp
qgsvectorfilewriter.cpp
qgsvectorlayer.cpp
qgsvectorlayerimport.cpp
qgsvectorlayerjoinbuffer.cpp
qgsvectorlayerundocommand.cpp
qgsvectoroverlay.cpp
Expand Down Expand Up @@ -333,6 +334,7 @@ SET(QGIS_CORE_HDRS
qgsvectordataprovider.h
qgsvectorfilewriter.h
qgsvectorlayer.h
qgsvectorlayerimport.h
qgsvectoroverlay.h
qgstolerance.h

Expand Down
12 changes: 11 additions & 1 deletion src/core/composer/qgscomposermap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,17 @@ void QgsComposerMap::syncLayerSet()
return;
}

QStringList currentLayerSet = mMapRenderer->layerSet();
//if layer set is fixed, do a lookup in the layer registry to also find the non-visible layers
QStringList currentLayerSet;
if ( mKeepLayerSet )
{
currentLayerSet = QgsMapLayerRegistry::instance()->mapLayers().uniqueKeys();
}
else //only consider layers visible in the map
{
currentLayerSet = mMapRenderer->layerSet();
}

for ( int i = mLayerSet.size() - 1; i >= 0; --i )
{
if ( !currentLayerSet.contains( mLayerSet.at( i ) ) )
Expand Down
3 changes: 2 additions & 1 deletion src/core/qgsproviderregistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "qgslogger.h"
#include "qgsmessageoutput.h"
#include "qgsprovidermetadata.h"
#include "qgsvectorlayer.h"


// typedefs for provider plugin functions of interest
Expand Down Expand Up @@ -468,7 +469,7 @@ void * QgsProviderRegistry::function( QString const & providerKey,
return 0;
}

QLibrary *QgsProviderRegistry::providerLibrary( QString const & providerKey )
QLibrary *QgsProviderRegistry::providerLibrary( QString const & providerKey ) const
{
QString lib = library( providerKey );

Expand Down
5 changes: 3 additions & 2 deletions src/core/qgsproviderregistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@

class QgsDataProvider;
class QgsProviderMetadata;

class QgsVectorLayer;
class QgsCoordinateReferenceSystem;


/** \ingroup core
Expand Down Expand Up @@ -78,7 +79,7 @@ class CORE_EXPORT QgsProviderRegistry
void *function( const QString & providerKey,
const QString & functionName );

QLibrary *providerLibrary( const QString & providerKey );
QLibrary *providerLibrary( const QString & providerKey ) const;

/** Return list of available providers by their keys */
QStringList providerList() const;
Expand Down
2 changes: 2 additions & 0 deletions src/core/qgsvectorfilewriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ class CORE_EXPORT QgsVectorFileWriter
/** add feature to the currently opened shapefile */
bool addFeature( QgsFeature& feature );

QMap<int, int> attrIdxToOgrIdx() { return mAttrIdxToOgrIdx; }

/** close opened shapefile for writing */
~QgsVectorFileWriter();

Expand Down
324 changes: 324 additions & 0 deletions src/core/qgsvectorlayerimport.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,324 @@
/***************************************************************************
qgsvectorlayerimport.cpp
vector layer importer
-------------------
begin : Thu Aug 25 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler at gmail.com
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgsfield.h"
#include "qgsfeature.h"
#include "qgsgeometry.h"
#include "qgslogger.h"
#include "qgscoordinatereferencesystem.h"
#include "qgsvectorlayerimport.h"
#include "qgsproviderregistry.h"

#include <QFile>
#include <QSettings>
#include <QFileInfo>
#include <QDir>
#include <QTextCodec>
#include <QTextStream>
#include <QSet>
#include <QMetaType>

#include <cassert>
#include <cstdlib> // size_t
#include <limits> // std::numeric_limits


#define FEATURE_BUFFER_SIZE 200

typedef QgsVectorLayerImport::ImportError createEmptyLayer_t(
const QString &uri,
const QgsFieldMap &fields,
QGis::WkbType geometryType,
const QgsCoordinateReferenceSystem *destCRS,
bool overwrite,
QMap<int, int> *oldToNewAttrIdx,
QString *errorMessage,
const QMap<QString, QVariant> *options
);


QgsVectorLayerImport::QgsVectorLayerImport(
const QString &uri,
const QString &providerKey,
const QgsFieldMap& fields,
QGis::WkbType geometryType,
const QgsCoordinateReferenceSystem* crs,
bool overwrite,
const QMap<QString, QVariant> *options )
{
mProvider = NULL;
QgsProviderRegistry * pReg = QgsProviderRegistry::instance();

QLibrary *myLib = pReg->providerLibrary( providerKey );
if ( !myLib )
{
mError = ErrInvalidProvider;
mErrorMessage = QObject::tr( "Unable to load %1 provider" ).arg( providerKey );
return;
}

createEmptyLayer_t * pCreateEmpty = ( createEmptyLayer_t * ) cast_to_fptr( myLib->resolve( "createEmptyLayer" ) );
if ( !pCreateEmpty )
{
delete myLib;
mError = ErrProviderUnsupportedFeature;
mErrorMessage = QObject::tr( "Provider %1 has no createEmptyLayer method" ).arg( providerKey );
return;
}

delete myLib;

// create an empty layer
QString errMsg;
mError = pCreateEmpty( uri, fields, geometryType, crs, overwrite, &mOldToNewAttrIdx, &errMsg, options );
if ( hasError() )
{
mErrorMessage = errMsg;
return;
}

QgsDebugMsg( "Created empty layer" );

QgsVectorDataProvider *vectorProvider = ( QgsVectorDataProvider* ) pReg->provider( providerKey, uri );
if ( !vectorProvider || !vectorProvider->isValid() )
{
mError = ErrInvalidLayer;
mErrorMessage = QObject::tr( "Loading of layer failed" );

if ( vectorProvider )
delete vectorProvider;
return;
}

mProvider = vectorProvider;
mError = NoError;
}

QgsVectorLayerImport::~QgsVectorLayerImport()
{
flushBuffer();

if ( mProvider )
delete mProvider;
}

QgsVectorLayerImport::ImportError QgsVectorLayerImport::hasError()
{
return mError;
}

QString QgsVectorLayerImport::errorMessage()
{
return mErrorMessage;
}

bool QgsVectorLayerImport::addFeature( QgsFeature& feat )
{
const QgsAttributeMap &attrs = feat.attributeMap();

QgsAttributeMap newAttrs;
for ( QgsAttributeMap::const_iterator it = attrs.begin(); it != attrs.end(); it++ )
{
if ( mOldToNewAttrIdx.contains( it.key() ) )
{
QgsDebugMsgLevel( QString( "moving field from pos %1 to %2" ).arg( it.key() ).arg( mOldToNewAttrIdx.value( it.key() ) ), 3 );
newAttrs.insert( mOldToNewAttrIdx.value( it.key() ), *it );
}
else
{
QgsDebugMsgLevel( QString( "added attr pos %1" ).arg( it.key() ), 3 );
newAttrs.insert( it.key(), *it );
}
}
feat.setAttributeMap( newAttrs );

mFeatureBuffer.append( feat );

if ( mFeatureBuffer.count() >= FEATURE_BUFFER_SIZE )
{
return flushBuffer();
}

return true;
}

bool QgsVectorLayerImport::flushBuffer()
{
if ( mFeatureBuffer.count() <= 0 )
return true;

if ( !mProvider->addFeatures( mFeatureBuffer ) )
{
mErrorMessage = QObject::tr( "Creation error for features from #%1 to #%2" )
.arg( mFeatureBuffer.first().id() )
.arg( mFeatureBuffer.last().id() );
mError = ErrFeatureWriteFailed;

mFeatureBuffer.clear();
QgsDebugMsg( mErrorMessage );
return false;
}

mFeatureBuffer.clear();
return true;
}


QgsVectorLayerImport::ImportError
QgsVectorLayerImport::importLayer( QgsVectorLayer* layer,
const QString& uri,
const QString& providerKey,
const QgsCoordinateReferenceSystem *destCRS,
bool onlySelected,
QString *errorMessage,
bool skipAttributeCreation,
QMap<QString, QVariant> *options )
{
const QgsCoordinateReferenceSystem* outputCRS;
QgsCoordinateTransform* ct = 0;
int shallTransform = false;

if ( layer == NULL )
{
return ErrInvalidLayer;
}

if ( destCRS && destCRS->isValid() )
{
// This means we should transform
outputCRS = destCRS;
shallTransform = true;
}
else
{
// This means we shouldn't transform, use source CRS as output (if defined)
outputCRS = &layer->crs();
}

QgsVectorLayerImport * writer =
new QgsVectorLayerImport( uri, providerKey, skipAttributeCreation ? QgsFieldMap() : layer->pendingFields(), layer->wkbType(), outputCRS, false, options );

// check whether file creation was successful
ImportError err = writer->hasError();
if ( err != NoError )
{
if ( errorMessage )
*errorMessage = writer->errorMessage();
delete writer;
return err;
}

if ( errorMessage )
{
errorMessage->clear();
}

QgsAttributeList allAttr = skipAttributeCreation ? QgsAttributeList() : layer->pendingAllAttributesList();
QgsFeature fet;

layer->select( allAttr, QgsRectangle(), layer->wkbType() != QGis::WKBNoGeometry );

const QgsFeatureIds& ids = layer->selectedFeaturesIds();

// Create our transform
if ( destCRS )
{
ct = new QgsCoordinateTransform( layer->crs(), *destCRS );
}

// Check for failure
if ( ct == NULL )
{
shallTransform = false;
}

int n = 0, errors = 0;

// write all features
while ( layer->nextFeature( fet ) )
{
if ( onlySelected && !ids.contains( fet.id() ) )
continue;

if ( shallTransform )
{
try
{
if ( fet.geometry() )
{
fet.geometry()->transform( *ct );
}
}
catch ( QgsCsException &e )
{
delete ct;
delete writer;

QString msg = QObject::tr( "Failed to transform a point while drawing a feature of type '%1'. Writing stopped. (Exception: %2)" )
.arg( fet.typeName() ).arg( e.what() );
QgsLogger::warning( msg );
if ( errorMessage )
*errorMessage = msg;

return ErrProjection;
}
}
if ( skipAttributeCreation )
{
fet.clearAttributeMap();
}
if ( !writer->addFeature( fet ) )
{
if ( writer->hasError() && errorMessage )
{
if ( errorMessage->isEmpty() )
{
*errorMessage = QObject::tr( "Feature write errors:" );
}
*errorMessage += "\n" + writer->errorMessage();
}
errors++;

if ( errors > 1000 )
{
if ( errorMessage )
{
*errorMessage += QObject::tr( "Stopping after %1 errors" ).arg( errors );
}

n = -1;
break;
}
}
n++;
}

delete writer;

if ( shallTransform )
{
delete ct;
}

if ( errors > 0 && errorMessage && n > 0 )
{
*errorMessage += QObject::tr( "\nOnly %1 of %2 features written." ).arg( n - errors ).arg( n );
}

return errors == 0 ? NoError : ErrFeatureWriteFailed;
}
104 changes: 104 additions & 0 deletions src/core/qgsvectorlayerimport.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/***************************************************************************
qgsvectorlayerimport.cpp
vector layer importer
-------------------
begin : Thu Aug 25 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler at gmail.com
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef _QGSVECTORLAYERIMPORT_H_
#define _QGSVECTORLAYERIMPORT_H_

#include "qgsvectordataprovider.h"
#include "qgsvectorlayer.h"

/** \ingroup core
* A convenience class for writing vector files to disk.
There are two possibilities how to use this class:
1. static call to QgsVectorFileWriter::writeAsShapefile(...) which saves the whole vector layer
2. create an instance of the class and issue calls to addFeature(...)
Currently supports only writing to shapefiles, but shouldn't be a problem to add capability
to support other OGR-writable formats.
*/
class CORE_EXPORT QgsVectorLayerImport
{
public:

enum ImportError
{
NoError = 0,
ErrDriverNotFound,
ErrCreateDataSource,
ErrCreateLayer,
ErrAttributeTypeUnsupported,
ErrAttributeCreationFailed,
ErrProjection,
ErrFeatureWriteFailed,
ErrInvalidLayer,
ErrInvalidProvider,
ErrProviderUnsupportedFeature,
ErrConnectionFailed
};


/** Write contents of vector layer to a different datasource */
static ImportError importLayer( QgsVectorLayer* layer,
const QString& uri,
const QString& providerKey,
const QgsCoordinateReferenceSystem *destCRS,
bool onlySelected = false,
QString *errorMessage = 0,
bool skipAttributeCreation = false,
QMap<QString, QVariant> *options = 0
);

/** create a empty layer and add fields to it */
QgsVectorLayerImport( const QString &uri,
const QString &provider,
const QgsFieldMap& fields,
QGis::WkbType geometryType,
const QgsCoordinateReferenceSystem* crs,
bool overwrite = false,
const QMap<QString, QVariant> *options = 0
);

/** checks whether there were any errors */
ImportError hasError();

/** retrieves error message */
QString errorMessage();

/** add feature to the new created layer */
bool addFeature( QgsFeature& feature );

/** close the new created layer */
~QgsVectorLayerImport();

protected:
/** flush the buffer writing the features to the new layer */
bool flushBuffer();

/** contains error value */
ImportError mError;
QString mErrorMessage;

QgsVectorDataProvider *mProvider;

/** map attribute indexes to new field indexes */
QMap<int, int> mOldToNewAttrIdx;

QgsFeatureList mFeatureBuffer;
};

#endif
19 changes: 14 additions & 5 deletions src/core/symbology-ng/qgsellipsesymbollayerv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void QgsEllipseSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2Rend
return;
}

//priority for rotation: 1. data defined, 2. symbol layer rotation (mAngle)
//priority for rotation: 1. data defined symbol level, 2. symbol layer rotation (mAngle)
double rotation = 0.0;
if ( f && mRotationField.first != -1 )
{
Expand Down Expand Up @@ -211,21 +211,30 @@ void QgsEllipseSymbolLayerV2::preparePath( const QString& symbolName, QgsSymbolV
mPainterPath = QPainterPath();

double width = 0;
if ( f && mWidthField.first != -1 )

if ( f && mWidthField.first != -1 ) //1. priority: data defined setting on symbol layer level
{
width = context.outputLineWidth( f->attributeMap()[mWidthField.first].toDouble() );
}
else
else if( context.renderHints() & QgsSymbolV2::DataDefinedSizeScale ) //2. priority: is data defined size on symbol level
{
width = context.outputLineWidth( mSize );
}
else //3. priority: global width setting
{
width = context.outputLineWidth( mSymbolWidth );
}

double height = 0;
if ( f && mHeightField.first != -1 )
if ( f && mHeightField.first != -1 ) //1. priority: data defined setting on symbol layer level
{
height = context.outputLineWidth( f->attributeMap()[mHeightField.first].toDouble() );
}
else
else if( context.renderHints() & QgsSymbolV2::DataDefinedSizeScale ) //2. priority: is data defined size on symbol level
{
height = context.outputLineWidth( mSize );
}
else //3. priority: global height setting
{
height = context.outputLineWidth( mSymbolHeight );
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/grass/modules-6.3/default.qgc
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@
<grass name="v.what.rast"/>
<grass name="v.sample"/>
</section>
<section label="Report and statistics">
<section label="Reports and statistics">
<grass name="v.to.db"/>
<grass name="v.report"/>
<grass name="v.univar"/>
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/grass/modules-6.4/default.qgc
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@
<grass name="v.what.rast"/>
<grass name="v.sample"/>
</section>
<section label="Report and statistics">
<section label="Reports and statistics">
<grass name="v.to.db"/>
<grass name="v.report"/>
<grass name="v.univar"/>
Expand Down
1 change: 0 additions & 1 deletion src/plugins/grass/modules-common/v.generalize.qgm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@
<option key="beta" answer="1.0" advanced="yes" />
<option key="iterations" answer="1" advanced="yes"/>
<option key="layer" answer="1" advanced="yes"/>
<flag key="r" />
<option key="output" />
</qgisgrassmodule>
133 changes: 131 additions & 2 deletions src/providers/ogr/qgsogrprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ email : sherman at mrcc.com
#include "qgsfield.h"
#include "qgsgeometry.h"
#include "qgscoordinatereferencesystem.h"
#include "qgsvectorfilewriter.h"
#include "qgsvectorlayer.h"
#include "qgsvectorlayerimport.h"

static const QString TEXT_PROVIDER_KEY = "ogr";
static const QString TEXT_PROVIDER_DESCRIPTION =
Expand Down Expand Up @@ -83,6 +82,121 @@ class QgsCPLErrorHandler
}
};


bool QgsOgrProvider::convertField( QgsField &field, const QTextCodec &encoding )
{
OGRFieldType ogrType = OFTString; //default to string
int ogrWidth = field.length();
int ogrPrecision = field.precision();
switch ( field.type() )
{
case QVariant::LongLong:
ogrType = OFTString;
ogrWidth = ogrWidth > 0 && ogrWidth <= 21 ? ogrWidth : 21;
ogrPrecision = -1;
break;

case QVariant::String:
ogrType = OFTString;
if ( ogrWidth < 0 || ogrWidth > 255 )
ogrWidth = 255;
break;

case QVariant::Int:
ogrType = OFTInteger;
ogrWidth = ogrWidth > 0 && ogrWidth <= 10 ? ogrWidth : 10;
ogrPrecision = 0;
break;

case QVariant::Double:
ogrType = OFTReal;
break;

default:
return false;
}

field.setTypeName( encoding.toUnicode( OGR_GetFieldTypeName( ogrType ) ) );
field.setLength( ogrWidth );
field.setPrecision( ogrPrecision );
return true;
}


QgsVectorLayerImport::ImportError QgsOgrProvider::createEmptyLayer(
const QString& uri,
const QgsFieldMap &fields,
QGis::WkbType wkbType,
const QgsCoordinateReferenceSystem *srs,
bool overwrite,
QMap<int, int> *oldToNewAttrIdxMap,
QString *errorMessage,
const QMap<QString,QVariant> *options )
{
QString encoding;
QString driverName = "ESRI Shapefile";
QStringList dsOptions, layerOptions;

if ( options )
{
if ( options->contains( "fileEncoding" ) )
encoding = options->value( "fileEncoding" ).toString();

if ( options->contains( "driverName" ) )
driverName = options->value( "driverName" ).toString();

if ( options->contains( "datasourceOptions" ) )
dsOptions << options->value( "datasourceOptions" ).toStringList();

if ( options->contains( "layerOptions" ) )
layerOptions << options->value( "layerOptions" ).toStringList();
}

if ( oldToNewAttrIdxMap )
oldToNewAttrIdxMap->clear();
if ( errorMessage )
errorMessage->clear();

if ( !overwrite )
{
QFileInfo fi( uri );
if ( fi.exists() )
{
if ( errorMessage )
*errorMessage += QObject::tr( "Unable to create the datasource. %1 exists and overwrite flag is false." )
.arg( uri );
return QgsVectorLayerImport::ErrCreateDataSource;
}
}

QgsVectorFileWriter *writer = new QgsVectorFileWriter(
uri, encoding, fields, wkbType,
srs, driverName, dsOptions, layerOptions );

QgsVectorFileWriter::WriterError error = writer->hasError();
if ( error )
{
if ( errorMessage )
*errorMessage += writer->errorMessage();

delete writer;
return ( QgsVectorLayerImport::ImportError ) error;
}

if ( oldToNewAttrIdxMap )
{
QMap<int, int> attrIdxMap = writer->attrIdxToOgrIdx();
for ( QMap<int, int>::const_iterator attrIt = attrIdxMap.begin(); attrIt != attrIdxMap.end(); ++attrIt )
{
oldToNewAttrIdxMap->insert( attrIt.key(), *attrIt );
}
}

delete writer;
return QgsVectorLayerImport::NoError;
}


QgsOgrProvider::QgsOgrProvider( QString const & uri )
: QgsVectorDataProvider( uri ),
ogrDataSource( 0 ),
Expand Down Expand Up @@ -2369,3 +2483,18 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
return 0;
}

QGISEXTERN QgsVectorLayerImport::ImportError createEmptyLayer(
const QString& uri,
const QgsFieldMap &fields,
QGis::WkbType wkbType,
const QgsCoordinateReferenceSystem *srs,
bool overwrite,
QMap<int, int> *oldToNewAttrIdxMap,
QString *errorMessage,
const QMap<QString,QVariant> *options )
{
return QgsOgrProvider::createEmptyLayer(
uri, fields, wkbType, srs, overwrite,
oldToNewAttrIdxMap, errorMessage, options
);
}
19 changes: 18 additions & 1 deletion src/providers/ogr/qgsogrprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ email : sherman at mrcc.com
#include "qgsdataitem.h"
#include "qgsrectangle.h"
#include "qgsvectordataprovider.h"
#include "qgsvectorfilewriter.h"
#include "qgsvectorlayerimport.h"

class QgsFeature;
class QgsField;
class QgsVectorLayerImport;

#include <ogr_api.h>

Expand All @@ -34,6 +36,18 @@ class QgsOgrProvider : public QgsVectorDataProvider

public:

/** convert a vector layer to a vector file */
static QgsVectorLayerImport::ImportError createEmptyLayer(
const QString& uri,
const QgsFieldMap &fields,
QGis::WkbType wkbType,
const QgsCoordinateReferenceSystem *srs,
bool overwrite,
QMap<int, int> *oldToNewAttrIdxMap,
QString *errorMessage = 0,
const QMap<QString,QVariant> *options = 0
);

/**
* Constructor of the vector provider
* @param uri uniform resource locator (URI) for a dataset
Expand Down Expand Up @@ -254,6 +268,9 @@ class QgsOgrProvider : public QgsVectorDataProvider
/** tell OGR, which fields to fetch in nextFeature/featureAtId (ie. which not to ignore) */
void setRelevantFields( bool fetchGeometry, const QgsAttributeList& fetchAttributes );

/** convert a QgsField to work with OGR */
static bool convertField( QgsField &field, const QTextCodec &encoding );

private:
bool crsFromWkt( QgsCoordinateReferenceSystem &srs, const char *wkt );
unsigned char *getGeometryPointer( OGRFeatureH fet );
Expand Down
414 changes: 410 additions & 4 deletions src/providers/postgres/qgspostgresprovider.cpp

Large diffs are not rendered by default.

30 changes: 28 additions & 2 deletions src/providers/postgres/qgspostgresprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extern "C"
#include "qgsvectordataprovider.h"
#include "qgsdataitem.h"
#include "qgsrectangle.h"
#include "qgsvectorlayerimport.h"

#include <list>
#include <queue>
Expand Down Expand Up @@ -66,6 +67,19 @@ class QgsPostgresProvider : public QgsVectorDataProvider
Q_OBJECT

public:

/** Import a vector layer into the database */
static QgsVectorLayerImport::ImportError createEmptyLayer(
const QString& uri,
const QgsFieldMap &fields,
QGis::WkbType wkbType,
const QgsCoordinateReferenceSystem *srs,
bool overwrite,
QMap<int, int> *oldToNewAttrIdxMap,
QString *errorMessage = 0,
const QMap<QString,QVariant> *options = 0
);

/**
* Constructor for the provider. The uri must be in the following format:
* host=localhost user=gsherman dbname=test password=xxx table=test.alaska (the_geom)
Expand Down Expand Up @@ -319,6 +333,7 @@ class QgsPostgresProvider : public QgsVectorDataProvider
*/
QString description() const;


signals:
/**
* This is emitted whenever the worker thread has fully calculated the
Expand All @@ -340,6 +355,7 @@ class QgsPostgresProvider : public QgsVectorDataProvider
void repaintRequested();

private:

int providerId; // id to append to provider specific identified (like cursors)

bool declareCursor( const QString &cursorName,
Expand Down Expand Up @@ -367,11 +383,11 @@ class QgsPostgresProvider : public QgsVectorDataProvider

/** Double quote a PostgreSQL identifier for placement in a SQL string.
*/
QString quotedIdentifier( QString ident ) const;
static QString quotedIdentifier( QString ident );

/** Quote a value for placement in a SQL string.
*/
QString quotedValue( QString value ) const;
static QString quotedValue( QString value );

/** expression to retrieve value
*/
Expand All @@ -381,6 +397,9 @@ class QgsPostgresProvider : public QgsVectorDataProvider
*/
bool loadFields();

/** convert a QgsField to work with PG */
static bool convertField( QgsField &field );

/**Parses the enum_range of an attribute and inserts the possible values into a stringlist
@param enumValues the stringlist where the values are appended
@param attributeName the name of the enum attribute
Expand Down Expand Up @@ -745,6 +764,13 @@ class QgsPostgresProvider : public QgsVectorDataProvider
* Default value for primary key
*/
QString mPrimaryKeyDefault;

#if 0
/** used to cache the lastest fetched features */
QHash<QgsFeatureId, QgsFeature> mFeatureMap;
QList<QgsFeatureId> mPriorityIds;
#endif

};

class QgsPGConnectionItem : public QgsDataCollectionItem
Expand Down
441 changes: 413 additions & 28 deletions src/providers/spatialite/qgsspatialiteprovider.cpp

Large diffs are not rendered by default.

46 changes: 44 additions & 2 deletions src/providers/spatialite/qgsspatialiteprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ extern "C"

#include "qgsvectordataprovider.h"
#include "qgsrectangle.h"
#include "qgsvectorlayerimport.h"
#include <list>
#include <queue>
#include <fstream>
Expand All @@ -45,6 +46,19 @@ class QgsField;
class QgsSpatiaLiteProvider: public QgsVectorDataProvider
{
Q_OBJECT public:

/** Import a vector layer into the database */
static QgsVectorLayerImport::ImportError createEmptyLayer(
const QString& uri,
const QgsFieldMap &fields,
QGis::WkbType wkbType,
const QgsCoordinateReferenceSystem *srs,
bool overwrite,
QMap<int, int> *oldToNewAttrIdxMap,
QString *errorMessage = 0,
const QMap<QString,QVariant> *options = 0
);

/**
* Constructor of the vector provider
* @param uri uniform resource locator (URI) for a dataset
Expand Down Expand Up @@ -262,6 +276,9 @@ class QgsSpatiaLiteProvider: public QgsVectorDataProvider
/** loads fields from input file to member attributeFields */
void loadFields();

/** convert a QgsField to work with SL */
static bool convertField( QgsField &field );

QgsFieldMap attributeFields;
/**
* Flag indicating if the layer data source is a valid SpatiaLite layer
Expand Down Expand Up @@ -370,8 +387,8 @@ class QgsSpatiaLiteProvider: public QgsVectorDataProvider
*/
//void sqliteOpen();
void closeDb();
QString quotedIdentifier( QString id ) const;
QString quotedValue( QString value ) const;
static QString quotedIdentifier( QString id );
static QString quotedValue( QString value );
bool checkLayerType();
bool getGeometryDetails();
bool getTableGeometryDetails();
Expand Down Expand Up @@ -458,6 +475,31 @@ class QgsSpatiaLiteProvider: public QgsVectorDataProvider
static QMap < QString, SqliteHandles * >handles;
};

struct SLException
{
SLException( char *msg ) : errMsg( msg )
{
}

SLException( const SLException &e ) : errMsg( e.errMsg )
{
}

~SLException()
{
if ( errMsg )
sqlite3_free( errMsg );
}

QString errorMessage() const
{
return errMsg ? QString::fromUtf8( errMsg ) : "unknown cause";
}

private:
char *errMsg;
};

/**
* sqlite3 handles pointer
*/
Expand Down
306 changes: 194 additions & 112 deletions src/providers/wms/qgswmsprovider.cpp

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/providers/wms/qgswmsprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,9 @@ class QgsWmsProvider : public QgsRasterDataProvider

QString layerMetadata( QgsWmsLayerProperty &layer );

//! remove query item and replace it with a new value
void setQueryItem( QUrl &url, QString key, QString value );

//! set authorization header
void setAuthorization( QNetworkRequest &request ) const;

Expand Down
2 changes: 1 addition & 1 deletion src/ui/qgsattributetabledialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
<string>Ctrl+E</string>
</property>
<property name="checkable">
<bool>true</bool>
<bool>false</bool>
</property>
</widget>
</item>
Expand Down