Code Duplication    Length = 17-22 lines in 2 locations

uaclient/mainwindow.py 2 locations

@@ 124-145 (lines=22) @@
121
122
class DataChangeUI(object):
123
124
    def __init__(self, window, uaclient):
125
        self.window = window
126
        self.uaclient = uaclient
127
        self._subhandler = DataChangeHandler()
128
        self._subscribed_nodes = []
129
        self.model = QStandardItemModel()
130
        self.window.ui.subView.setModel(self.model)
131
        self.window.ui.subView.horizontalHeader().setSectionResizeMode(1)
132
133
        self.window.ui.actionSubscribeDataChange.triggered.connect(self._subscribe)
134
        self.window.ui.actionUnsubscribeDataChange.triggered.connect(self._unsubscribe)
135
136
        # populate contextual menu
137
        self.window.addAction(self.window.ui.actionSubscribeDataChange)
138
        self.window.addAction(self.window.ui.actionUnsubscribeDataChange)
139
140
        # handle subscriptions
141
        self._subhandler.data_change_fired.connect(self._update_subscription_model, type=Qt.QueuedConnection)
142
        
143
        # accept drops
144
        self.model.canDropMimeData = self.canDropMimeData
145
        self.model.dropMimeData = self.dropMimeData
146
147
    def canDropMimeData(self, mdata, action, row, column, parent):
148
        return True
@@ 56-72 (lines=17) @@
53
54
class EventUI(object):
55
56
    def __init__(self, window, uaclient):
57
        self.window = window
58
        self.uaclient = uaclient
59
        self._handler = EventHandler()
60
        self._subscribed_nodes = []  # FIXME: not really needed
61
        self.model = QStandardItemModel()
62
        self.window.ui.evView.setModel(self.model)
63
        self.window.ui.actionSubscribeEvent.triggered.connect(self._subscribe)
64
        self.window.ui.actionUnsubscribeEvents.triggered.connect(self._unsubscribe)
65
        # context menu
66
        self.window.addAction(self.window.ui.actionSubscribeEvent)
67
        self.window.addAction(self.window.ui.actionUnsubscribeEvents)
68
        self._handler.event_fired.connect(self._update_event_model, type=Qt.QueuedConnection)
69
70
        # accept drops
71
        self.model.canDropMimeData = self.canDropMimeData
72
        self.model.dropMimeData = self.dropMimeData
73
74
    def canDropMimeData(self, mdata, action, row, column, parent):
75
        return True