openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #00119
[Merge] lp:~trb143/openlp/servicing2 into lp:openlp
Tim Bentley has proposed merging lp:~trb143/openlp/servicing2 into lp:openlp.
Requested reviews:
openlp.org Core (openlp-core)
Add Author Search to Songs plugin
Add Page_up/Down to SlideController
--
https://code.launchpad.net/~trb143/openlp/servicing2/+merge/7735
Your team openlp.org Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/songxmlhandler.py'
--- openlp/core/lib/songxmlhandler.py 2009-06-16 18:21:24 +0000
+++ openlp/core/lib/songxmlhandler.py 2009-06-21 16:26:33 +0000
@@ -29,6 +29,7 @@
</song>
"""
+import logging
from xml.dom.minidom import Document
from xml.etree.ElementTree import ElementTree, XML, dump
@@ -70,11 +71,20 @@
def extract_xml(self):
# Print our newly created XML
- return self.song_xml.toxml()
+ return self.song_xml.toxml(u'utf-8')
class SongXMLParser():
+ global log
+ log = logging.getLogger(u'SongXMLParser')
+ log.info(u'SongXMLParser Loaded')
+
def __init__(self, xml):
- self.song_xml = ElementTree(element=XML(xml))
+ #print xml
+ try:
+ self.song_xml = ElementTree(element=XML(xml))
+ except:
+ #print "invalid xml ", xml
+ log.debug(u'invalid xml %s', xml)
def get_verses(self):
#return a list of verse's and attributes
=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py 2009-06-20 10:44:12 +0000
+++ openlp/core/ui/slidecontroller.py 2009-06-21 16:26:33 +0000
@@ -21,14 +21,11 @@
import os
from PyQt4 import QtCore, QtGui
-
from openlp.core.lib import OpenLPToolbar, translate
class SlideData(QtCore.QAbstractListModel):
"""
- Tree of items for an order of Theme.
- Includes methods for reading and writing the contents to an OOS file
- Root contains a list of ThemeItems
+ List of frames to be displayed on the list and the main display.
"""
global log
log = logging.getLogger(u'SlideData')
@@ -98,6 +95,24 @@
filelist = [item[3] for item in self.items];
return filelist
+class SlideList(QtGui.QListView):
+
+ def __init__(self,parent=None,name=None):
+ QtGui.QListView.__init__(self,parent.Controller)
+ self.parent = parent
+
+ def keyPressEvent(self, event):
+ if type(event) == QtGui.QKeyEvent:
+ #here accept the event and do something
+ if event.key() == QtCore.Qt.Key_PageUp:
+ self.parent.onSlideSelectedPrevious()
+ event.accept()
+ elif event.key() == QtCore.Qt.Key_PageDown:
+ self.parent.onSlideSelectedNext()
+ event.accept()
+ event.ignore()
+ else:
+ event.ignore()
class SlideController(QtGui.QWidget):
"""
@@ -132,7 +147,7 @@
self.ControllerLayout.setSpacing(0)
self.ControllerLayout.setMargin(0)
# Controller list view
- self.PreviewListView = QtGui.QListView(self.Controller)
+ self.PreviewListView = SlideList(self)
self.PreviewListView.setUniformItemSizes(True)
self.PreviewListView.setIconSize(QtCore.QSize(250, 190))
self.PreviewListData = SlideData()
@@ -210,6 +225,11 @@
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected)
QtCore.QObject.connect(self.PreviewListView,
QtCore.SIGNAL(u'activated(QModelIndex)'), self.onSlideSelected)
+ QtCore.QObject.connect(self.PreviewListView,
+ QtCore.SIGNAL(u'entered(QModelIndex)'), self.onTest)
+
+ def onTest(self , item):
+ print "found", item
def onSlideSelectedFirst(self):
"""
=== modified file 'openlp/plugins/songs/lib/manager.py'
--- openlp/plugins/songs/lib/manager.py 2009-06-14 13:50:56 +0000
+++ openlp/plugins/songs/lib/manager.py 2009-06-21 17:45:59 +0000
@@ -60,8 +60,8 @@
metadata.create_all()
log.debug(u'Song Initialised')
- def process_dialog(self, dialogobject):
- self.dialogobject = dialogobject
+# def process_dialog(self, dialogobject):
+# self.dialogobject = dialogobject
def get_songs(self):
"""
@@ -81,6 +81,12 @@
"""
return self.session.query(Song).filter(Song.search_lyrics.like(u'%' + keywords + u'%')).order_by(Song.search_lyrics.asc()).all()
+ def get_song_from_author(self, keywords):
+ """
+ Searches the song authors for keywords.
+ """
+ return self.session.query(Author).filter(Author.display_name.like(u'%' + keywords + u'%')).order_by(Author.display_name.asc()).all()
+
def get_song(self, id=None):
"""
Returns the details of a song
=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py 2009-06-19 18:41:38 +0000
+++ openlp/plugins/songs/lib/mediaitem.py 2009-06-21 17:45:59 +0000
@@ -160,8 +160,25 @@
self.SearchTypeComboBox.addItem(translate(u'SongMediaItem', u'Lyrics'))
self.SearchTypeComboBox.addItem(translate(u'SongMediaItem', u'Authors'))
- def displayResults(self, searchresults):
- log.debug(u'display results')
+ def onSearchTextButtonClick(self):
+ search_keywords = unicode(self.SearchTextEdit.displayText())
+ search_results = []
+ search_type = self.SearchTypeComboBox.currentIndex()
+ if search_type == 0:
+ log.debug(u'Titles Search')
+ search_results = self.parent.songmanager.search_song_title(search_keywords)
+ self.displayResultsSong(search_results)
+ elif search_type == 1:
+ log.debug(u'Lyrics Search')
+ search_results = self.parent.songmanager.search_song_lyrics(search_keywords)
+ self.displayResultsSong(search_results)
+ elif search_type == 2:
+ log.debug(u'Authors Search')
+ search_results = self.parent.songmanager.get_song_from_author(search_keywords)
+ self.displayResultsAuthor(search_results)
+
+ def displayResultsSong(self, searchresults):
+ log.debug(u'display results Song')
self.SongListWidget.clear()
#log.debug(u'Records returned from search %s", len(searchresults))
for song in searchresults:
@@ -175,6 +192,16 @@
song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id))
self.SongListWidget.addItem(song_name)
+ def displayResultsAuthor(self, searchresults):
+ log.debug(u'display results Author')
+ self.SongListWidget.clear()
+ for author in searchresults:
+ for song in author.songs:
+ song_detail = unicode(u'%s (%s)' % (unicode(author.display_name), unicode(song.title)))
+ song_name = QtGui.QListWidgetItem(song_detail)
+ song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id))
+ self.SongListWidget.addItem(song_name)
+
def onClearTextButtonClick(self):
"""
Clear the search text.
@@ -188,21 +215,6 @@
if len(text) > search_length:
self.onSearchTextButtonClick()
- def onSearchTextButtonClick(self):
- search_keywords = unicode(self.SearchTextEdit.displayText())
- search_results = []
- search_type = self.SearchTypeComboBox.currentIndex()
- if search_type == 0:
- log.debug(u'Titles Search')
- search_results = self.parent.songmanager.search_song_title(search_keywords)
- elif search_type == 1:
- log.debug(u'Lyrics Search')
- search_results = self.parent.songmanager.search_song_lyrics(search_keywords)
- elif search_type == 2:
- log.debug(u'Authors Search')
- #searchresults = self.songmanager.get_song_from_author(searchtext)
- self.displayResults(search_results)
-
def onSongNewClick(self):
self.edit_song_form.newSong()
self.edit_song_form.exec_()
=== modified file 'openlp/plugins/songs/songsplugin.py'
--- openlp/plugins/songs/songsplugin.py 2009-06-16 18:21:24 +0000
+++ openlp/plugins/songs/songsplugin.py 2009-06-21 17:45:59 +0000
@@ -103,7 +103,7 @@
QtCore.QObject.connect(self.ExportOpenSongItem, QtCore.SIGNAL(u'triggered()'), self.onExportOpenSongItemClicked)
def initialise(self):
- self.media_item.displayResults(self.songmanager.get_songs())
+ self.media_item.displayResultsSong(self.songmanager.get_songs())
def onImportOpenlp1ItemClick(self):
self.openlp_import_form.show()
@@ -136,4 +136,4 @@
self.media_item.onSongLiveClick()
if event.event_type == EventType.LoadSongList :
log.debug(u'Load Load Song List Item received')
- self.media_item.displayResults(self.songmanager.get_songs())
\ No newline at end of file
+ self.media_item.displayResults(self.songmanager.get_songs())
Follow ups