@@ 107-128 (lines=22) @@ | ||
104 | def _unsubscribe(self): |
|
105 | node = self.window.get_current_node() |
|
106 | if node is None: |
|
107 | return |
|
108 | self._subscribed_nodes.remove(node) |
|
109 | self.uaclient.unsubscribe_events(node) |
|
110 | ||
111 | @trycatchslot |
|
112 | def _update_event_model(self, event): |
|
113 | self.model.appendRow([QStandardItem(str(event))]) |
|
114 | ||
115 | ||
116 | class DataChangeUI(object): |
|
117 | ||
118 | def __init__(self, window, uaclient): |
|
119 | self.window = window |
|
120 | self.uaclient = uaclient |
|
121 | self._subhandler = DataChangeHandler() |
|
122 | self._subscribed_nodes = [] |
|
123 | self.model = QStandardItemModel() |
|
124 | self.window.ui.subView.setModel(self.model) |
|
125 | self.window.ui.subView.horizontalHeader().setSectionResizeMode(1) |
|
126 | ||
127 | self.window.ui.actionSubscribeDataChange.triggered.connect(self._subscribe) |
|
128 | self.window.ui.actionUnsubscribeDataChange.triggered.connect(self._unsubscribe) |
|
129 | ||
130 | # populate contextual menu |
|
131 | self.window.ui.treeView.addAction(self.window.ui.actionSubscribeDataChange) |
|
@@ 43-59 (lines=17) @@ | ||
40 | ||
41 | class EventHandler(QObject): |
|
42 | event_fired = pyqtSignal(object) |
|
43 | ||
44 | def event_notification(self, event): |
|
45 | self.event_fired.emit(event) |
|
46 | ||
47 | ||
48 | class EventUI(object): |
|
49 | ||
50 | def __init__(self, window, uaclient): |
|
51 | self.window = window |
|
52 | self.uaclient = uaclient |
|
53 | self._handler = EventHandler() |
|
54 | self._subscribed_nodes = [] # FIXME: not really needed |
|
55 | self.model = QStandardItemModel() |
|
56 | self.window.ui.evView.setModel(self.model) |
|
57 | self.window.ui.actionSubscribeEvent.triggered.connect(self._subscribe) |
|
58 | self.window.ui.actionUnsubscribeEvents.triggered.connect(self._unsubscribe) |
|
59 | # context menu |
|
60 | self.window.ui.treeView.addAction(self.window.ui.actionSubscribeEvent) |
|
61 | self.window.ui.treeView.addAction(self.window.ui.actionUnsubscribeEvents) |
|
62 | self._handler.event_fired.connect(self._update_event_model, type=Qt.QueuedConnection) |