diff --git a/openlp.pyw b/openlp.pyw index ac7b93051..2117a0584 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -28,6 +28,7 @@ import sip sip.setapi(u'QString', 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 dd84d1a8c..c453472eb 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -64,23 +64,6 @@ class ServiceItemAction(object): Next = 3 -class MissingTypeConversion(Exception): - """ - A exception class which is used when a setting is not converted. - """ - def __init__(self, msg): - """ - Constructor - """ - self.msg = msg - - def __str__(self): - """ - Returns a string representation. - """ - return repr(self.msg) - - class Settings(QtCore.QSettings): """ This class customises the ``QSettings`` class. You must use this class @@ -109,25 +92,17 @@ class Settings(QtCore.QSettings): **Note**, this method only converts a few types and might need to be extended if a certain type is missing! """ - setting = super(Settings, self).value(key, defaultValue) + # FIXME + if key == u'recent files': + return [] + setting = super(Settings, self).value(key, defaultValue) # Convert the setting to the correct type. if isinstance(defaultValue, bool): - return setting.toBool() - if isinstance(defaultValue, QtCore.QByteArray): - return setting.toByteArray() + return bool(setting) # Enumerations are also taken care of. if isinstance(defaultValue, int): - return setting.toInt()[0] - if isinstance(defaultValue, basestring): - return setting.toString() - if isinstance(defaultValue, list): - return setting.toStringList() - if isinstance(defaultValue, QtCore.QPoint): - return setting.toPoint() - if isinstance(defaultValue, (datetime.date, QtCore.QDate)): - return setting.toDate() - print u'No!', type(defaultValue) - raise MissingTypeConversion(u'Setting could not be converted') + return int(setting) + return setting def translate(context, text, comment=None, diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 881efb28b..6d6a6cf71 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -622,11 +622,11 @@ class MediaManagerItem(QtGui.QWidget): item = self.listView.currentItem() if item is None: return False - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + item_id = item.data(QtCore.Qt.UserRole) else: item_id = remoteItem else: - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + item_id = item.data(QtCore.Qt.UserRole) return item_id def saveAutoSelectId(self): @@ -637,7 +637,7 @@ class MediaManagerItem(QtGui.QWidget): if self.autoSelectId == -1: item = self.listView.currentItem() if item: - self.autoSelectId = item.data(QtCore.Qt.UserRole).toInt()[0] + self.autoSelectId = item.data(QtCore.Qt.UserRole) def search(self, string, showError=True): """ diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index 22d628dbb..598fe7f72 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -121,7 +121,7 @@ class SearchEdit(QtGui.QLineEdit): """ menu = self.menuButton.menu() for action in menu.actions(): - if identifier == action.data().toInt()[0]: + if identifier == action.data(): # setPlaceholderText has been implemented in Qt 4.7 and in at # least PyQt 4.9 (I am not sure, if it was implemented in # PyQt 4.8). @@ -209,7 +209,7 @@ class SearchEdit(QtGui.QLineEdit): for action in self.menuButton.menu().actions(): action.setChecked(False) self.menuButton.setDefaultAction(sender) - self._currentSearchType = sender.data().toInt()[0] + self._currentSearchType = sender.data() # setPlaceholderText has been implemented in Qt 4.7 and in at least # PyQt 4.9 (I am not sure, if it was implemented in PyQt 4.8). try: diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index e3713d7ae..406d90a59 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -407,9 +407,9 @@ class WebkitPlayer(MediaPlayer): controller = display.controller if controller.media_info.is_flash: currentTime = display.frame.evaluateJavaScript( \ - u'show_flash("currentTime");').toInt()[0] + u'show_flash("currentTime");') length = display.frame.evaluateJavaScript( \ - u'show_flash("length");').toInt()[0] + u'show_flash("length");') else: if display.frame.evaluateJavaScript( \ u'show_video("isEnded");').toString() == 'true': diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index ef8152565..b30cbcfae 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -737,9 +737,9 @@ class ServiceManager(QtGui.QWidget): if item is None: return if item.parent(): - pos = item.parent().data(0, QtCore.Qt.UserRole).toInt()[0] + pos = item.parent().data(0, QtCore.Qt.UserRole) else: - pos = item.data(0, QtCore.Qt.UserRole).toInt()[0] + pos = item.data(0, QtCore.Qt.UserRole) serviceItem = self.serviceItems[pos - 1] self.editAction.setVisible(False) self.maintainAction.setVisible(False) @@ -841,7 +841,7 @@ class ServiceManager(QtGui.QWidget): while serviceIterator.value(): if serviceIterator.value() == selected: if message == u'last slide' and prevItemLastSlide: - pos = prevItem.data(0, QtCore.Qt.UserRole).toInt()[0] + pos = prevItem.data(0, QtCore.Qt.UserRole) check_expanded = self.serviceItems[pos - 1][u'expanded'] self.serviceManagerList.setCurrentItem(prevItemLastSlide) if not check_expanded: @@ -908,7 +908,7 @@ class ServiceManager(QtGui.QWidget): Record if an item is collapsed. Used when repainting the list to get the correct state. """ - pos = item.data(0, QtCore.Qt.UserRole).toInt()[0] + pos = item.data(0, QtCore.Qt.UserRole) self.serviceItems[pos - 1][u'expanded'] = False def onExpandAll(self): @@ -924,7 +924,7 @@ class ServiceManager(QtGui.QWidget): Record if an item is collapsed. Used when repainting the list to get the correct state. """ - pos = item.data(0, QtCore.Qt.UserRole).toInt()[0] + pos = item.data(0, QtCore.Qt.UserRole) self.serviceItems[pos - 1][u'expanded'] = True def onServiceTop(self): @@ -1133,10 +1133,9 @@ class ServiceManager(QtGui.QWidget): serviceIterator += 1 if selectedItem is not None: if selectedItem.parent() is None: - pos = selectedItem.data(0, QtCore.Qt.UserRole).toInt()[0] + pos = selectedItem.data(0, QtCore.Qt.UserRole) else: - pos = selectedItem.parent().data(0, QtCore.Qt.UserRole). \ - toInt()[0] + pos = selectedItem.parent().data(0, QtCore.Qt.UserRole) self.serviceItems[pos - 1][u'selected'] = True tempServiceItems = self.serviceItems self.serviceManagerList.clear() @@ -1321,10 +1320,10 @@ class ServiceManager(QtGui.QWidget): for item in items: parentitem = item.parent() if parentitem is None: - serviceItem = item.data(0, QtCore.Qt.UserRole).toInt()[0] + serviceItem = item.data(0, QtCore.Qt.UserRole) else: - serviceItem = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0] - serviceItemChild = item.data(0, QtCore.Qt.UserRole).toInt()[0] + serviceItem = parentitem.data(0, QtCore.Qt.UserRole) + serviceItemChild = item.data(0, QtCore.Qt.UserRole) # Adjust for zero based arrays. serviceItem -= 1 # Only process the first item on the list for this method. @@ -1441,9 +1440,9 @@ class ServiceManager(QtGui.QWidget): def _getParentItemData(self, item): parentitem = item.parent() if parentitem is None: - return item.data(0, QtCore.Qt.UserRole).toInt()[0] + return item.data(0, QtCore.Qt.UserRole) else: - return parentitem.data(0, QtCore.Qt.UserRole).toInt()[0] + return parentitem.data(0, QtCore.Qt.UserRole) def printServiceOrder(self): """ diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 25e4c1cf5..3eb70a484 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -551,40 +551,34 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): log.debug(u'updateTheme') # main page self.theme.font_main_name = self.mainFontComboBox.currentFont().family() - self.theme.font_main_size = self.field(u'mainSizeSpinBox').toInt()[0] - self.theme.font_main_line_adjustment = \ - self.field(u'lineSpacingSpinBox').toInt()[0] - self.theme.font_main_outline_size = \ - self.field(u'outlineSizeSpinBox').toInt()[0] - self.theme.font_main_shadow_size = \ - self.field(u'shadowSizeSpinBox').toInt()[0] + self.theme.font_main_size = self.field(u'mainSizeSpinBox') + 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() + # FIXME ? self.theme.font_main_italics = \ self.field(u'mainItalicsCheckBox').toBool() # footer page self.theme.font_footer_name = \ self.footerFontComboBox.currentFont().family() - self.theme.font_footer_size = \ - self.field(u'footerSizeSpinBox').toInt()[0] + self.theme.font_footer_size = self.field(u'footerSizeSpinBox') # position page - self.theme.font_main_x = self.field(u'mainPositionX').toInt()[0] - self.theme.font_main_y = self.field(u'mainPositionY').toInt()[0] - self.theme.font_main_height = \ - self.field(u'mainPositionHeight').toInt()[0] - self.theme.font_main_width = self.field(u'mainPositionWidth').toInt()[0] - self.theme.font_footer_x = self.field(u'footerPositionX').toInt()[0] - self.theme.font_footer_y = self.field(u'footerPositionY').toInt()[0] - self.theme.font_footer_height = \ - self.field(u'footerPositionHeight').toInt()[0] - self.theme.font_footer_width = \ - self.field(u'footerPositionWidth').toInt()[0] + self.theme.font_main_x = self.field(u'mainPositionX') + self.theme.font_main_y = self.field(u'mainPositionY') + self.theme.font_main_height = self.field(u'mainPositionHeight') + self.theme.font_main_width = self.field(u'mainPositionWidth') + #print self.field(u'footerPositionX') + self.theme.font_footer_x = self.field(u'footerPositionX') + self.theme.font_footer_y = self.field(u'footerPositionY') + self.theme.font_footer_height = self.field(u'footerPositionHeight') + self.theme.font_footer_width = self.field(u'footerPositionWidth') # position page self.theme.display_horizontal_align = \ self.horizontalComboBox.currentIndex() - self.theme.display_vertical_align = \ - self.verticalComboBox.currentIndex() - self.theme.display_slide_transition = \ - self.field(u'slideTransition').toBool() + self.theme.display_vertical_align = self.verticalComboBox.currentIndex() + # TODO Check + self.theme.display_slide_transition = self.field(u'slideTransition').toBool() def accept(self): """ diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index 8f86be7b1..fed001682 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -93,7 +93,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): """ item = self.alertListWidget.currentItem() if item: - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + item_id = item.data(QtCore.Qt.UserRole) self.manager.delete_object(AlertItem, item_id) row = self.alertListWidget.row(item) self.alertListWidget.takeItem(row) @@ -147,7 +147,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): bitem = self.alertListWidget.item(item.row()) self.triggerAlert(bitem.text()) self.alertTextEdit.setText(bitem.text()) - self.item_id = (bitem.data(QtCore.Qt.UserRole)).toInt()[0] + self.item_id = bitem.data(QtCore.Qt.UserRole) self.saveButton.setEnabled(False) def onSingleClick(self): @@ -158,7 +158,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): item = self.alertListWidget.selectedIndexes()[0] bitem = self.alertListWidget.item(item.row()) self.alertTextEdit.setText(bitem.text()) - self.item_id = (bitem.data(QtCore.Qt.UserRole)).toInt()[0] + self.item_id = bitem.data(QtCore.Qt.UserRole) # If the alert does not contain '<>' we clear the ParameterEdit field. if self.alertTextEdit.text().find(u'<>') == -1: self.parameterEdit.setText(u'') diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 736cde23b..2a028b23b 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -432,13 +432,13 @@ class BibleImportForm(OpenLPWizard): if self.currentPage() == self.welcomePage: return True elif self.currentPage() == self.selectPage: - if self.field(u'source_format').toInt()[0] == BibleFormat.OSIS: + if self.field(u'source_format') == BibleFormat.OSIS: if not self.field(u'osis_location').toString(): critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % WizardStrings.OSIS) self.osisFileEdit.setFocus() return False - elif self.field(u'source_format').toInt()[0] == BibleFormat.CSV: + elif self.field(u'source_format') == BibleFormat.CSV: if not self.field(u'csv_booksfile').toString(): critical_error_message_box(UiStrings().NFSs, translate('BiblesPlugin.ImportWizardForm', @@ -453,19 +453,19 @@ class BibleImportForm(OpenLPWizard): 'verses to import.')) self.csvVersesEdit.setFocus() return False - elif self.field(u'source_format').toInt()[0] == \ + elif self.field(u'source_format') == \ BibleFormat.OpenSong: if not self.field(u'opensong_file').toString(): critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % WizardStrings.OS) self.openSongFileEdit.setFocus() return False - elif self.field(u'source_format').toInt()[0] == \ + elif self.field(u'source_format') == \ BibleFormat.WebDownload: self.versionNameEdit.setText( self.webTranslationComboBox.currentText()) return True - elif self.field(u'source_format').toInt()[0] == BibleFormat.OpenLP1: + elif self.field(u'source_format') == BibleFormat.OpenLP1: if not self.field(u'openlp1_location').toString(): critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % UiStrings().OLPV1) @@ -643,7 +643,7 @@ class BibleImportForm(OpenLPWizard): Prepare the UI for the import. """ OpenLPWizard.preWizard(self) - bible_type = self.field(u'source_format').toInt()[0] + bible_type = self.field(u'source_format') if bible_type == BibleFormat.WebDownload: self.progressLabel.setText(translate( 'BiblesPlugin.ImportWizardForm', @@ -656,7 +656,7 @@ class BibleImportForm(OpenLPWizard): """ Perform the actual import. """ - bible_type = self.field(u'source_format').toInt()[0] + 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() @@ -683,7 +683,7 @@ class BibleImportForm(OpenLPWizard): elif bible_type == BibleFormat.WebDownload: # Import a bible from the web. self.progressBar.setMaximum(1) - download_location = self.field(u'web_location').toInt()[0] + download_location = self.field(u'web_location') bible_version = self.webTranslationComboBox.currentText() bible = self.web_bible_list[download_location][bible_version] importer = self.manager.import_bible( diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 338dd7201..b407a626e 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -160,7 +160,7 @@ class CustomMediaItem(MediaManagerItem): """ if check_item_selected(self.listView, UiStrings().SelectEdit): item = self.listView.currentItem() - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + item_id = item.data(QtCore.Qt.UserRole) self.edit_custom_form.loadCustom(item_id, False) self.edit_custom_form.exec_() self.autoSelectId = -1 @@ -184,7 +184,7 @@ class CustomMediaItem(MediaManagerItem): return row_list = [item.row() for item in self.listView.selectedIndexes()] row_list.sort(reverse=True) - id_list = [(item.data(QtCore.Qt.UserRole)).toInt()[0] + id_list = [(item.data(QtCore.Qt.UserRole)) for item in self.listView.selectedIndexes()] for id in id_list: self.plugin.manager.delete_object(CustomSlide, id) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index cda715d77..fa38ffec7 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -372,7 +372,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): else: return elif item > 0: - item_id = (self.authorsComboBox.itemData(item)).toInt()[0] + item_id = (self.authorsComboBox.itemData(item)) author = self.manager.get_object(Author, item_id) if self.authorsListView.findItems(unicode(author.display_name), QtCore.Qt.MatchExactly): @@ -427,7 +427,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): else: return elif item > 0: - item_id = (self.topicsComboBox.itemData(item)).toInt()[0] + item_id = (self.topicsComboBox.itemData(item)) topic = self.manager.get_object(Topic, item_id) if self.topicsListView.findItems(unicode(topic.name), QtCore.Qt.MatchExactly): @@ -858,12 +858,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.song.authors = [] for row in xrange(self.authorsListView.count()): item = self.authorsListView.item(row) - authorId = (item.data(QtCore.Qt.UserRole)).toInt()[0] + authorId = (item.data(QtCore.Qt.UserRole)) self.song.authors.append(self.manager.get_object(Author, authorId)) self.song.topics = [] for row in xrange(self.topicsListView.count()): item = self.topicsListView.item(row) - topicId = (item.data(QtCore.Qt.UserRole)).toInt()[0] + topicId = (item.data(QtCore.Qt.UserRole)) self.song.topics.append(self.manager.get_object(Topic, topicId)) # Save the song here because we need a valid id for the audio files. clean_song(self.manager, self.song) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 2d8322ff3..7123506dc 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -741,7 +741,7 @@ class SongImportForm(OpenLPWizard): self.finishButton.setVisible(False) self.cancelButton.setVisible(True) last_import_type = Settings().value( - u'songs/last import type').toInt()[0] + u'songs/last import type') if last_import_type < 0 or \ last_import_type >= self.formatComboBox.count(): last_import_type = 0 diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 5df73634c..2f47dcce9 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -98,7 +98,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def _getCurrentItemId(self, listWidget): item = listWidget.currentItem() if item: - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + item_id = (item.data(QtCore.Qt.UserRole)) return item_id else: return -1 diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index c822c1281..65724e796 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -381,7 +381,7 @@ class SongMediaItem(MediaManagerItem): log.debug(u'onEditClick') if check_item_selected(self.listView, UiStrings().SelectEdit): self.editItem = self.listView.currentItem() - item_id = (self.editItem.data(QtCore.Qt.UserRole)).toInt()[0] + item_id = self.editItem.data(QtCore.Qt.UserRole) self.editSongForm.loadSong(item_id, False) self.editSongForm.exec_() self.autoSelectId = -1 @@ -406,7 +406,7 @@ class SongMediaItem(MediaManagerItem): Receiver.send_message(u'cursor_busy') self.plugin.formParent.displayProgressBar(len(items)) for item in items: - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + item_id = item.data(QtCore.Qt.UserRole) media_files = self.plugin.manager.get_all_objects(MediaFile, MediaFile.song_id == item_id) for media_file in media_files: @@ -435,7 +435,7 @@ class SongMediaItem(MediaManagerItem): log.debug(u'onCloneClick') if check_item_selected(self.listView, UiStrings().SelectEdit): self.editItem = self.listView.currentItem() - item_id = (self.editItem.data(QtCore.Qt.UserRole)).toInt()[0] + item_id = self.editItem.data(QtCore.Qt.UserRole) old_song = self.plugin.manager.get_object(Song, item_id) song_xml = self.openLyrics.song_to_xml(old_song) new_song = self.openLyrics.xml_to_song(song_xml)