Corrections from last merge

Clean up Bibles plugin
Clean up Custom plugin
Fix python 2.6 error mesage.
This commit is contained in:
Tim Bentley 2009-06-17 06:11:16 +01:00
commit 42d196d751
19 changed files with 121 additions and 443 deletions

View File

@ -43,4 +43,3 @@ class EventManager(object):
log.debug(u'post event called for event %s', event.event_type)
for point in self.endpoints:
point.handle_event(event)

View File

@ -41,7 +41,7 @@ class Receiver():
As there is only one instance of it in the systems the QT signal/slot architecture
can send messages across the system
Send message
Receiver().send_message(u'messageid",data)
Receiver().send_message(u'messageid',data)
Receive Message
QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL(u'openlprepaint'),<<ACTION>>)
@ -58,4 +58,4 @@ class Receiver():
@staticmethod
def get_receiver():
return Receiver.eventreceiver
return Receiver.eventreceiver

View File

@ -64,7 +64,6 @@ class PluginConfig(object):
return self.set_config(u'data path', os.path.basename(path))
def get_files(self, suffix=None):
#suffix = self.get_config(u'suffix name", default_suffixes)
try:
files = os.listdir(self.get_data_path())
except:
@ -136,4 +135,4 @@ class PluginConfig(object):
name = u'last directory %d' % num
else:
name = u'last directory'
self.set_config(name, directory)
self.set_config(name, directory)

View File

@ -73,7 +73,7 @@ class PluginManager(object):
try:
__import__(modulename, globals(), locals(), [])
except ImportError, e:
log.error(u'Failed to import module %s on path %s for reason %s', modulename, path, e.message)
log.error(u'Failed to import module %s on path %s for reason %s', modulename, path, sys.exc_info()[1])
self.plugin_classes = Plugin.__subclasses__()
self.plugins = []
plugin_objects = []

View File

@ -28,22 +28,6 @@ from renderer import Renderer
import sys
import linecache
def traceit(frame, event, arg):
"""
Code to allow calls to be traced by python runtime
"""
if event == "line":
lineno = frame.f_lineno
filename = frame.f_globals["__file__"]
if (filename.endswith(u'.pyc') or
filename.endswith(u'.pyo')):
filename = filename[:-1]
name = frame.f_globals["__name__"]
line = linecache.getline(filename, lineno)
if name.startswith(u'openlp'):
print "%s:%s: %s" % (name, lineno, line.rstrip())
return traceit
class RenderManager:
"""
Class to pull all Renderer interactions into one place.
@ -61,7 +45,7 @@ class RenderManager:
self.displays = len(screen_list)
self.current_display = screen_number
self.renderer = Renderer()
self.calculate_default(self.screen_list[self.current_display]['size'])
self.calculate_default(self.screen_list[self.current_display][u'size'])
self.theme = u''
self.service_theme = u''
self.global_style = u''
@ -73,7 +57,7 @@ class RenderManager:
log.debug(u'Update Display')
if self.current_display != screen_number:
self.current_display = screen_number
self.calculate_default(self.screen_list[self.current_display]['size'])
self.calculate_default(self.screen_list[self.current_display][u'size'])
def set_global_theme(self, global_theme, global_style = u'Global'):
self.global_theme = global_theme
@ -160,7 +144,6 @@ class RenderManager:
log.debug(u'calculate default %s' , screen)
self.width = screen.width()
self.height = screen.height()
self.width = 1024
self.height = 768
log.debug(u'calculate default %d,%d' , self.width, self.height)
self.footer_start = int(self.height*0.90) # 90% is start of footer
# 90% is start of footer
self.footer_start = int(self.height*0.90)

View File

@ -167,7 +167,7 @@ class GeneralTab(SettingsTab):
screen_name = translate(u'GeneralTab', u'Screen') + u' ' + \
unicode(screen[u'number'] + 1)
if screen[u'primary']:
screen_name = screen_name + u' (u' + \
screen_name = screen_name + u' (' + \
translate(u'GeneralTab', u'primary') + u')'
self.MonitorComboBox.addItem(screen_name)
# Get the configs
@ -191,4 +191,4 @@ class GeneralTab(SettingsTab):
self.config.set_config(u'Auto Open', self.AutoOpen)
self.config.set_config(u'CCL Number', self.CCLNumber)
self.config.set_config(u'User Name', self.Username)
self.config.set_config(u'Password', self.Password)
self.config.set_config(u'Password', self.Password)

View File

@ -114,4 +114,4 @@ class MainDisplay(QtGui.QWidget):
painter.end()
self.display.setPixmap(alertframe)
QtTest.QTest.qWait(self.alertTab.timeout*1000)
self.display.QtGui.QPixmap.fromImage(self.frame)
self.display.setPixmap(QtGui.QPixmap.fromImage(self.frame))

View File

@ -17,10 +17,7 @@ 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
"""
from textlistdata import TextListData
from common import BibleCommon
from manager import BibleManager
from biblestab import BiblesTab
from mediaitem import BibleMediaItem
__all__ = ['BibleCommon', 'BibleManager', 'BiblesTab', 'BibleMediaItem', 'TextListData']

View File

@ -29,16 +29,18 @@ class BibleOSISImpl():
def __init__(self, biblepath, bibledb):
self.bibledb = bibledb
self.booksOfBible = {} # books of the bible linked to bibleid {osis , name}
self.abbrevOfBible = {} # books of the bible linked to bibleid {osis ,Abbrev }
# books of the bible linked to bibleid {osis , name}
self.booksOfBible = {}
# books of the bible linked to bibleid {osis ,Abbrev }
self.abbrevOfBible = {}
filepath = os.path.split(os.path.abspath(__file__))[0]
filepath = os.path.abspath(os.path.join(filepath, u'..', u'resources',u'osisbooks.csv'))
fbibles=open(filepath, u'r')
for line in fbibles:
p = line.split(u',')
self.booksOfBible[p[0]] = p[1].replace(u'\n', '')
self.abbrevOfBible[p[0]] = p[2].replace(u'\n', '')
self.booksOfBible[p[0]] = p[1].replace(u'\n', u'')
self.abbrevOfBible[p[0]] = p[2].replace(u'\n', u'')
self.loadbible = True
QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL(u'openlpstopimport'),self.stop_import)
@ -64,8 +66,10 @@ class BibleOSISImpl():
ref = file[pos+15:epos-1] # Book Reference
#lets find the bible text only
pos = epos + 1 # find start of text
epos = file.find(u'</verse>', pos) # end of text
# find start of text
pos = epos + 1
# end of text
epos = file.find(u'</verse>', pos)
text = unicode(file[pos : epos], u'utf8')
#print pos, e, f[pos:e] # Found Basic Text
@ -103,12 +107,15 @@ class BibleOSISImpl():
#print p, ">>>", text
if book_ptr != p[0]:
if book_ptr == None: # first time through
if p[0] == u'Gen': # set the max book size depending on the first book read
# first time through
if book_ptr == None:
# set the max book size depending on the first book read
if p[0] == u'Gen':
dialogobject.setMax(65)
else:
dialogobject.setMax(27)
if p[0] == u'Matt': # First book of NT
# First book of NT
if p[0] == u'Matt':
testament += 1
book_ptr = p[0]
book = self.bibledb.create_book(self.booksOfBible[p[0]] , self.abbrevOfBible[p[0]], testament)
@ -117,7 +124,8 @@ class BibleOSISImpl():
count = 0
self.bibledb.add_verse(book.id, p[1], p[2], text)
count += 1
if count % 3 == 0: #Every 3 verses repaint the screen
#Every 3 verses repaint the screen
if count % 3 == 0:
Receiver().send_message(u'openlpprocessevents')
count = 0
@ -129,7 +137,7 @@ class BibleOSISImpl():
pos = text.find(start_tag)
while pos > -1:
epos = text.find(end_tag, pos)
if epos == -1: # TODO
if epos == -1:
#print "Y", pos, epos
pos = -1
else:

View File

@ -23,9 +23,8 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import ServiceItem, MediaManagerItem, Receiver, translate
from openlp.plugins.bibles.forms import BibleImportForm
from openlp.plugins.bibles.lib import TextListData
class BibleList(QtGui.QListView):
class BibleList(QtGui.QListWidget):
def __init__(self,parent=None,name=None):
QtGui.QListView.__init__(self,parent)
@ -189,13 +188,11 @@ class BibleMediaItem(MediaManagerItem):
self.SearchTabWidget.addTab(self.AdvancedTab, u'Advanced')
# Add the search tab widget to the page layout
self.PageLayout.addWidget(self.SearchTabWidget)
self.BibleListView = BibleList()
self.BibleListView.setAlternatingRowColors(True)
self.BibleListData = TextListData()
self.BibleListView.setModel(self.BibleListData)
self.BibleListView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
self.BibleListView.setDragEnabled(True)
self.PageLayout.addWidget(self.BibleListView)
self.BibleListWidget = BibleList()
self.BibleListWidget.setAlternatingRowColors(True)
self.BibleListWidget.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
self.BibleListWidget.setDragEnabled(True)
self.PageLayout.addWidget(self.BibleListWidget)
# Combo Boxes
QtCore.QObject.connect(self.AdvancedVersionComboBox,
QtCore.SIGNAL(u'activated(int)'), self.onAdvancedVersionComboBox)
@ -212,18 +209,18 @@ class BibleMediaItem(MediaManagerItem):
QtCore.SIGNAL(u'pressed()'), self.onAdvancedSearchButton)
QtCore.QObject.connect(self.QuickSearchButton,
QtCore.SIGNAL(u'pressed()'), self.onQuickSearchButton)
QtCore.QObject.connect(self.BibleListView,
QtCore.QObject.connect(self.BibleListWidget,
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onBiblePreviewClick)
# Context Menus
self.BibleListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.BibleListView.addAction(self.contextMenuAction(
self.BibleListView, u':/system/system_preview.png',
self.BibleListWidget.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.BibleListWidget.addAction(self.contextMenuAction(
self.BibleListWidget, u':/system/system_preview.png',
translate(u'BibleMediaItem',u'&Preview Verse'), self.onBiblePreviewClick))
self.BibleListView.addAction(self.contextMenuAction(
self.BibleListView, u':/system/system_live.png',
self.BibleListWidget.addAction(self.contextMenuAction(
self.BibleListWidget, u':/system/system_live.png',
translate(u'BibleMediaItem',u'&Show Live'), self.onBibleLiveClick))
self.BibleListView.addAction(self.contextMenuAction(
self.BibleListView, u':/system/system_add.png',
self.BibleListWidget.addAction(self.contextMenuAction(
self.BibleListWidget, u':/system/system_add.png',
translate(u'BibleMediaItem',u'&Add to Service'), self.onBibleAddClick))
def retranslateUi(self):
@ -293,7 +290,8 @@ class BibleMediaItem(MediaManagerItem):
if t1 != t2:
bible = unicode(self.AdvancedVersionComboBox.currentText())
book = unicode(self.AdvancedBookComboBox.currentText())
vse = self.parent.biblemanager.get_book_verse_count(bible, book, int(t2))[0] # get the verse count for new chapter
# get the verse count for new chapter
vse = self.parent.biblemanager.get_book_verse_count(bible, book, int(t2))[0]
self.adjustComboBox(1, vse, self.AdvancedToVerse)
def onAdvancedSearchButton(self):
@ -307,15 +305,16 @@ class BibleMediaItem(MediaManagerItem):
self.search_results = self.parent.biblemanager.get_verse_text(bible, book,
chapter_from, chapter_to, verse_from, verse_to)
if self.ClearAdvancedSearchComboBox.currentIndex() == 0:
self.BibleListData.resetStore()
self.displayResults(bible)
self.BibleListWidget.clear()
self.displayResults(bible)
def onAdvancedFromChapter(self):
bible = unicode(self.AdvancedVersionComboBox.currentText())
book = unicode(self.AdvancedBookComboBox.currentText())
cf = self.AdvancedFromChapter.currentText()
self.adjustComboBox(cf, self.chapters_from, self.AdvancedToChapter)
vse = self.parent.biblemanager.get_book_verse_count(bible, book, int(cf))[0] # get the verse count for new chapter
# get the verse count for new chapter
vse = self.parent.biblemanager.get_book_verse_count(bible, book, int(cf))[0]
self.adjustComboBox(1, vse, self.AdvancedFromVerse)
self.adjustComboBox(1, vse, self.AdvancedToVerse)
@ -324,12 +323,12 @@ class BibleMediaItem(MediaManagerItem):
bible = unicode(self.QuickVersionComboBox.currentText())
text = unicode(self.QuickSearchEdit.displayText())
if self.ClearQuickSearchComboBox.currentIndex() == 0:
self.BibleListData.resetStore()
self.BibleListWidget.clear()
if self.QuickSearchComboBox.currentIndex() == 1:
self.search_results = self.parent.biblemanager.get_verse_from_text(bible, text)
else:
self.searchByReference(bible, text)
if not self.search_results == None:
if self.search_results is not None:
self.displayResults(bible)
def onBibleLiveClick(self):
@ -352,13 +351,14 @@ class BibleMediaItem(MediaManagerItem):
def generateSlideData(self, service_item):
log.debug(u'generating slide data')
items = self.BibleListView.selectedIndexes()
items = self.BibleListWidget.selectedIndexes()
old_chapter = u''
raw_slides=[]
raw_footer = []
bible_text = u''
for item in items:
text = self.BibleListData.getValue(item)
bitem = self.BibleListWidget.item(item.row())
text = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
verse = text[:text.find(u'(')]
bible = text[text.find(u'(') + 1:text.find(u')')]
self.searchByReference(bible, verse)
@ -433,8 +433,10 @@ class BibleMediaItem(MediaManagerItem):
def displayResults(self, bible):
for book, chap, vse , txt in self.search_results:
text = unicode(u' %s %d:%d (%s)'%(book , chap,vse, bible))
self.BibleListData.addRow(0,text)
bible_text = unicode(u' %s %d:%d (%s)'%(book , chap,vse, bible))
bible_verse = QtGui.QListWidgetItem(bible_text)
bible_verse.setData(QtCore.Qt.UserRole, QtCore.QVariant(bible_text))
self.BibleListWidget.addItem(bible_verse)
def searchByReference(self, bible, search):
log.debug(u'searchByReference %s ,%s', bible, search)

View File

@ -1,83 +0,0 @@
# -*- 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-2009 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
class TextListData(QtCore.QAbstractListModel):
"""
An abstract list of strings
"""
global log
log = logging.getLogger(u'TextListData')
log.info(u'started')
def __init__(self):
QtCore.QAbstractListModel.__init__(self)
# will be a list of (database id , title) tuples
self.items = []
def resetStore(self):
#reset list so can be reloaded
self.items = []
def rowCount(self, parent):
return len(self.items)
def insertRow(self, row, id, title):
self.beginInsertRows(QtCore.QModelIndex(),row,row)
log.debug(u'insert row %d:%s for id %d' % (row,title, id))
self.items.insert(row, (id, title))
self.endInsertRows()
def removeRow(self, row):
self.beginRemoveRows(QModelIndex(), row,row)
self.items.pop(row)
self.endRemoveRows()
def addRow(self, id, title):
self.insertRow(len(self.items), id, title)
def data(self, index, role):
row = index.row()
# if the last row is selected and deleted, we then get called with an empty row!
if row > len(self.items):
return QtCore.QVariant()
if role == QtCore.Qt.DisplayRole:
retval = self.items[row][1]
else:
retval = QtCore.QVariant()
if type(retval) is not type(QtCore.QVariant):
return QtCore.QVariant(retval)
else:
return retval
def getIdList(self):
filelist = [item[0] for item in self.items];
return filelist
def getValue(self, index):
row = index.row()
return self.items[row][1]
def deleteRow(self, index):
row = index.row()
self.removeRow(row)

View File

@ -23,7 +23,7 @@ from PyQt4 import QtCore, QtGui
from forms import EditCustomForm
from openlp.core.lib import Plugin, Event, EventType
from openlp.plugins.custom.lib import CustomManager, CustomTab, CustomMediaItem, CustomServiceItem
from openlp.plugins.custom.lib import CustomManager, CustomTab, CustomMediaItem
class CustomPlugin(Plugin):
@ -42,8 +42,6 @@ class CustomPlugin(Plugin):
self.icon = QtGui.QIcon()
self.icon.addPixmap(QtGui.QPixmap(u':/media/media_custom.png'),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.preview_service_item = CustomServiceItem(self.preview_controller)
self.live_service_item = CustomServiceItem(self.live_controller)
def get_media_manager_item(self):
# Create the CustomManagerItem object
@ -66,4 +64,4 @@ class CustomPlugin(Plugin):
self.media_item.onCustomPreviewClick()
if event.event_type == EventType.LiveShow and event.payload == 'Custom':
log.debug(u'Load Live Show Item received')
self.media_item.onCustomLiveClick()
self.media_item.onCustomLiveClick()

View File

@ -32,6 +32,7 @@ class Ui_customEditDialog(object):
self.horizontalLayout_4.setObjectName(u'horizontalLayout_4')
self.VerseListView = QtGui.QListWidget(customEditDialog)
self.VerseListView.setObjectName(u'VerseListView')
self.VerseListView.setAlternatingRowColors(True)
self.horizontalLayout_4.addWidget(self.VerseListView)
self.verticalLayout = QtGui.QVBoxLayout()
self.verticalLayout.setObjectName(u'verticalLayout')
@ -107,7 +108,6 @@ class Ui_customEditDialog(object):
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName(u'buttonBox')
self.gridLayout.addWidget(self.buttonBox, 5, 0, 1, 1)
self.retranslateUi(customEditDialog)
QtCore.QMetaObject.connectSlotsByName(customEditDialog)
customEditDialog.setTabOrder(self.TitleEdit, self.VerseTextEdit)

View File

@ -53,7 +53,6 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
# Create other objects and forms
self.custommanager = custommanager
self.initialise()
self.VerseListView.setAlternatingRowColors(True)
def initialise(self):
self.valid = True
@ -96,8 +95,7 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
self.ThemecomboBox.setCurrentIndex(0)
def accept(self):
self.validate()
if self.valid:
if self.validate():
sxml=SongXMLBuilder()
sxml.new_document()
sxml.add_lyrics_to_song()
@ -124,7 +122,8 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
def onDownButtonPressed(self):
selectedRow = self.VerseListView.currentRow()
if selectedRow != self.VerseListView.count() - 1: # zero base arrays
# zero base arrays
if selectedRow != self.VerseListView.count() - 1:
qw = self.VerseListView.takeItem(selectedRow)
self.VerseListView.insertItem(selectedRow + 1, qw)
self.VerseListView.setCurrentRow(selectedRow + 1)
@ -146,6 +145,7 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
self.VerseListView.addItem(self.VerseTextEdit.toPlainText())
self.DeleteButton.setEnabled(False)
self.VerseTextEdit.clear()
self.validate()
def onEditButtonPressed(self):
self.VerseTextEdit.setPlainText(self.VerseListView.currentItem().text())
@ -163,16 +163,16 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
self.EditButton.setEnabled(False)
def validate(self):
invalid = 0
self.valid = True
valid = True
if len(self.TitleEdit.displayText()) == 0:
invalid += 1
self.TitleLabel.setStyleSheet(u'color: red')
valid = False
self.TitleEdit.setStyleSheet(u'background-color: red; color: white')
else:
self.TitleLabel.setStyleSheet(u'color: black')
if self.VerseListView.count() == 0: # must have 1 slide
invalid += 1
if invalid == 1:
self.valid = False
self.TitleEdit.setStyleSheet(u'')
# must have 1 slide
if self.VerseListView.count() == 0:
valid = False
self.VerseListView.setStyleSheet(u'background-color: red; color: white')
else:
self.VerseListView.setStyleSheet(u'')
return valid

View File

@ -17,9 +17,6 @@ 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
"""
from textlistdata import TextListData
from customserviceitem import CustomServiceItem
from manager import CustomManager
from customtab import CustomTab
from mediaitem import CustomMediaItem

View File

@ -1,117 +0,0 @@
# -*- 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
"""
from PyQt4 import QtCore, QtGui
import logging
from openlp.core.lib import ServiceItem
from openlp.plugins.custom.lib import TextListData
class CustomServiceItem(ServiceItem):
"""
The service item is a base class for the plugins to use to interact with
* the service manager (and hence the OOS disk files),
* the slide controller(s - both preview and live)
* and the renderer - which produces the
main screen
the preview preview and
the live preview
The image plugin passes one of these to the preview/live when requested
The preview/live controllers keep hold of it
The service manager has one in its service structure for each Image item in the OOS
When something goes live/previews -
it simply tells the slide controller to use it???
It contains 1 or more images
"""
global log
log=logging.getLogger(u'CustomServiceItem')
log.info(u'CustomServiceItem loaded')
def __init__(self, controller):
"""
Init Method
"""
log.info(u'init')
self.imgs=TextListData()
# self.slide_controller=controller
# self.slide_controller.ControllerContents=QtGui.QListView()
# c=self.slide_controller.ControllerContents
# c.uniformItemSizes=True
# c.setModel(self.imgs)
# c.setGeometry(0,0,200,200)
def render(self):
"""
The render method is what the plugin uses to render its meda to the
screen.
"""
# render the "image chooser first"
# for f in self.imgs:
# fl , nm = os.path.split(unicode(f))
# c = self.slide_controller.rowCount()
# self.slide_controller.setRowCount(c+1)
# twi = QtGui.QTableWidgetItem(unicode(f))
# self.slide_controller.setItem(c , 0, twi)
# twi = QtGui.QTableWidgetItem(unicode(nm))
# self.slide_controller.setItem(c , 1, twi)
# self.slide_controller.setRowHeight(c, 80)
# render the preview screen here
def get_parent_node(self):
"""
This method returns a parent node to be inserted into the Service
Manager.
"""
pass
def add(self, data):
"""
append an image to the list
"""
if type(data)==type(u'string'):
log.info(u'add filename:'+data)
self.imgs.addRow(data)
else: # it's another service item to be merged in
log.info(u'add Item...'+unicode(data))
for filename in data.imgs.get_file_list():
self.add(filename)
def get_oos_text(self):
"""
Turn the image list into a set of filenames for storage in the oos file
"""
log.info(u'Get oos text')
log.info(unicode(self.imgs))
log.info(unicode(self.imgs.get_file_list()))
return '\n'.join(self.imgs.get_file_list())
def set_from_oos(self, text):
"""
get text from the OOS file and setup the internal structure
"""
log.info(u'Set from OOS:'+text)
files=text.split(u'\n')
for f in files:
self.imgs.addRow(f)

View File

@ -22,9 +22,8 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, SongXMLParser, ServiceItem, translate
from openlp.plugins.custom.lib import TextListData
class CustomList(QtGui.QListView):
class CustomList(QtGui.QListWidget):
def __init__(self,parent=None,name=None):
QtGui.QListView.__init__(self,parent)
@ -103,60 +102,38 @@ class CustomMediaItem(MediaManagerItem):
self.CustomWidget.setObjectName(u'CustomWidget')
# Add the Custom widget to the page layout
self.PageLayout.addWidget(self.CustomWidget)
self.CustomListView = CustomList()
self.CustomListView.setAlternatingRowColors(True)
self.CustomListData = TextListData()
self.CustomListView.setModel(self.CustomListData)
self.CustomListView.setDragEnabled(True)
self.PageLayout.addWidget(self.CustomListView)
self.CustomListWidget = CustomList()
self.CustomListWidget.setAlternatingRowColors(True)
self.CustomListWidget.setDragEnabled(True)
self.PageLayout.addWidget(self.CustomListWidget)
# Signals
QtCore.QObject.connect(self.CustomListView,
QtCore.QObject.connect(self.CustomListWidget,
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onCustomPreviewClick)
#define and add the context menu
self.CustomListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.CustomListView.addAction(self.contextMenuAction(self.CustomListView,
self.CustomListWidget.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.CustomListWidget.addAction(self.contextMenuAction(self.CustomListWidget,
':/custom/custom_edit.png', translate(u'CustomMediaItem', u'&Edit Custom'),
self.onCustomEditClick))
self.CustomListView.addAction(self.contextMenuSeparator(self.CustomListView))
self.CustomListView.addAction(self.contextMenuAction(
self.CustomListView, ':/system/system_preview.png',
self.CustomListWidget.addAction(self.contextMenuSeparator(self.CustomListWidget))
self.CustomListWidget.addAction(self.contextMenuAction(
self.CustomListWidget, ':/system/system_preview.png',
translate(u'CustomMediaItem',u'&Preview Custom'), self.onCustomPreviewClick))
self.CustomListView.addAction(self.contextMenuAction(
self.CustomListView, ':/system/system_live.png',
self.CustomListWidget.addAction(self.contextMenuAction(
self.CustomListWidget, ':/system/system_live.png',
translate(u'CustomMediaItem',u'&Show Live'), self.onCustomLiveClick))
self.CustomListView.addAction(self.contextMenuAction(
self.CustomListView, ':/system/system_add.png',
self.CustomListWidget.addAction(self.contextMenuAction(
self.CustomListWidget, ':/system/system_add.png',
translate(u'CustomMediaItem',u'&Add to Service'), self.onCustomAddClick))
# def retranslateUi(self):
# self.ClearTextButton.setText(translate(u'CustomMediaItem', u'Clear'))
# self.SearchTextButton.setText(translate(u'CustomMediaItem', u'Search'))
def initialise(self):
self.loadCustomList(self.parent.custommanager.get_all_slides())
def loadCustomList(self, list):
self.CustomListData.resetStore()
self.CustomListWidget.clear()
for CustomSlide in list:
self.CustomListData.addRow(CustomSlide.id,CustomSlide.title)
def onClearTextButtonClick(self):
"""
Clear the search text.
"""
self.SearchTextEdit.clear()
def onSearchTextEditChanged(self, text):
# only search if > 3 characters
if len(text) > 3:
self.onSearchTextButtonClick()
def onSearchTextButtonClick(self):
search_keywords = unicode(self.SearchTextEdit.displayText())
search_results = []
search_type = self.SearchTypeComboBox.currentText()
search_results = self.Custommanager.search_Custom_lyrics(search_keywords)
self._display_results(search_results)
custom_name = QtGui.QListWidgetItem(CustomSlide.title)
custom_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(CustomSlide.id))
self.CustomListWidget.addItem(custom_name)
def onCustomNewClick(self):
self.parent.edit_custom_form.loadCustom(0)
@ -164,18 +141,18 @@ class CustomMediaItem(MediaManagerItem):
self.initialise()
def onCustomEditClick(self):
indexes = self.CustomListView.selectedIndexes()
for index in indexes:
self.parent.edit_custom_form.loadCustom(self.CustomListData.getId(index))
self.parent.edit_custom_form.exec_()
item = self.CustomListWidget.currentItem()
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.parent.edit_custom_form.loadCustom(item_id)
self.parent.edit_custom_form.exec_()
self.initialise()
def onCustomDeleteClick(self):
indexes = self.CustomListView.selectedIndexes()
for index in indexes:
id = self.CustomListData.getId(index)
self.parent.custommanager.delete_custom(id)
self.CustomListData.deleteRow(index)
item = self.CustomListWidget.currentItem()
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.parent.custommanager.delete_custom(item_id)
row = self.CustomListWidget.row(item)
self.CustomListWidget.takeItem(row)
def onCustomPreviewClick(self):
log.debug(u'Custom Preview Requested')
@ -203,22 +180,21 @@ class CustomMediaItem(MediaManagerItem):
raw_footer = []
slide = None
theme = None
indexes = self.CustomListView.selectedIndexes()
for index in indexes:
id = self.CustomListData.getId(index)
customSlide = self.parent.custommanager.get_custom(id)
title = customSlide.title
credit = customSlide.credits
theme = customSlide.theme_name
if len(theme) is not 0 :
service_item.theme = theme
songXML=SongXMLParser(customSlide.text)
verseList = songXML.get_verses()
for verse in verseList:
raw_slides.append(verse[1])
raw_footer.append(title + u' '+ credit)
item = self.CustomListWidget.currentItem()
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
customSlide = self.parent.custommanager.get_custom(item_id)
title = customSlide.title
credit = customSlide.credits
theme = customSlide.theme_name
if len(theme) is not 0 :
service_item.theme = theme
songXML=SongXMLParser(customSlide.text)
verseList = songXML.get_verses()
for verse in verseList:
raw_slides.append(verse[1])
raw_footer.append(title + u' '+ credit)
if theme is not None:
service_item.title = title
for slide in raw_slides:
service_item.add_from_text(slide[:30], slide)
service_item.raw_footer = raw_footer
service_item.raw_footer = raw_footer

View File

@ -1,80 +0,0 @@
# -*- 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-2009 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
class TextListData(QtCore.QAbstractListModel):
"""
An abstract list of strings
"""
global log
log = logging.getLogger(u'TextListData')
log.info(u'started')
def __init__(self):
QtCore.QAbstractListModel.__init__(self)
self.items = [] # will be a list of (database id , title) tuples
def resetStore(self):
#reset list so can be reloaded
self.items = []
def rowCount(self, parent):
return len(self.items)
def insertRow(self, row, id, title):
self.beginInsertRows(QtCore.QModelIndex(),row,row)
log.debug(u'insert row %d:%s for id %d' % (row,title, id))
self.items.insert(row, (id, title))
self.endInsertRows()
def removeRow(self, row):
self.beginRemoveRows(QtCore.QModelIndex(), row,row)
self.items.pop(row)
self.endRemoveRows()
def addRow(self, id, title):
self.insertRow(len(self.items), id, title)
def data(self, index, role):
row = index.row()
if row > len(self.items): # if the last row is selected and deleted, we then get called with an empty row!
return QtCore.QVariant()
if role == QtCore.Qt.DisplayRole:
retval = self.items[row][1]
else:
retval = QtCore.QVariant()
if type(retval) is not type(QtCore.QVariant):
return QtCore.QVariant(retval)
else:
return retval
def getIdList(self):
filelist = [item[0] for item in self.items];
return filelist
def getId(self, index):
row = index.row()
return self.items[row][0]
def deleteRow(self, index):
row = index.row()
self.removeRow(row)

View File

@ -357,7 +357,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
def onAccept(self):
log.debug(u'OnAccept')
#self.song.topics.append(9) << need opject here
if not self._validate_song():
return
self.song.title = unicode(self.TitleEditItem.displayText())
@ -390,7 +389,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
text = text.replace(u',', u'')
text = text.replace(u';', u'')
text = text.replace(u':', u'')
text = text.replace(u'(u', u'')
text = text.replace(u'(', u'')
text = text.replace(u')', u'')
text = text.replace(u'{', u'')
text = text.replace(u'}', u'')
@ -404,7 +403,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.song.search_title = self.song.search_title.replace(u',', u'')
self.song.search_title = self.song.search_title.replace(u';', u'')
self.song.search_title = self.song.search_title.replace(u':', u'')
self.song.search_title = self.song.search_title.replace(u'(u', u'')
self.song.search_title = self.song.search_title.replace(u'(', u'')
self.song.search_title = self.song.search_title.replace(u')', u'')
self.song.search_title = self.song.search_title.replace(u'{', u'')
self.song.search_title = self.song.search_title.replace(u'}', u'')