From a085694be152c2d66eb1ee960898b1ccb4ddf493 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 19 May 2012 17:10:05 +0200 Subject: [PATCH] removed toString(), toPyObject() --- openlp.pyw | 6 ++++ openlp/core/lib/__init__.py | 11 +++--- openlp/core/lib/mediamanageritem.py | 4 +-- openlp/core/ui/firsttimeform.py | 16 ++++----- openlp/core/ui/maindisplay.py | 4 +-- openlp/core/ui/mainwindow.py | 5 ++- openlp/core/ui/media/webkitplayer.py | 2 +- openlp/core/ui/shortcutlistform.py | 30 ++++++++-------- openlp/core/ui/themeform.py | 8 ++--- openlp/core/ui/thememanager.py | 20 +++++------ openlp/core/utils/languagemanager.py | 10 +++--- .../plugins/bibles/forms/bibleimportform.py | 36 +++++++++---------- openlp/plugins/bibles/lib/mediaitem.py | 14 +++----- openlp/plugins/images/lib/mediaitem.py | 6 ++-- openlp/plugins/media/lib/mediaitem.py | 4 +-- openlp/plugins/media/mediaplugin.py | 2 +- openlp/plugins/presentations/lib/mediaitem.py | 5 ++- openlp/plugins/remotes/lib/httpserver.py | 2 +- openlp/plugins/remotes/lib/remotetab.py | 15 ++++---- openlp/plugins/songs/forms/editsongform.py | 14 ++++---- openlp/plugins/songs/forms/editverseform.py | 10 +++--- openlp/plugins/songs/forms/mediafilesform.py | 2 +- openlp/plugins/songs/forms/songexportform.py | 5 ++- 23 files changed, 113 insertions(+), 118 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 2117a0584..0b225ded0 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -27,9 +27,15 @@ ############################################################################### import sip +sip.setapi(u'QDate', 2) +sip.setapi(u'QDateTime', 2) sip.setapi(u'QString', 2) +sip.setapi(u'QTextStream', 2) +sip.setapi(u'QTime', 2) +sip.setapi(u'QUrl', 2) sip.setapi(u'QVariant', 2) + from openlp.core import main diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index c453472eb..d723a6b2f 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -92,19 +92,18 @@ class Settings(QtCore.QSettings): **Note**, this method only converts a few types and might need to be extended if a certain type is missing! """ - # FIXME - if key == u'recent files': - return [] setting = super(Settings, self).value(key, defaultValue) + # An empty list saved to the settings results ins a None type being + # returned. + if setting is None: + return [] # Convert the setting to the correct type. if isinstance(defaultValue, bool): - return bool(setting) - # Enumerations are also taken care of. + return setting == u'true' if isinstance(defaultValue, int): return int(setting) return setting - def translate(context, text, comment=None, encoding=QtCore.QCoreApplication.CodecForTr, n=-1, translate=QtCore.QCoreApplication.translate): diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 6d6a6cf71..2f17984be 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -380,7 +380,7 @@ class MediaManagerItem(QtGui.QWidget): for count in range(self.listView.count()): names.append(self.listView.item(count).text()) fullList.append(self.listView.item(count). - data(QtCore.Qt.UserRole).toString()) + data(QtCore.Qt.UserRole)) duplicatesFound = False filesAdded = False for file in files: @@ -420,7 +420,7 @@ class MediaManagerItem(QtGui.QWidget): filelist = [] while count < self.listView.count(): bitem = self.listView.item(count) - filename = bitem.data(QtCore.Qt.UserRole).toString() + filename = bitem.data(QtCore.Qt.UserRole) filelist.append(filename) count += 1 return filelist diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 1e7aa366e..1daf0cd40 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -133,7 +133,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): language = unicode(self.config.get( u'bibles_%s' % lang, u'title'), u'utf8') langItem = QtGui.QTreeWidgetItem( - self.biblesTreeWidget, language) + self.biblesTreeWidget, [language]) bibles = self.config.get(u'bibles_%s' % lang, u'translations') bibles = bibles.split(u',') for bible in bibles: @@ -141,7 +141,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): u'bible_%s' % bible, u'title'), u'utf8') filename = unicode(self.config.get( u'bible_%s' % bible, u'filename')) - item = QtGui.QTreeWidgetItem(langItem, title) + item = QtGui.QTreeWidgetItem(langItem, [title]) item.setData(0, QtCore.Qt.UserRole, filename) item.setCheckState(0, QtCore.Qt.Unchecked) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) @@ -332,7 +332,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): for i in xrange(self.songsListWidget.count()): item = self.songsListWidget.item(i) if item.checkState() == QtCore.Qt.Checked: - filename = item.data(QtCore.Qt.UserRole).toString() + filename = item.data(QtCore.Qt.UserRole) size = self._getFileSize(u'%s%s' % (self.web, filename)) self.max_progress += size # Loop through the Bibles list and increase for each selected item @@ -340,7 +340,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): while iterator.value(): item = iterator.value() if item.parent() and item.checkState(0) == QtCore.Qt.Checked: - filename = item.data(0, QtCore.Qt.UserRole).toString() + filename = item.data(0, QtCore.Qt.UserRole) size = self._getFileSize(u'%s%s' % (self.web, filename)) self.max_progress += size iterator += 1 @@ -348,7 +348,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): for i in xrange(self.themesListWidget.count()): item = self.themesListWidget.item(i) if item.checkState() == QtCore.Qt.Checked: - filename = item.data(QtCore.Qt.UserRole).toString() + filename = item.data(QtCore.Qt.UserRole) size = self._getFileSize(u'%s%s' % (self.web, filename)) self.max_progress += size if self.max_progress: @@ -421,7 +421,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): for i in xrange(self.songsListWidget.count()): item = self.songsListWidget.item(i) if item.checkState() == QtCore.Qt.Checked: - filename = item.data(QtCore.Qt.UserRole).toString() + filename = item.data(QtCore.Qt.UserRole) self._incrementProgressBar(self.downloading % filename, 0) self.previous_size = 0 destination = os.path.join(songs_destination, @@ -433,7 +433,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): while bibles_iterator.value(): item = bibles_iterator.value() if item.parent() and item.checkState(0) == QtCore.Qt.Checked: - bible = item.data(0, QtCore.Qt.UserRole).toString() + bible = item.data(0, QtCore.Qt.UserRole) self._incrementProgressBar(self.downloading % bible, 0) self.previous_size = 0 self.urlGetFile(u'%s%s' % (self.web, bible), @@ -443,7 +443,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): for i in xrange(self.themesListWidget.count()): item = self.themesListWidget.item(i) if item.checkState() == QtCore.Qt.Checked: - theme = item.data(QtCore.Qt.UserRole).toString() + theme = item.data(QtCore.Qt.UserRole) self._incrementProgressBar(self.downloading % theme, 0) self.previous_size = 0 self.urlGetFile(u'%s%s' % (self.web, theme), diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 34d5434ec..1dcffaebe 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -257,7 +257,7 @@ class MainDisplay(Display): height = self.frame.evaluateJavaScript(js) if shrink: if text: - alert_height = int(height.toString()) + alert_height = int(height) self.resize(self.width(), alert_height) self.setVisible(True) if location == AlertLocation.Middle: @@ -335,7 +335,7 @@ class MainDisplay(Display): if self.serviceItem.themedata and \ self.serviceItem.themedata.display_slide_transition: while self.frame.evaluateJavaScript(u'show_text_complete()') \ - .toString() == u'false': + == u'false': Receiver.send_message(u'openlp_process_events') # Wait for the webview to update before getting the preview. # Important otherwise first preview will miss the background ! diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 273041311..0fb410ce1 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -1308,7 +1308,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): settings.remove(u'custom slide') settings.remove(u'service') settings.beginGroup(self.generalSettingsSection) - self.recentFiles = settings.value(u'recent files', list()) + self.recentFiles = settings.value(u'recent files', self.recentFiles) settings.endGroup() settings.beginGroup(self.uiSettingsSection) self.move(settings.value(u'main window position', QtCore.QPoint(0, 0))) @@ -1334,8 +1334,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): log.debug(u'Saving QSettings') settings = Settings() settings.beginGroup(self.generalSettingsSection) - settings.setValue( - u'recent files', self.recentFiles if self.recentFiles else list()) + settings.setValue(u'recent files', self.recentFiles) settings.endGroup() settings.beginGroup(self.uiSettingsSection) settings.setValue(u'main window position', self.pos()) diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index 406d90a59..f01f154e8 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -412,7 +412,7 @@ class WebkitPlayer(MediaPlayer): u'show_flash("length");') else: if display.frame.evaluateJavaScript( \ - u'show_video("isEnded");').toString() == 'true': + u'show_video("isEnded");') == 'true': self.stop(display) (currentTime, ok) = display.frame.evaluateJavaScript( \ u'show_video("currentTime");').toFloat() diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index fe62f3d16..2d998cd9b 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -89,7 +89,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): if key == QtCore.Qt.Key_Shift or key == QtCore.Qt.Key_Control or \ key == QtCore.Qt.Key_Meta or key == QtCore.Qt.Key_Alt: return - key_string = QtGui.QKeySequence(key).toString() + key_string = QtGui.QKeySequence(key) if event.modifiers() & QtCore.Qt.ControlModifier == \ QtCore.Qt.ControlModifier: key_string = u'Ctrl+' + key_string @@ -105,10 +105,10 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): if self._validiate_shortcut(self._currentItemAction(), key_sequence): if self.primaryPushButton.isChecked(): self._adjustButton(self.primaryPushButton, - False, text=key_sequence.toString()) + False, text=key_sequence) elif self.alternatePushButton.isChecked(): self._adjustButton(self.alternatePushButton, - False, text=key_sequence.toString()) + False, text=key_sequence) def exec_(self): self.changedActions = {} @@ -154,11 +154,11 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): item.setText(1, u'') item.setText(2, u'') elif len(shortcuts) == 1: - item.setText(1, shortcuts[0].toString()) + item.setText(1, shortcuts[0]) item.setText(2, u'') else: - item.setText(1, shortcuts[0].toString()) - item.setText(2, shortcuts[1].toString()) + item.setText(1, shortcuts[0]) + item.setText(2, shortcuts[1]) self.onCurrentItemChanged() def onPrimaryPushButtonClicked(self, toggled): @@ -241,9 +241,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.alternatePushButton.setChecked(False) else: if action.defaultShortcuts: - primary_label_text = action.defaultShortcuts[0].toString() + primary_label_text = action.defaultShortcuts[0] if len(action.defaultShortcuts) == 2: - alternate_label_text = action.defaultShortcuts[1].toString() + alternate_label_text = action.defaultShortcuts[1] shortcuts = self._actionShortcuts(action) # We do not want to loose pending changes, that is why we have to # keep the text when, this function has not been triggered by a @@ -252,10 +252,10 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): primary_text = self.primaryPushButton.text() alternate_text = self.alternatePushButton.text() elif len(shortcuts) == 1: - primary_text = shortcuts[0].toString() + primary_text = shortcuts[0] elif len(shortcuts) == 2: - primary_text = shortcuts[0].toString() - alternate_text = shortcuts[1].toString() + primary_text = shortcuts[0] + alternate_text = shortcuts[1] # When we are capturing a new shortcut, we do not want, the buttons to # display the current shortcut. if self.primaryPushButton.isChecked(): @@ -313,9 +313,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): primary_button_text = u'' alternate_button_text = u'' if temp_shortcuts: - primary_button_text = temp_shortcuts[0].toString() + primary_button_text = temp_shortcuts[0] if len(temp_shortcuts) == 2: - alternate_button_text = temp_shortcuts[1].toString() + alternate_button_text = temp_shortcuts[1] self.primaryPushButton.setText(primary_button_text) self.alternatePushButton.setText(alternate_button_text) @@ -443,7 +443,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): 'Duplicate Shortcut'), u'message': translate('OpenLP.ShortcutListDialog', 'The shortcut "%s" is already assigned to another action, ' - 'please use a different shortcut.') % key_sequence.toString() + 'please use a different shortcut.') % key_sequence }) return is_valid @@ -466,7 +466,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): item = self.treeWidget.currentItem() if item is None: return - return item.data(0, QtCore.Qt.UserRole).toPyObject() + return item.data(0, QtCore.Qt.UserRole) def _adjustButton(self, button, checked=None, enabled=None, text=None): """ diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 3eb70a484..017285888 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -555,10 +555,10 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): self.theme.font_main_line_adjustment = self.field(u'lineSpacingSpinBox') self.theme.font_main_outline_size = self.field(u'outlineSizeSpinBox') self.theme.font_main_shadow_size = self.field(u'shadowSizeSpinBox') - self.theme.font_main_bold = self.field(u'mainBoldCheckBox').toBool() + self.theme.font_main_bold = self.field(u'mainBoldCheckBox') # FIXME ? self.theme.font_main_italics = \ - self.field(u'mainItalicsCheckBox').toBool() + self.field(u'mainItalicsCheckBox') # footer page self.theme.font_footer_name = \ self.footerFontComboBox.currentFont().family() @@ -578,14 +578,14 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): self.horizontalComboBox.currentIndex() self.theme.display_vertical_align = self.verticalComboBox.currentIndex() # TODO Check - self.theme.display_slide_transition = self.field(u'slideTransition').toBool() + self.theme.display_slide_transition = self.field(u'slideTransition') def accept(self): """ Lets save the theme as Finish has been triggered """ # Save the theme name - self.theme.theme_name = self.field(u'name').toString() + self.theme.theme_name = self.field(u'name') if not self.theme.theme_name: critical_error_message_box( translate('OpenLP.ThemeForm', 'Theme Name Missing'), diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index b153310d5..8ab15ba2a 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -173,7 +173,7 @@ class ThemeManager(QtGui.QWidget): """ if item is None: return - real_theme_name = item.data(QtCore.Qt.UserRole).toString() + real_theme_name = item.data(QtCore.Qt.UserRole) theme_name = item.text() # If default theme restrict actions if real_theme_name == theme_name: @@ -189,7 +189,7 @@ class ThemeManager(QtGui.QWidget): item = self.themeListWidget.itemAt(point) if item is None: return - real_theme_name = item.data(QtCore.Qt.UserRole).toString() + real_theme_name = item.data(QtCore.Qt.UserRole) theme_name = item.text() self.deleteAction.setVisible(False) self.renameAction.setVisible(False) @@ -211,7 +211,7 @@ class ThemeManager(QtGui.QWidget): # reset the old name item = self.themeListWidget.item(count) old_name = item.text() - new_name = item.data(QtCore.Qt.UserRole).toString() + new_name = item.data(QtCore.Qt.UserRole) if old_name != new_name: self.themeListWidget.item(count).setText(new_name) # Set the new name @@ -233,9 +233,9 @@ class ThemeManager(QtGui.QWidget): item = self.themeListWidget.item(count) old_name = item.text() # reset the old name - if old_name != item.data(QtCore.Qt.UserRole).toString(): + if old_name != item.data(QtCore.Qt.UserRole): self.themeListWidget.item(count).setText( - item.data(QtCore.Qt.UserRole).toString()) + item.data(QtCore.Qt.UserRole)) # Set the new name if count == selected_row: self.global_theme = self.themeListWidget.item(count).text() @@ -267,7 +267,7 @@ class ThemeManager(QtGui.QWidget): translate('OpenLP.ThemeManager', 'Rename %s theme?'), False, False): item = self.themeListWidget.currentItem() - old_theme_name = item.data(QtCore.Qt.UserRole).toString() + old_theme_name = item.data(QtCore.Qt.UserRole) self.fileRenameForm.fileNameEdit.setText(old_theme_name) if self.fileRenameForm.exec_(): new_theme_name = self.fileRenameForm.fileNameEdit.text() @@ -287,7 +287,7 @@ class ThemeManager(QtGui.QWidget): Copies an existing theme to a new name """ item = self.themeListWidget.currentItem() - old_theme_name = item.data(QtCore.Qt.UserRole).toString() + old_theme_name = item.data(QtCore.Qt.UserRole) self.fileRenameForm.fileNameEdit.setText( translate('OpenLP.ThemeManager', 'Copy of %s', 'Copy of ') % old_theme_name) @@ -321,7 +321,7 @@ class ThemeManager(QtGui.QWidget): translate('OpenLP.ThemeManager', 'You must select a theme to edit.')): item = self.themeListWidget.currentItem() - theme = self.getThemeData(item.data(QtCore.Qt.UserRole).toString()) + theme = self.getThemeData(item.data(QtCore.Qt.UserRole)) if theme.background_type == u'image': self.old_background_image = theme.background_filename self.themeForm.theme = theme @@ -371,7 +371,7 @@ class ThemeManager(QtGui.QWidget): critical_error_message_box(message=translate('OpenLP.ThemeManager', 'You have not selected a theme.')) return - theme = item.data(QtCore.Qt.UserRole).toString() + theme = item.data(QtCore.Qt.UserRole) path = QtGui.QFileDialog.getExistingDirectory(self, translate('OpenLP.ThemeManager', 'Save Theme - (%s)') % theme, SettingsManager.get_last_dir(self.settingsSection, 1)) @@ -775,7 +775,7 @@ class ThemeManager(QtGui.QWidget): if answer == QtGui.QMessageBox.No: return False # should be the same unless default - if theme != item.data(QtCore.Qt.UserRole).toString(): + if theme != item.data(QtCore.Qt.UserRole): critical_error_message_box( message=translate('OpenLP.ThemeManager', 'You are unable to delete the default theme.')) diff --git a/openlp/core/utils/languagemanager.py b/openlp/core/utils/languagemanager.py index 21ccffbc1..6de5b2b42 100644 --- a/openlp/core/utils/languagemanager.py +++ b/openlp/core/utils/languagemanager.py @@ -29,6 +29,7 @@ The :mod:`languagemanager` module provides all the translation settings and language file loading for OpenLP. """ import logging +import re import sys from PyQt4 import QtCore, QtGui @@ -104,13 +105,12 @@ class LanguageManager(object): """ Retrieve a saved language to use from settings """ - settings = Settings() - language = settings.value(u'general/language', u'[en]') + language = Settings().value(u'general/language', u'[en]') + language = str(language) log.info(u'Language file: \'%s\' Loaded from conf file' % language) - reg_ex = QtCore.QRegExp("^\[(.*)\]") - if reg_ex.exactMatch(language): + if re.match(r'[[].*[]]', language): LanguageManager.auto_language = True - language = reg_ex.cap(1) + language = re.sub(r'[\[\]]', '', language) return language @staticmethod diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 2a028b23b..5b164a1d0 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -433,20 +433,20 @@ class BibleImportForm(OpenLPWizard): return True elif self.currentPage() == self.selectPage: if self.field(u'source_format') == BibleFormat.OSIS: - if not self.field(u'osis_location').toString(): + if not self.field(u'osis_location'): critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % WizardStrings.OSIS) self.osisFileEdit.setFocus() return False elif self.field(u'source_format') == BibleFormat.CSV: - if not self.field(u'csv_booksfile').toString(): + if not self.field(u'csv_booksfile'): critical_error_message_box(UiStrings().NFSs, translate('BiblesPlugin.ImportWizardForm', 'You need to specify a file with books of ' 'the Bible to use in the import.')) self.csvBooksEdit.setFocus() return False - elif not self.field(u'csv_versefile').toString(): + elif not self.field(u'csv_versefile'): critical_error_message_box(UiStrings().NFSs, translate('BiblesPlugin.ImportWizardForm', 'You need to specify a file of Bible ' @@ -455,7 +455,7 @@ class BibleImportForm(OpenLPWizard): return False elif self.field(u'source_format') == \ BibleFormat.OpenSong: - if not self.field(u'opensong_file').toString(): + if not self.field(u'opensong_file'): critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % WizardStrings.OS) self.openSongFileEdit.setFocus() @@ -466,15 +466,15 @@ class BibleImportForm(OpenLPWizard): self.webTranslationComboBox.currentText()) return True elif self.field(u'source_format') == BibleFormat.OpenLP1: - if not self.field(u'openlp1_location').toString(): + if not self.field(u'openlp1_location'): critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % UiStrings().OLPV1) self.openlp1FileEdit.setFocus() return False return True elif self.currentPage() == self.licenseDetailsPage: - license_version = self.field(u'license_version').toString() - license_copyright = self.field(u'license_copyright').toString() + license_version = self.field(u'license_version') + license_copyright = self.field(u'license_copyright') path = AppLocation.get_section_data_path(u'bibles') if not license_version: critical_error_message_box(UiStrings().EmptyField, @@ -657,28 +657,28 @@ class BibleImportForm(OpenLPWizard): Perform the actual import. """ bible_type = self.field(u'source_format') - license_version = self.field(u'license_version').toString() - license_copyright = self.field(u'license_copyright').toString() - license_permissions = self.field(u'license_permissions').toString() + license_version = self.field(u'license_version') + license_copyright = self.field(u'license_copyright') + license_permissions = self.field(u'license_permissions') importer = None if bible_type == BibleFormat.OSIS: # Import an OSIS bible. importer = self.manager.import_bible(BibleFormat.OSIS, name=license_version, - filename=self.field(u'osis_location').toString() + filename=self.field(u'osis_location') ) elif bible_type == BibleFormat.CSV: # Import a CSV bible. importer = self.manager.import_bible(BibleFormat.CSV, name=license_version, - booksfile=self.field(u'csv_booksfile').toString(), - versefile=self.field(u'csv_versefile').toString() + booksfile=self.field(u'csv_booksfile'), + versefile=self.field(u'csv_versefile') ) elif bible_type == BibleFormat.OpenSong: # Import an OpenSong bible. importer = self.manager.import_bible(BibleFormat.OpenSong, name=license_version, - filename=self.field(u'opensong_file').toString() + filename=self.field(u'opensong_file') ) elif bible_type == BibleFormat.WebDownload: # Import a bible from the web. @@ -690,15 +690,15 @@ class BibleImportForm(OpenLPWizard): BibleFormat.WebDownload, name=license_version, download_source=WebDownload.Names[download_location], download_name=bible, - proxy_server=self.field(u'proxy_server').toString(), - proxy_username=self.field(u'proxy_username').toString(), - proxy_password=self.field(u'proxy_password').toString() + proxy_server=self.field(u'proxy_server'), + proxy_username=self.field(u'proxy_username'), + proxy_password=self.field(u'proxy_password') ) elif bible_type == BibleFormat.OpenLP1: # Import an openlp.org 1.x bible. importer = self.manager.import_bible(BibleFormat.OpenLP1, name=license_version, - filename=self.field(u'openlp1_location').toString() + filename=self.field(u'openlp1_location') ) if importer.do_import(license_version): self.manager.save_meta_data(license_version, license_version, diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 174ec2e22..1dd688759 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -99,11 +99,7 @@ class BibleMediaItem(MediaManagerItem): def _decodeQtObject(self, bitem, key): reference = bitem.data(QtCore.Qt.UserRole) - if isinstance(reference, QtCore.QVariant): - reference = reference.toPyObject() obj = reference[unicode(key)] - if isinstance(obj, QtCore.QVariant): - obj = obj.toPyObject() return unicode(obj).strip() def requiredIcons(self): @@ -624,7 +620,7 @@ class BibleMediaItem(MediaManagerItem): self.initialiseChapterVerse( self.advancedVersionComboBox.currentText(), self.advancedBookComboBox.currentText(), - self.advancedBookComboBox.itemData(item).toString()) + self.advancedBookComboBox.itemData(item)) def onAdvancedFromVerse(self): chapter_from = int(self.advancedFromChapter.currentText()) @@ -632,7 +628,7 @@ class BibleMediaItem(MediaManagerItem): if chapter_from == chapter_to: bible = self.advancedVersionComboBox.currentText() book_ref_id = self.advancedBookComboBox.itemData( - int(self.advancedBookComboBox.currentIndex())).toString() + int(self.advancedBookComboBox.currentIndex())) verse_from = int(self.advancedFromVerse.currentText()) verse_count = self.plugin.manager.get_verse_count_by_book_ref_id( bible, book_ref_id, chapter_to) @@ -642,7 +638,7 @@ class BibleMediaItem(MediaManagerItem): def onAdvancedToChapter(self): bible = self.advancedVersionComboBox.currentText() book_ref_id = self.advancedBookComboBox.itemData( - int(self.advancedBookComboBox.currentIndex())).toString() + int(self.advancedBookComboBox.currentIndex())) chapter_from = int(self.advancedFromChapter.currentText()) chapter_to = int(self.advancedToChapter.currentText()) verse_from = int(self.advancedFromVerse.currentText()) @@ -657,7 +653,7 @@ class BibleMediaItem(MediaManagerItem): def onAdvancedFromChapter(self): bible = self.advancedVersionComboBox.currentText() book_ref_id = self.advancedBookComboBox.itemData( - int(self.advancedBookComboBox.currentIndex())).toString() + int(self.advancedBookComboBox.currentIndex())) chapter_from = int(self.advancedFromChapter.currentText()) chapter_to = int(self.advancedToChapter.currentText()) verse_count = self.plugin.manager.get_verse_count_by_book_ref_id(bible, @@ -711,7 +707,7 @@ class BibleMediaItem(MediaManagerItem): second_bible = self.advancedSecondComboBox.currentText() book = self.advancedBookComboBox.currentText() book_ref_id = self.advancedBookComboBox.itemData( - int(self.advancedBookComboBox.currentIndex())).toString() + int(self.advancedBookComboBox.currentIndex())) chapter_from = self.advancedFromChapter.currentText() chapter_to = self.advancedToChapter.currentText() verse_from = self.advancedFromVerse.currentText() diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index b318ed55d..d1f5015af 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -168,7 +168,7 @@ class ImageMediaItem(MediaManagerItem): missing_items = [] missing_items_filenames = [] for bitem in items: - filename = bitem.data(QtCore.Qt.UserRole).toString() + filename = bitem.data(QtCore.Qt.UserRole) if not os.path.exists(filename): missing_items.append(bitem) missing_items_filenames.append(filename) @@ -194,7 +194,7 @@ class ImageMediaItem(MediaManagerItem): return False # Continue with the existing images. for bitem in items: - filename = bitem.data(QtCore.Qt.UserRole).toString() + filename = bitem.data(QtCore.Qt.UserRole) name = os.path.split(filename)[1] service_item.add_from_image(filename, name, background) return True @@ -223,7 +223,7 @@ class ImageMediaItem(MediaManagerItem): self.settingsSection + u'/background color', u'#000000')) item = self.listView.selectedIndexes()[0] bitem = self.listView.item(item.row()) - filename = bitem.data(QtCore.Qt.UserRole).toString() + filename = bitem.data(QtCore.Qt.UserRole) if os.path.exists(filename): name = os.path.split(filename)[1] if self.plugin.liveController.display.directImage(name, diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 15cd5e6aa..535f9ebf2 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -170,7 +170,7 @@ class MediaMediaItem(MediaManagerItem): translate('MediaPlugin.MediaItem', 'You must select a media file to replace the background with.')): item = self.listView.currentItem() - filename = item.data(QtCore.Qt.UserRole).toString() + filename = item.data(QtCore.Qt.UserRole) if os.path.exists(filename): if self.plugin.liveController.mediaController.video( \ self.plugin.liveController, filename, True, True): @@ -191,7 +191,7 @@ class MediaMediaItem(MediaManagerItem): item = self.listView.currentItem() if item is None: return False - filename = item.data(QtCore.Qt.UserRole).toString() + filename = item.data(QtCore.Qt.UserRole) if not os.path.exists(filename): if not remote: # File is no longer present diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index 954ab8d00..07d72df66 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -133,7 +133,7 @@ class MediaPlugin(Plugin): log.info(u'Found old Phonon setting') players = self.mediaController.mediaPlayers.keys() has_phonon = u'phonon' in players - if settings.value(u'use phonon').toBool() and has_phonon: + if settings.value(u'use phonon') and has_phonon: log.debug(u'Converting old setting to new setting') new_players = [] if players: diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 1bfb4f123..966d89fc4 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -231,8 +231,7 @@ class PresentationMediaItem(MediaManagerItem): Receiver.send_message(u'cursor_busy') self.plugin.formParent.displayProgressBar(len(row_list)) for item in items: - filepath = unicode(item.data( - QtCore.Qt.UserRole).toString()) + filepath = unicode(item.data(QtCore.Qt.UserRole)) for cidx in self.controllers: doc = self.controllers[cidx].add_document(filepath) doc.presentation_deleted() @@ -266,7 +265,7 @@ class PresentationMediaItem(MediaManagerItem): if not shortname: return False for bitem in items: - filename = bitem.data(QtCore.Qt.UserRole).toString() + filename = bitem.data(QtCore.Qt.UserRole) if os.path.exists(filename): if shortname == self.Automatic: service_item.shortname = self.findControllerByType(filename) diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index ecd1b6b0d..56ba1fe9f 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -233,7 +233,7 @@ class HttpConnection(object): Initialise the http connection. Listen out for socket signals. """ log.debug(u'Initialise HttpConnection: %s' % - socket.peerAddress().toString()) + socket.peerAddress()) self.socket = socket self.parent = parent self.routes = [ diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index be08bb500..9c1de5cc6 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -138,7 +138,7 @@ class RemoteTab(SettingsTab): ip = addr.ip() if ip.protocol() == 0 and \ ip != QtNetwork.QHostAddress.LocalHost: - ipAddress = ip.toString() + ipAddress = ip break else: ipAddress = self.addressEdit.text() @@ -149,11 +149,9 @@ class RemoteTab(SettingsTab): def load(self): self.portSpinBox.setValue( - Settings().value(self.settingsSection + u'/port', - 4316)) + Settings().value(self.settingsSection + u'/port', 4316)) self.addressEdit.setText( - Settings().value(self.settingsSection + u'/ip address', - ZERO_URL)) + Settings().value(self.settingsSection + u'/ip address', ZERO_URL)) self.twelveHour = Settings().value( self.settingsSection + u'/twelve hour', True) self.twelveHourCheckBox.setChecked(self.twelveHour) @@ -161,10 +159,9 @@ class RemoteTab(SettingsTab): def save(self): changed = False - if Settings().value(self.settingsSection + u'/ip address', - ZERO_URL != self.addressEdit.text() or - Settings().value(self.settingsSection + u'/port', - 4316) != self.portSpinBox.value()): + if Settings().value(self.settingsSection + u'/ip address', ZERO_URL != + self.addressEdit.text() or Settings().value(self.settingsSection + + u'/port', 4316) != self.portSpinBox.value()): changed = True Settings().setValue(self.settingsSection + u'/port', self.portSpinBox.value()) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index fa38ffec7..617cce5f4 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -336,7 +336,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): row_label = [] for row in range(self.verseListWidget.rowCount()): item = self.verseListWidget.item(row, 0) - verse_def = item.data(QtCore.Qt.UserRole).toString() + verse_def = item.data(QtCore.Qt.UserRole) verse_tag = VerseType.translated_tag(verse_def[0]) row_def = u'%s%s' % (verse_tag, verse_def[1:]) row_label.append(row_def) @@ -479,7 +479,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): item = self.verseListWidget.currentItem() if item: tempText = item.text() - verseId = item.data(QtCore.Qt.UserRole).toString() + verseId = item.data(QtCore.Qt.UserRole) self.verseForm.setVerse(tempText, True, verseId) if self.verseForm.exec_(): after_text, verse_tag, verse_num = self.verseForm.getVerse() @@ -509,7 +509,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): if self.verseListWidget.rowCount() > 0: for row in range(self.verseListWidget.rowCount()): item = self.verseListWidget.item(row, 0) - field = item.data(QtCore.Qt.UserRole).toString() + field = item.data(QtCore.Qt.UserRole) verse_tag = VerseType.translated_name(field[0]) verse_num = field[1:] verse_list += u'---[%s:%s]---\n' % (verse_tag, verse_num) @@ -576,7 +576,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): order = self.__extractVerseOrder(text) for index in range(self.verseListWidget.rowCount()): verse = self.verseListWidget.item(index, 0) - verse = verse.data(QtCore.Qt.UserRole).toString() + verse = verse.data(QtCore.Qt.UserRole) if verse not in verse_names: verses.append(verse) verse_names.append(u'%s%s' % ( @@ -617,7 +617,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): order = self.__extractVerseOrder(verse_order) for index in range(verse_count): verse = self.verseListWidget.item(index, 0) - verse = verse.data(QtCore.Qt.UserRole).toString() + verse = verse.data(QtCore.Qt.UserRole) if verse not in verse_names: verses.append(verse) verse_names.append(u'%s%s' % ( @@ -879,7 +879,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): files = [] for row in xrange(self.audioListWidget.count()): item = self.audioListWidget.item(row) - filename = item.data(QtCore.Qt.UserRole).toString() + filename = item.data(QtCore.Qt.UserRole) if not filename.startswith(save_path): oldfile, filename = filename, os.path.join(save_path, os.path.split(filename)[1]) @@ -916,7 +916,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): multiple = [] for i in range(self.verseListWidget.rowCount()): item = self.verseListWidget.item(i, 0) - verseId = item.data(QtCore.Qt.UserRole).toString() + verseId = item.data(QtCore.Qt.UserRole) verse_tag = verseId[0] verse_num = verseId[1:] sxml.add_verse_to_lyrics(verse_tag, verse_num, item.text()) diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index 172f7ad49..8ec50857b 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -180,19 +180,19 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): def getVerseAll(self): text = self.verseTextEdit.toPlainText() - if not text.startsWith(u'---['): + if not text.startswith(u'---['): text = u'---[%s:1]---\n%s' % \ (VerseType.TranslatedNames[VerseType.Verse], text) return text def accept(self): if self.hasSingleVerse: - value = unicode(self.getVerse()[0]) + value = self.getVerse()[0] else: - log.debug(unicode(self.getVerse()[0]).split(u'\n')) - value = unicode(self.getVerse()[0]).split(u'\n')[1] + log.debug(self.getVerse()[0].split(u'\n')) + value = self.getVerse()[0].split(u'\n')[1] if not value: - lines = unicode(self.getVerse()[0]).split(u'\n') + lines = self.getVerse()[0].split(u'\n') index = 2 while index < len(lines) and not value: value = lines[index] diff --git a/openlp/plugins/songs/forms/mediafilesform.py b/openlp/plugins/songs/forms/mediafilesform.py index 49fcc0137..5eb7f66ef 100644 --- a/openlp/plugins/songs/forms/mediafilesform.py +++ b/openlp/plugins/songs/forms/mediafilesform.py @@ -52,6 +52,6 @@ class MediaFilesForm(QtGui.QDialog, Ui_MediaFilesDialog): self.fileListWidget.addItem(item) def getSelectedFiles(self): - return map(lambda item: item.data(QtCore.Qt.UserRole).toString(), + return map(lambda item: item.data(QtCore.Qt.UserRole), self.fileListWidget.selectedItems()) diff --git a/openlp/plugins/songs/forms/songexportform.py b/openlp/plugins/songs/forms/songexportform.py index f75c34eb5..ff74ba33c 100644 --- a/openlp/plugins/songs/forms/songexportform.py +++ b/openlp/plugins/songs/forms/songexportform.py @@ -218,8 +218,7 @@ class SongExportForm(OpenLPWizard): # Add the songs to the list of selected songs. for item in items: song = QtGui.QListWidgetItem(item.text()) - song.setData(QtCore.Qt.UserRole, - item.data(QtCore.Qt.UserRole).toPyObject()) + song.setData(QtCore.Qt.UserRole, item.data(QtCore.Qt.UserRole)) song.setFlags(QtCore.Qt.ItemIsEnabled) self.selectedListWidget.addItem(song) return True @@ -282,7 +281,7 @@ class SongExportForm(OpenLPWizard): and calls the *do_export* method. """ songs = [ - song.data(QtCore.Qt.UserRole).toPyObject() + song.data(QtCore.Qt.UserRole) for song in self._findListWidgetItems(self.selectedListWidget) ] exporter = OpenLyricsExport(self, songs, self.directoryLineEdit.text())