def __init__(self, parent, fl): QDialog.__init__(self, parent, fl) self.setupUi(self) self.fl = fl self.setWindowTitle('QGIS WPS-Client ' + version()) self.dlgAbout = DlgAbout(parent) self.filterText = '' self.lneFilter.setText('')
def __init__(self, iface, version): QDockWidget.__init__(self, None) self.iface = iface self.clouddb = True self.version = version # Set up the user interface from Designer. self.ui = Ui_QgisCloudPlugin() self.ui.setupUi(self) myAbout = DlgAbout() self.ui.aboutText.setText(myAbout.aboutString() + myAbout.contribString() + myAbout.licenseString() + "<p>Version: " + version + "</p>") self.ui.tblLocalLayers.setColumnCount(5) header = ["Layers", "Data source", "Table name", "Geometry type", "SRID"] self.ui.tblLocalLayers.setHorizontalHeaderLabels(header) self.ui.tblLocalLayers.resizeColumnsToContents() # TODO; delegate for read only columns self.ui.btnUploadData.setEnabled(False) self.ui.uploadProgressBar.hide() self.ui.btnPublishMapUpload.hide() self.ui.btnLogout.hide() self.ui.lblLoginStatus.hide() # map<data source, table name> self.data_sources_table_names = {} # flag to disable update of local data sources during upload self.do_update_local_data_sources = True QObject.connect(self.ui.btnLogin, SIGNAL("clicked()"), self.login) QObject.connect(self.ui.btnDbCreate, SIGNAL("clicked()"), self.create_database) QObject.connect(self.ui.btnDbDelete, SIGNAL("clicked()"), self.delete_database) QObject.connect(self.ui.btnDbRefresh, SIGNAL("clicked()"), self.refresh_databases) QObject.connect(self.ui.tabDatabases, SIGNAL("itemSelectionChanged()"), self.select_database) QObject.connect(self.ui.btnPublishMap, SIGNAL("clicked()"), self.publish_map) QObject.connect(self.ui.btnRefreshLocalLayers, SIGNAL("clicked()"), self.refresh_local_data_sources) QObject.connect(self.iface, SIGNAL("newProjectCreated()"), self.reset_load_data) QObject.connect(QgsMapLayerRegistry.instance(), SIGNAL("layerWillBeRemoved(QString)"), self.remove_layer) QObject.connect(QgsMapLayerRegistry.instance(), SIGNAL("layerWasAdded(QgsMapLayer *)"), self.add_layer) QObject.connect(self.ui.cbUploadDatabase, SIGNAL("currentIndexChanged(int)"), self.upload_database_selected) QObject.connect(self.ui.btnUploadData, SIGNAL("clicked()"), self.upload_data) QObject.connect(self.ui.btnPublishMapUpload, SIGNAL("clicked()"), self.publish_map) self.ui.editServer.textChanged.connect(self.serverURL) self.ui.resetUrlBtn.clicked.connect(self.resetApiUrl) self.read_settings() self.api = API() self.db_connections = DbConnections() self.local_data_sources = LocalDataSources() self.data_upload = DataUpload(self.iface, self.statusBar(), self.ui.uploadProgressBar, self.api, self.db_connections) if self.URL == "": self.ui.editServer.setText(self.api.api_url()) else: self.ui.editServer.setText(self.URL) self.palette_red = QPalette(self.ui.serviceLinks.palette()) self.palette_red.setColor(QPalette.WindowText, QColor('red'))
def __init__(self, parent, fl): QDialog.__init__(self, parent, fl) self.setupUi(self) self.fl = fl self.setWindowTitle('QGIS WPS-Client '+version()) self.dlgAbout = DlgAbout(parent) self.filterText = '' self.lneFilter.setText('')
class QgsWpsGui(QDialog, QObject, Ui_QgsWps): MSG_BOX_TITLE = "WPS" getDescription = pyqtSignal(str, QTreeWidgetItem) newServer = pyqtSignal() editServer = pyqtSignal(str) deleteServer = pyqtSignal(str) connectServer = pyqtSignal(list) pushDefaultWPSServer = pyqtSignal(str) requestDescribeProcess = pyqtSignal(str, str) def __init__(self, parent, fl): QDialog.__init__(self, parent, fl) self.setupUi(self) self.fl = fl self.setWindowTitle('QGIS WPS-Client '+version()) self.dlgAbout = DlgAbout(parent) self.filterText = '' self.lneFilter.setText('') def initQgsWpsGui(self): ## self.btnOk.setEnabled(False) self.btnConnect.setEnabled(False) settings = QSettings() settings.beginGroup("WPS") connections = settings.childGroups() self.cmbConnections.clear() self.cmbConnections.addItems(connections) self.treeWidget.clear() if self.cmbConnections.size() > 0: self.btnConnect.setEnabled(True) self.btnEdit.setEnabled(True) self.btnDelete.setEnabled(True) return 1 def getBookmark(self, item): self.requestDescribeProcess.emit(item.text(0), item.text(1)) def on_buttonBox_rejected(self): self.close() # see http://www.riverbankcomputing.com/Docs/PyQt4/pyqt4ref.html#connecting-signals-and-slots # without this magic, the on_btnOk_clicked will be called two times: one clicked() and one clicked(bool checked) @pyqtSignature("on_buttonBox_accepted()") def on_buttonBox_accepted(self): if self.treeWidget.topLevelItemCount() == 0: QMessageBox.warning(None, 'WPS Warning','No Service connected!') else: try: self.getDescription.emit(self.cmbConnections.currentText(), self.treeWidget.currentItem() ) except: QMessageBox.information(None, self.tr('Error'), self.tr('Please select a process!')) # see http://www.riverbankcomputing.com/Docs/PyQt4/pyqt4ref.html#connecting-signals-and-slots # without this magic, the on_btnOk_clicked will be called two times: one clicked() and one clicked(bool checked) @pyqtSignature("on_btnConnect_clicked()") def on_btnConnect_clicked(self): self.treeWidget.clear() self.filterText = '' self.lneFilter.setText('') selectedWPS = self.cmbConnections.currentText() self.server = WpsServer.getServer(selectedWPS) self.server.capabilitiesRequestFinished.connect(self.createCapabilitiesGUI) self.server.requestCapabilities() @pyqtSignature("on_btnBookmarks_clicked()") def on_btnBookmarks_clicked(self): self.dlgBookmarks = Bookmarks(self.fl) self.dlgBookmarks.getBookmarkDescription.connect(self.getBookmark) # self.dlgBookmarks.bookmarksChanged.connect(bookmarksChanged()) self.dlgBookmarks.show() @pyqtSignature("on_btnNew_clicked()") def on_btnNew_clicked(self): self.newServer.emit() @pyqtSignature("on_btnEdit_clicked()") def on_btnEdit_clicked(self): self.editServer.emit(self.cmbConnections.currentText()) @pyqtSignature("on_cmbConnections_currentIndexChanged()") def on_cmbConnections_currentIndexChanged(self): pass @pyqtSignature("on_btnDelete_clicked()") def on_btnDelete_clicked(self): self.deleteServer.emit(self.cmbConnections.currentText()) def initTreeWPSServices(self, taglist): self.treeWidget.clear() self.treeWidget.setColumnCount(self.treeWidget.columnCount()) itemList = [] for items in taglist: if self.filterText == '': item = QTreeWidgetItem() ident = pystring(items[0]) title = pystring(items[1]) abstract = pystring(items[2]) item.setText(0,ident.strip()) item.setText(1,title.strip()) item.setText(2,abstract.strip()) itemList.append(item) else: if self.filterText in pystring(items[0]) or self.filterText in pystring(items[1]) or self.filterText in pystring(items[2]): item = QTreeWidgetItem() ident = pystring(items[0]) title = pystring(items[1]) abstract = pystring(items[2]) item.setText(0,ident.strip()) item.setText(1,title.strip()) item.setText(2,abstract.strip()) itemList.append(item) self.treeWidget.addTopLevelItems(itemList) @pyqtSignature("on_btnAbout_clicked()") def on_btnAbout_clicked(self): self.dlgAbout.show() pass @pyqtSignature("QTreeWidgetItem*, int") def on_treeWidget_itemDoubleClicked(self, item, column): self.getDescription.emit(self.cmbConnections.currentText(), self.treeWidget.currentItem() ) def createCapabilitiesGUI(self): # try: self.treeWidget.clear() self.itemListAll = self.server.parseCapabilitiesXML() self.initTreeWPSServices(self.itemListAll) # except: # pass @pyqtSignature("QString") def on_lneFilter_textChanged(self, p0): """ Slot documentation goes here. """ # TODO: not implemented yet self.filterText = p0 self.initTreeWPSServices(self.itemListAll)
class QgsWpsGui(QDialog, QObject, Ui_QgsWps): MSG_BOX_TITLE = "WPS" getDescription = pyqtSignal(str, QTreeWidgetItem) newServer = pyqtSignal() editServer = pyqtSignal(str) deleteServer = pyqtSignal(str) connectServer = pyqtSignal(list) pushDefaultWPSServer = pyqtSignal(str) requestDescribeProcess = pyqtSignal(str, str) def __init__(self, parent, fl): QDialog.__init__(self, parent, fl) self.setupUi(self) self.fl = fl self.setWindowTitle('QGIS WPS-Client ' + version()) self.dlgAbout = DlgAbout(parent) self.filterText = '' self.lneFilter.setText('') def initQgsWpsGui(self): ## self.btnOk.setEnabled(False) self.btnConnect.setEnabled(False) settings = QSettings() settings.beginGroup("WPS") connections = settings.childGroups() self.cmbConnections.clear() self.cmbConnections.addItems(connections) self.treeWidget.clear() if self.cmbConnections.size() > 0: self.btnConnect.setEnabled(True) self.btnEdit.setEnabled(True) self.btnDelete.setEnabled(True) try: settings = QSettings() myIndex = pyint(settings.value("WPS-lastConnection/Index", "Index")) self.cmbConnections.setCurrentIndex(myIndex) except: pass return 1 def getBookmark(self, item): self.requestDescribeProcess.emit(item.text(0), item.text(1)) def on_buttonBox_rejected(self): self.close() # see http://www.riverbankcomputing.com/Docs/PyQt4/pyqt4ref.html#connecting-signals-and-slots # without this magic, the on_btnOk_clicked will be called two times: one clicked() and one clicked(bool checked) @pyqtSignature("on_buttonBox_accepted()") def on_buttonBox_accepted(self): if self.treeWidget.topLevelItemCount() == 0: QMessageBox.warning(None, 'WPS Warning', 'No Service connected!') else: try: self.getDescription.emit(self.cmbConnections.currentText(), self.treeWidget.currentItem()) except: QMessageBox.information(None, self.tr('Error'), self.tr('Please select a process!')) # see http://www.riverbankcomputing.com/Docs/PyQt4/pyqt4ref.html#connecting-signals-and-slots # without this magic, the on_btnOk_clicked will be called two times: one clicked() and one clicked(bool checked) @pyqtSignature("on_btnConnect_clicked()") def on_btnConnect_clicked(self): self.treeWidget.clear() self.filterText = '' self.lneFilter.setText('') selectedWPS = self.cmbConnections.currentText() self.server = WpsServer.getServer(selectedWPS) self.server.capabilitiesRequestFinished.connect( self.createCapabilitiesGUI) self.server.requestCapabilities() @pyqtSignature("on_btnBookmarks_clicked()") def on_btnBookmarks_clicked(self): self.dlgBookmarks = Bookmarks(self.fl) self.dlgBookmarks.getBookmarkDescription.connect(self.getBookmark) # self.dlgBookmarks.bookmarksChanged.connect(bookmarksChanged()) self.dlgBookmarks.show() @pyqtSignature("on_btnNew_clicked()") def on_btnNew_clicked(self): self.newServer.emit() @pyqtSignature("on_btnEdit_clicked()") def on_btnEdit_clicked(self): self.editServer.emit(self.cmbConnections.currentText()) @pyqtSignature("on_cmbConnections_activated(int)") def on_cmbConnections_activated(self, index): settings = QSettings() settings.setValue("WPS-lastConnection/Index", pystring(index)) @pyqtSignature("on_btnDelete_clicked()") def on_btnDelete_clicked(self): self.deleteServer.emit(self.cmbConnections.currentText()) def initTreeWPSServices(self, taglist): self.treeWidget.clear() self.treeWidget.setColumnCount(self.treeWidget.columnCount()) itemList = [] for items in taglist: if self.filterText == '': item = QTreeWidgetItem() ident = pystring(items[0]) title = pystring(items[1]) abstract = pystring(items[2]) item.setText(0, ident.strip()) item.setText(1, title.strip()) item.setText(2, abstract.strip()) itemList.append(item) else: if self.filterText in pystring( items[0]) or self.filterText in pystring( items[1]) or self.filterText in pystring(items[2]): item = QTreeWidgetItem() ident = pystring(items[0]) title = pystring(items[1]) abstract = pystring(items[2]) item.setText(0, ident.strip()) item.setText(1, title.strip()) item.setText(2, abstract.strip()) itemList.append(item) self.treeWidget.addTopLevelItems(itemList) @pyqtSignature("on_btnAbout_clicked()") def on_btnAbout_clicked(self): self.dlgAbout.show() pass @pyqtSignature("QTreeWidgetItem*, int") def on_treeWidget_itemDoubleClicked(self, item, column): self.getDescription.emit(self.cmbConnections.currentText(), self.treeWidget.currentItem()) def createCapabilitiesGUI(self): # try: self.treeWidget.clear() self.itemListAll = self.server.parseCapabilitiesXML() self.initTreeWPSServices(self.itemListAll) # except: # pass @pyqtSignature("QString") def on_lneFilter_textChanged(self, p0): """ Slot documentation goes here. """ # TODO: not implemented yet self.filterText = p0 self.initTreeWPSServices(self.itemListAll)
def __init__(self, parent, fl): QDialog.__init__(self, parent, fl) self.setupUi(self) self.fl = fl self.setWindowTitle('QgsWPSClient-' + version() + ' Service Chooser') self.dlgAbout = DlgAbout(parent)
class QgsWps: MSG_BOX_TITLE = "WPS Client" def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface self.localePath = "" #Initialise the translation environment userPluginPath = QFileInfo( QgsApplication.qgisUserDbFilePath()).path() + "/python/plugins/wps" systemPluginPath = QgsApplication.prefixPath( ) + "/share/qgis/python/plugins/wps" myLocale = pystring(QSettings().value("locale/userLocale"))[0:2] if QFileInfo(userPluginPath).exists(): self.pluginPath = userPluginPath self.localePath = userPluginPath + "/i18n/wps_" + myLocale + ".qm" elif QFileInfo(systemPluginPath).exists(): self.pluginPath = systemPluginPath self.localePath = systemPluginPath + "/i18n/wps_" + myLocale + ".qm" if QFileInfo(self.localePath).exists(): self.translator = QTranslator() self.translator.load(self.localePath) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) ############################################################################## def initGui(self): # Create action that will start plugin configuration self.action = QAction(QIcon(":/plugins/wps/images/wps-add.png"), "WPS-Client", self.iface.mainWindow()) self.action.triggered.connect(self.run) self.actionAbout = QAction("About", self.iface.mainWindow()) self.actionAbout.triggered.connect(self.doAbout) # Add toolbar button and menu item self.iface.addToolBarIcon(self.action) if hasattr(self.iface, "addPluginToWebMenu"): self.iface.addPluginToWebMenu("WPS-Client", self.action) self.iface.addPluginToWebMenu("WPS-Client", self.actionAbout) else: self.iface.addPluginToMenu("WPS", self.action) self.iface.addPluginToWebMenu("WPS", self.action) self.myDockWidget = QgsWpsDockWidget(self.iface) self.myDockWidget.setWindowTitle('WPS') self.iface.addDockWidget(Qt.LeftDockWidgetArea, self.myDockWidget) self.myDockWidget.show() if SEXTANTE_SUPPORT: self.provider = WpsAlgorithmProvider(self.myDockWidget) else: self.provider = None if self.provider: try: Sextante.addProvider(self.provider, True) #Force tree update except TypeError: Sextante.addProvider(self.provider) ############################################################################## def unload(self): if hasattr(self.iface, "addPluginToWebMenu"): self.iface.removePluginWebMenu("WPS-Client", self.action) self.iface.removePluginWebMenu("WPS-Client", self.actionAbout) else: self.iface.removePluginToMenu("WPS", self.action) self.iface.removePluginToMenu("WPS", self.actionAbout) self.iface.removeToolBarIcon(self.action) if self.myDockWidget: self.myDockWidget.close() self.myDockWidget = None if self.provider: Sextante.removeProvider(self.provider) ############################################################################## def run(self): if self.myDockWidget.isVisible(): self.myDockWidget.hide() else: self.myDockWidget.show() def doAbout(self): self.dlgAbout = DlgAbout() self.dlgAbout.show()
def __init__(self, parent, tools, fl): QDialog.__init__(self, parent, fl) self.setupUi(self) self.fl = fl self.tools = tools self.dlgAbout = DlgAbout(parent)
class QgsWPSClient: MSG_BOX_TITLE = "QgsWPSClient" def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface self.localePath = "" #Initialise the translation environment userPluginPath = QFileInfo(QgsApplication.qgisUserDbFilePath()).path()+"/python/plugins/QgsWPSClient" systemPluginPath = QgsApplication.prefixPath()+"/share/qgis/python/plugins/QgsWPSClient" myLocale = pystring(QSettings().value("locale/userLocale"))[0:2] if QFileInfo(userPluginPath).exists(): self.pluginPath = userPluginPath self.localePath = userPluginPath+"/i18n/wps_"+myLocale+".qm" elif QFileInfo(systemPluginPath).exists(): self.pluginPath = systemPluginPath self.localePath = systemPluginPath+"/i18n/wps_"+myLocale+".qm" if QFileInfo(self.localePath).exists(): self.translator = QTranslator() self.translator.load(self.localePath) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) ############################################################################## def initGui(self): # Create action that will start plugin configuration self.action = QAction(QIcon(":/plugins/QgsWPSClient/images/wps-add.png"), "QgsWPSClient", self.iface.mainWindow()) self.action.triggered.connect(self.run) self.actionAbout = QAction("About", self.iface.mainWindow()) self.actionAbout.triggered.connect(self.doAbout) # Add toolbar button and menu item self.iface.addToolBarIcon(self.action) if hasattr(self.iface, "addPluginToWebMenu"): self.iface.addPluginToWebMenu("QgsWPSClient", self.action) self.iface.addPluginToWebMenu("QgsWPSClient", self.actionAbout) else: self.iface.addPluginToMenu("QgsWPSClient", self.action) self.iface.addPluginToWebMenu("QgsWPSClient", self.action) self.myDockWidget = QgsWpsDockWidget(self.iface) self.myDockWidget.setWindowTitle('QgsWPSClient-'+version()) self.iface.addDockWidget(Qt.LeftDockWidgetArea, self.myDockWidget) self.myDockWidget.show() if SEXTANTE_SUPPORT: self.provider = WpsAlgorithmProvider(self.myDockWidget) else: self.provider = None if self.provider: try: Sextante.addProvider(self.provider, True) #Force tree update except TypeError: Sextante.addProvider(self.provider) ############################################################################## def unload(self): if hasattr(self.iface, "addPluginToWebMenu"): self.iface.removePluginWebMenu("QgsWPSClient", self.action) self.iface.removePluginWebMenu("QgsWPSClient", self.actionAbout) else: self.iface.removePluginToMenu("QgsWPSClient", self.action) self.iface.removePluginToMenu("QgsWPSClient", self.actionAbout) self.iface.removeToolBarIcon(self.action) if self.myDockWidget: self.myDockWidget.close() self.myDockWidget = None if self.provider: Sextante.removeProvider(self.provider) ############################################################################## def run(self): if self.myDockWidget.isVisible(): self.myDockWidget.hide() else: self.myDockWidget.show() def doAbout(self): self.dlgAbout = DlgAbout() self.dlgAbout.show()
def doAbout(self): self.dlgAbout = DlgAbout() self.dlgAbout.show()
def __init__(self, iface, version): QDockWidget.__init__(self, None) self.iface = iface self.clouddb = True self.version = version # Set up the user interface from Designer. self.ui = Ui_QgisCloudPlugin() self.ui.setupUi(self) self.storage_exceeded = True myAbout = DlgAbout() self.ui.aboutText.setText( myAbout.aboutString() + myAbout.contribString() + myAbout.licenseString() + "<p>Versions:<ul>" + "<li>QGIS: %s</li>" % unicode(QGis.QGIS_VERSION).encode("utf-8") + "<li>Python: %s</li>" % sys.version.replace("\n", " ") + "<li>OS: %s</li>" % platform.platform() + "</ul></p>") self.ui.lblVersionPlugin.setText(self.version) self.ui.tblLocalLayers.setColumnCount(5) header = [ "Layers", "Data source", "Table name", "Geometry type", "SRID" ] self.ui.tblLocalLayers.setHorizontalHeaderLabels(header) self.ui.tblLocalLayers.resizeColumnsToContents() self.ui.tblLocalLayers.setEditTriggers( QAbstractItemView.NoEditTriggers) self.ui.btnUploadData.setEnabled(False) self.ui.btnPublishMap.setEnabled(False) self.ui.progressWidget.hide() self.ui.btnLogout.hide() self.ui.lblLoginStatus.hide() self.ui.widgetServices.hide() self.ui.widgetDatabases.setEnabled(False) self.ui.labelOpenLayersPlugin.hide() try: if QGis.QGIS_VERSION_INT >= 20300: from openlayers_menu import OpenlayersMenu else: # QGIS 1.x - QGIS-2.2 from openlayers_menu_compat import OpenlayersMenu self.ui.btnBackgroundLayer.setMenu(OpenlayersMenu(self.iface)) except: self.ui.btnBackgroundLayer.hide() self.ui.labelOpenLayersPlugin.show() # map<data source, table name> self.data_sources_table_names = {} # flag to disable update of local data sources during upload self.do_update_local_data_sources = True QObject.connect(self.ui.btnLogin, SIGNAL("clicked()"), self.check_login) QObject.connect(self.ui.btnDbCreate, SIGNAL("clicked()"), self.create_database) QObject.connect(self.ui.btnDbDelete, SIGNAL("clicked()"), self.delete_database) QObject.connect(self.ui.btnDbRefresh, SIGNAL("clicked()"), self.refresh_databases) QObject.connect(self.ui.tabDatabases, SIGNAL("itemSelectionChanged()"), self.select_database) QObject.connect(self.ui.btnPublishMap, SIGNAL("clicked()"), self.publish_map) QObject.connect(self.ui.btnRefreshLocalLayers, SIGNAL("clicked()"), self.refresh_local_data_sources) QObject.connect(self.iface, SIGNAL("newProjectCreated()"), self.reset_load_data) QObject.connect(QgsMapLayerRegistry.instance(), SIGNAL("layerWillBeRemoved(QString)"), self.remove_layer) QObject.connect(QgsMapLayerRegistry.instance(), SIGNAL("layerWasAdded(QgsMapLayer *)"), self.add_layer) QObject.connect(self.ui.cbUploadDatabase, SIGNAL("currentIndexChanged(int)"), lambda idx: self.activate_upload_button()) QObject.connect(self.ui.btnUploadData, SIGNAL("clicked()"), self.upload_data) self.ui.editServer.textChanged.connect(self.serverURL) self.ui.resetUrlBtn.clicked.connect(self.resetApiUrl) self.read_settings() self.api = API() self.db_connections = DbConnections() self.local_data_sources = LocalDataSources() self.data_upload = DataUpload(self.iface, self.statusBar(), self.ui.lblProgress, self.api, self.db_connections) if self.URL == "": self.ui.editServer.setText(self.api.api_url()) else: self.ui.editServer.setText(self.URL) self.palette_red = QPalette(self.ui.lblVersionPlugin.palette()) self.palette_red.setColor(QPalette.WindowText, Qt.red)
class QgsWps: MSG_BOX_TITLE = "WPS Client" def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface self.localePath = "" #Initialise the translation environment # TODO with this solution probably we could look only for a path and # not for userPluginPath and systemPluginPath, in this way it should # recognize what is the right path userPluginPath = os.path.dirname(os.path.realpath(__file__)) systemPluginPath = QgsApplication.prefixPath() + "/share/qgis/python/plugins/wps" myLocaleName = QSettings().value("locale/userLocale") myLocale = myLocaleName[0:2] print userPluginPath if QFileInfo(userPluginPath).exists(): self.pluginPath = userPluginPath self.localePath = userPluginPath + "/i18n/wps_" + myLocale + ".qm" elif QFileInfo(systemPluginPath).exists(): self.pluginPath = systemPluginPath self.localePath = systemPluginPath + "/i18n/wps_" + myLocale + ".qm" if QFileInfo(self.localePath).exists(): self.translator = QTranslator() self.translator.load(self.localePath) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) ############################################################################ def initGui(self): # Create action that will start plugin configuration self.action = QAction(QIcon(":/plugins/wps/images/wps-add.png"), "WPS-Client", self.iface.mainWindow()) QObject.connect(self.action, SIGNAL("triggered()"), self.run) self.actionAbout = QAction("About", self.iface.mainWindow()) QObject.connect(self.actionAbout, SIGNAL("triggered()"), self.doAbout) # Add toolbar button and menu item self.iface.addToolBarIcon(self.action) if hasattr(self.iface, "addPluginToWebMenu"): self.iface.addPluginToWebMenu("WPS-Client", self.action) self.iface.addPluginToWebMenu("WPS-Client", self.actionAbout) else: self.iface.addPluginToMenu("WPS", self.action) self.iface.addPluginToWebMenu("WPS", self.action) self.myDockWidget = QgsWpsDockWidget(self.iface) self.myDockWidget.setWindowTitle('WPS') self.iface.addDockWidget(Qt.LeftDockWidgetArea, self.myDockWidget) self.myDockWidget.show() if PROCESSING_SUPPORT: self.provider = WpsAlgorithmProvider(self.myDockWidget) else: self.provider = None if self.provider: try: Processing.addProvider(self.provider, True) #Force tree update except TypeError: Processing.addProvider(self.provider) ############################################################################ def unload(self): if hasattr(self.iface, "addPluginToWebMenu"): self.iface.removePluginWebMenu("WPS-Client", self.action) self.iface.removePluginWebMenu("WPS-Client", self.actionAbout) else: self.iface.removePluginToMenu("WPS", self.action) self.iface.removePluginToMenu("WPS", self.actionAbout) self.iface.removeToolBarIcon(self.action) if self.myDockWidget: self.myDockWidget.close() self.myDockWidget = None if self.provider: Processing.removeProvider(self.provider) ############################################################################## def run(self): if self.myDockWidget.isVisible(): self.myDockWidget.hide() else: self.myDockWidget.show() def doAbout(self): self.dlgAbout = DlgAbout() self.dlgAbout.show()
def __init__(self, parent, fl): QDialog.__init__(self, parent, fl) self.setupUi(self) self.fl = fl self.setWindowTitle('QGIS WPS-Client '+version()) self.dlgAbout = DlgAbout(parent)
def __init__(self, parent, fl): QDialog.__init__(self, parent, fl) self.setupUi(self) self.fl = fl self.setWindowTitle('QgsWPSClient-'+version()+' Service Chooser') self.dlgAbout = DlgAbout(parent)
def __init__(self, iface, version): QDockWidget.__init__(self, None) self.iface = iface self.clouddb = True self.version = version # Set up the user interface from Designer. self.ui = Ui_QgisCloudPlugin() self.ui.setupUi(self) self.storage_exceeded = True myAbout = DlgAbout() self.ui.aboutText.setText( myAbout.aboutString() + myAbout.contribString() + myAbout.licenseString() + "<p>Versions:<ul>" + "<li>QGIS: %s</li>" % unicode(QGis.QGIS_VERSION).encode("utf-8") + "<li>Python: %s</li>" % sys.version.replace("\n", " ") + "<li>OS: %s</li>" % platform.platform() + "</ul></p>") self.ui.lblVersionPlugin.setText(self.version) self.ui.tblLocalLayers.setColumnCount(5) header = ["Layers", "Data source", "Table name", "Geometry type", "SRID"] self.ui.tblLocalLayers.setHorizontalHeaderLabels(header) self.ui.tblLocalLayers.resizeColumnsToContents() self.ui.tblLocalLayers.setEditTriggers(QAbstractItemView.NoEditTriggers) self.ui.btnUploadData.setEnabled(False) self.ui.btnPublishMap.setEnabled(False) self.ui.progressWidget.hide() self.ui.btnLogout.hide() self.ui.lblLoginStatus.hide() self.ui.widgetServices.hide() self.ui.widgetDatabases.setEnabled(False) self.ui.labelOpenLayersPlugin.hide() try: if QGis.QGIS_VERSION_INT >= 20300: from openlayers_menu import OpenlayersMenu else: # QGIS 1.x - QGIS-2.2 from openlayers_menu_compat import OpenlayersMenu self.ui.btnBackgroundLayer.setMenu(OpenlayersMenu(self.iface)) except: self.ui.btnBackgroundLayer.hide() self.ui.labelOpenLayersPlugin.show() # map<data source, table name> self.data_sources_table_names = {} # flag to disable update of local data sources during upload self.do_update_local_data_sources = True QObject.connect(self.ui.btnLogin, SIGNAL("clicked()"), self.check_login) QObject.connect( self.ui.btnDbCreate, SIGNAL("clicked()"), self.create_database) QObject.connect( self.ui.btnDbDelete, SIGNAL("clicked()"), self.delete_database) QObject.connect( self.ui.btnDbRefresh, SIGNAL("clicked()"), self.refresh_databases) QObject.connect(self.ui.tabDatabases, SIGNAL( "itemSelectionChanged()"), self.select_database) QObject.connect( self.ui.btnPublishMap, SIGNAL("clicked()"), self.publish_map) QObject.connect(self.ui.btnRefreshLocalLayers, SIGNAL( "clicked()"), self.refresh_local_data_sources) QObject.connect( self.iface, SIGNAL("newProjectCreated()"), self.reset_load_data) QObject.connect(QgsMapLayerRegistry.instance(), SIGNAL( "layerWillBeRemoved(QString)"), self.remove_layer) QObject.connect(QgsMapLayerRegistry.instance(), SIGNAL( "layerWasAdded(QgsMapLayer *)"), self.add_layer) QObject.connect(self.ui.cbUploadDatabase, SIGNAL( "currentIndexChanged(int)"), lambda idx: self.activate_upload_button()) QObject.connect( self.ui.btnUploadData, SIGNAL("clicked()"), self.upload_data) self.ui.editServer.textChanged.connect(self.serverURL) self.ui.resetUrlBtn.clicked.connect(self.resetApiUrl) self.read_settings() self.api = API() self.db_connections = DbConnections() self.local_data_sources = LocalDataSources() self.data_upload = DataUpload( self.iface, self.statusBar(), self.ui.lblProgress, self.api, self.db_connections) if self.URL == "": self.ui.editServer.setText(self.api.api_url()) else: self.ui.editServer.setText(self.URL) self.palette_red = QPalette(self.ui.lblVersionPlugin.palette()) self.palette_red.setColor(QPalette.WindowText, Qt.red)
class QgsWpsGui(QDialog, QObject, Ui_QgsWps): MSG_BOX_TITLE = "WPS" def __init__(self, parent, tools, fl): QDialog.__init__(self, parent, fl) self.setupUi(self) self.fl = fl self.tools = tools self.dlgAbout = DlgAbout(parent) def initQgsWpsGui(self): ## self.btnOk.setEnabled(False) self.btnConnect.setEnabled(False) settings = QSettings() settings.beginGroup("WPS") connections = settings.childGroups() self.cmbConnections.clear() self.cmbConnections.addItems(connections) self.treeWidget.clear() if self.cmbConnections.size() > 0: self.btnConnect.setEnabled(True) self.btnEdit.setEnabled(True) self.btnDelete.setEnabled(True) return 1 def getDescription(self, name, item): QMessageBox.information(None, '', name) self.tools.getServiceXML(name,"DescribeProcess",item.text(0)) def getBookmark(self, item): self.tools.getServiceXML(item.text(0),"DescribeProcess",item.text(1)) def on_buttonBox_rejected(self): self.close() # see http://www.riverbankcomputing.com/Docs/PyQt4/pyqt4ref.html#connecting-signals-and-slots # without this magic, the on_btnOk_clicked will be called two times: one clicked() and one clicked(bool checked) @pyqtSignature("on_buttonBox_accepted()") def on_buttonBox_accepted(self): if self.treeWidget.topLevelItemCount() == 0: QMessageBox.warning(None, 'WPS Warning','No Service connected!') else: self.emit(SIGNAL("getDescription(QString,QTreeWidgetItem)"), self.cmbConnections.currentText(), self.treeWidget.currentItem() ) # see http://www.riverbankcomputing.com/Docs/PyQt4/pyqt4ref.html#connecting-signals-and-slots # without this magic, the on_btnOk_clicked will be called two times: one clicked() and one clicked(bool checked) @pyqtSignature("on_btnConnect_clicked()") def on_btnConnect_clicked(self): self.treeWidget.clear() self.selectedWPS = self.cmbConnections.currentText() self.tools.getServiceXML(self.selectedWPS, 'GetCapabilities' ) try: QObject.disconnect(self.tools, SIGNAL("capabilitiesRequestIsFinished(QNetworkReply)"), self.createCapabilitiesGUI) except: pass QObject.connect(self.tools, SIGNAL("capabilitiesRequestIsFinished(QNetworkReply)"), self.createCapabilitiesGUI) @pyqtSignature("on_btnBookmarks_clicked()") def on_btnBookmarks_clicked(self): # QObject.connect(self.dlgBookmarks, SIGNAL("getBookmarkDescription(QString, QTreeWidgetItem)"), self.getDescription) # QObject.connect(self.dlgBookmarks, SIGNAL("removeBookmark(QTreeWidgetItem, int)"), self.removeBookmark) self.dlgBookmarks = Bookmarks(self.fl) QObject.connect(self.dlgBookmarks, SIGNAL("getBookmarkDescription(QTreeWidgetItem)"), self.getBookmark) self.dlgBookmarks.show() @pyqtSignature("on_btnNew_clicked()") def on_btnNew_clicked(self): self.emit(SIGNAL("newServer()")) @pyqtSignature("on_btnEdit_clicked()") def on_btnEdit_clicked(self): self.emit(SIGNAL("editServer(QString)"), self.cmbConnections.currentText()) @pyqtSignature("on_cmbConnections_currentIndexChanged()") def on_cmbConnections_currentIndexChanged(self): pass @pyqtSignature("on_btnDelete_clicked()") def on_btnDelete_clicked(self): self.emit(SIGNAL("deleteServer(QString)"), self.cmbConnections.currentText()) @pyqtSignature("on_pushDefaultServer_clicked()") def on_pushDefaultServer_clicked(self): self.emit(SIGNAL("pushDefaultServer()")) def initTreeWPSServices(self, taglist): self.treeWidget.setColumnCount(self.treeWidget.columnCount()) itemList = [] for items in taglist: item = QTreeWidgetItem() ident = unicode(items[0],'latin1') title = unicode(items[1],'latin1') abstract = unicode(items[2],'latin1') item.setText(0,ident.strip()) item.setText(1,title.strip()) item.setText(2,abstract.strip()) itemList.append(item) self.treeWidget.addTopLevelItems(itemList) @pyqtSignature("on_btnAbout_clicked()") def on_btnAbout_clicked(self): self.dlgAbout.show() pass @pyqtSignature("QTreeWidgetItem*, int") def on_treeWidget_itemDoubleClicked(self, item, column): self.emit(SIGNAL("getDescription(QString,QTreeWidgetItem)"), self.cmbConnections.currentText(), self.treeWidget.currentItem() ) def createCapabilitiesGUI(self, reply): if reply.error() == 1: QMessageBox.information(None, '', QApplication.translate("QgsWpsGui","Connection Refused. Please check your Proxy-Settings")) pass else: try: self.treeWidget.clear() itemListAll = self.tools.parseCapabilitiesXML(reply.readAll().data()) self.initTreeWPSServices(itemListAll) except: pass