reverse the list
This commit is contained in:
@ -15,9 +15,12 @@ class DictList(QListWidget):
|
||||
def add(self, key, value):
|
||||
if key not in self.data:
|
||||
itm = QListWidgetItem(key)
|
||||
self.addItem(itm)
|
||||
self.prependItem(itm)
|
||||
self.data[key] = value
|
||||
|
||||
def prependItem(self, itm):
|
||||
self.insertItem(0, itm)
|
||||
|
||||
def get(self, index):
|
||||
key = self.get_key(index)
|
||||
value = self.data[key]
|
||||
@ -29,6 +32,7 @@ class DictList(QListWidget):
|
||||
|
||||
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]
|
||||
|
||||
|
Reference in New Issue
Block a user