-
Notifications
You must be signed in to change notification settings - Fork 0
/
parcelySearchForm.py
102 lines (80 loc) · 3.52 KB
/
parcelySearchForm.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
# -*- 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 PyQt4.QtGui import *
from PyQt4.QtCore import QAbstractItemModel, QRegExp, SIGNAL
from ui_parcelysearchform import *
class ParcelySearchForm(QWidget):
def __init__(self, parent=None):
super(ParcelySearchForm, self).__init__(parent)
# Set up the user interface from Designer.
self.ui = Ui_ParcelySearchForm()
self.ui.setupUi(self)
self.__defaultModel = QAbstractItemModel
self.__stavebniModel = QAbstractItemModel
self.__pozemkovaModel = QAbstractItemModel
self.connect(self.ui.typParcelyCombo, SIGNAL(
"currentIndexChanged(int)"), self.__setDruhModel)
self.rx = QRegExp("[0-9]*/?[0-9]*")
self.validator = QRegExpValidator(self.rx)
self.ui.parCisloLineEdit.setValidator(self.validator)
def parcelniCislo(self):
return unicode(self.ui.parCisloLineEdit.text()).strip()
def lv(self):
return unicode(self.ui.lvParcelyLineEdit.text()).strip()
def setDruhPozemkuModel(self, model):
"""
:type model: QAbstractItemModel
"""
self.__defaultModel = model
self.__pozemkovaModel = model
self.__stavebniModel = model
self.ui.druhPozemkuCombo.setModel(model)
self.ui.druhPozemkuCombo.setModelColumn(1)
def __setDruhModel(self):
if self.ui.typParcelyCombo.currentIndex() == 1:
self.ui.druhPozemkuCombo.setModel(self.__pozemkovaModel)
elif self.ui.typParcelyCombo.currentIndex() == 2:
self.ui.druhPozemkuCombo.setModel(self.__stavebniModel)
else:
self.ui.druhPozemkuCombo.setModel(self.__defaultModel)
def setDruhPozemkuStavebniModel(self, model):
"""
:param model: QAbstractItemModel
"""
self.__stavebniModel = model
def setDruhPozemkuPozemkovaModel(self, model):
"""
:param model: QAbstractItemModel
"""
self.__pozemkovaModel = model
def typParcely(self):
return self.ui.typParcelyCombo.currentIndex()
def druhPozemkuKod(self):
"""
:return: str
"""
row = self.ui.druhPozemkuCombo.currentIndex()
index = self.ui.druhPozemkuCombo.model().index(row, 1)
if self.ui.druhPozemkuCombo.model().data(index) == u"libovolný":
return u''
else:
return u"{}".format(self.ui.druhPozemkuCombo.model().data(index))