From b5ceb59e27a35777309ecb4c94de19bfb778e278 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 23 Jul 2010 01:01:06 +0100 Subject: [PATCH] Cleanup getters and setters --- openlp/core/lib/settingsmanager.py | 29 --------- openlp/core/ui/mainwindow.py | 22 +++---- openlp/core/utils/languagemanager.py | 1 - openlp/plugins/bibles/lib/common.py | 19 ------ openlp/plugins/bibles/lib/http.py | 20 +------ openlp/plugins/bibles/lib/manager.py | 2 +- openlp/plugins/songs/lib/songxml.py | 89 +--------------------------- 7 files changed, 18 insertions(+), 164 deletions(-) diff --git a/openlp/core/lib/settingsmanager.py b/openlp/core/lib/settingsmanager.py index a8c8e7c50..d4569a647 100644 --- a/openlp/core/lib/settingsmanager.py +++ b/openlp/core/lib/settingsmanager.py @@ -57,34 +57,6 @@ class SettingsManager(object): self.mainwindow_left + self.mainwindow_right) - 100 ) / 2 self.slidecontroller_image = self.slidecontroller - 50 - def get_preview_visibility(self): - """ - Return the preview panel's visibility. - """ - return QtCore.QSettings().value(u'user interface/preview panel', - QtCore.QVariant(True)).toBool() - - def set_preview_visibility(self, visible): - """ - Set the preview panel's visibility. - """ - QtCore.QSettings().setValue(u'user interface/preview panel', - QtCore.QVariant(visible)) - - def get_live_visibility(self): - """ - Return the live panel's visibility. - """ - return QtCore.QSettings().value(u'user interface/live panel', - QtCore.QVariant(True)).toBool() - - def set_live_visibility(self, visible): - """ - Set the live panel's visibility. - """ - QtCore.QSettings().setValue(u'user interface/live panel', - QtCore.QVariant(visible)) - @staticmethod def get_last_dir(section, num=None): """ @@ -206,4 +178,3 @@ class SettingsManager(object): else: # no filtering required return files - diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index ec34a483b..c7082ddf9 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -303,18 +303,18 @@ class Ui_MainWindow(object): self.ToolsAddToolItem.setObjectName(u'ToolsAddToolItem') self.ViewPreviewPanel = QtGui.QAction(MainWindow) self.ViewPreviewPanel.setCheckable(True) - self.ViewPreviewPanel.setChecked( - self.settingsmanager.get_preview_visibility()) + previewVisible = QtCore.QSettings().value( + u'user interface/preview panel', QtCore.QVariant(True)).toBool() + self.ViewPreviewPanel.setChecked(previewVisible) self.ViewPreviewPanel.setObjectName(u'ViewPreviewPanel') - self.PreviewController.Panel.setVisible( - self.settingsmanager.get_preview_visibility()) + self.PreviewController.Panel.setVisible(previewVisible) self.ViewLivePanel = QtGui.QAction(MainWindow) self.ViewLivePanel.setCheckable(True) - self.ViewLivePanel.setChecked( - self.settingsmanager.get_live_visibility()) + liveVisible = QtCore.QSettings().value(u'user interface/live panel', + QtCore.QVariant(True)).toBool() + self.ViewLivePanel.setChecked(liveVisible) self.ViewLivePanel.setObjectName(u'ViewLivePanel') - self.LiveController.Panel.setVisible( - self.settingsmanager.get_live_visibility()) + self.LiveController.Panel.setVisible(liveVisible) self.ModeDefaultItem = QtGui.QAction(MainWindow) self.ModeDefaultItem.setCheckable(True) self.ModeDefaultItem.setObjectName(u'ModeDefaultItem') @@ -890,7 +890,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): False - Hidden """ self.PreviewController.Panel.setVisible(visible) - self.settingsmanager.set_preview_visibility(visible) + QtCore.QSettings().setValue(u'user interface/preview panel', + QtCore.QVariant(visible)) self.ViewPreviewPanel.setChecked(visible) def setLivePanelVisibility(self, visible): @@ -904,7 +905,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): False - Hidden """ self.LiveController.Panel.setVisible(visible) - self.settingsmanager.set_live_visibility(visible) + QtCore.QSettings().setValue(u'user interface/live panel', + QtCore.QVariant(visible)) self.ViewLivePanel.setChecked(visible) def loadSettings(self): diff --git a/openlp/core/utils/languagemanager.py b/openlp/core/utils/languagemanager.py index c0315559f..9cb87e891 100644 --- a/openlp/core/utils/languagemanager.py +++ b/openlp/core/utils/languagemanager.py @@ -143,4 +143,3 @@ class LanguageManager(object): if LanguageManager.__qmList__ is None: LanguageManager.init_qm_list() return LanguageManager.__qmList__ - diff --git a/openlp/plugins/bibles/lib/common.py b/openlp/plugins/bibles/lib/common.py index 30777b3a2..a4cd2a42a 100644 --- a/openlp/plugins/bibles/lib/common.py +++ b/openlp/plugins/bibles/lib/common.py @@ -138,24 +138,6 @@ class SearchResults(object): self.chapter = chapter self.verselist = verselist - def get_verselist(self): - """ - Returns the list of verses. - """ - return self.verselist - - def get_book(self): - """ - Returns the book of the Bible. - """ - return self.book - - def get_chapter(self): - """ - Returns the chapter of the book. - """ - return self.chapter - def has_verselist(self): """ Returns whether or not the verse list contains verses. @@ -277,4 +259,3 @@ def unescape(text): pass return text # leave as is return re.sub(u'&#?\w+;', fixup, text) - diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 8bf7ac63e..dc3e8f906 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -178,7 +178,6 @@ class BGExtract(BibleCommon): """ Extract verses from BibleGateway """ - def __init__(self, proxyurl=None): log.debug(u'init %s', proxyurl) self.proxyurl = proxyurl @@ -269,7 +268,6 @@ class CWExtract(BibleCommon): """ Extract verses from CrossWalk/BibleStudyTools """ - def __init__(self, proxyurl=None): log.debug(u'init %s', proxyurl) self.proxyurl = proxyurl @@ -429,13 +427,12 @@ class HTTPBible(BibleDB): ## if it was there. By reusing the returned book name ## we get a correct book. For example it is possible ## to request ac and get Acts back. - bookname = search_results.get_book() + bookname = search_results.book Receiver.send_message(u'openlp_process_events') # check to see if book/chapter exists db_book = self.get_book(bookname) - self.create_chapter(db_book.id, - search_results.get_chapter(), - search_results.get_verselist()) + self.create_chapter(db_book.id, search_results.chapter, + search_results.verselist) Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'bibles_hideprogress') Receiver.send_message(u'openlp_process_events') @@ -487,14 +484,3 @@ class HTTPBible(BibleDB): The chapter whose verses are being counted. """ return HTTPBooks.get_verse_count(book, chapter) - - def set_proxy_server(self, server): - """ - Sets the proxy server. - - **Note: This is not actually used.** - - ``server`` - The hostname or IP address of the proxy server. - """ - self.proxy_server = server diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index f862e1d1c..a252c2632 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -148,7 +148,7 @@ class BibleManager(object): file=filename, download_source=source.value, download_name=download_name) if meta_proxy: - web_bible.set_proxy_server(meta_proxy.value) + web_bible.proxy_server = meta_proxy.value self.db_cache[name] = web_bible log.debug(u'Bibles reloaded') diff --git a/openlp/plugins/songs/lib/songxml.py b/openlp/plugins/songs/lib/songxml.py index 85aa5dcc6..0a54bea9b 100644 --- a/openlp/plugins/songs/lib/songxml.py +++ b/openlp/plugins/songs/lib/songxml.py @@ -24,15 +24,9 @@ ############################################################################### import logging -#import sys -#import os from types import ListType -# Do we need these two lines? -#sys.path.append(os.path.abspath(u'./../../../..')) -#sys.path.append(os.path.abspath(os.path.join(u'.', u'..', u'..'))) - log = logging.getLogger(__name__) class SongException(Exception): @@ -70,14 +64,7 @@ class Song(object): from_ccli_text_buffer to_ccli_text_buffer - OpenSong: - from_opensong_file - to_opensong_file - from_opensong_buffer - to_opensong_buffer - presentation (screen): - get_number_of_slides get_preview_slide get_render_slide @@ -215,8 +202,8 @@ class Song(object): author_list = u', '.join(lst) self.set_title(sName) self.set_author_list(author_list) - self.set_copyright(sCopyright) - self.set_ccli_number(sCcli) + self.copyright = sCopyright + self.ccli_number = sCcli self.set_lyrics(lyrics) def from_ccli_text_file(self, textFileName): @@ -267,58 +254,30 @@ class Song(object): """Return copyright info string""" return self._assure_string(self.copyright) - def set_copyright(self, copyright): - """Set the copyright string""" - self.copyright = copyright - def get_ccli_number(self): """Return the songCclino""" return self._assure_string(self.ccli_number) - def set_ccli_number(self, ccli_number): - """Set the ccli_number""" - self.ccli_number = ccli_number - def get_theme_name(self): """Return the theme name for the song""" return self._assure_string(self.theme_name) - def set_theme_name(self, theme_name): - """Set the theme name (string)""" - self.theme_name = theme_name - def get_song_book(self): """Return the song_book (string)""" return self._assure_string(self.song_book) - def set_song_book(self, song_book): - """Set the song_book (string)""" - self.song_book = song_book - def get_song_number(self): """Return the song_number (string)""" return self._assure_string(self.song_number) - def set_song_number(self, song_number): - """Set the song_number (string)""" - self.song_number = song_number - def get_comments(self): """Return the comments (string)""" return self._assure_string(self.comments) - def set_comments(self, comments): - """Set the comments (string)""" - self.comments = comments - def get_verse_order(self): """Get the verseOrder (string) - preferably space delimited""" return self._assure_string(self.verse_order) - def set_verse_order(self, verse_order): - """Set the verse order (string) - space delimited""" - self.verse_order = verse_order - def get_author_list(self, asOneString = True): """Return the list of authors as a string @@ -369,45 +328,6 @@ class Song(object): else: self.category_array = self._list_to_string(category_array) - def get_show_title(self): - """Return the show_title flag (bool)""" - return self.show_title - - def set_show_title(self, show_title): - """Set the show_title flag (bool)""" - self.show_title = show_title - - def get_show_author_list(self): - """Return the show_author_list flag""" - return self.show_author_list - - def set_show_author_list(self, show_author_list): - """Set the show_author_list flag (bool)""" - self.show_author_list = show_author_list - - def get_show_copyright(self): - """Return the show_copyright flag""" - return self.show_copyright - - def set_show_copyright(self, show_copyright): - """Set the show_copyright flag (bool)""" - self.show_copyright = show_copyright - - def get_show_ccli_number(self): - """Return the showSongCclino (string)""" - return self.show_ccli_number - - def set_show_ccli_number(self, show_ccli_number): - """Set the show_ccli_number flag (bool)""" - self.show_ccli_number = show_ccli_number - - def get_lyrics(self): - """Return the lyrics as a list of strings - - this will return all the strings in the song - """ - return self.lyrics - def set_lyrics(self, lyrics): """Set the lyrics as a list of strings""" self.lyrics = lyrics @@ -431,11 +351,6 @@ class Song(object): if tmpSlide: self.slideList.append(tmpSlide) - def get_number_of_slides(self): - """Return the number of slides in the song (int)""" - numOfSlides = len(self.slideList) - return numOfSlides - def get_preview_slide(self, slideNumber): """Return the preview text for specified slide number