forked from openlp/openlp
Moved code out into SongMediaItem
bzr-revno: 401
This commit is contained in:
parent
34ace15939
commit
735527d558
@ -26,7 +26,7 @@ from openlp.core.lib import MediaManagerItem, Receiver
|
|||||||
from openlp.core.resources import *
|
from openlp.core.resources import *
|
||||||
|
|
||||||
from openlp.plugins.bibles.forms import BibleImportForm
|
from openlp.plugins.bibles.forms import BibleImportForm
|
||||||
from openlp.plugins.bibles.lib import BiblesTab
|
#from openlp.plugins.bibles.lib import BiblesTab
|
||||||
|
|
||||||
class BibleMediaItem(MediaManagerItem):
|
class BibleMediaItem(MediaManagerItem):
|
||||||
"""
|
"""
|
||||||
@ -244,7 +244,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.ClearAdvancedSearchComboBox.clear()
|
self.ClearAdvancedSearchComboBox.clear()
|
||||||
|
|
||||||
def loadBibles(self):
|
def loadBibles(self):
|
||||||
log.debug("Loading Bibles")
|
log.debug("Loading Bibles")
|
||||||
bibles = self.parent.biblemanager.get_bibles('full')
|
bibles = self.parent.biblemanager.get_bibles('full')
|
||||||
for bible in bibles: # load bibles into the combo boxes
|
for bible in bibles: # load bibles into the combo boxes
|
||||||
self.QuickVersionComboBox.addItem(bible)
|
self.QuickVersionComboBox.addItem(bible)
|
||||||
@ -326,7 +326,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.displayResults(bible)
|
self.displayResults(bible)
|
||||||
|
|
||||||
def onBiblePreviewClick(self):
|
def onBiblePreviewClick(self):
|
||||||
log.debug("Bible Preview Button pressed")
|
log.debug("Bible Preview Button pressed")
|
||||||
items = self.BibleListView.selectedItems()
|
items = self.BibleListView.selectedItems()
|
||||||
old_chapter = ''
|
old_chapter = ''
|
||||||
for item in items:
|
for item in items:
|
||||||
@ -344,7 +344,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
loc = self.formatVerse(old_chapter, chapter, verse, u'(', u')')
|
loc = self.formatVerse(old_chapter, chapter, verse, u'(', u')')
|
||||||
elif self.parent.bibles_tab.display_style == 2:
|
elif self.parent.bibles_tab.display_style == 2:
|
||||||
loc = self.formatVerse(old_chapter, chapter, verse, u'{', u'}')
|
loc = self.formatVerse(old_chapter, chapter, verse, u'{', u'}')
|
||||||
elif self.parent.bibles_tab.display_style == 3:
|
elif self.parent.bibles_tab.display_style == 3:
|
||||||
loc = self.formatVerse(old_chapter, chapter, verse, u'[', u']')
|
loc = self.formatVerse(old_chapter, chapter, verse, u'[', u']')
|
||||||
else:
|
else:
|
||||||
loc = self.formatVerse(old_chapter, chapter, verse, u'', u'')
|
loc = self.formatVerse(old_chapter, chapter, verse, u'', u'')
|
||||||
@ -364,7 +364,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
return loc
|
return loc
|
||||||
|
|
||||||
def reloadBibles(self):
|
def reloadBibles(self):
|
||||||
log.debug("Reloading Bibles")
|
log.debug("Reloading Bibles")
|
||||||
self.parent.biblemanager.reload_bibles()
|
self.parent.biblemanager.reload_bibles()
|
||||||
#self.initialiseForm()
|
#self.initialiseForm()
|
||||||
self.loadBibles()
|
self.loadBibles()
|
||||||
@ -414,7 +414,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.BibleListView.setRowHeight(row_count, 20)
|
self.BibleListView.setRowHeight(row_count, 20)
|
||||||
|
|
||||||
def searchByReference(self, bible, search):
|
def searchByReference(self, bible, search):
|
||||||
log.debug("searchByReference %s ,%s", bible, search)
|
log.debug("searchByReference %s ,%s", bible, search)
|
||||||
book = ''
|
book = ''
|
||||||
start_chapter = ''
|
start_chapter = ''
|
||||||
end_chapter = ''
|
end_chapter = ''
|
||||||
|
@ -29,6 +29,10 @@ class BiblesTab(SettingsTab):
|
|||||||
BiblesTab is the Bibles settings tab in the settings dialog.
|
BiblesTab is the Bibles settings tab in the settings dialog.
|
||||||
"""
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.paragraph_style = True
|
||||||
|
self.show_new_chapters = False
|
||||||
|
self.display_style = 0
|
||||||
|
self.bible_search = True
|
||||||
SettingsTab.__init__(self, u'Bibles')
|
SettingsTab.__init__(self, u'Bibles')
|
||||||
|
|
||||||
def setupUi(self):
|
def setupUi(self):
|
||||||
@ -120,7 +124,7 @@ class BiblesTab(SettingsTab):
|
|||||||
QtCore.QObject.connect(self.ParagraphRadioButton,
|
QtCore.QObject.connect(self.ParagraphRadioButton,
|
||||||
QtCore.SIGNAL("pressed()"), self.onParagraphRadioButtonPressed)
|
QtCore.SIGNAL("pressed()"), self.onParagraphRadioButtonPressed)
|
||||||
QtCore.QObject.connect(self.DisplayStyleComboBox,
|
QtCore.QObject.connect(self.DisplayStyleComboBox,
|
||||||
QtCore.SIGNAL("activated(int)"), self.onDisplayStyleComboBoxChanged)
|
QtCore.SIGNAL("activated(int)"), self.onDisplayStyleComboBoxChanged)
|
||||||
|
|
||||||
def retranslateUi(self):
|
def retranslateUi(self):
|
||||||
self.VerseDisplayGroupBox.setTitle(translate('SettingsForm', 'Verse Display'))
|
self.VerseDisplayGroupBox.setTitle(translate('SettingsForm', 'Verse Display'))
|
||||||
@ -138,7 +142,7 @@ class BiblesTab(SettingsTab):
|
|||||||
|
|
||||||
def onDisplayStyleComboBoxChanged(self):
|
def onDisplayStyleComboBoxChanged(self):
|
||||||
self.display_style = self.DisplayStyleComboBox.currentIndex()
|
self.display_style = self.DisplayStyleComboBox.currentIndex()
|
||||||
|
|
||||||
def onVerseRadioButtonPressed(self):
|
def onVerseRadioButtonPressed(self):
|
||||||
self.paragraph_style = False
|
self.paragraph_style = False
|
||||||
|
|
||||||
@ -146,35 +150,32 @@ class BiblesTab(SettingsTab):
|
|||||||
self.paragraph_style = True
|
self.paragraph_style = True
|
||||||
|
|
||||||
def onNewChaptersCheckBoxChanged(self):
|
def onNewChaptersCheckBoxChanged(self):
|
||||||
check_box = self.NewChaptersCheckBox.checkState()
|
check_state = self.NewChaptersCheckBox.checkState()
|
||||||
self.new_chapter_check = False
|
self.show_new_chapters = False
|
||||||
if check_box == 2: # we have a set value convert to True/False
|
if check_state == 2: # we have a set value convert to True/False
|
||||||
self.new_chapter_check = True
|
self.show_new_chapters = True
|
||||||
|
|
||||||
def onBibleSearchCheckBoxChanged(self):
|
def onBibleSearchCheckBoxChanged(self):
|
||||||
bible_search = self.BibleSearchCheckBox.checkState()
|
check_state = self.BibleSearchCheckBox.checkState()
|
||||||
self.bible_search_check = False
|
self.bible_search = False
|
||||||
if bible_search == 2: # we have a set value convert to True/False
|
if check_state == 2: # we have a set value convert to True/False
|
||||||
self.bible_search_check = True
|
self.bible_search = True
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
self.paragraph_style = self.convertStringToBoolean(self.config.get_config('paragraph style', u'True'))
|
self.paragraph_style = self.convertStringToBoolean(self.config.get_config('paragraph style', u'True'))
|
||||||
self.new_chapter_check = self.convertStringToBoolean(self.config.get_config('display new chapter', u"False"))
|
self.show_new_chapters = self.convertStringToBoolean(self.config.get_config('display new chapter', u"False"))
|
||||||
self.display_style = int(self.config.get_config('display brackets', '0'))
|
self.display_style = int(self.config.get_config('display brackets', '0'))
|
||||||
self.search_as_type = self.convertStringToBoolean(self.config.get_config('search as type', u'True'))
|
self.bible_search = self.convertStringToBoolean(self.config.get_config('search as type', u'True'))
|
||||||
if self.paragraph_style:
|
if self.paragraph_style:
|
||||||
self.ParagraphRadioButton.setChecked(True)
|
self.ParagraphRadioButton.setChecked(True)
|
||||||
else:
|
else:
|
||||||
self.VerseRadioButton.setChecked(True)
|
self.VerseRadioButton.setChecked(True)
|
||||||
if self.new_chapter_check:
|
self.NewChaptersCheckBox.setChecked(self.show_new_chapters)
|
||||||
self.NewChaptersCheckBox.setChecked(True)
|
|
||||||
self.DisplayStyleComboBox.setCurrentIndex(self.display_style)
|
self.DisplayStyleComboBox.setCurrentIndex(self.display_style)
|
||||||
if self.search_as_type:
|
self.BibleSearchCheckBox.setChecked(self.bible_search)
|
||||||
self.BibleSearchCheckBox.setChecked(True)
|
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
self.config.set_config("paragraph style", str(self.paragraph_style))
|
self.config.set_config("paragraph style", str(self.paragraph_style))
|
||||||
self.config.set_config("display new chapter", str(self.new_chapter_check))
|
self.config.set_config("display new chapter", str(self.show_new_chapters))
|
||||||
self.config.set_config("display brackets", str(self.display_style))
|
self.config.set_config("display brackets", str(self.display_style))
|
||||||
self.config.set_config("search as type", str(self.bible_search_check))
|
self.config.set_config("search as type", str(self.bible_search))
|
||||||
|
|
||||||
|
@ -18,11 +18,11 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|||||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from editsongform import EditSongForm
|
|
||||||
from authorsform import AuthorsForm
|
from authorsform import AuthorsForm
|
||||||
from topicsform import TopicsForm
|
from topicsform import TopicsForm
|
||||||
from songbookform import SongBookForm
|
from songbookform import SongBookForm
|
||||||
from editverseform import EditVerseForm
|
from editverseform import EditVerseForm
|
||||||
|
from editsongform import EditSongForm
|
||||||
|
|
||||||
from openlpexportform import OpenLPExportForm
|
from openlpexportform import OpenLPExportForm
|
||||||
from openlpimportform import OpenLPImportForm
|
from openlpimportform import OpenLPImportForm
|
||||||
|
@ -16,16 +16,15 @@ You should have received a copy of the GNU General Public License along with
|
|||||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
"""
|
"""
|
||||||
from openlp.core.resources import *
|
|
||||||
|
|
||||||
from PyQt4 import QtGui, QtCore
|
from PyQt4 import QtGui, QtCore
|
||||||
from PyQt4.QtGui import QDialog
|
|
||||||
from PyQt4.QtCore import pyqtSignature
|
from PyQt4.QtCore import pyqtSignature
|
||||||
|
|
||||||
from authorsdialog import Ui_AuthorsDialog
|
from openlp.core.resources import *
|
||||||
from openlp.plugins.songs.lib.classes import *
|
from openlp.plugins.songs.lib.classes import *
|
||||||
|
|
||||||
class AuthorsForm(QDialog, Ui_AuthorsDialog):
|
from openlp.plugins.songs.forms.authorsdialog import Ui_AuthorsDialog
|
||||||
|
|
||||||
|
class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
|
||||||
"""
|
"""
|
||||||
Class to control the Maintenance of Authors Dialog
|
Class to control the Maintenance of Authors Dialog
|
||||||
"""
|
"""
|
||||||
@ -33,7 +32,7 @@ class AuthorsForm(QDialog, Ui_AuthorsDialog):
|
|||||||
"""
|
"""
|
||||||
Set up the screen and common data
|
Set up the screen and common data
|
||||||
"""
|
"""
|
||||||
QDialog.__init__(self, parent)
|
QtGui.QDialog.__init__(self, parent)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.songmanager = songmanager
|
self.songmanager = songmanager
|
||||||
self.AuthorListView.setColumnCount(2)
|
self.AuthorListView.setColumnCount(2)
|
||||||
|
@ -19,10 +19,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
"""
|
"""
|
||||||
from PyQt4 import Qt, QtCore, QtGui
|
from PyQt4 import Qt, QtCore, QtGui
|
||||||
|
|
||||||
from authorsform import AuthorsForm
|
from openlp.plugins.songs.forms import AuthorsForm, TopicsForm, SongBookForm, \
|
||||||
from topicsform import TopicsForm
|
EditVerseForm
|
||||||
from songbookform import SongBookForm
|
|
||||||
from editverseform import EditVerseForm
|
|
||||||
|
|
||||||
from editsongdialog import Ui_EditSongDialog
|
from editsongdialog import Ui_EditSongDialog
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
|
|
||||||
from manager import SongManager
|
from manager import SongManager
|
||||||
from songstab import SongsTab
|
from songstab import SongsTab
|
||||||
|
from mediaitem import SongMediaItem
|
||||||
#from xml import SongOpenXml
|
#from xml import SongOpenXml
|
||||||
|
|
||||||
__all__ = ['SongManager', SongsTab]
|
#__all__ = ['SongManager', 'SongsTab', 'SongMediaItem']
|
||||||
|
|
||||||
|
220
openlp/plugins/songs/lib/mediaitem.py
Normal file
220
openlp/plugins/songs/lib/mediaitem.py
Normal file
@ -0,0 +1,220 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||||
|
"""
|
||||||
|
OpenLP - Open Source Lyrics Projection
|
||||||
|
Copyright (c) 2008 Raoul Snyman
|
||||||
|
Portions copyright (c) 2008 Martin Thompson, Tim Bentley
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
Foundation; version 2 of the License.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with
|
||||||
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||||
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
"""
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
|
from openlp.core import translate
|
||||||
|
from openlp.core.lib import MediaManagerItem
|
||||||
|
from openlp.core.resources import *
|
||||||
|
|
||||||
|
from openlp.plugins.songs.forms import EditSongForm
|
||||||
|
|
||||||
|
class SongMediaItem(MediaManagerItem):
|
||||||
|
"""
|
||||||
|
This is the custom media manager item for Songs.
|
||||||
|
"""
|
||||||
|
global log
|
||||||
|
log=logging.getLogger("SongMediaItem")
|
||||||
|
log.info("Song Media Item loaded")
|
||||||
|
|
||||||
|
def __init__(self, parent, icon, title):
|
||||||
|
MediaManagerItem.__init__(self, parent, icon, title)
|
||||||
|
self.edit_song_form = EditSongForm(self.parent.songmanager)
|
||||||
|
|
||||||
|
def setupUi(self):
|
||||||
|
# Add a toolbar
|
||||||
|
self.addToolbar()
|
||||||
|
# Create buttons for the toolbar
|
||||||
|
## New Song Button ##
|
||||||
|
self.addToolbarButton(translate('SongMediaItem', u'New Song'),
|
||||||
|
translate('SongMediaItem', u'Add a new song'),
|
||||||
|
':/songs/song_new.png', self.onSongNewClick, 'SongNewItem')
|
||||||
|
## Edit Song Button ##
|
||||||
|
self.addToolbarButton(translate('SongMediaItem', u'Edit Song'),
|
||||||
|
translate('SongMediaItem', u'Edit the selected song'),
|
||||||
|
':/songs/song_edit.png', self.onSongEditClick, 'SongEditItem')
|
||||||
|
## Delete Song Button ##
|
||||||
|
self.addToolbarButton(translate('SongMediaItem', u'Delete Song'),
|
||||||
|
translate('SongMediaItem', u'Delete the selected song'),
|
||||||
|
':/songs/song_delete.png', self.onSongDeleteClick, 'SongDeleteItem')
|
||||||
|
## Separator Line ##
|
||||||
|
self.addToolbarSeparator()
|
||||||
|
## Preview Song Button ##
|
||||||
|
self.addToolbarButton(translate('SongMediaItem', u'Preview Song'),
|
||||||
|
translate('SongMediaItem', u'Preview the selected song'),
|
||||||
|
':/system/system_preview.png', self.onSongPreviewClick, 'SongPreviewItem')
|
||||||
|
## Live Song Button ##
|
||||||
|
self.addToolbarButton(translate('SongMediaItem', u'Go Live'),
|
||||||
|
translate('SongMediaItem', u'Send the selected song live'),
|
||||||
|
':/system/system_live.png', self.onSongLiveClick, 'SongLiveItem')
|
||||||
|
## Add Song Button ##
|
||||||
|
self.addToolbarButton(translate('SongMediaItem', u'Add Song To Service'),
|
||||||
|
translate('SongMediaItem', u'Add the selected song(s) to the service'),
|
||||||
|
':/system/system_add.png', self.onSongAddClick, 'SongAddItem')
|
||||||
|
## Add the songlist widget ##
|
||||||
|
# Create the tab widget
|
||||||
|
self.SongWidget = QtGui.QWidget(self)
|
||||||
|
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||||
|
sizePolicy.setHorizontalStretch(0)
|
||||||
|
sizePolicy.setVerticalStretch(0)
|
||||||
|
sizePolicy.setHeightForWidth(self.SongWidget.sizePolicy().hasHeightForWidth())
|
||||||
|
self.SongWidget.setSizePolicy(sizePolicy)
|
||||||
|
self.SongWidget.setObjectName('SongWidget')
|
||||||
|
self.SearchLayout = QtGui.QGridLayout(self.SongWidget)
|
||||||
|
self.SearchLayout.setObjectName('SearchLayout')
|
||||||
|
self.SearchTypeComboBox = QtGui.QComboBox(self.SongWidget)
|
||||||
|
self.SearchTypeComboBox.setObjectName('SearchTypeComboBox')
|
||||||
|
self.SearchLayout.addWidget(self.SearchTypeComboBox, 0, 1, 1, 2)
|
||||||
|
self.SearchTypeLabel = QtGui.QLabel(self.SongWidget)
|
||||||
|
self.SearchTypeLabel.setObjectName('SearchTypeLabel')
|
||||||
|
self.SearchLayout.addWidget(self.SearchTypeLabel, 0, 0, 1, 1)
|
||||||
|
self.SearchTextLabel = QtGui.QLabel(self.SongWidget)
|
||||||
|
self.SearchTextLabel.setObjectName('SearchTextLabel')
|
||||||
|
self.SearchLayout.addWidget(self.SearchTextLabel, 2, 0, 1, 1)
|
||||||
|
self.SearchTextEdit = QtGui.QLineEdit(self.SongWidget)
|
||||||
|
self.SearchTextEdit.setObjectName('SearchTextEdit')
|
||||||
|
self.SearchLayout.addWidget(self.SearchTextEdit, 2, 1, 1, 2)
|
||||||
|
self.ClearTextButton = QtGui.QPushButton(self.SongWidget)
|
||||||
|
self.ClearTextButton.setObjectName('ClearTextButton')
|
||||||
|
self.SearchLayout.addWidget(self.ClearTextButton, 3, 1, 1, 1)
|
||||||
|
self.SearchTextButton = QtGui.QPushButton(self.SongWidget)
|
||||||
|
self.SearchTextButton.setObjectName('SearchTextButton')
|
||||||
|
self.SearchLayout.addWidget(self.SearchTextButton, 3, 2, 1, 1)
|
||||||
|
# Add the song widget to the page layout
|
||||||
|
self.PageLayout.addWidget(self.SongWidget)
|
||||||
|
self.SongListView = QtGui.QTableWidget()
|
||||||
|
self.SongListView.setColumnCount(2)
|
||||||
|
self.SongListView.setColumnHidden(0, True)
|
||||||
|
self.SongListView.setColumnWidth(1, 240)
|
||||||
|
self.SongListView.setShowGrid(False)
|
||||||
|
self.SongListView.setSortingEnabled(False)
|
||||||
|
self.SongListView.setAlternatingRowColors(True)
|
||||||
|
self.SongListView.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
|
||||||
|
self.SongListView.horizontalHeader().setVisible(False)
|
||||||
|
self.SongListView.verticalHeader().setVisible(False)
|
||||||
|
self.SongListView.setGeometry(QtCore.QRect(10, 100, 256, 591))
|
||||||
|
self.SongListView.setObjectName('listView')
|
||||||
|
self.PageLayout.addWidget(self.SongListView)
|
||||||
|
# Signals and slots
|
||||||
|
QtCore.QObject.connect(self.SearchTextButton,
|
||||||
|
QtCore.SIGNAL("pressed()"), self.onSearchTextButtonClick)
|
||||||
|
QtCore.QObject.connect(self.ClearTextButton,
|
||||||
|
QtCore.SIGNAL("pressed()"), self.onClearTextButtonClick)
|
||||||
|
QtCore.QObject.connect(self.SearchTextEdit,
|
||||||
|
QtCore.SIGNAL("textChanged(const QString&)"), self.onSearchTextEditChanged)
|
||||||
|
QtCore.QObject.connect(self.SongListView,
|
||||||
|
QtCore.SIGNAL("itemPressed(QTableWidgetItem * item)"), self.onSongSelected)
|
||||||
|
#define and add the context menu
|
||||||
|
self.SongListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||||
|
self.SongListView.addAction(self.contextMenuAction(self.SongListView,
|
||||||
|
':/songs/song_new.png', translate('SongMediaItem', u'&Edit Song'),
|
||||||
|
self.onSongEditClick))
|
||||||
|
self.SongListView.addAction(self.contextMenuSeparator(self.SongListView))
|
||||||
|
self.SongListView.addAction(self.contextMenuAction(self.SongListView,
|
||||||
|
':/system/system_preview.png', translate('SongMediaItem', u'&Preview Song'),
|
||||||
|
self.onSongPreviewClick))
|
||||||
|
self.SongListView.addAction(self.contextMenuAction(self.SongListView,
|
||||||
|
':/system/system_live.png', translate('SongMediaItem', u'&Show Live'),
|
||||||
|
self.onSongLiveClick))
|
||||||
|
self.SongListView.addAction(self.contextMenuAction(self.SongListView,
|
||||||
|
':/system/system_add.png', translate('SongMediaItem', u'&Add to Service'),
|
||||||
|
self.onSongEditClick))
|
||||||
|
|
||||||
|
def retranslateUi(self):
|
||||||
|
self.SearchTypeLabel.setText(translate('SongMediaItem', u'Search Type:'))
|
||||||
|
self.SearchTextLabel.setText(translate('SongMediaItem', u'Search Text:'))
|
||||||
|
self.ClearTextButton.setText(translate('SongMediaItem', u'Clear'))
|
||||||
|
self.SearchTextButton.setText(translate('SongMediaItem', u'Search'))
|
||||||
|
|
||||||
|
def initialise(self):
|
||||||
|
self.SearchTypeComboBox.addItem(translate('SongMediaItem', u'Titles'))
|
||||||
|
self.SearchTypeComboBox.addItem(translate('SongMediaItem', u'Lyrics'))
|
||||||
|
self.SearchTypeComboBox.addItem(translate('SongMediaItem', u'Authors'))
|
||||||
|
|
||||||
|
def displayResults(self, searchresults):
|
||||||
|
log.debug("_search results")
|
||||||
|
self.SongListView.clear() # clear the results
|
||||||
|
self.SongListView.horizontalHeader().setVisible(False)
|
||||||
|
self.SongListView.verticalHeader().setVisible(False)
|
||||||
|
self.SongListView.setRowCount(0)
|
||||||
|
#log.debug("Records returned from search %s", len(searchresults))
|
||||||
|
for song in searchresults:
|
||||||
|
for author in song.authors:
|
||||||
|
c = self.SongListView.rowCount()
|
||||||
|
self.SongListView.setRowCount(c + 1)
|
||||||
|
song_index = QtGui.QTableWidgetItem(str(song.id))
|
||||||
|
self.SongListView.setItem(c , 0, song_index)
|
||||||
|
song_detail = QtGui.QTableWidgetItem(
|
||||||
|
u'%s (%s)' % (str(song.title), str(author.display_name)))
|
||||||
|
self.SongListView.setItem(c , 1, song_detail)
|
||||||
|
self.SongListView.setRowHeight(c, 20)
|
||||||
|
|
||||||
|
def onClearTextButtonClick(self):
|
||||||
|
"""
|
||||||
|
Clear the search text.
|
||||||
|
"""
|
||||||
|
self.SearchTextEdit.clear()
|
||||||
|
|
||||||
|
def onSearchTextEditChanged(self, text):
|
||||||
|
search_length = 3
|
||||||
|
if self.SearchTypeComboBox.currentIndex() == 1:
|
||||||
|
search_length = 7
|
||||||
|
if len(text) > search_length: # only search if > 3 characters
|
||||||
|
self.onSearchTextButtonClick()
|
||||||
|
|
||||||
|
def onSearchTextButtonClick(self):
|
||||||
|
search_keywords = str(self.SearchTextEdit.displayText())
|
||||||
|
search_results = []
|
||||||
|
search_type = self.SearchTypeComboBox.currentIndex()
|
||||||
|
if search_type == 0:
|
||||||
|
log.debug("Titles Search")
|
||||||
|
search_results = self.parent.songmanager.search_song_title(search_keywords)
|
||||||
|
elif search_type == 1:
|
||||||
|
log.debug("Lyrics Search")
|
||||||
|
search_results = self.parent.songmanager.search_song_lyrics(search_keywords)
|
||||||
|
elif search_type == 2:
|
||||||
|
log.debug("Authors Search")
|
||||||
|
#searchresults = self.songmanager.get_song_from_author(searchtext)
|
||||||
|
self.displayResults(search_results)
|
||||||
|
|
||||||
|
def onSongSelected(self, item):
|
||||||
|
print item
|
||||||
|
|
||||||
|
def onSongNewClick(self):
|
||||||
|
self.edit_song_form.exec_()
|
||||||
|
|
||||||
|
def onSongEditClick(self):
|
||||||
|
current_row = self.SongListView.currentRow()
|
||||||
|
id = int(self.SongListView.item(current_row, 0).text())
|
||||||
|
self.parent.edit_song_form.loadSong(id)
|
||||||
|
self.parent.edit_song_form.exec_()
|
||||||
|
|
||||||
|
def onSongDeleteClick(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def onSongPreviewClick(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def onSongLiveClick(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def onSongAddClick(self):
|
||||||
|
pass
|
@ -22,10 +22,10 @@ import logging
|
|||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.resources import *
|
from openlp.core.resources import *
|
||||||
from openlp.core.lib import Plugin, PluginUtils, MediaManagerItem
|
from openlp.core.lib import Plugin, PluginUtils
|
||||||
from forms import EditSongForm, OpenLPImportForm, OpenSongImportForm, \
|
from openlp.plugins.songs.lib import SongManager, SongsTab, SongMediaItem
|
||||||
OpenLPExportForm, OpenSongExportForm
|
from openlp.plugins.songs.forms import OpenLPImportForm, OpenSongExportForm, \
|
||||||
from openlp.plugins.songs.lib import SongManager, SongsTab
|
OpenSongImportForm, OpenLPExportForm
|
||||||
|
|
||||||
class SongsPlugin(Plugin, PluginUtils):
|
class SongsPlugin(Plugin, PluginUtils):
|
||||||
|
|
||||||
@ -38,7 +38,6 @@ class SongsPlugin(Plugin, PluginUtils):
|
|||||||
Plugin.__init__(self, 'Songs', '1.9.0')
|
Plugin.__init__(self, 'Songs', '1.9.0')
|
||||||
self.weight = -10
|
self.weight = -10
|
||||||
self.songmanager = SongManager(self.config)
|
self.songmanager = SongManager(self.config)
|
||||||
self.edit_song_form = EditSongForm(self.songmanager)
|
|
||||||
self.openlp_import_form = OpenLPImportForm()
|
self.openlp_import_form = OpenLPImportForm()
|
||||||
self.opensong_import_form = OpenSongImportForm()
|
self.opensong_import_form = OpenSongImportForm()
|
||||||
self.openlp_export_form = OpenLPExportForm()
|
self.openlp_export_form = OpenLPExportForm()
|
||||||
@ -48,101 +47,9 @@ class SongsPlugin(Plugin, PluginUtils):
|
|||||||
self.icon.addPixmap(QtGui.QPixmap(':/media/media_song.png'),
|
self.icon.addPixmap(QtGui.QPixmap(':/media/media_song.png'),
|
||||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
|
|
||||||
|
|
||||||
def get_media_manager_item(self):
|
def get_media_manager_item(self):
|
||||||
# Create the MediaManagerItem object
|
# Create the MediaManagerItem object
|
||||||
self.MediaManagerItem = MediaManagerItem(self, self.icon, 'Songs')
|
self.MediaManagerItem = SongMediaItem(self, self.icon, 'Songs')
|
||||||
# Add a toolbar
|
|
||||||
self.MediaManagerItem.addToolbar()
|
|
||||||
# Create buttons for the toolbar
|
|
||||||
## New Song Button ##
|
|
||||||
self.MediaManagerItem.addToolbarButton('New Song', 'Add a new song',
|
|
||||||
':/songs/song_new.png', self.onSongNewClick, 'SongNewItem')
|
|
||||||
## Edit Song Button ##
|
|
||||||
self.MediaManagerItem.addToolbarButton('Edit Song', 'Edit the selected song',
|
|
||||||
':/songs/song_edit.png', self.onSongEditClick, 'SongEditItem')
|
|
||||||
## Delete Song Button ##
|
|
||||||
self.MediaManagerItem.addToolbarButton('Delete Song', 'Delete the selected song',
|
|
||||||
':/songs/song_delete.png', self.onSongDeleteClick, 'SongDeleteItem')
|
|
||||||
## Separator Line ##
|
|
||||||
self.MediaManagerItem.addToolbarSeparator()
|
|
||||||
## Preview Song Button ##
|
|
||||||
self.MediaManagerItem.addToolbarButton('Preview Song', 'Preview the selected song',
|
|
||||||
':/system/system_preview.png', self.onSongPreviewClick, 'SongPreviewItem')
|
|
||||||
## Live Song Button ##
|
|
||||||
self.MediaManagerItem.addToolbarButton('Go Live', 'Send the selected song live',
|
|
||||||
':/system/system_live.png', self.onSongLiveClick, 'SongLiveItem')
|
|
||||||
## Add Song Button ##
|
|
||||||
self.MediaManagerItem.addToolbarButton('Add Song To Service',
|
|
||||||
'Add the selected song(s) to the service', ':/system/system_add.png',
|
|
||||||
self.onSongAddClick, 'SongAddItem')
|
|
||||||
## Add the songlist widget ##
|
|
||||||
# Create the tab widget
|
|
||||||
self.SongWidget = QtGui.QWidget(self.MediaManagerItem)
|
|
||||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
|
||||||
sizePolicy.setHorizontalStretch(0)
|
|
||||||
sizePolicy.setVerticalStretch(0)
|
|
||||||
sizePolicy.setHeightForWidth(self.SongWidget.sizePolicy().hasHeightForWidth())
|
|
||||||
self.SongWidget.setSizePolicy(sizePolicy)
|
|
||||||
self.SongWidget.setObjectName('SongWidget')
|
|
||||||
self.SearchLayout = QtGui.QGridLayout(self.SongWidget)
|
|
||||||
self.SearchLayout.setObjectName('SearchLayout')
|
|
||||||
self.SearchTypeComboBox = QtGui.QComboBox(self.SongWidget)
|
|
||||||
self.SearchTypeComboBox.setObjectName('SearchTypeComboBox')
|
|
||||||
self.SearchLayout.addWidget(self.SearchTypeComboBox, 0, 1, 1, 2)
|
|
||||||
self.SearchTypeLabel = QtGui.QLabel(self.SongWidget)
|
|
||||||
self.SearchTypeLabel.setObjectName('SearchTypeLabel')
|
|
||||||
self.SearchTypeLabel.setText('Search Type:')
|
|
||||||
self.SearchLayout.addWidget(self.SearchTypeLabel, 0, 0, 1, 1)
|
|
||||||
self.SearchTextLabel = QtGui.QLabel(self.SongWidget)
|
|
||||||
self.SearchTextLabel.setObjectName('SearchTextLabel')
|
|
||||||
self.SearchTextLabel.setText('Search Text:')
|
|
||||||
self.SearchLayout.addWidget(self.SearchTextLabel, 2, 0, 1, 1)
|
|
||||||
self.SearchTextEdit = QtGui.QLineEdit(self.SongWidget)
|
|
||||||
self.SearchTextEdit.setObjectName('SearchTextEdit')
|
|
||||||
self.SearchLayout.addWidget(self.SearchTextEdit, 2, 1, 1, 2)
|
|
||||||
self.ClearTextButton = QtGui.QPushButton(self.SongWidget)
|
|
||||||
self.ClearTextButton.setObjectName('ClearTextButton')
|
|
||||||
self.ClearTextButton.setText('Clear')
|
|
||||||
self.SearchLayout.addWidget(self.ClearTextButton, 3, 1, 1, 1)
|
|
||||||
self.SearchTextButton = QtGui.QPushButton(self.SongWidget)
|
|
||||||
self.SearchTextButton.setObjectName('SearchTextButton')
|
|
||||||
self.SearchTextButton.setText('Search')
|
|
||||||
self.SearchLayout.addWidget(self.SearchTextButton, 3, 2, 1, 1)
|
|
||||||
# Add the song widget to the page layout
|
|
||||||
self.MediaManagerItem.PageLayout.addWidget(self.SongWidget)
|
|
||||||
self.SongListView = QtGui.QTableWidget()
|
|
||||||
self.SongListView.setColumnCount(2)
|
|
||||||
self.SongListView.setColumnHidden(0, True)
|
|
||||||
self.SongListView.setColumnWidth(1, 240)
|
|
||||||
#self.SongListView.setColumnWidth(2, 80)
|
|
||||||
self.SongListView.setShowGrid(False)
|
|
||||||
self.SongListView.setSortingEnabled(False)
|
|
||||||
self.SongListView.setAlternatingRowColors(True)
|
|
||||||
self.SongListView.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
|
|
||||||
self.SongListView.setHorizontalHeaderLabels(QtCore.QStringList(['', u'Song Name']))
|
|
||||||
self.SongListView.horizontalHeader().setVisible(False)
|
|
||||||
self.SongListView.verticalHeader().setVisible(False)
|
|
||||||
self.SongListView.setGeometry(QtCore.QRect(10, 100, 256, 591))
|
|
||||||
self.SongListView.setObjectName('listView')
|
|
||||||
self.MediaManagerItem.PageLayout.addWidget(self.SongListView)
|
|
||||||
|
|
||||||
QtCore.QObject.connect(self.SearchTextButton, QtCore.SIGNAL("pressed()"), self.onSearchTextButtonClick)
|
|
||||||
QtCore.QObject.connect(self.ClearTextButton, QtCore.SIGNAL("pressed()"), self.onClearTextButtonClick)
|
|
||||||
QtCore.QObject.connect(self.SearchTextEdit, QtCore.SIGNAL("textChanged(const QString&)"), self.onSearchTextEditChanged)
|
|
||||||
|
|
||||||
QtCore.QObject.connect(self.SongListView, QtCore.SIGNAL("itemPressed(QTableWidgetItem * item)"), self.onSongSelected)
|
|
||||||
|
|
||||||
|
|
||||||
#define and add the context menu
|
|
||||||
self.SongListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
|
||||||
|
|
||||||
self.SongListView.addAction(self.add_to_context_menu(self.SongListView, ':/songs/song_new.png', "&Edit Song", self.onSongEditClick))
|
|
||||||
self.SongListView.addAction(self.add_to_context_separator(self.SongListView))
|
|
||||||
self.SongListView.addAction(self.add_to_context_menu(self.SongListView, ':/system/system_preview.png', "&Preview Song", self.onSongPreviewClick))
|
|
||||||
self.SongListView.addAction(self.add_to_context_menu(self.SongListView, ':/system/system_live.png', "&Show Live", self.onSongLiveClick))
|
|
||||||
self.SongListView.addAction(self.add_to_context_menu(self.SongListView, ':/system/system_add.png', "&Add to Service", self.onSongEditClick))
|
|
||||||
|
|
||||||
return self.MediaManagerItem
|
return self.MediaManagerItem
|
||||||
|
|
||||||
def add_import_menu_item(self, import_menu):
|
def add_import_menu_item(self, import_menu):
|
||||||
@ -202,60 +109,6 @@ class SongsPlugin(Plugin, PluginUtils):
|
|||||||
return self.SongsTab
|
return self.SongsTab
|
||||||
|
|
||||||
def initialise(self):
|
def initialise(self):
|
||||||
self.SearchTypeComboBox.addItem(u'Titles')
|
|
||||||
self.SearchTypeComboBox.addItem(u'Lyrics')
|
|
||||||
self.SearchTypeComboBox.addItem(u'Authors')
|
|
||||||
|
|
||||||
def onClearTextButtonClick(self):
|
|
||||||
"""
|
|
||||||
Clear the search text.
|
|
||||||
"""
|
|
||||||
self.SearchTextEdit.clear()
|
|
||||||
|
|
||||||
def onSearchTextEditChanged(self, text):
|
|
||||||
sl = 3
|
|
||||||
if self.SearchTypeComboBox.currentText() == u'Lyrics':
|
|
||||||
sl = 7
|
|
||||||
if len(text) > sl: # only search if > 3 characters
|
|
||||||
self.onSearchTextButtonClick()
|
|
||||||
|
|
||||||
def onSearchTextButtonClick(self):
|
|
||||||
search_keywords = str(self.SearchTextEdit.displayText())
|
|
||||||
search_results = []
|
|
||||||
search_type = self.SearchTypeComboBox.currentText()
|
|
||||||
if search_type == u'Titles':
|
|
||||||
log.debug("Titles Search")
|
|
||||||
search_results = self.songmanager.search_song_title(search_keywords)
|
|
||||||
elif search_type == u'Lyrics':
|
|
||||||
log.debug("Lyrics Search")
|
|
||||||
search_results = self.songmanager.search_song_lyrics(search_keywords)
|
|
||||||
elif search_type == u'Authors':
|
|
||||||
log.debug("Authors Search")
|
|
||||||
#searchresults = self.songmanager.get_song_from_author(searchtext)
|
|
||||||
self._display_results(search_results)
|
|
||||||
|
|
||||||
def onSongSelected(self, item):
|
|
||||||
print item
|
|
||||||
|
|
||||||
def onSongNewClick(self):
|
|
||||||
self.edit_song_form.exec_()
|
|
||||||
|
|
||||||
def onSongEditClick(self):
|
|
||||||
current_row = self.SongListView.currentRow()
|
|
||||||
id = int(self.SongListView.item(current_row, 0).text())
|
|
||||||
self.edit_song_form.loadSong(id)
|
|
||||||
self.edit_song_form.exec_()
|
|
||||||
|
|
||||||
def onSongDeleteClick(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def onSongPreviewClick(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def onSongLiveClick(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def onSongAddClick(self):
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def onImportOpenlp1ItemClick(self):
|
def onImportOpenlp1ItemClick(self):
|
||||||
@ -269,24 +122,3 @@ class SongsPlugin(Plugin, PluginUtils):
|
|||||||
|
|
||||||
def onExportOpenSongItemClicked(self):
|
def onExportOpenSongItemClicked(self):
|
||||||
self.opensong_export_form.show()
|
self.opensong_export_form.show()
|
||||||
|
|
||||||
def _display_results(self, searchresults):
|
|
||||||
log.debug("_search results")
|
|
||||||
self.SongListView.clear() # clear the results
|
|
||||||
self.SongListView.setHorizontalHeaderLabels(QtCore.QStringList(['', u'Song Name']))
|
|
||||||
self.SongListView.horizontalHeader().setVisible(False)
|
|
||||||
self.SongListView.verticalHeader().setVisible(False)
|
|
||||||
self.SongListView.setRowCount(0)
|
|
||||||
#log.debug("Records returned from search %s", len(searchresults))
|
|
||||||
for song in searchresults:
|
|
||||||
for author in song.authors:
|
|
||||||
c = self.SongListView.rowCount()
|
|
||||||
self.SongListView.setRowCount(c + 1)
|
|
||||||
song_index = QtGui.QTableWidgetItem(str(song.id))
|
|
||||||
self.SongListView.setItem(c , 0, song_index)
|
|
||||||
song_detail = QtGui.QTableWidgetItem(u'%s (%s)' % (str(song.title), str(author.display_name)))
|
|
||||||
self.SongListView.setItem(c , 1, song_detail)
|
|
||||||
#twi = QtGui.QTableWidgetItem()
|
|
||||||
#self.SongListView.setItem(c , 2, twi)
|
|
||||||
self.SongListView.setRowHeight(c, 20)
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user