diff --git a/grum/dictlist/dictlistwidget.py b/grum/dictlist/dictlistwidget.py index 25da830..f9859f1 100644 --- a/grum/dictlist/dictlistwidget.py +++ b/grum/dictlist/dictlistwidget.py @@ -32,31 +32,9 @@ class DictListWidget(QListWidget): def prependItem(self, itm): self.insertItem(0, itm) - - def get(self, index): - key = self.get_key(index) - value = self.data[key] - return key, value - - def get_value(self, index): - _key, value = self.get(index) - return value - - def get_key(self, index): # this relies on dict being ordered - lst = list(self.data) - lst.reverse() # add prepends the new items - row = index.row() - return lst[row] - - def set_alarm_by_key(self, key, state): itm = self.findItems(key, Qt.MatchExactly)[0] itm.set_alarm(state) - def set_alarm_by_index(self, index, state): - row = index.row() - itm = self.item(row) - itm.set_alarm(state) - diff --git a/grum/mainwin.py b/grum/mainwin.py index b454a61..9610051 100644 --- a/grum/mainwin.py +++ b/grum/mainwin.py @@ -20,7 +20,7 @@ class MainWindow(QMainWindow): self.lst = lst = DictListWidget(exampledata, factory=PlotDescription) lst.setAlternatingRowColors(True) - lst.doubleClicked.connect(self.on_select_list_item) + lst.itemDoubleClicked.connect(self.on_select_list_item) bar = self.menuBar() self.mdi = mdi = MDIArea(bar) @@ -57,9 +57,12 @@ class MainWindow(QMainWindow): self.lst.set_alarm_by_key(name, True) - def on_select_list_item(self, index): - self.lst.set_alarm_by_index(index, False) - name, desc = self.lst.get(index) + def on_select_list_item(self, item): + item.set_alarm(False) + + name = item.text() + desc = self.lst.data[name] + sub = self.mdi.findSubWindow(name) if sub: self.mdi.setActiveSubWindow(sub)