Ejemplo n.º 1
0
    def set_ui_configuration_panel(self):
        """Set UI related the configuration panel."""

        self._set_custom_ui(Panels.QuickQuery)

        # noinspection PyUnresolvedReferences
        self.combo_default_overpass.currentIndexChanged.connect(
            self.set_server_overpass_api)

        # Set settings about the overpass API
        self.default_server = get_setting('defaultOAPI')
        if self.default_server:
            index = self.combo_default_overpass.findText(self.default_server)
            self.combo_default_overpass.setCurrentIndex(index)
        else:
            self.default_server = self.combo_default_overpass.currentText()
            set_setting('defaultOAPI', self.default_server)

        for server in OVERPASS_SERVERS:
            self.combo_default_overpass.addItem(server)

        # Read the config file
        custom_config = custom_config_file()
        if custom_config:
            with open(custom_config) as f:
                config_json = load(f)
                for server in config_json.get('overpass_servers'):
                    if server not in OVERPASS_SERVERS:
                        LOGGER.info(
                            'Custom overpass server list added: {}'.format(
                                server))
                        self.combo_default_overpass.addItem(server)
Ejemplo n.º 2
0
    def setup_panel(self):
        """Set UI related the configuration panel."""
        self.dialog.save_config.clicked.connect(self.set_server_overpass_api)

        for server in OVERPASS_SERVERS:
            self.dialog.combo_default_overpass.addItem(server)

        # Read the config file
        custom_config = custom_config_file()
        if custom_config:
            with open(custom_config) as f:
                config_json = load(f)
                for server in config_json.get('overpass_servers'):
                    if server not in OVERPASS_SERVERS:
                        LOGGER.info(
                            'Custom overpass server list added: {}'.format(
                                server))
                        self.dialog.combo_default_overpass.addItem(server)

        # Set settings about the overpass API
        # Set it after populating the combobox #235
        default_server = get_setting('defaultOAPI')
        if default_server:
            index = self.dialog.combo_default_overpass.findText(default_server)
            self.dialog.combo_default_overpass.setCurrentIndex(index)
        else:
            default_server = self.dialog.combo_default_overpass.currentText()
            set_setting('defaultOAPI', default_server)
Ejemplo n.º 3
0
 def set_output_format(self):
     """
     Save the new output format
     """
     if self.radioButton_outputJson.isChecked():
         set_setting('outputFormat', 'geojson')
     else:
         set_setting('outputFormat', 'shape')
Ejemplo n.º 4
0
 def set_output_format(self):
     """
     Save the new output format
     """
     if self.radioButton_outputJson.isChecked():
         set_setting('outputFormat', 'geojson')
     else:
         set_setting('outputFormat', 'shape')
Ejemplo n.º 5
0
    def __init__(self, parent=None):
        """
        Constructor
        """
        QDialog.__init__(self, parent)
        self.setupUi(self)
        self.set_help_web_view()
        self.help_file = None

        # Connect
        # noinspection PyUnresolvedReferences
        self.pushButton_homeHelp.clicked.connect(self.get_root_help)
        # noinspection PyUnresolvedReferences
        self.pushButton_OAPI_timestamp.clicked.connect(
            self.get_timestamp_overpass_api)
        # noinspection PyUnresolvedReferences
        self.comboBox_default_OAPI.currentIndexChanged[int].connect(
            self.set_server_overpass_api)
        self.query.signal_new_query_successful.connect(
            self.signal_new_query_successful.emit)
        self.my_queries.signal_delete_query_successful.connect(
            self.signal_delete_query_successful.emit)
        # noinspection PyUnresolvedReferences
        self.pushButton_restoreQueries.clicked.connect(
            self.restore_default_queries)
        # noinspection PyUnresolvedReferences
        self.radioButton_outputJson.toggled.connect(self.set_output_format)

        # Set settings about the overpass API
        self.defaultServer = get_setting('defaultOAPI')
        if self.defaultServer:
            index = self.comboBox_default_OAPI.findText(self.defaultServer)
            self.comboBox_default_OAPI.setCurrentIndex(index)
        else:
            self.defaultServer = self.comboBox_default_OAPI.currentText()
            set_setting('defaultOAPI', self.defaultServer)

        # Set settings about the output
        self.outputFormat = get_setting('outputFormat')
        if self.outputFormat == "geojson":
            self.radioButton_outputJson.setChecked(True)
        elif self.outputFormat == "shape":
            self.radioButton_outputShape.setChecked(True)
        elif self.outputFormat == "spatialite":
            self.radioButton_outputSpatialite.setChecked(True)
        else:
            set_setting('outputFormat', 'shape')
            self.radioButton_outputShape.setChecked(True)

        # Set minimum width for the menu
        self.listWidget.setMinimumWidth(
            self.listWidget.sizeHintForColumn(0) + 10)
Ejemplo n.º 6
0
    def __init__(self, parent=None):
        """
        Constructor
        """
        QDialog.__init__(self, parent)
        self.setupUi(self)
        self.set_help_web_view()
        self.help_file = None

        # Connect
        # noinspection PyUnresolvedReferences
        self.pushButton_homeHelp.clicked.connect(self.get_root_help)
        # noinspection PyUnresolvedReferences
        self.pushButton_OAPI_timestamp.clicked.connect(
            self.get_timestamp_overpass_api)
        # noinspection PyUnresolvedReferences
        self.comboBox_default_OAPI.currentIndexChanged[int].connect(
            self.set_server_overpass_api)
        self.query.signal_new_query_successful.connect(
            self.signal_new_query_successful.emit)
        self.my_queries.signal_delete_query_successful.connect(
            self.signal_delete_query_successful.emit)
        # noinspection PyUnresolvedReferences
        self.pushButton_restoreQueries.clicked.connect(
            self.restore_default_queries)
        # noinspection PyUnresolvedReferences
        self.radioButton_outputJson.toggled.connect(self.set_output_format)

        # Set settings about the overpass API
        self.defaultServer = get_setting('defaultOAPI')
        if self.defaultServer:
            index = self.comboBox_default_OAPI.findText(self.defaultServer)
            self.comboBox_default_OAPI.setCurrentIndex(index)
        else:
            self.defaultServer = self.comboBox_default_OAPI.currentText()
            set_setting('defaultOAPI', self.defaultServer)

        # Set settings about the output
        self.outputFormat = get_setting('outputFormat')
        if self.outputFormat == "geojson":
            self.radioButton_outputJson.setChecked(True)
        elif self.outputFormat == "shape":
            self.radioButton_outputShape.setChecked(True)
        else:
            set_setting('outputFormat', 'shape')
            self.radioButton_outputShape.setChecked(True)

        # Set minimum width for the menu
        self.listWidget.setMinimumWidth(
            self.listWidget.sizeHintForColumn(0) + 10)
Ejemplo n.º 7
0
    def __init__(self, parent=None):
        """
        Constructor
        """
        QDialog.__init__(self, parent)
        self.setupUi(self)

        # Set icons
        item = self.listWidget.item(0)
        item.setIcon(QIcon(resources_path('quick.png')))
        item = self.listWidget.item(1)
        item.setIcon(QIcon(resources_path('edit.png')))
        item = self.listWidget.item(2)
        item.setIcon(QIcon(resources_path('open.png')))
        item = self.listWidget.item(3)
        item.setIcon(QIcon(resources_path('general.svg')))
        item = self.listWidget.item(4)
        item.setIcon(QIcon(resources_path('info.png')))
        self.label_gnu.setPixmap(QPixmap(resources_path('gnu.png')))

        # Disabled in QGIS3
        # self.set_help_web_view()
        self.restore_queries_group.setVisible(False)
        self.timestamp_group.setVisible(False)

        self.help_file = None

        # Connect
        # noinspection PyUnresolvedReferences
        # self.pushButton_homeHelp.clicked.connect(self.get_root_help) QGIS 3
        # noinspection PyUnresolvedReferences
        # self.pushButton_OAPI_timestamp.clicked.connect(
        #     self.get_timestamp_overpass_api)
        # noinspection PyUnresolvedReferences
        self.comboBox_default_OAPI.currentIndexChanged[int].connect(
            self.set_server_overpass_api)

        # Set settings about the overpass API
        self.defaultServer = get_setting('defaultOAPI')
        if self.defaultServer:
            index = self.comboBox_default_OAPI.findText(self.defaultServer)
            self.comboBox_default_OAPI.setCurrentIndex(index)
        else:
            self.defaultServer = self.comboBox_default_OAPI.currentText()
            set_setting('defaultOAPI', self.defaultServer)

        # Set minimum width for the menu
        self.listWidget.setMinimumWidth(
            self.listWidget.sizeHintForColumn(0) + 10)
Ejemplo n.º 8
0
 def know_copyright():
     set_setting("copyright_dialog", "OpenStreetMap")
Ejemplo n.º 9
0
 def read_copyright():
     open_webpage('https://www.openstreetmap.org/copyright')
     set_setting("copyright_dialog", "OpenStreetMap")
Ejemplo n.º 10
0
 def set_server_nominatim_api(self):
     """Save the new Nominatim server."""
     default_server = self.dialog.combo_default_nominatim.currentText()
     set_setting('defaultNominatimAPI', default_server)
Ejemplo n.º 11
0
 def set_server_overpass_api(self):
     """Save the new Overpass server."""
     default_server = self.dialog.combo_default_overpass.currentText()
     set_setting('defaultOAPI', default_server)
Ejemplo n.º 12
0
 def set_server_overpass_api(self):
     """
     Save the new OAPI server
     """
     self.defaultServer = self.comboBox_default_OAPI.currentText()
     set_setting('defaultOAPI', self.defaultServer)
Ejemplo n.º 13
0
    def initGui(self):

        # Setup menu
        self.quickosm_menu = QMenu('QuickOSM')
        self.quickosm_menu.setIcon(
            QIcon(join(dirname(__file__), 'resources', 'QuickOSM.svg')))
        self.vector_menu = self.iface.vectorMenu()
        self.vector_menu.addMenu(self.quickosm_menu)

        # Main window
        self.mainWindowAction = QAction(
            QIcon(join(dirname(__file__), 'resources', 'QuickOSM.svg')),
            u'QuickOSM', self.iface.mainWindow())
        # noinspection PyUnresolvedReferences
        self.mainWindowAction.triggered.connect(self.openMainWindow)
        self.toolbar.addAction(self.mainWindowAction)
        self.iface.QuickOSM_mainWindowDialog = MainWindowDialog()

        # Action JOSM
        self.josmAction = QAction(
            QIcon(join(dirname(__file__), 'resources', 'josm_icon.svg')),
            'JOSM Remote', self.iface.mainWindow())
        self.josmAction.triggered.connect(self.josm_remote)
        self.toolbar.addAction(self.josmAction)

        # Insert in the good order
        self.quickosm_menu.addAction(self.mainWindowAction)
        self.quickosm_menu.addAction(self.josmAction)

        for server in OVERPASS_SERVERS:
            self.iface.QuickOSM_mainWindowDialog.comboBox_default_OAPI. \
                addItem(server)

        # Read the config file
        custom_config = join(quickosm_user_folder(), 'custom_config.json')
        if isfile(custom_config):
            with open(custom_config) as f:
                config_json = load(f)
                for server in config_json.get('overpass_servers'):
                    if server not in OVERPASS_SERVERS:
                        LOGGER.info(
                            'Custom overpass server list added: {}'.format(
                                server))
                        self.iface.QuickOSM_mainWindowDialog.\
                            comboBox_default_OAPI.addItem(server)

        # Check previous version and if new queries are available
        version = get_setting('version')
        current_version = get_current_version()
        if version != current_version:
            if new_queries_available():
                widget = self.iface.messageBar().createMessage(
                    'QuickOSM',
                    tr('New queries are available in the plugin. Would like '
                       'to install them ? This will overwrite the current '
                       'default queries.'))
                button_ok = QPushButton(widget)
                button_ok.setText(tr('Install'))
                button_ok.pressed.connect(self.restoreDefaultQueries)
                widget.layout().addWidget(button_ok)
                self.iface.messageBar().pushWidget(widget, Qgis.Info, 0)

            set_setting('version', current_version)
Ejemplo n.º 14
0
    def __init__(self, parent=None):
        """
        Constructor
        """
        QDialog.__init__(self, parent)
        self.setupUi(self)

        # Set icons
        item = self.listWidget.item(0)
        item.setIcon(QIcon(resources_path('quick.png')))
        item = self.listWidget.item(1)
        item.setIcon(QIcon(resources_path('edit.png')))
        item = self.listWidget.item(2)
        item.setIcon(QIcon(resources_path('open.png')))
        item = self.listWidget.item(3)
        item.setIcon(QIcon(resources_path('general.svg')))
        item = self.listWidget.item(4)
        item.setIcon(QIcon(resources_path('info.png')))
        self.label_gnu.setPixmap(QPixmap(resources_path('gnu.png')))

        # Disabled in QGIS3
        # self.set_help_web_view()
        self.restore_queries_group.setVisible(False)
        self.timestamp_group.setVisible(False)
        self.output_format_option.setVisible(False)

        self.help_file = None

        # Connect
        # noinspection PyUnresolvedReferences
        # self.pushButton_homeHelp.clicked.connect(self.get_root_help) QGIS 3
        # noinspection PyUnresolvedReferences
        # self.pushButton_OAPI_timestamp.clicked.connect(
        #     self.get_timestamp_overpass_api)
        # noinspection PyUnresolvedReferences
        self.comboBox_default_OAPI.currentIndexChanged[int].connect(
            self.set_server_overpass_api)
        self.query.signal_new_query_successful.connect(
            self.signal_new_query_successful.emit)
        # self.my_queries.signal_delete_query_successful.connect(
        #     self.signal_delete_query_successful.emit)
        # noinspection PyUnresolvedReferences
        self.pushButton_restoreQueries.clicked.connect(
            self.restore_default_queries)
        # noinspection PyUnresolvedReferences
        self.radioButton_outputJson.toggled.connect(self.set_output_format)

        # Set settings about the overpass API
        self.defaultServer = get_setting('defaultOAPI')
        if self.defaultServer:
            index = self.comboBox_default_OAPI.findText(self.defaultServer)
            self.comboBox_default_OAPI.setCurrentIndex(index)
        else:
            self.defaultServer = self.comboBox_default_OAPI.currentText()
            set_setting('defaultOAPI', self.defaultServer)

        # Set settings about the output
        self.outputFormat = get_setting('outputFormat')
        if self.outputFormat == "geojson":
            self.radioButton_outputJson.setChecked(True)
        elif self.outputFormat == "shape":
            self.radioButton_outputShape.setChecked(True)
        else:
            set_setting('outputFormat', 'shape')
            self.radioButton_outputShape.setChecked(True)

        # Set minimum width for the menu
        self.listWidget.setMinimumWidth(
            self.listWidget.sizeHintForColumn(0) + 10)
Ejemplo n.º 15
0
    def initGui(self):

        # Setup menu
        self.quickosm_menu = QMenu('Quick OSM')
        self.quickosm_menu.setIcon(
            QIcon(join(dirname(__file__), 'resources', 'QuickOSM.svg')))
        self.dock_menu = QMenu(tr('QuickOSM', u'Dock'))
        self.vector_menu = self.iface.vectorMenu()
        self.vector_menu.addMenu(self.quickosm_menu)

        # Main window
        self.mainWindowAction = QAction(
            QIcon(join(dirname(__file__), 'resources', 'QuickOSM.svg')),
            u'QuickOSM', self.iface.mainWindow())
        # noinspection PyUnresolvedReferences
        self.mainWindowAction.triggered.connect(self.openMainWindow)
        self.toolbar.addAction(self.mainWindowAction)
        self.iface.QuickOSM_mainWindowDialog = MainWindowDialog()

        self.josmAction = QAction(
            QIcon(join(dirname(__file__), 'resources', 'josm_icon.svg')),
            'JOSM Remote', self.iface.mainWindow())
        self.josmAction.triggered.connect(self.josm_remote)
        self.toolbar.addAction(self.josmAction)

        # OSM File
        # self.osmFileAction = QAction(
        #     QIcon(':/plugins/QuickOSM/resources/open.png'),
        #     tr('ui_osm_file', 'OSM File'),
        #     self.iface.mainWindow())
        # # noinspection PyUnresolvedReferences
        # self.osmFileAction.triggered.connect(self.openOsmFileDockWidget)
        # self.osmFileDockWidget = OsmFileDockWidget()
        # self.iface.addDockWidget(
        #     Qt.RightDockWidgetArea, self.osmFileDockWidget)
        # self.osmFileDockWidget.hide()
        # self.osmFileDockWidget.setObjectName('osmFileWidget')

        # My queries
        # self.myQueriesAction = QAction(
        #     QIcon(':/plugins/QuickOSM/resources/favorites.png'),
        #     tr('ui_my_queries', 'My queries'),
        #     self.iface.mainWindow())
        # # noinspection PyUnresolvedReferences
        # self.myQueriesAction.triggered.connect(self.openMyQueriesDockWidget)
        # self.myQueriesDockWidget = MyQueriesDockWidget()
        # self.iface.addDockWidget(
        #     Qt.RightDockWidgetArea, self.myQueriesDockWidget)
        # self.myQueriesDockWidget.hide()
        # self.myQueriesDockWidget.setObjectName('myQueriesWidget')

        # Query
        # self.queryAction = QAction(
        #     QIcon(':/plugins/QuickOSM/resources/edit.png'),
        #     tr('ui_query', 'Query'),
        #     self.iface.mainWindow())
        # # noinspection PyUnresolvedReferences
        # self.queryAction.triggered.connect(self.openQueryDockWidget)
        # self.queryDockWidget = QueryDockWidget()
        # self.iface.addDockWidget(Qt.RightDockWidgetArea, self.queryDockWidget)
        # self.queryDockWidget.hide()
        # self.queryDockWidget.setObjectName('queryWidget')

        # Quick query
        # self.quickQueryAction = QAction(
        #     QIcon(':/plugins/QuickOSM/resources/quick.png'),
        #     tr('ui_quick_query', 'Quick query'),
        #     self.iface.mainWindow())
        # # noinspection PyUnresolvedReferences
        # self.quickQueryAction.triggered.connect(self.openQuickQueryDockWidget)
        # self.quickQueryDockWidget = QuickQueryDockWidget()
        # self.iface.addDockWidget(
        #     Qt.RightDockWidgetArea, self.quickQueryDockWidget)
        # self.quickQueryDockWidget.hide()
        # self.quickQueryDockWidget.setObjectName('quickQueryWidget')

        # Insert in the good order
        self.quickosm_menu.addAction(self.mainWindowAction)
        # self.quickosm_menu.addMenu(self.dock_menu)
        # self.dock_menu.addAction(self.quickQueryAction)
        # self.dock_menu.addAction(self.queryAction)
        # self.dock_menu.addAction(self.myQueriesAction)
        # self.dock_menu.addAction(self.osmFileAction)

        # Connect signals and slots from dock
        # self.queryDockWidget.signal_new_query_successful.connect(
        #     self.iface.QuickOSM_mainWindowDialog.refresh_my_queries_tree)
        # self.queryDockWidget.signal_new_query_successful.connect(
        #     self.myQueriesDockWidget.refresh_my_queries_tree)
        # self.myQueriesDockWidget.signal_delete_query_successful.connect(
        #     self.myQueriesDockWidget.refresh_my_queries_tree)
        # self.myQueriesDockWidget.signal_delete_query_successful.connect(
        #     self.iface.QuickOSM_mainWindowDialog.refresh_my_queries_tree)

        # Connect signals and slots from mainWindow
        # self.iface.QuickOSM_mainWindowDialog.signal_new_query_successful.\
        #     connect(self.myQueriesDockWidget.refresh_my_queries_tree)
        # self.iface.QuickOSM_mainWindowDialog.signal_new_query_successful.\
        #     connect(
        #         self.iface.QuickOSM_mainWindowDialog.refresh_my_queries_tree)
        # self.iface.QuickOSM_mainWindowDialog.signal_delete_query_successful.\
        #     connect(self.myQueriesDockWidget.refresh_my_queries_tree)
        # self.iface.QuickOSM_mainWindowDialog.signal_delete_query_successful.\
        #     connect(
        #         self.iface.QuickOSM_mainWindowDialog.refresh_my_queries_tree)

        # Read the config file
        json_file_config = join(dirname(abspath(__file__)), 'config.json')
        if isfile(json_file_config):
            with open(json_file_config) as f:
                config_json = load(f)
                for server in config_json['overpass_servers']:
                    self.iface.QuickOSM_mainWindowDialog.comboBox_default_OAPI.\
                        addItem(server)

        # Check previous version and if new queries are available
        version = get_setting('version')
        current_version = get_current_version()
        if version != current_version:
            if new_queries_available():
                message = 'New queries are available in the plugin. Would ' \
                          'like to install them ? This will overwrite the ' \
                          'current default queries.'
                title = 'QuickOSM'
                message = tr('QuickOSM', message)
                widget = self.iface.messageBar().createMessage(title, message)
                button_ok = QPushButton(widget)
                button_ok.setText(tr('QuickOSM', 'Install'))
                button_ok.pressed.connect(self.restoreDefaultQueries)
                widget.layout().addWidget(button_ok)
                self.iface.messageBar().pushWidget(widget, Qgis.Info, 0)

            set_setting('version', current_version)