Skip to content

Commit

Permalink
* Add functionality to Create Map buttons.
Browse files Browse the repository at this point in the history
* Fix #31 Style Categorized: The generation of CartoCSS fails if there is data with special characters.
* Remove unnecessary files in the plugin package.
  • Loading branch information
elesdoar committed Aug 11, 2015
1 parent 90a17c0 commit 96ede10
Show file tree
Hide file tree
Showing 13 changed files with 521 additions and 51 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<a name="0.1.10"></a>
### 0.1.10 (2015-07-31)
<a name="0.2.0"></a>
### 0.2.0 (2015-08-10)

#### Enhancements

* Add functionality to Create Map buttons.

#### Fixes

* Fix #25 Error creating map from CartoDB.
* Fix #5 Filter data by attribute or extent.
* Fix problems with SQL layers in maps.
* Fix #31 Style Categorized: The generation of CartoCSS fails if there is data with special characters.
* Remove unnecessary files in the plugin package.

<a name="0.1.9"></a>
### 0.1.9 (2015-07-22)
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ install: transcompile compile
mkdir -p $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)
cp -r ./* $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)
rm -R $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)/scripts
rm -R $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)/test
rm -R $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)/qgis_cartodb.egg-info
rm -R $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)/_site
@echo " "

uninstall:
Expand Down
53 changes: 48 additions & 5 deletions dialogs/CreateViz.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
class CartoDBPluginCreateViz(CartoDBPluginUserDialog):
def __init__(self, toolbar, parent=None):
CartoDBPluginUserDialog.__init__(self, toolbar, parent)
self.toolbar = toolbar

self.ui = Ui_CreateViz()
self.ui.setupUi(self)
Expand Down Expand Up @@ -77,6 +76,10 @@ def __init__(self, toolbar, parent=None):
self.ui.cancelBT.clicked.connect(self.reject)
self.ui.saveBT.clicked.connect(self.createViz)
self.ui.cartoCssBT.clicked.connect(self.createCartoCss)
self.ui.addAllBT.clicked.connect(self.addAllItems)
self.ui.addBT.clicked.connect(self.addItems)
self.ui.removeAllBT.clicked.connect(self.removeAllItems)
self.ui.removeBT.clicked.connect(self.removeItems)

# TODO Implement functionality
self.ui.sqlBT.hide()
Expand All @@ -87,12 +90,52 @@ def __init__(self, toolbar, parent=None):
layers = QgsMapLayerRegistry.instance().mapLayers()

self.ui.availableList.clear()
cartoDBLayers = 0
for id, ly in layers.iteritems():
if ly.type() == QgsMapLayer.VectorLayer and isinstance(ly, CartoDBLayer):
item = QListWidgetItem(self.ui.availableList)
widget = CartoDBLayerListItem(ly.name(), ly, self.getSize(ly), ly.dataProvider().featureCount())
item.setSizeHint(widget.sizeHint())
self.ui.availableList.setItemWidget(item, widget)
cartoDBLayers = cartoDBLayers + 1
if ly.user == self.currentUser:
item = QListWidgetItem(self.ui.availableList)
widget = CartoDBLayerListItem(ly.name(), ly, self.getSize(ly), ly.dataProvider().featureCount())
item.setSizeHint(widget.sizeHint())
self.ui.availableList.setItemWidget(item, widget)

if cartoDBLayers > 0 and len(self.ui.availableList) == 0:
self.ui.bar.clearWidgets()
self.ui.bar.pushMessage(QApplication.translate('CartoDBPlugin', 'Warning') + '!!',
QApplication.translate('CartoDBPlugin',
'At least one CartoDB layer should belong or be visible to {}').format(self.currentUser),
level=QgsMessageBar.WARNING)

def copyItem(self, source, dest, item):
itemWidget = source.itemWidget(item)
newItemWidget = CartoDBLayerListItem(itemWidget.tableName, itemWidget.layer, itemWidget.size, itemWidget.rows)
newItem = source.takeItem(source.row(item))

dest.addItem(newItem)
dest.setItemWidget(newItem, newItemWidget)
dest.setItemSelected(newItem, True)

def addAllItems(self):
self.ui.availableList.selectAll()
self.addItems()

def addItems(self):
if len(self.ui.availableList.selectedItems()) > 0:
for item in self.ui.availableList.selectedItems():
self.copyItem(self.ui.availableList, self.ui.mapList, item)
self.ui.mapList.setFocus()

def removeAllItems(self):
self.ui.mapList.selectAll()
self.removeItems()

def removeItems(self):
if len(self.ui.mapList.selectedItems()) > 0:
for item in self.ui.mapList.selectedItems():
self.copyItem(self.ui.mapList, self.ui.availableList, item)
self.ui.availableList.setFocus()
self.validateButtons()

def getSize(self, layer):
filePath = layer.dataProvider().dataSourceUri()
Expand Down
24 changes: 24 additions & 0 deletions i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
<source>Uploading {}</source>
<translation>Uploading {}</translation>
</message>
<message>
<source>Upload Complete</source>
<translation>Upload Complete</translation>
</message>
<message>
<source>Using {} of {}</source>
<translation>Using {} of {}</translation>
Expand Down Expand Up @@ -100,6 +104,10 @@
<source>All layers are SQL layers</source>
<translation>All layers are SQL layers</translation>
</message>
<message>
<source>At least one CartoDB layer should belong or be visible to {}</source>
<translation>At least one CartoDB layer should belong or be visible to {}</translation>
</message>
<message>
<source>Copy Link</source>
<translation>Copy Link</translation>
Expand Down Expand Up @@ -256,6 +264,22 @@
<source>Create</source>
<translation>Create</translation>
</message>
<message>
<source>Add</source>
<translation>Add</translation>
</message>
<message>
<source>Remove</source>
<translation>Remove</translation>
</message>
<message>
<source>Add all</source>
<translation>Add all</translation>
</message>
<message>
<source>Remove all</source>
<translation>Remove all</translation>
</message>
</context>
<context>
<name>NewSQL</name>
Expand Down
24 changes: 24 additions & 0 deletions i18n/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
<source>Uploading {}</source>
<translation>Subiendo {}</translation>
</message>
<message>
<source>Upload Complete</source>
<translation>Capas Cargadas</translation>
</message>
<message>
<source>Using {} of {}</source>
<translation>Usando {} de {}</translation>
Expand Down Expand Up @@ -100,6 +104,10 @@
<source>All layers are SQL layers</source>
<translation>Todas las capas son capas SQL</translation>
</message>
<message>
<source>At least one CartoDB layer should belong or be visible to {}</source>
<translation>Al menos una capa de CartoDB debe pertenecer o ser visible a {}</translation>
</message>
<message>
<source>Copy Link</source>
<translation>Copiar Enlace</translation>
Expand Down Expand Up @@ -256,6 +264,22 @@
<source>Create</source>
<translation>Crear</translation>
</message>
<message>
<source>Add</source>
<translation>Agregar</translation>
</message>
<message>
<source>Remove</source>
<translation>Remover</translation>
</message>
<message>
<source>Add all</source>
<translation>Agregar todas</translation>
</message>
<message>
<source>Remove all</source>
<translation>Remover todas</translation>
</message>
</context>
<context>
<name>NewSQL</name>
Expand Down
Binary file modified images/icons/add.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/icons/sql.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/icons/upload.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions layers/CartoDBLayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ def _loadData(self, sql, geoJSON=None, spatiaLite=None):
else:
QgsMessageLog.logMessage('Some error ocurred opening GeoJSON datasource', 'CartoDB Plugin', QgsMessageLog.WARNING)
else:
QgsMessageLog.logMessage('New Layer created', 'CartoDB Plugin', QgsMessageLog.INFO)
QgsMessageLog.logMessage('New Connection: ' + spatiaLite, 'CartoDB Plugin', QgsMessageLog.INFO)
# QgsMessageLog.logMessage('New Layer created', 'CartoDB Plugin', QgsMessageLog.INFO)
# QgsMessageLog.logMessage('New Connection: ' + spatiaLite, 'CartoDB Plugin', QgsMessageLog.INFO)

path = spatiaLite
self.layerType = 'ogr'
readonly = False
Expand All @@ -156,6 +157,9 @@ def _loadData(self, sql, geoJSON=None, spatiaLite=None):
super(QgsVectorLayer, self).__init__(geoJSON, self.layerName, self.layerType)
else:
super(QgsVectorLayer, self).__init__(path, self.layerName, self.layerType)
# Set encoding to UTF-8
self.setProviderEncoding('UTF-8')

self.readonly = readonly
self._deletedFeatures = []

Expand Down
9 changes: 6 additions & 3 deletions metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name=QGISCartoDB
description=CartoDB Plugin for QGis. It allows to view, create, edit or delete data from your CartoDB account using your favorite opensource desktop GIS: QGIS.
category=Web
version=0.1.10
version=0.2.0
qgisMinimumVersion=2.4
icon=images/icon.png
author=Kudos Ltda. and contributors
Expand All @@ -23,7 +23,10 @@ about=
- simplejson
- certifi
[email protected]
changelog=0.1.10
changelog=0.2.0
- Add functionality to Create Map buttons.
- Fix Style Categorized: The generation of CartoCSS fails if there is data with special characters.
- Remove unnecessary files in the plugin package.
- Fix error creating map from CartoDB.
- Fix filter data by attribute or extent.
- Fix problems with SQL layers in maps.
Expand Down Expand Up @@ -83,5 +86,5 @@ tags=cartodb,OSM,tiles,kudos
homepage=https://github.com/gkudos/qgis-cartodb
tracker=https://github.com/gkudos/qgis-cartodb/issues
repository=https://github.com/gkudos/qgis-cartodb
experimental=True
experimental=False
deprecated=False
Loading

0 comments on commit 96ede10

Please sign in to comment.