Skip to content

Commit

Permalink
QGIS3 major update (#41)
Browse files Browse the repository at this point in the history
* apply qgis2to3, see #2
* update metadata.txt to qgis3, see #2
* update resources file to qt5, see #2
* fix another qgis2to3 issue, see #2
* Rewriting code for QGIS 3 part 1
Undertaken steps:
- importing some modules and classes in due to splitting the original ones (QtGui > QtGui, QtWidget)
- renaming some QGIS API 3.x classes
Result:
- plugin can be started in QGIS 3
- VFK file can be imported
* Update README.md
* Decoding UTF-8
ad vfkTableModel.py:
- in Python 3 no longer needed "prefixes" u'...'/u"..."
ad mainApp.py:
- problem with decoding the file
I found this hack (can't find the source again), but the traceback says the byte can't be decoded - is the encoding truly utf-8?
sources:
https://timothybramlett.com/Strings_Bytes_and_Unicode_in_Python_2_and_3.html
https://medium.com/@andreacolangelo/strings-unicode-and-bytes-in-python-3-everything-you-always-wanted-to-know-27dc02ff2686
* quick and dirty QByteArray fix, see #3
* Completing API functions
Functions which run correctly
- import
- search form (owners excluded)
- export (HTML, LaTeX)
* add sample data

Co-authored-by: luciestara <[email protected]>
  • Loading branch information
landam and luciestara authored Feb 15, 2021
1 parent 9497342 commit 6a94435
Show file tree
Hide file tree
Showing 29 changed files with 1,885 additions and 1,820 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ default: compile
compile: $(COMPILED_RESOURCE_FILES)

%_rc.py : %.qrc $(RESOURCES_SRC)
pyrcc4 -o $*_rc.py $<
pyrcc5 -o $*_rc.py $<

%.qm : %.ts
$(LRELEASE) $<
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Zásuvný plugin QGIS pro katastrální data
# Assignment
Rewriting plugin from QGIS 2 to QGIS 3

Zahrnuje přepsání [stávajícího zásuvného pluginu pro
QGIS](https://github.com/ctu-osgeorel/qgis-vfk-plugin-cpp) (C++) pro
zobrazování katastrálních dat do jazyka Python. Funkcionalita tohoto
pluginu bude dále rozšiřována.
# Author
Lucie Stará
3 changes: 2 additions & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
***************************************************************************/
This script initializes the plugin, making it known to QGIS.
"""
from __future__ import absolute_import


def classFactory(iface):
from vfkPlugin import vfkPlugin
from .vfkPlugin import vfkPlugin
return vfkPlugin(iface)
17 changes: 10 additions & 7 deletions applyChanges.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* *
***************************************************************************/
"""
from __future__ import print_function
from builtins import str
from builtins import zip

import sqlite3
import sys
Expand All @@ -29,8 +32,8 @@
import argparse
from datetime import datetime

from PyQt4.QtGui import QWidget, QApplication
from PyQt4.QtCore import qDebug, pyqtSignal, SIGNAL
from qgis.PyQt.QtWidgets import QWidget, QApplication
from qgis.PyQt.QtCore import qDebug, pyqtSignal


class ApplyChanges(QWidget):
Expand Down Expand Up @@ -58,7 +61,7 @@ def run(self, db_full, db_amendment, db_updated, use_debug=False):
:type db_amendment: str
:type db_updated: str
"""
self.emit(SIGNAL('preprocessingDatabase'))
self.preprocessingDatabase.emit()

db_full = os.path.abspath(db_full)
db_amendment = os.path.abspath(db_amendment)
Expand All @@ -82,18 +85,18 @@ def run(self, db_full, db_amendment, db_updated, use_debug=False):

self.__applyChanges()

self.emit(SIGNAL('finishedStatus'))
self.finishedStatus.emit()

def __applyChanges(self):
"""
Method updates rows in main database by rows from databse with amendment data.
"""
table_names = self.__findTablesWithChanges()
self.emit(SIGNAL("maxRangeProgressBar"), len(table_names))
self.maxRangeProgressBar.emit(len(table_names))

# process all relevant tables
for i, table in enumerate(table_names):
self.emit(SIGNAL("updateStatus"), i+1, table)
self.updateStatus.emit(i+1, table)

# Delete data which are in both databases --> there are updates in amendment database
query = 'DELETE FROM main.{table} ' \
Expand Down Expand Up @@ -138,7 +141,7 @@ def __doInsertOperation(self, table):
for item in row:
tmp.append(item)

data_rows.append(dict(zip(columns, tmp)))
data_rows.append(dict(list(zip(columns, tmp))))

# sort data according to the date 'DATUM_VZNIKU'
if 'DATUM_VZNIKU' in data_rows[0]:
Expand Down
15 changes: 9 additions & 6 deletions budovySearchForm.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
* *
***************************************************************************/
"""
from builtins import str

from PyQt4.QtGui import *
from PyQt4.QtCore import QAbstractItemModel
from qgis.PyQt import QtGui, QtWidgets
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from qgis.PyQt.QtCore import QAbstractItemModel

from ui_budovysearchform import *
from .ui_budovysearchform import *


class BudovySearchForm(QWidget):
Expand All @@ -40,13 +43,13 @@ def __init__(self, parent=None):
self.__mZpusobVyuzitiModel = QAbstractItemModel

def domovniCislo(self):
return unicode(self.ui.cisloDomovniLineEdit.text()).strip()
return str(self.ui.cisloDomovniLineEdit.text()).strip()

def naParcele(self):
return unicode(self.ui.naParceleLineEdit.text()).strip()
return str(self.ui.naParceleLineEdit.text()).strip()

def lv(self):
return unicode(self.ui.lvBudovyLineEdit.text()).strip()
return str(self.ui.lvBudovyLineEdit.text()).strip()

def setZpusobVyuzitiModel(self, model):
"""
Expand Down
Loading

0 comments on commit 6a94435

Please sign in to comment.