def load(self):
     worker = CartoDBPluginWorker(self, 'loadLayer')
     worker.error.connect(self.workerError)
     self.loop = QEventLoop()
     worker.finished.connect(self.workerFinished)
     worker.start()
     self.loop.exec_()
Example #2
0
    def __init__(self, toolbar, parent=None):
        QDialog.__init__(self, parent)
        self.toolbar = toolbar
        self.settings = QSettings()

        self.ui = Ui_Upload()
        self.ui.setupUi(self)

        self.ui.uploadBT.clicked.connect(self.upload)
        self.ui.cancelBT.clicked.connect(self.reject)

        self.currentUser = self.toolbar.currentUser
        self.currentApiKey = self.toolbar.currentApiKey
        self.currentMultiuser = self.toolbar.currentMultiuser

        layers = QgsMapLayerRegistry.instance().mapLayers()

        self.ui.layersList.clear()
        self.ui.uploadBar.setValue(0)
        self.ui.uploadBar.hide()
        self.ui.uploadingLB.hide()
        for id, ly in layers.iteritems():
            if ly.type() == QgsMapLayer.VectorLayer and not isinstance(ly, CartoDBLayer):
                item = QListWidgetItem(self.ui.layersList)
                widget = CartoDBLayerListItem(ly.name(), ly, self.getSize(ly), ly.dataProvider().featureCount())
                item.setSizeHint(widget.sizeHint())
                self.ui.layersList.setItemWidget(item, widget)

        worker = CartoDBPluginWorker(self, 'connectUser')
        worker.start()
    def initGui(self):
        self._cdbMenu = QMenu("CartoDB plugin", self.iface.mainWindow())
        self._cdbMenu.setIcon(QIcon(":/plugins/qgis-cartodb/images/icon.png"))
        self._mainAction = QAction(self.tr('Add CartoDB Layer'),
                                   self.iface.mainWindow())
        self._mainAction.setIcon(
            QIcon(":/plugins/qgis-cartodb/images/icons/add.png"))
        self._loadDataAction = QAction(self.tr('Upload layers to CartoDB'),
                                       self.iface.mainWindow())
        self._loadDataAction.setIcon(
            QIcon(":/plugins/qgis-cartodb/images/icons/polygon.png"))
        self._createVizAction = QAction(self.tr('Create New Map'),
                                        self.iface.mainWindow())
        self._createVizAction.setIcon(
            QIcon(":/plugins/qgis-cartodb/images/icons/rectangle.png"))
        self._addSQLAction = QAction(self.tr('Add SQL CartoDB Layer'),
                                     self.iface.mainWindow())
        self._addSQLAction.setIcon(
            QIcon(":/plugins/qgis-cartodb/images/icons/add_sql.png"))

        self.toolbar = CartoDBToolbar()
        self.toolbar.setClick(self.connectionManager)
        self.toolbar.error.connect(self.toolbarError)
        self._toolbarAction = self.iface.addWebToolBarWidget(self.toolbar)
        worker = CartoDBPluginWorker(self.toolbar, 'connectCartoDB')
        worker.start()

        if not self.toolbar.isCurrentUserValid():
            self._mainAction.setEnabled(False)
            self._loadDataAction.setEnabled(False)
            self._createVizAction.setEnabled(False)
            self._addSQLAction.setEnabled(False)

        self._mainAction.activated.connect(self.run)
        self._loadDataAction.activated.connect(self.upload)
        self._createVizAction.activated.connect(self.createNewMap)
        self._addSQLAction.activated.connect(self.addSQL)

        self._cdbMenu.addAction(self._mainAction)
        self._cdbMenu.addAction(self._loadDataAction)
        self._cdbMenu.addAction(self._createVizAction)
        self._cdbMenu.addAction(self._addSQLAction)
        self.iface.addWebToolBarIcon(self._mainAction)
        self.iface.addWebToolBarIcon(self._loadDataAction)
        self.iface.addWebToolBarIcon(self._createVizAction)
        self.iface.addWebToolBarIcon(self._addSQLAction)

        # Create Web menu, if it doesn't exist yet
        tmpAction = QAction("Temporal", self.iface.mainWindow())
        self.iface.addPluginToWebMenu("_tmp", tmpAction)
        self._menu = self.iface.webMenu()
        self._menu.addMenu(self._cdbMenu)
        self.iface.removePluginWebMenu("_tmp", tmpAction)

        # Register plugin layer type
        self.pluginLayerType = CartoDBPluginLayerType(self.iface,
                                                      self.createLayerCB)
        QgsPluginLayerRegistry.instance().addPluginLayerType(
            self.pluginLayerType)
Example #4
0
    def initGui(self):
        self._cdbMenu = QMenu("CartoDB plugin", self.iface.mainWindow())
        self._cdbMenu.setIcon(QIcon(":/plugins/qgis-cartodb/images/icon.png"))
        self._mainAction = QAction(self.tr('Add CartoDB Layer'), self.iface.mainWindow())
        self._mainAction.setIcon(QIcon(":/plugins/qgis-cartodb/images/icons/add.png"))
        self._loadDataAction = QAction(self.tr('Upload layers to CartoDB'), self.iface.mainWindow())
        self._loadDataAction.setIcon(QIcon(":/plugins/qgis-cartodb/images/icons/upload.png"))
        self._createVizAction = QAction(self.tr('Create New Map'), self.iface.mainWindow())
        self._createVizAction.setIcon(QIcon(":/plugins/qgis-cartodb/images/icons/map.png"))
        self._addSQLAction = QAction(self.tr('Add SQL CartoDB Layer'), self.iface.mainWindow())
        self._addSQLAction.setIcon(QIcon(":/plugins/qgis-cartodb/images/icons/sql.png"))

        self.toolbar = CartoDBToolbar()
        self.toolbar.setClick(self.connectionManager)
        self.toolbar.error.connect(self.toolbarError)
        self._toolbarAction = self.iface.addWebToolBarWidget(self.toolbar)
        worker = CartoDBPluginWorker(self.toolbar, 'connectCartoDB')
        worker.start()

        if not self.toolbar.isCurrentUserValid():
            self._mainAction.setEnabled(False)
            self._loadDataAction.setEnabled(False)
            self._createVizAction.setEnabled(False)
            self._addSQLAction.setEnabled(False)

        self._mainAction.triggered.connect(self.run)
        self._loadDataAction.triggered.connect(self.upload)
        self._createVizAction.triggered.connect(self.createNewMap)
        self._addSQLAction.triggered.connect(self.addSQL)

        self._cdbMenu.addAction(self._mainAction)
        self._cdbMenu.addAction(self._loadDataAction)
        self._cdbMenu.addAction(self._createVizAction)
        self._cdbMenu.addAction(self._addSQLAction)
        try:
            self.iface.layerToolBar().addAction(self._mainAction)
        except:
            self.iface.addWebToolBarIcon(self._mainAction)
        self.iface.addWebToolBarIcon(self._loadDataAction)
        self.iface.addWebToolBarIcon(self._createVizAction)
        try:
            self.iface.layerToolBar().addAction(self._addSQLAction)
        except:
            self.iface.addWebToolBarIcon(self._addSQLAction)

        # Create Web menu, if it doesn't exist yet
        tmpAction = QAction("Temporal", self.iface.mainWindow())
        self.iface.addPluginToWebMenu("_tmp", tmpAction)
        self._menu = self.iface.webMenu()
        self._menu.addMenu(self._cdbMenu)
        self.iface.removePluginWebMenu("_tmp", tmpAction)

        # Register plugin layer type
        self.pluginLayerType = CartoDBPluginLayerType(self.iface, self.createLayerCB)
        QgsPluginLayerRegistry.instance().addPluginLayerType(self.pluginLayerType)
Example #5
0
    def __init__(self, toolbar, parent=None):
        QDialog.__init__(self, parent)
        self.toolbar = toolbar
        self.settings = QSettings()

        self.currentUser = self.toolbar.currentUser
        self.currentApiKey = self.toolbar.currentApiKey
        self.currentMultiuser = self.toolbar.currentMultiuser
        self.currentUserData = self.toolbar.currentUserData

        worker = CartoDBPluginWorker(self, 'connectUser')
        worker.start()
Example #6
0
    def __init__(self, toolbar, parent=None):
        QDialog.__init__(self, parent)
        self.toolbar = toolbar
        self.settings = QSettings()

        self.currentUser = self.toolbar.currentUser
        self.currentApiKey = self.toolbar.currentApiKey
        self.currentMultiuser = self.toolbar.currentMultiuser
        self.currentUserData = self.toolbar.currentUserData

        worker = CartoDBPluginWorker(self, 'connectUser')
        worker.start()
Example #7
0
 def showEvent(self, event):
     worker = CartoDBPluginWorker(self, 'findTables')
     worker.start()
Example #8
0
 def showEvent(self, event):
     worker = CartoDBPluginWorker(self, 'findTables')
     worker.start()
Example #9
0
 def setUserCredentials(self, user, apiKey, multiuser=False):
     self.currentUser = user
     self.currentApiKey = apiKey
     self.currentMultiuser = multiuser
     worker = CartoDBPluginWorker(self, 'connectCartoDB')
     worker.start()
Example #10
0
 def showEvent(self, event):
     worker = CartoDBPluginWorker(self, 'connect')
     worker.start()
Example #11
0
 def initUserConnection(self):
     worker = CartoDBPluginWorker(self, 'connectUser')
     worker.start()
Example #12
0
 def showEvent(self, event):
     worker = CartoDBPluginWorker(self, 'connect')
     worker.start()
Example #13
0
 def setUserCredentials(self, user, apiKey, multiuser=False):
     self.currentUser = user
     self.currentApiKey = apiKey
     self.currentMultiuser = multiuser
     worker = CartoDBPluginWorker(self, 'connectCartoDB')
     worker.start()