-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathselectDateDialog.py
72 lines (64 loc) · 2.7 KB
/
selectDateDialog.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
"""
/***************************************************************************
QGIS Historize Plugin
-------------------------------------------------------------------
Date : 09 Mai 2017
Copyright : (C) 2017 by William Habelt
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.QtCore import *
from PyQt4.QtGui import *
from qgis.utils import *
from qgis.core import *
from qgis.gui import *
from ui_selectDate import Ui_SelectDate
from sqlexecute import SQLExecute
from dbconn import DBConn
class SelectDateDialog(QDialog, Ui_SelectDate):
"""
Class responsible for handling the date selection.
"""
def __init__(self, iface, parent=None):
QDialog.__init__(self, parent)
self.setupUi(self)
self.iface = iface
self.dbconn = DBConn(iface)
self.cmbDate.clear()
self.getDates()
def getDates(self):
"""Get all historized dates from layer"""
provider = self.iface.activeLayer().dataProvider()
self.uri = QgsDataSourceURI(provider.dataSourceUri())
self.conn = self.dbconn.connectToDb(self.uri)
# self.schema = self.uri.schema()
self.execute = SQLExecute(self.conn, self.iface.activeLayer())
self.dateList = self.execute.retrieveHistVersions(self.iface.activeLayer().name(), self.uri.schema())
if not self.dateList:
self.records = False
QMessageBox.warning(self.iface.mainWindow(), self.tr(u"Error"), self.tr(u"No historized versions found!"))
else:
for date in self.dateList:
self.cmbDate.addItem(str(date[0]))
self.records = True
@pyqtSignature("")
def on_buttonBox_accepted(self):
"""
Run hist_tabs.version() SQL-function
"""
if self.records:
self.execute.histTabsVersion(self.uri.schema(), self.iface.activeLayer().name(), self.cmbDate.currentText(), self.uri)
@pyqtSignature("")
def on_buttonBox_rejected(self):
"""
Close Window and DB-Connection
"""
self.conn.close()
self.close()