openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #13193
[Merge] lp:~mahfiaz/openlp/unicode_warning_fix into lp:openlp
mahfiaz has proposed merging lp:~mahfiaz/openlp/unicode_warning_fix into lp:openlp.
Requested reviews:
Tim Bentley (trb143)
Raoul Snyman (raoul-snyman)
For more details, see:
https://code.launchpad.net/~mahfiaz/openlp/unicode_warning_fix/+merge/84934
Ensure that action category names are unicode, to prevent warnings on comparison.
--
https://code.launchpad.net/~mahfiaz/openlp/unicode_warning_fix/+merge/84934
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/utils/actions.py'
--- openlp/core/utils/actions.py 2011-12-06 19:25:12 +0000
+++ openlp/core/utils/actions.py 2011-12-08 12:17:53 +0000
@@ -149,6 +149,8 @@
return self.__next__()
def has_key(self, key):
+ if isinstance(key, QtCore.QString):
+ key = unicode(key)
for category in self.categories:
if category.name == key:
return True
@@ -164,6 +166,8 @@
self.add(name, weight)
def add(self, name, weight=0, actions=None):
+ if name and isinstance(name, QtCore.QString):
+ name = unicode(name)
category = ActionCategory(name, weight)
if actions:
for action in actions:
@@ -217,7 +221,7 @@
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)
@@ -226,7 +230,7 @@
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.
@@ -250,7 +254,7 @@
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
@@ -270,6 +274,8 @@
``weight``
The category's weight (int).
"""
+ if isinstance(name, QtCore.QString):
+ name = unicode(name)
if name in self.categories:
# Only change the weight and resort the categories again.
for category in self.categories:
Follow ups