Add sorting capability to status and importance labels

This commit is contained in:
Veronica Berglyd Olsen
2022-04-16 18:17:01 +02:00
parent fd2248de17
commit 6aa13e318b
3 changed files with 93 additions and 55 deletions
+22
View File
@@ -167,6 +167,28 @@ class NWStatus():
else:
return self._defaultIcon
def reorder(self, order):
"""Reorder the items according to list.
"""
if len(order) != len(self._store):
logger.error("Length mismatch between new and old order")
return False
if order == list(self._store.keys()):
return True
store = {}
for key in order:
if key in self._store:
store[key] = self._store[key]
else:
logger.error("Unknown key '%s' in order", key)
return False
self._store = store
return True
def resetCounts(self):
"""Clear the counts of references to the status entries.
"""