The category strings, if not unicode, can only be QStrings. Thanks to superfly.

This commit is contained in:
Mattias Põldaru 2011-12-08 14:13:57 +02:00
parent ef3e3252e7
commit 97560f6947
1 changed files with 6 additions and 6 deletions

View File

@ -149,7 +149,7 @@ class CategoryList(object):
return self.__next__()
def has_key(self, key):
if key and not isinstance(key, unicode):
if isinstance(key, QtCore.QString):
key = unicode(key)
for category in self.categories:
if category.name == key:
@ -166,7 +166,7 @@ class CategoryList(object):
self.add(name, weight)
def add(self, name, weight=0, actions=None):
if name and not isinstance(name, unicode):
if name and isinstance(name, QtCore.QString):
name = unicode(name)
category = ActionCategory(name, weight)
if actions:
@ -221,7 +221,7 @@ class ActionList(object):
The weight specifies how important a category is. However, this only
has an impact on the order the categories are displayed.
"""
if category is not None:
if category:
category = unicode(category)
if category not in self.categories:
self.categories.append(category)
@ -230,7 +230,7 @@ class ActionList(object):
self.categories[category].actions.append(action)
else:
self.categories[category].actions.add(action, weight)
if category is None:
if not category:
# Stop here, as this action is not configurable.
return
# Load the shortcut from the config.
@ -254,7 +254,7 @@ class ActionList(object):
The name (unicode string) of the category, which contains the
action. Defaults to None.
"""
if category is not None:
if isinstance(category, QtCore.QString):
category = unicode(category)
if category not in self.categories:
return
@ -274,7 +274,7 @@ class ActionList(object):
``weight``
The category's weight (int).
"""
if name and not isinstance(name, unicode):
if isinstance(name, QtCore.QString):
name = unicode(name)
if name in self.categories:
# Only change the weight and resort the categories again.