def run( self ): dest_crs, poly = self.get_selected_polygons() is_new = False if not self.layer: if not poly: QMessageBox.critical( None, self.tr("Mask plugin error"), self.tr("No polygon selection !") ) return self.layer = QgsVectorLayer("MultiPolygon?crs=%s" % dest_crs.authid(), self.mask_name, "memory") style_tools.set_default_layer_symbology( self.layer ) is_new = True self.parameters.layer = self.layer if self.must_reload_from_layer: self.layer = self.must_reload_from_layer self.parameters.load_from_layer( self.layer ) self.must_reload_from_layer = None dlg = MainDialog( self.parameters, is_new ) dlg.applied.connect( self.apply_mask_parameters ) r = dlg.exec_() if r == 1: self.apply_mask_parameters() self.update_menus()
class Qgis2Web(object): """Class abstraction for managing Qgis2Web plugin in QGIS.""" def __init__(self, iface): self.iface = iface self.dlg = None def initGui(self): self.action = QAction( QIcon(":/plugins/qgis2web/icons/qgis2web.png"), u"Create web map", self.iface.mainWindow()) self.action.triggered.connect(self.run) self.iface.addPluginToWebMenu(u"&qgis2web", self.action) self.iface.addToolBarIcon(self.action) def unload(self): self.iface.removePluginWebMenu(u"&qgis2web", self.action) self.iface.removeToolBarIcon(self.action) def run(self): if not self.dlg: self.dlg = MainDialog(self.iface) self.dlg.show() # bring to front self.dlg.raise_()
def run(self): dest_crs, poly = self.get_selected_polygons() is_new = False if not self.layer: if not poly: QMessageBox.critical(None, self.tr("Mask plugin error"), self.tr("No polygon selection !")) return self.layer = QgsVectorLayer( "MultiPolygon?crs=%s" % dest_crs.authid(), self.mask_name, "memory") style_tools.set_default_layer_symbology(self.layer) is_new = True self.parameters.layer = self.layer if self.must_reload_from_layer: self.layer = self.must_reload_from_layer self.parameters.load_from_layer(self.layer) self.must_reload_from_layer = None dlg = MainDialog(self.parameters, is_new) dlg.applied.connect(self.apply_mask_parameters) r = dlg.exec_() if r == 1: self.apply_mask_parameters() self.update_menus()
def run(self): if not self.dlg or sip.isdeleted(self.dlg): self.dlg = MainDialog(self.iface) self.dlg.setAttribute(Qt.WA_DeleteOnClose) self.dlg.show() # bring to front self.dlg.raise_()
def main(): app = QtGui.QApplication(sys.argv) mainDialog = MainDialog() mainDialog.setWindowState(QtCore.Qt.WindowMaximized) mainDialog.initOptions() mainDialog.initWebKit() mainDialog.show() sys.exit(app.exec_())
def run(self): appdef = None projFile = QgsProject.instance().fileName() if projFile: appdefFile = projFile + ".appdef" if os.path.exists(appdefFile): ret = QMessageBox.question(self.iface.mainWindow(), "Web app builder", "This project has been already published as a web app.\n" "Do you want to reload app configuration?", QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes) if ret == QMessageBox.Yes: appdef = loadAppdef(appdefFile) initialize() dlg = MainDialog(appdef) dlg.exec_()
def test25_Leaflet_json_poly_graduated(self): """Leaflet JSON polygon graduated (test_qgis2web_dialog.test_Leaflet_json_poly_graduated)""" layer_path = test_data_path('layer', 'polygon.shp') layer_style = test_data_path('style', 'json_polygon_graduated.qml') control_path = test_data_path('control', 'leaflet_json_polygon_graduated.html') layer = load_layer(layer_path) layer.loadNamedStyle(layer_style) registry = QgsMapLayerRegistry.instance() registry.addMapLayer(layer) control_file = open(control_path, 'r') control_output = control_file.read() self.dialog = MainDialog(IFACE) self.dialog.paramsTreeOL.itemWidget( self.dialog.paramsTreeOL.findItems( 'Extent', (Qt.MatchExactly | Qt.MatchRecursive))[0], 1).setCurrentIndex(1) self.dialog.leaflet.click() test_file = open(self.dialog.preview.url().toString().replace( "file://", "")) test_output = test_file.read() self.assertEqual(test_output, control_output)
def test10_Leaflet_wfs_pnt_single(self): """Leaflet WFS point single (test_qgis2web_dialog.test_Leaflet_wfs_pnt_single)""" layer_url = ('http://maps.nationalparks.gov.uk/geoserver/wfs?SERVICE' '=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=dartmoor' ':dnpa-tpo-point&SRSNAME=EPSG:27700') layer_style = test_data_path('style', 'point_single.qml') layer = load_wfs_layer(layer_url, 'point') layer.loadNamedStyle(layer_style) registry = QgsMapLayerRegistry.instance() registry.addMapLayer(layer) control_file = open( test_data_path('control', 'leaflet_wfs_point_single.html'), 'r') control_output = control_file.read() self.dialog = MainDialog(IFACE) self.dialog.paramsTreeOL.itemWidget( self.dialog.paramsTreeOL.findItems( 'Extent', (Qt.MatchExactly | Qt.MatchRecursive))[0], 1).setCurrentIndex(1) self.dialog.leaflet.click() test_file = open(self.dialog.preview.url().toString().replace( 'file://', '')) test_output = test_file.read() self.assertEqual(test_output, control_output)
def test09_Leaflet_json_pnt_single(self): """Leaflet JSON point single (test_qgis2web_dialog.test_Leaflet_json_pnt_single)""" layer_path = test_data_path('layer', 'point.shp') style_path = test_data_path('style', 'point_single.qml') layer = load_layer(layer_path) layer.loadNamedStyle(style_path) registry = QgsMapLayerRegistry.instance() registry.addMapLayer(layer) control_file = open( test_data_path('control', 'leaflet_json_point_single.html'), 'r') control_output = control_file.read() # Export to web map self.dialog = MainDialog(IFACE) self.dialog.paramsTreeOL.itemWidget( self.dialog.paramsTreeOL.findItems( 'Extent', (Qt.MatchExactly | Qt.MatchRecursive))[0], 1).setCurrentIndex(1) self.dialog.leaflet.click() # Open the test file test_file = open(self.dialog.preview.url().toString().replace( 'file://', '')) test_output = test_file.read() # Compare with control file self.assertEqual(test_output, control_output)
def test26_Leaflet_wfs_poly_graduated(self): """Leaflet WFS polygon graduated (test_qgis2web_dialog.test_Leaflet_wfs_poly_graduated)""" layer_url = ('http://maps.nationalparks.gov.uk/geoserver/wfs?SERVICE' '=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME' '=yorkshire_dales:ydnpa_conservationareas&SRSNAME=EPSG' ':27700') layer_style = test_data_path('style', 'wfs_polygon_graduated.qml') control_path = test_data_path('control', 'leaflet_wfs_polygon_graduated.html') layer = load_wfs_layer(layer_url, 'polygon') layer.loadNamedStyle(layer_style) registry = QgsMapLayerRegistry.instance() registry.addMapLayer(layer) control_file = open(control_path, 'r') control_output = control_file.read() self.dialog = MainDialog(IFACE) self.dialog.paramsTreeOL.itemWidget( self.dialog.paramsTreeOL.findItems( 'Extent', (Qt.MatchExactly | Qt.MatchRecursive))[0], 1).setCurrentIndex(1) self.dialog.leaflet.click() test_file = open(self.dialog.preview.url().toString().replace( "file://", "")) test_output = test_file.read() self.assertEqual(test_output, control_output)
def setUp(self): """Runs before each test""" self.dialog = MainDialog(IFACE) self.dialog.paramsTreeOL.itemWidget( self.dialog.paramsTreeOL.findItems( "Template", (Qt.MatchExactly | Qt.MatchRecursive))[0], 1).setCurrentIndex(1)
def run(self): appdef = None projFile = QgsProject.instance().fileName() if projFile: appdefFile = projFile + ".appdef" if os.path.exists(appdefFile): ret = QMessageBox.question( self.iface.mainWindow(), "Web app builder", "This project has been already published as a web app.\n" "Do you want to reload app configuration?", QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes) if ret == QMessageBox.Yes: appdef = loadAppdef(appdefFile) initialize() dlg = MainDialog(appdef) dlg.exec_()
def tearDown(self): """Runs after each test""" registry = QgsMapLayerRegistry.instance() registry.removeAllMapLayers() self.dialog = MainDialog(IFACE) self.dialog.ol3.click() self.dialog = None
def test35_OL3_poly_graduated(self): """OL3 polygon graduated (test_qgis2web_dialog.test_OL3_poly_graduated)""" layer_path = test_data_path('layer', 'polygon.shp') style_path = test_data_path('style', 'json_polygon_graduated.qml') control_path = test_data_path('control', 'ol3_json_polygon_graduated.html') layer = load_layer(layer_path) layer.loadNamedStyle(style_path) registry = QgsMapLayerRegistry.instance() registry.addMapLayer(layer) control_file = open(control_path, 'r') control_output = control_file.read() self.dialog = MainDialog(IFACE) self.dialog.paramsTreeOL.itemWidget( self.dialog.paramsTreeOL.findItems( "Extent", (Qt.MatchExactly | Qt.MatchRecursive))[0], 1).setCurrentIndex(1) self.dialog.ol3.click() test_file = open(self.dialog.preview.url().toString().replace( 'file://', '')) test_output = test_file.read() test_style_file = open(self.dialog.preview.url().toString().replace( 'file://', '').replace('index.html', 'styles/polygon_style.js')) test_style_output = test_style_file.read() test_output += test_style_output self.assertEqual(test_output, control_output)
class qgis2web_classDialogTest(unittest.TestCase): """Test dialog works.""" def setUp(self): """Runs before each test.""" self.dialog = MainDialog(IFACE) def tearDown(self): """Runs after each test.""" self.dialog = None def test_OL3(self): """Export to OL3 (test_qgis2web_dialog.test_OL3).""" self.dialog.previewOL3() # result = self.dialog.result() # self.assertEqual(result, QDialog.Accepted) def test_Leaflet(self): """Export to Leaflet (test_qgis2web_dialog.test_Leaflet).""" self.dialog.previewLeaflet()
def test11_Leaflet_shp_poly_simple(self): """Leaflet shape polygon simple (test_qgis2web_dialog.test_Leaflet_shp_poly_simple).""" layer = QgsVectorLayer( "/home/travis/build/tomchadwin/qgis2web/test_data/polygon_feature.shp", "polygon feature", "ogr") if not layer: print "Layer failed to load!" registry = QgsMapLayerRegistry.instance() registry.addMapLayer(layer) self.dialog = MainDialog(IFACE) self.dialog.leaflet.click()
class Qgis2Web(object): """Class abstraction for managing Qgis2Web plugin in QGIS.""" def __init__(self, iface): self.provider = qgis2webProvider() self.iface = iface self.dlg = None def initGui(self): Processing.addProvider(self.provider) self.action = QAction(QIcon(":/plugins/qgis2web/icons/qgis2web.png"), u"Create web map", self.iface.mainWindow()) self.action.triggered.connect(self.run) self.iface.addPluginToWebMenu(u"&qgis2web", self.action) self.iface.addToolBarIcon(self.action) def unload(self): Processing.removeProvider(self.provider) self.iface.removePluginWebMenu(u"&qgis2web", self.action) self.iface.removeToolBarIcon(self.action) def run(self): if not self.dlg or sip.isdeleted(self.dlg): self.dlg = MainDialog(self.iface) self.dlg.setAttribute(Qt.WA_DeleteOnClose) self.dlg.show() # bring to front self.dlg.raise_()
def run( self ): dest_crs, poly = self.get_selected_polygons() is_new = False layer, parameters = self.load_from_project() if not layer: if not poly: QMessageBox.critical( None, self.tr("Mask plugin error"), self.tr("No polygon selection !") ) return layer = QgsVectorLayer("MultiPolygon?crs=%s" % dest_crs.authid(), self.MASK_NAME, "memory") style_tools.set_default_layer_symbology( layer ) is_new = True parameters.layer = layer dlg = MainDialog( parameters, is_new ) # for "Apply" and "Ok" self.layer = layer def on_applied_(): keep_layer = not is_new and self.parameters.have_same_layer_options( parameters ) new_layer = self.apply_mask_parameters( self.layer, parameters, keep_layer = keep_layer ) self.save_to_project( new_layer, parameters ) self.layer = new_layer self.parameters = parameters # connect apply dlg.applied.connect( on_applied_ ) r = dlg.exec_() if r == 1: # Ok on_applied_() self.update_menus()
def test09_Leaflet_shp_pnt_simple(self): """Leaflet shape point simple (test_qgis2web_dialog.test_Leaflet_shp_pnt_simple).""" layer = QgsVectorLayer( "/home/travis/build/tomchadwin/qgis2web/test_data/places_few_1.shp", "point feature", "ogr") if not layer: print "Layer failed to load!" registry = QgsMapLayerRegistry.instance() registry.addMapLayer(layer) testFile = open( '/home/travis/build/tomchadwin/qgis2web/test_data/shp_point_simple.html', 'r') goodOutput = testFile.read() self.dialog = MainDialog(IFACE) self.dialog.leaflet.click()
def test07_preview_OL3(self): """Preview OL3 - no data (test_qgis2web_dialog.test_preview_OL3).""" self.dialog = MainDialog(IFACE) self.dialog.ol3.click() self.dialog.buttonPreview.click()
def test06_toggle_OL3(self): """Toggle to OL3 (test_qgis2web_dialog.test_toggle_OL3).""" self.dialog = MainDialog(IFACE) self.dialog.ol3.click()
def test05_export_Leaflet(self): """Export Leaflet - no data (test_qgis2web_dialog.test_export_Leaflet).""" self.dialog = MainDialog(IFACE) self.dialog.leaflet.click() self.dialog.buttonExport.click()
def test04_preview_Leaflet(self): """Preview Leaflet - no data (test_qgis2web_dialog.test_preview_Leaflet).""" self.dialog = MainDialog(IFACE) self.dialog.leaflet.click() self.dialog.buttonPreview.click()
def test03_toggle_Leaflet(self): """Toggle to Leaflet (test_qgis2web_dialog.test_toggle_Leaflet).""" self.dialog = MainDialog(IFACE) self.dialog.leaflet.click()
def test02_save_default(self): """Save default - no data (OL3) (test_qgis2web_dialog.test_save_default).""" self.dialog = MainDialog(IFACE) self.dialog.buttonExport.click()
def run(self): dlg = MainDialog(self.iface) dlg.show()
from kdecore import * from kdeui import * import kdedesigner from maindialog import MainDialog from about import aboutData from dumlogging import logger def handleException(exception, value, tb): logger.error("".join(traceback.format_exception(exception, value, tb))) if __name__ == '__main__': sys.excepthook = handleException KCmdLineArgs.init(sys.argv, aboutData) app = KUniqueApplication(True, True, True) args = KCmdLineArgs.parsedArgs() dbus.mainloop.qt3.DBusQtMainLoop(set_as_default=True) manager = MainDialog() app.setMainWidget(manager) manager.setCaption(i18n('Upgrade Manager')) manager.setIcon(KGlobal.iconLoader().loadIcon("package-manager", KIcon.Small)) manager.show() sys.exit(app.exec_loop())
def run(self): dlg = MainDialog(self.iface) dlg.exec_()
def run(self): dlg = MainDialog() dlg.exec_()
def test08_export_OL3(self): """Export OL3 - no data (test_qgis2web_dialog.test_export_OL3).""" self.dialog = MainDialog(IFACE) self.dialog.ol3.click() self.dialog.buttonExport.click()
def test01_preview_default(self): """Preview default - no data (OL3) (test_qgis2web_dialog.test_preview_default).""" self.dialog = MainDialog(IFACE) self.dialog.buttonPreview.click()
def setUp(self): """Runs before each test.""" self.dialog = MainDialog(IFACE)
def run(self): if not self.dlg: self.dlg = MainDialog(self.iface) self.dlg.show() # bring to front self.dlg.raise_()
from PyQt4 import QtGui from PyQt4 import QtCore from PyKDE4.kdeui import KUniqueApplication from PyKDE4.kdecore import KCmdLineArgs from maindialog import MainDialog from about import aboutData from dumlogging import logger def handleException(exception, value, tb): logger.error("".join(traceback.format_exception(exception, value, tb))) if __name__ == '__main__': KCmdLineArgs.init(sys.argv, aboutData) app = KUniqueApplication(True, True) args = KCmdLineArgs.parsedArgs() if not dbus.get_default_main_loop(): from dbus.mainloop.qt import DBusQtMainLoop DBusQtMainLoop(set_as_default = True) manager = MainDialog() manager.show() sys.excepthook = handleException app.exec_()