diff --git a/importer/process_import.py b/importer/process_import.py index f79489e..57561af 100644 --- a/importer/process_import.py +++ b/importer/process_import.py @@ -215,7 +215,7 @@ def _file_is_readable(self, gpx_path): else: return True except Exception as ex: - self.error_type = ex.message + self.error_type = str(ex) def gpx_to_point_list(self): """ diff --git a/ui/gps_importer.py b/ui/gps_importer.py index 1edab72..8493a79 100644 --- a/ui/gps_importer.py +++ b/ui/gps_importer.py @@ -12,7 +12,7 @@ class Ui_BatchGpsImporter(object): def setupUi(self, BatchGpsImporter): BatchGpsImporter.setObjectName("BatchGpsImporter") BatchGpsImporter.setEnabled(True) - BatchGpsImporter.resize(587, 437) + BatchGpsImporter.resize(660, 444) self.horizontalLayout = QtWidgets.QHBoxLayout(BatchGpsImporter) self.horizontalLayout.setObjectName("horizontalLayout") self.verticalLayout = QtWidgets.QVBoxLayout() @@ -113,69 +113,61 @@ def setupUi(self, BatchGpsImporter): self.verticalLayout_3.setObjectName("verticalLayout_3") self.gridLayout_2 = QtWidgets.QGridLayout() self.gridLayout_2.setObjectName("gridLayout_2") - self.invalid_gpx_folder = QtWidgets.QLineEdit(self.validation_tab) - self.invalid_gpx_folder.setObjectName("invalid_gpx_folder") - self.gridLayout_2.addWidget(self.invalid_gpx_folder, 6, 1, 1, 2) + self.exclude_with_errors_rbtn = QtWidgets.QRadioButton(self.validation_tab) + self.exclude_with_errors_rbtn.setObjectName("exclude_with_errors_rbtn") + self.buttonGroup = QtWidgets.QButtonGroup(BatchGpsImporter) + self.buttonGroup.setObjectName("buttonGroup") + self.buttonGroup.addButton(self.exclude_with_errors_rbtn) + self.gridLayout_2.addWidget(self.exclude_with_errors_rbtn, 3, 1, 1, 1) + self.valid_folder_btn = QtWidgets.QPushButton(self.validation_tab) + self.valid_folder_btn.setObjectName("valid_folder_btn") + self.gridLayout_2.addWidget(self.valid_folder_btn, 5, 3, 1, 1) + self.no_exclude_few_points = QtWidgets.QRadioButton(self.validation_tab) + self.no_exclude_few_points.setObjectName("no_exclude_few_points") + self.buttonGroup_2 = QtWidgets.QButtonGroup(BatchGpsImporter) + self.buttonGroup_2.setObjectName("buttonGroup_2") + self.buttonGroup_2.addButton(self.no_exclude_few_points) + self.gridLayout_2.addWidget(self.no_exclude_few_points, 4, 2, 1, 1) + self.valid_gpx_folder = QtWidgets.QLineEdit(self.validation_tab) + self.valid_gpx_folder.setObjectName("valid_gpx_folder") + self.gridLayout_2.addWidget(self.valid_gpx_folder, 5, 1, 1, 2) + self.invalid_folder_btn = QtWidgets.QPushButton(self.validation_tab) + self.invalid_folder_btn.setObjectName("invalid_folder_btn") + self.gridLayout_2.addWidget(self.invalid_folder_btn, 6, 3, 1, 1) + self.label_4 = QtWidgets.QLabel(self.validation_tab) + self.label_4.setWordWrap(True) + self.label_4.setObjectName("label_4") + self.gridLayout_2.addWidget(self.label_4, 3, 0, 1, 1) self.label_5 = QtWidgets.QLabel(self.validation_tab) self.label_5.setWordWrap(True) self.label_5.setObjectName("label_5") self.gridLayout_2.addWidget(self.label_5, 4, 0, 1, 1) - self.invalid_folder_btn = QtWidgets.QPushButton(self.validation_tab) - self.invalid_folder_btn.setObjectName("invalid_folder_btn") - self.gridLayout_2.addWidget(self.invalid_folder_btn, 6, 3, 1, 1) - self.valid_folder_btn = QtWidgets.QPushButton(self.validation_tab) - self.valid_folder_btn.setObjectName("valid_folder_btn") - self.gridLayout_2.addWidget(self.valid_folder_btn, 5, 3, 1, 1) self.label_10 = QtWidgets.QLabel(self.validation_tab) self.label_10.setObjectName("label_10") self.gridLayout_2.addWidget(self.label_10, 6, 0, 1, 1) self.exclude_with_few_points = QtWidgets.QRadioButton(self.validation_tab) self.exclude_with_few_points.setObjectName("exclude_with_few_points") - self.buttonGroup_2 = QtWidgets.QButtonGroup(BatchGpsImporter) - self.buttonGroup_2.setObjectName("buttonGroup_2") self.buttonGroup_2.addButton(self.exclude_with_few_points) self.gridLayout_2.addWidget(self.exclude_with_few_points, 4, 1, 1, 1) - self.no_exclude_few_points = QtWidgets.QRadioButton(self.validation_tab) - self.no_exclude_few_points.setObjectName("no_exclude_few_points") - self.buttonGroup_2.addButton(self.no_exclude_few_points) - self.gridLayout_2.addWidget(self.no_exclude_few_points, 4, 2, 1, 1) + self.label_7 = QtWidgets.QLabel(self.validation_tab) + self.label_7.setObjectName("label_7") + self.gridLayout_2.addWidget(self.label_7, 5, 0, 1, 1) + self.invalid_gpx_folder = QtWidgets.QLineEdit(self.validation_tab) + self.invalid_gpx_folder.setObjectName("invalid_gpx_folder") + self.gridLayout_2.addWidget(self.invalid_gpx_folder, 6, 1, 1, 2) self.no_exclude_with_errors_rbtn = QtWidgets.QRadioButton(self.validation_tab) self.no_exclude_with_errors_rbtn.setObjectName("no_exclude_with_errors_rbtn") - self.buttonGroup = QtWidgets.QButtonGroup(BatchGpsImporter) - self.buttonGroup.setObjectName("buttonGroup") self.buttonGroup.addButton(self.no_exclude_with_errors_rbtn) self.gridLayout_2.addWidget(self.no_exclude_with_errors_rbtn, 3, 2, 1, 1) - self.exclude_with_errors_rbtn = QtWidgets.QRadioButton(self.validation_tab) - self.exclude_with_errors_rbtn.setObjectName("exclude_with_errors_rbtn") - self.buttonGroup.addButton(self.exclude_with_errors_rbtn) - self.gridLayout_2.addWidget(self.exclude_with_errors_rbtn, 3, 1, 1, 1) - self.label_4 = QtWidgets.QLabel(self.validation_tab) - self.label_4.setWordWrap(True) - self.label_4.setObjectName("label_4") - self.gridLayout_2.addWidget(self.label_4, 3, 0, 1, 1) - self.valid_gpx_folder = QtWidgets.QLineEdit(self.validation_tab) - self.valid_gpx_folder.setObjectName("valid_gpx_folder") - self.gridLayout_2.addWidget(self.valid_gpx_folder, 5, 1, 1, 2) - self.label_7 = QtWidgets.QLabel(self.validation_tab) - self.label_7.setObjectName("label_7") - self.gridLayout_2.addWidget(self.label_7, 5, 0, 1, 1) + self.label_9 = QtWidgets.QLabel(self.validation_tab) + self.label_9.setWordWrap(True) + self.label_9.setObjectName("label_9") + self.gridLayout_2.addWidget(self.label_9, 2, 0, 1, 1) self.extent_box = QgsExtentGroupBox(self.validation_tab) - self.extent_box.setMaximumSize(QtCore.QSize(16777215, 150)) - self.extent_box.setAlignment(QtCore.Qt.AlignBottom|QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft) - self.extent_box.setFlat(False) self.extent_box.setCheckable(True) self.extent_box.setChecked(False) - self.extent_box.setProperty("collapsed", False) - self.extent_box.setProperty("syncGroup", "") - self.extent_box.setProperty("scrollOnExpand", False) - self.extent_box.setProperty("saveCollapsedState", False) - self.extent_box.setProperty("saveCheckedState", False) self.extent_box.setObjectName("extent_box") self.gridLayout_2.addWidget(self.extent_box, 2, 1, 1, 3) - self.label_9 = QtWidgets.QLabel(self.validation_tab) - self.label_9.setWordWrap(True) - self.label_9.setObjectName("label_9") - self.gridLayout_2.addWidget(self.label_9, 2, 0, 1, 1) self.verticalLayout_3.addLayout(self.gridLayout_2) self.tab_widget.addTab(self.validation_tab, "") self.fields_tab = QtWidgets.QWidget() @@ -215,7 +207,7 @@ def setupUi(self, BatchGpsImporter): self.scrollArea.setWidgetResizable(True) self.scrollArea.setObjectName("scrollArea") self.scrollAreaWidgetContents = QtWidgets.QWidget() - self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 528, 327)) + self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 528, 334)) self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents) self.verticalLayout_5.setContentsMargins(0, 0, 0, 0) @@ -253,8 +245,7 @@ def setupUi(self, BatchGpsImporter): sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.dynamic_help_box.sizePolicy().hasHeightForWidth()) self.dynamic_help_box.setSizePolicy(sizePolicy) - self.dynamic_help_box.setUrl(QtCore.QUrl("about:blank")) - self.dynamic_help_box.setRenderHints(QtGui.QPainter.HighQualityAntialiasing|QtGui.QPainter.SmoothPixmapTransform|QtGui.QPainter.TextAntialiasing) + self.dynamic_help_box.setProperty("url", QtCore.QUrl("about:blank")) self.dynamic_help_box.setObjectName("dynamic_help_box") self.horizontalLayout.addWidget(self.dynamic_help_box) @@ -282,19 +273,18 @@ def retranslateUi(self, BatchGpsImporter): self.prefix_label.setText(_translate("BatchGpsImporter", "File name prefix")) self.suffix_label.setText(_translate("BatchGpsImporter", "File name suffix")) self.tab_widget.setTabText(self.tab_widget.indexOf(self.input_output_tab), _translate("BatchGpsImporter", "Input and Output")) - self.label_5.setText(_translate("BatchGpsImporter", "Exclude with insufficient points")) - self.invalid_folder_btn.setText(_translate("BatchGpsImporter", "Browse...")) + self.exclude_with_errors_rbtn.setText(_translate("BatchGpsImporter", "Yes")) self.valid_folder_btn.setText(_translate("BatchGpsImporter", "Browse...")) - self.label_10.setText(_translate("BatchGpsImporter", "Invalid GPX folder")) - self.exclude_with_few_points.setText(_translate("BatchGpsImporter", "Yes")) self.no_exclude_few_points.setText(_translate("BatchGpsImporter", "No")) - self.no_exclude_with_errors_rbtn.setText(_translate("BatchGpsImporter", "No")) - self.exclude_with_errors_rbtn.setText(_translate("BatchGpsImporter", "Yes")) + self.invalid_folder_btn.setText(_translate("BatchGpsImporter", "Browse...")) self.label_4.setText(_translate("BatchGpsImporter", "Exclude with geometry error")) + self.label_5.setText(_translate("BatchGpsImporter", "Exclude with insufficient points")) + self.label_10.setText(_translate("BatchGpsImporter", "Invalid GPX folder")) + self.exclude_with_few_points.setText(_translate("BatchGpsImporter", "Yes")) self.label_7.setText(_translate("BatchGpsImporter", "Valid GPX folder")) - self.extent_box.setTitle(_translate("BatchGpsImporter", "Map extent (current: none)")) - self.extent_box.setProperty("titleBase", _translate("BatchGpsImporter", "Map extent")) + self.no_exclude_with_errors_rbtn.setText(_translate("BatchGpsImporter", "No")) self.label_9.setText(_translate("BatchGpsImporter", "Exclude outside extent")) + self.extent_box.setTitle(_translate("BatchGpsImporter", "Map extent (current: none)")) self.tab_widget.setTabText(self.tab_widget.indexOf(self.validation_tab), _translate("BatchGpsImporter", "Validation")) self.label_12.setText(_translate("BatchGpsImporter", "Choose layer fields")) self.exclude_fields_groupbox.setTitle(_translate("BatchGpsImporter", "Check All/ Uncheck All")) @@ -303,7 +293,7 @@ def retranslateUi(self, BatchGpsImporter): self.about_box.setHtml(_translate("BatchGpsImporter", "\n" "\n" +"\n" "

Batch GPS Importer

\n" "

Version 1.0.0

\n" "


\n" @@ -317,6 +307,7 @@ def retranslateUi(self, BatchGpsImporter): "

Copyright © 2017 Wondimagegn Tesfaye Beshah. All rights reserved.

")) self.tab_widget.setTabText(self.tab_widget.indexOf(self.tab), _translate("BatchGpsImporter", "About")) + from PyQt5 import QtWebKitWidgets from qgis.gui import QgsExtentGroupBox from qgis.gui import QgsProjectionSelectionWidget diff --git a/ui/gps_importer.ui b/ui/gps_importer.ui index 368b270..6060b02 100644 --- a/ui/gps_importer.ui +++ b/ui/gps_importer.ui @@ -9,8 +9,8 @@ 0 0 - 587 - 437 + 660 + 444 @@ -109,7 +109,7 @@ - + 16777215 @@ -204,19 +204,36 @@ - - + + + + Yes + + + buttonGroup + + - - + + - Exclude with insufficient points + Browse... - - true + + + + + + No + + buttonGroup_2 + + + + @@ -224,10 +241,23 @@ - - + + - Browse... + Exclude with geometry error + + + true + + + + + + + Exclude with insufficient points + + + true @@ -248,16 +278,16 @@ - - + + - No + Valid GPX folder - - buttonGroup_2 - + + + @@ -268,87 +298,27 @@ - - - - Yes - - - buttonGroup - - - - - + + - Exclude with geometry error + Exclude outside extent true - - - - - - - Valid GPX folder - - - - - - 16777215 - 150 - - Map extent (current: none) - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - - false - true false - - false - - - - - - false - - - false - - - false - - - Map extent - - - - - - - Exclude outside extent - - - true - @@ -436,7 +406,7 @@ 0 0 528 - 327 + 334 @@ -473,7 +443,7 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:7.5pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:7.8pt; font-weight:400; font-style:normal;"> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">Batch GPS Importer</span></p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:11pt;">Version 1.0.0</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt;"><br /></p> @@ -505,7 +475,7 @@ p, li { white-space: pre-wrap; } - + true @@ -515,24 +485,16 @@ p, li { white-space: pre-wrap; } 0 - + about:blank - - QPainter::HighQualityAntialiasing|QPainter::SmoothPixmapTransform|QPainter::TextAntialiasing - - - QWebView - QWidget -
QtWebKit/QWebView
-
QgsCollapsibleGroupBox QGroupBox @@ -550,6 +512,11 @@ p, li { white-space: pre-wrap; } QWidget
qgsprojectionselectionwidget.h
+ + QWebView + QWidget +
QtWebKit/QWebView
+
@@ -587,7 +554,7 @@ p, li { white-space: pre-wrap; } - + diff --git a/ui/gps_importer_starter.py b/ui/gps_importer_starter.py index 4abe50f..916b0b2 100644 --- a/ui/gps_importer_starter.py +++ b/ui/gps_importer_starter.py @@ -34,7 +34,8 @@ ) from PyQt5.QtWebKit import QWebSettings -from qgis.core import QgsCoordinateReferenceSystem, QgsCoordinateTransform +from qgis.core import QgsCoordinateReferenceSystem, QgsCoordinateTransform, \ + QgsProject from .gps_importer import Ui_BatchGpsImporter from ..importer.process_import import ( @@ -60,6 +61,7 @@ def __init__(self, iface): self.help_box_width = 206 self.curr_help_box_width = 0 # the width of the help box before hiding self.setupUi(self) + self.field_items = {} self.param_store = ParamStore() self.init_gui() @@ -73,6 +75,7 @@ def __init__(self, iface): self.input_projection_cbo.setCrs( QgsCoordinateReferenceSystem('EPSG:4326') ) + # self.on_update_extent_box(True) self.waypoint.setProperty('name', 'waypoints') self.track.setProperty('name', 'tracks') self.route.setProperty('name', 'routes') @@ -88,7 +91,7 @@ def init_gui(self): self.rename_buttonbox() self.add_dynamic_help_button() self.hide_dynamic_help(on_load_hide=True) - self.hide_extent_buttons() + # self.hide_extent_buttons() self.tab_widget.removeTab(3) self.exclude_fields_view.setHeaderHidden(True) self.exclude_fields_view.setColumnWidth(0, 150) @@ -289,7 +292,6 @@ def on_update_progress(self, text): :type text: String """ QApplication.processEvents() - self.progress_text_edit.append(text) def on_prevent_collapse(self): @@ -298,49 +300,51 @@ def on_prevent_collapse(self): """ self.extent_box.setCollapsed(False) - def on_update_extent_box(self): + def on_update_extent_box(self, init=False): """ A slot raised to automatically update the bounding box coordinates when the the map zoom level changes and when the extent box is enabled. :return: :rtype: """ - if not self.extent_box.isChecked(): - return - try: - canvas_extent = self.canvas.extent() + if not init: + if not self.extent_box.isChecked(): + return + # try: + canvas_extent = self.canvas.extent() - transformer = QgsCoordinateTransform( - self.canvas.mapRenderer().destinationCrs(), - self.input_projection_cbo.crs() - ) + transformer = QgsCoordinateTransform( + self.canvas.mapSettings().destinationCrs(), + self.input_projection_cbo.crs(), + QgsProject.instance() + ) - transformer.setDestCRS( - self.input_projection_cbo.crs() - ) - transformed_extent = transformer.transform(canvas_extent) + transformer.setDestinationCrs( + self.input_projection_cbo.crs() + ) + transformed_extent = transformer.transform(canvas_extent) - self.extent_box.setOriginalExtent( - transformed_extent, - QgsCoordinateReferenceSystem( - self.input_projection_cbo.crs().authid() - ) + self.extent_box.setOriginalExtent( + transformed_extent, + QgsCoordinateReferenceSystem( + self.input_projection_cbo.crs().authid() ) + ) - self.extent_box.setOutputCrs( - QgsCoordinateReferenceSystem( - self.input_projection_cbo.crs().authid() - ) + self.extent_box.setOutputCrs( + QgsCoordinateReferenceSystem( + self.input_projection_cbo.crs().authid() ) - self.extent_box.setOutputExtentFromOriginal() - self.extent_box.setCurrentExtent( - transformed_extent, - QgsCoordinateReferenceSystem( - self.input_projection_cbo.crs().authid() - ) + ) + self.extent_box.setOutputExtentFromOriginal() + self.extent_box.setCurrentExtent( + transformed_extent, + QgsCoordinateReferenceSystem( + self.input_projection_cbo.crs().authid() ) - except Exception as ex: - pass + ) + # except Exception as ex: + # pass def populate_geometry_type(self): """