-
Notifications
You must be signed in to change notification settings - Fork 0
/
searchFormController.py
236 lines (185 loc) · 8.41 KB
/
searchFormController.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# -*- coding: utf-8 -*-
"""
/***************************************************************************
vfkPluginDialog
A QGIS plugin
Plugin umoznujici praci s daty katastru nemovitosti
-------------------
begin : 2015-06-11
git sha : $Format:%H$
copyright : (C) 2015 by Stepan Bambula
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
"""
from __future__ import absolute_import
from builtins import range
from builtins import object
from qgis.PyQt.QtCore import QObject, QUrl, QRegExp, QModelIndex, Qt, pyqtSignal, qDebug
from qgis.PyQt.QtGui import QStandardItemModel, QStandardItem
from qgis.PyQt.QtWidgets import QStackedWidget, QApplication
from .vfkTableModel import *
class SearchFormController(QObject):
class SearchForms(QStackedWidget):
vlastnici = None
parcely = None
budovy = None
jednotky = None
class MainControls(object):
formCombobox = None
searchForms = None
searchButton = None
class Form(object):
Vlastnici = 0
Parcely = 1
Budovy = 2
Jednotky = 3
# signals
actionTriggered = pyqtSignal(QUrl)
def __init__(self, mainControls, searchForms, parent=None):
"""
:type mainControls: MainControls
:type searchForms: SearchForms
:type parent: QObject
:return:
"""
QObject.__init__(self)
self.__controls = mainControls
self.__forms = searchForms
self.__mConnectionName = ''
self.__mDruhParcely = ''
self.__mDruhPozemkoveParcely = ''
self.__mDruhStavebniParcely = ''
self.__mZpusobVyuzitiBudovy = ''
self.__mZpusobVyuzitiJednotek = ''
self.__controls.formCombobox.addItem(u"vlastníky", self.Form.Vlastnici)
self.__controls.formCombobox.addItem(u"parcely", self.Form.Parcely)
self.__controls.formCombobox.addItem(u"budovy", self.Form.Budovy)
self.__controls.formCombobox.addItem(u"jednotky", self.Form.Jednotky)
self.__controls.formCombobox.activated.connect(self.__controls.searchForms.setCurrentIndex)
self.__controls.searchButton.clicked.connect(self.search)
self.__controls.searchForms.setCurrentIndex(0)
self.__controls.searchButton.setEnabled(False)
def setConnectionName(self, connectionName):
"""
:type connectionName: str
"""
self.__mConnectionName = connectionName
self.__initComboBoxModels()
self.__controls.searchButton.setEnabled(True)
def search(self):
"""
"""
QApplication.setOverrideCursor(Qt.WaitCursor)
QApplication.processEvents()
if int(self.__controls.formCombobox.itemData(self.__controls.formCombobox.currentIndex())) == self.Form.Parcely:
self.__searchParcely()
elif int(self.__controls.formCombobox.itemData(self.__controls.formCombobox.currentIndex())) == self.Form.Budovy:
self.__searchBudovy()
elif int(self.__controls.formCombobox.itemData(self.__controls.formCombobox.currentIndex())) == self.Form.Jednotky:
self.__searchJednotky()
elif int(self.__controls.formCombobox.itemData(self.__controls.formCombobox.currentIndex())) == self.Form.Vlastnici:
self.__searchVlastnici()
else:
qDebug("Neplatna hodnota v SearchComboBoxu!!!")
QApplication.restoreOverrideCursor()
def __searchVlastnici(self):
"""
"""
jmeno = self.__forms.vlastnici.jmeno()
rcIco = self.__forms.vlastnici.rcIco()
lv = self.__forms.vlastnici.lv()
sjm = self.__forms.vlastnici.isSjm()
opo = self.__forms.vlastnici.isOpo()
ofo = self.__forms.vlastnici.isOfo()
url = QUrl(u"showText?page=search&type=vlastnici&jmeno={}&rcIco={}&sjm={}&opo={}&ofo={}&lv={}"
.format(jmeno, rcIco, 1 if sjm else 0, 1 if opo else 0, 1 if ofo else 0, lv))
self.actionTriggered.emit(url)
def __searchParcely(self):
"""
"""
parcelniCislo = self.__forms.parcely.parcelniCislo()
typ = int(self.__forms.parcely.typParcely())
druh = self.__forms.parcely.druhPozemkuKod()
lv = self.__forms.parcely.lv()
url = QUrl(u"showText?page=search&type=parcely&parcelniCislo={}&typ={}&druh={}&lv={}"
.format(parcelniCislo, typ, druh, lv))
self.actionTriggered.emit(url)
def __searchBudovy(self):
"""
"""
domovniCislo = self.__forms.budovy.domovniCislo()
naParcele = self.__forms.budovy.naParcele()
zpusobVyuziti = self.__forms.budovy.zpusobVyuzitiKod()
lv = self.__forms.budovy.lv()
url = QUrl(u"showText?page=search&type=budovy&domovniCislo={}&naParcele={}&zpusobVyuziti={}&lv={}"
.format(domovniCislo, naParcele, zpusobVyuziti, lv))
self.actionTriggered.emit(url)
def __searchJednotky(self):
"""
"""
cisloJednotky = self.__forms.jednotky.cisloJednotky()
domovniCislo = self.__forms.jednotky.domovniCislo()
naParcele = self.__forms.jednotky.naParcele()
zpusobVyuziti = self.__forms.jednotky.zpusobVyuzitiKod()
lv = self.__forms.jednotky.lv()
url = QUrl(u"showText?page=search&type=jednotky&cisloJednotky={}&domovniCislo={}&naParcele={}&zpusobVyuziti={}&lv={}"
.format(cisloJednotky, domovniCislo, naParcele, zpusobVyuziti, lv))
self.actionTriggered.emit(url)
def __initComboBoxModels(self):
"""
"""
self.__mDruhParcely = VfkTableModel(self.__mConnectionName, self)
self.__mDruhParcely.druhyPozemku(True, True)
self.__mDruhPozemkoveParcely = VfkTableModel(
self.__mConnectionName, self)
self.__mDruhPozemkoveParcely.druhyPozemku(True, False)
self.__mDruhStavebniParcely = VfkTableModel(
self.__mConnectionName, self)
self.__mDruhStavebniParcely.druhyPozemku(False, True)
self.__mZpusobVyuzitiBudovy = VfkTableModel(
self.__mConnectionName, self)
self.__mZpusobVyuzitiBudovy.zpusobVyuzitiBudov()
self.__mZpusobVyuzitiJednotek = VfkTableModel(
self.__mConnectionName, self)
self.__mZpusobVyuzitiJednotek.zpusobVyuzitiJednotek()
falseKodForDefaultDruh = ''
text = u'libovolný'
fakeRow = [falseKodForDefaultDruh, text]
self.__forms.parcely.setDruhPozemkuModel(
self.__addFirstRowToModel(self.__mDruhParcely, fakeRow))
self.__forms.parcely.setDruhPozemkuPozemkovaModel(
self.__addFirstRowToModel(self.__mDruhPozemkoveParcely, fakeRow))
self.__forms.parcely.setDruhPozemkuStavebniModel(
self.__mDruhStavebniParcely)
self.__forms.budovy.setZpusobVyuzitiModel(
self.__addFirstRowToModel(self.__mZpusobVyuzitiBudovy, fakeRow))
self.__forms.jednotky.setZpusobVyuzitiModel(
self.__addFirstRowToModel(self.__mZpusobVyuzitiJednotek, fakeRow))
def __addFirstRowToModel(self, oldModel, newRow):
"""
:type oldModel: QAbstractItemModel
:type newRow: list
:return: QStandardItemModel
"""
model = QStandardItemModel(self)
items = []
for str in newRow:
items.append(QStandardItem(str))
model.appendRow(items)
for i in range(oldModel.rowCount()):
items = []
for j in range(oldModel.columnCount()):
index = QModelIndex(oldModel.index(i, j))
data = oldModel.data(index)
item = QStandardItem(data)
items.append(item)
model.appendRow(items)
return model