-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtlayerconfig.py
87 lines (61 loc) · 2.53 KB
/
tlayerconfig.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
# -*- coding: utf-8 -*-
"""
/***************************************************************************
tLayerConfig
New Layer Dialog
***************************************************************************/
"""
from PyQt4 import QtCore, QtGui
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
from forms.ui_tlayerconfig import Ui_tLayerConfig
from tlbrokers import tlBrokers as Brokers
from lib.tlsettings import tlSettings as Settings
from lib.tllogging import tlLogging as Log
from tltopicmanagerfactory import tlTopicManagerFactory as tmFactory
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
_fromUtf8 = lambda s: s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class tLayerConfig(QtGui.QDialog, Ui_tLayerConfig):
"""
Dialog to support creation of a new Telemetry Layer
"""
def __init__(self, creator):
super(tLayerConfig, self).__init__()
self._creator = creator
self._brokers = Brokers.instance().list()
self._invalidTypes = []
self.setupUi()
self.selectBroker.currentIndexChanged.connect(self._brokerChanged)
# self.selectTopicManager.currentIndexChanged.connect(self._topicManagerChanged)
def setupUi(self):
super(tLayerConfig, self).setupUi(self)
self.selectBroker.addItem("Select Broker ...", None)
for broker in self._brokers: # Note: If NOT already Layer in Layers!
self.selectBroker.addItem(broker.name(), broker)
self._brokerChanged(0)
self.buttonCreate.clicked.connect(self.accept)
self.buttonCancel.clicked.connect(self.reject)
self.buttonCreate.setEnabled(False)
for tm in tmFactory.list():
self.selectTopicManager.addItem(tm.name,tm.id)
return
def _brokerChanged(self, idx):
broker = self.selectBroker.itemData(idx)
self.buttonCreate.setEnabled(idx > 0)
self.selectTopicManager.setEnabled(idx > 0)
def getBroker(self):
return self.selectBroker.itemData(self.selectBroker.currentIndex())
def getTopicManager(self):
return tmFactory.load(self.selectTopicManager.itemData(self.selectTopicManager.currentIndex()))
def accept(self):
super(tLayerConfig, self).accept()