fixed reloading

This commit is contained in:
Andreas Preikschat 2011-03-30 12:12:39 +02:00
parent e20fd7d85d
commit 9b939bb962
2 changed files with 9 additions and 8 deletions

View File

@ -90,12 +90,11 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
return QtGui.QDialog.exec_(self)
def refreshActionList(self):
# As refreshing does not work, the check does not work either.
self.assingedShortcuts = []
#self.treeWidget.clear()
self.treeWidget.clear()
for category in actionList.categories:
item = QtGui.QTreeWidgetItem([category.name])
for action in category.actions:
for action, default in category.actions:
self.assingedShortcuts.extend(action.shortcuts())
actionText = REMOVE_AMPERSAND.sub('', unicode(action.text()))
if len(action.shortcuts()) == 2:

View File

@ -27,9 +27,9 @@
The :mod:`~openlp.core.utils.actions` module provides action list classes used
by the shortcuts system.
"""
class ActionCategory(object):
class Category(object):
"""
The :class:`~openlp.core.utils.ActionCategory` class encapsulates a
The :class:`~openlp.core.utils.Category` class encapsulates a
category for the :class:`~openlp.core.utils.CategoryList` class.
"""
def __init__(self, name, weight=0):
@ -67,10 +67,11 @@ class CategoryActionList(object):
Python 3 "next" method.
"""
if self.index >= len(self.actions):
self.index = 0
raise StopIteration
else:
self.index += 1
return self.actions[self.index - 1][1]
return self.actions[self.index - 1][1:]
def next(self):
"""
@ -91,7 +92,7 @@ class CategoryActionList(object):
self.add(name, weight)
def add(self, action, weight=0):
self.actions.append((weight, action))
self.actions.append((weight, action, action.shortcuts()))
self.actions.sort(key=lambda act: act[0])
@ -126,6 +127,7 @@ class CategoryList(object):
Python 3 "next" method for iterator.
"""
if self.index >= len(self.categories):
self.index = 0
raise StopIteration
else:
self.index += 1
@ -153,7 +155,7 @@ class CategoryList(object):
self.add(name, weight)
def add(self, name, weight=0, actions=None):
category = ActionCategory(name, weight)
category = Category(name, weight)
if actions:
for action in actions:
if isinstance(action, tuple):