From cbd22b71415b5a0d21a3f63e9255c23f40cf65b1 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 27 Dec 2012 17:46:27 +0100 Subject: [PATCH] fixed bug caused by merge --- openlp/core/lib/__init__.py | 3 +++ openlp/core/ui/mainwindow.py | 5 +++-- openlp/plugins/songs/lib/__init__.py | 13 +++++++------ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 4a3cf7d54..023c460e1 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -136,6 +136,9 @@ class Settings(QtCore.QSettings): **Note**, this method only converts a few types and might need to be extended if a certain type is missing! """ + # Check for none as u'' is passed as default and is valid! + if defaultValue is None and not super(Settings, self).contains(key): + return None setting = super(Settings, self).value(key, defaultValue) # An empty list saved to the settings results in a None type being # returned. diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 42b4740a2..f02a64229 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -1075,8 +1075,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): export_settings.endGroup() # Write all the sections and keys. for section_key in keys: - key_value = settings.value(section_key) - export_settings.setValue(section_key, key_value) + key_value = settings.value(section_key, None) + if key_value is not None: + export_settings.setValue(section_key, key_value) export_settings.sync() # Temp CONF file has been written. Blanks in keys are now '%20'. # Read the temp file and output the user's CONF file with blanks to diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 0d4b523ae..1dc2c528b 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -41,7 +41,7 @@ PATTERN = re.compile(r"\\([a-z]{1,32})(-?\d{1,10})?[ ]?|\\'" r"([0-9a-f]{2})|\\([^a-z])|([{}])|[\r\n]+|(.)", re.I) # RTF control words which specify a "destination" to be ignored. DESTINATIONS = frozenset(( - u'aftncn', u'aftnsep', u'aftnsepc', u'annotation', u'atnauthor', + u'aftncn', u'aftnsep', u'aftnsepc', u'annotation', u'atnauthor', u'atndate', u'atnicn', u'atnid', u'atnparent', u'atnref', u'atntime', u'atrfend', u'atrfstart', u'author', u'background', u'bkmkend', u'bkmkstart', u'blipuid', u'buptim', u'category', @@ -579,7 +579,7 @@ def strip_rtf(text, default_encoding=None): failed = False while True: try: - encoding, default_encoding = get_encoding(font, + encoding, default_encoding = get_encoding(font, font_table, default_encoding, failed=failed) out.append(chr(charcode).decode(encoding)) except UnicodeDecodeError: @@ -594,6 +594,7 @@ def strip_rtf(text, default_encoding=None): text = u''.join(out) return text, default_encoding + def natcmp(a, b): """ Natural string comparison which mimics the behaviour of Python's internal @@ -604,9 +605,9 @@ def natcmp(a, b): if isinstance(key, int) and isinstance(b[i], int): result = cmp(key, b[i]) elif isinstance(key, int) and not isinstance(b[i], int): - result = locale_direct_compare(QtCore.QString(str(key)), b[i]) + result = locale_direct_compare(str(key), b[i]) elif not isinstance(key, int) and isinstance(b[i], int): - result = locale_direct_compare(key, QtCore.QString(str(b[i]))) + result = locale_direct_compare(key, str(b[i])) else: result = locale_direct_compare(key, b[i]) if result != 0: @@ -620,9 +621,9 @@ def natcmp(a, b): if isinstance(a[i], int) and isinstance(key, int): result = cmp(a[i], key) elif isinstance(a[i], int) and not isinstance(key, int): - result = locale_direct_compare(QtCore.QString(str(a[i])), key) + result = locale_direct_compare(str(a[i]), key) elif not isinstance(a[i], int) and isinstance(key, int): - result = locale_direct_compare(a[i], QtCore.QString(str(key))) + result = locale_direct_compare(a[i], str(key)) else: result = locale_direct_compare(a[i], key) if result != 0: