diff --git a/.eric4project/openlp.org 2.0.e4q b/.eric4project/openlp.org 2.0.e4q
index c90790196..33e29a204 100644
--- a/.eric4project/openlp.org 2.0.e4q
+++ b/.eric4project/openlp.org 2.0.e4q
@@ -1,7 +1,7 @@
-
+
-
+
\ No newline at end of file
diff --git a/.eric4project/openlp.org 2.0.e4t b/.eric4project/openlp.org 2.0.e4t
index 797daa910..8bf1b495d 100644
--- a/.eric4project/openlp.org 2.0.e4t
+++ b/.eric4project/openlp.org 2.0.e4t
@@ -1,7 +1,7 @@
-
+
TODO: what is the tags for bridge, pre-chorus?
@@ -111,4 +111,4 @@
534
-
+
\ No newline at end of file
diff --git a/openlp.org 2.0.e4p b/openlp.org 2.0.e4p
index f0695f12b..f1426e2f7 100644
--- a/openlp.org 2.0.e4p
+++ b/openlp.org 2.0.e4p
@@ -1,7 +1,7 @@
-
+
Python
@@ -66,7 +66,6 @@
openlp/plugins/bibles/bibleplugin.py
openlp/plugins/bibles/forms/bibleimportdialog.py
openlp/plugins/bibles/forms/bibleimportform.py
- openlp/plugins/bibles/lib/biblemanager.py
openlp/plugins/bibles/lib/bibleDBimpl.py
openlp/plugins/bibles/lib/bibleOSISimpl.py
openlp/plugins/bibles/lib/bibleHTTPimpl.py
@@ -74,7 +73,6 @@
openlp/plugins/bibles/__init__.py
openlp/plugins/bibles/lib/__init__.py
openlp/plugins/bibles/forms/__init__.py
- openlp/plugins/bibles/lib/biblecommon.py
openlp/plugins/songs/lib/__init__.py
openlp/plugins/songs/lib/songxml.py
openlp/plugins/songs/lib/models.py
@@ -93,12 +91,8 @@
openlp/plugins/videos/videoplugin.py
openlp/plugins/images/__init__.py
openlp/plugins/images/imageplugin.py
- openlp/plugins/songs/lib/songinterface.py
- openlp/plugins/songs/lib/songfile.py
openlp/plugins/songs/forms/editsongdialog.py
openlp/core/lib/pluginutils.py
- openlp/plugins/songs/lib/songmanager.py
- openlp/plugins/songs/lib/songDBimpl.py
openlpcnv.pyw
openlp/plugins/songs/forms/songbookdialog.py
openlp/plugins/songs/forms/topicsdialog.py
@@ -111,8 +105,17 @@
openlp/migration/migratesongs.py
openlp/migration/display.py
openlp/migration/migratebibles.py
- openlp/plugins/songs/lib/songclasses.py
- openlp/plugins/songs/lib/songtables.py
+ openlp/plugins/songs/lib/tables.py
+ openlp/plugins/songs/lib/classes.py
+ openlp/plugins/songs/lib/manager.py
+ openlp/plugins/bibles/lib/classes.py
+ openlp/plugins/bibles/lib/tables.py
+ openlp/plugins/bibles/lib/manager.py
+ openlp/plugins/bibles/lib/common.py
+ openlp/plugins/songs/lib/meta.py
+ openlp/core/test/testplugins/deeper/__init__.py
+ openlp/core/test/testplugins/deeper/toodeep/__init__.py
+ openlp/core/test/testplugins/deeper/toodeep/plugin3toodeep.py
@@ -148,7 +151,7 @@
openlp.pyw
- PySvn
+ Subversion
@@ -220,7 +223,7 @@
-
+
diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py
index d8a3b79a3..a1924a7b3 100644
--- a/openlp/plugins/songs/forms/editsongform.py
+++ b/openlp/plugins/songs/forms/editsongform.py
@@ -27,8 +27,6 @@ from songbookform import SongBookForm
from editsongdialog import Ui_EditSongDialog
-from openlp.plugins.songs.lib.models import Session, Song, Author, Topic
-
class EditSongForm(QWidget, Ui_EditSongDialog):
"""
Class documentation goes here.
@@ -61,11 +59,7 @@ class EditSongForm(QWidget, Ui_EditSongDialog):
self.AuthorsSelectionComboItem.addItem( i.display_name)
def load_song(self, songid):
- if songid == None: # We have a new Song
- self.song = Song()
- else:
- self.songid = songid
- self.song = self.songmanager.get_song(songid)
+ self.song = self.songmanager.get_song(songid)
self.TitleEditItem.setText(self.song.title)
self.LyricsTextEdit.setText(self.song.lyrics)
self.CopyrightEditItem.setText(self.song.copyright)
diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py
index 5e6f06d8a..f1164145d 100644
--- a/openlp/plugins/songs/lib/__init__.py
+++ b/openlp/plugins/songs/lib/__init__.py
@@ -18,8 +18,8 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
"""
-from songmanager import SongManager
-from songtable import Author
+from manager import SongManager
+#from xml import SongOpenXml
-__all__ = ['SongManager', 'Author']
+__all__ = ['SongManager']
diff --git a/openlp/plugins/songs/lib/classes.py b/openlp/plugins/songs/lib/classes.py
index eedcdd625..a693641d3 100644
--- a/openlp/plugins/songs/lib/classes.py
+++ b/openlp/plugins/songs/lib/classes.py
@@ -16,8 +16,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 sqlalchemy.orm import mapper, relation
-from openlp.plugins.songs.lib.tables import *
class BaseModel(object):
"""
@@ -58,14 +56,3 @@ class Topic(BaseModel):
Topic model
"""
pass
-
-
-mapper(Author, authors_table)
-mapper(Book, song_books_table)
-mapper(Song, songs_table,
- properties={'authors': relation(Author, backref='songs',
- secondary=authors_songs_table),
- 'book': relation(Book, backref='songs'),
- 'topics': relation(Topic, backref='songs',
- secondary=songs_topics_table)})
-mapper(Topic, topics_table)
diff --git a/openlp/plugins/songs/lib/manager.py b/openlp/plugins/songs/lib/manager.py
index 410d95827..372b3b7c0 100644
--- a/openlp/plugins/songs/lib/manager.py
+++ b/openlp/plugins/songs/lib/manager.py
@@ -23,7 +23,7 @@ import sys
from sqlalchemy import asc, desc
from openlp.plugins.songs.lib.models import init_models, metadata, session, \
- songs_table, Song, Author, Topic
+ engine, songs_table, Song, Author, Topic
import logging
@@ -47,15 +47,17 @@ class SongManager():
self.db_url = u''
db_type = self.config.get_config(u'db type')
if db_type == u'sqlite':
- self.db_url = u'sqlite://' + self.config.get_data_path() + \
+ self.db_url = u'sqlite:///' + self.config.get_data_path() + \
u'/songs.sqlite'
+ print self.db_url
else:
self.db_url = db_type + 'u://' + \
self.config.get_config(u'db username') + u':' + \
self.config.get_config(u'db password') + u'@' + \
self.config.get_config(u'db hostname') + u'/' + \
self.config.get_config(u'db database')
- init_models(self.db_url)
+ #print self.db_url
+ self.session = init_models(self.db_url)
if not songs_table.exists():
metadata.create_all()
log.debug( "Song Initialised")
@@ -67,19 +69,19 @@ class SongManager():
"""
Returns the details of a song
"""
- return session.query(Song).order_by(title).all()
+ return self.session.query(Song).order_by(title).all()
def search_song_title(self, keywords):
"""
Searches the song title for keywords.
"""
- return session.query(Song).filter(search_title.like(u'%' + keywords + u'%'))
+ return self.session.query(Song).filter(search_title.like(u'%' + keywords + u'%'))
def search_song_lyrics(self, keywords):
"""
Searches the song lyrics for keywords.
"""
- return session.query(Song).filter(search_lyrics.like(u'%' + keywords + u'%'))
+ return self.session.query(Song).filter(search_lyrics.like(u'%' + keywords + u'%'))
def get_song(self, id=None):
"""
@@ -88,23 +90,23 @@ class SongManager():
if id is None:
return Song()
else:
- return session.query(Song).get(id)
+ return self.session.query(Song).get(id)
def save_song(self, song):
"""
Saves a song to the database
"""
try:
- session.add(song)
- session.commit()
+ self.session.add(song)
+ self.session.commit()
return True
except:
return False
def delete_song(self, song):
try:
- session.delete(song)
- session.commit()
+ self.session.delete(song)
+ self.session.commit()
return True
except:
return False
@@ -113,21 +115,21 @@ class SongManager():
"""
Returns a list of all the authors
"""
- return session.query(Author).order_by(display_name).all()
+ return self.session.query(Author).order_by(Author.display_name).all()
def get_author(self, id):
"""
Details of the Author
"""
- return session.query(Author).get(id)
+ return self.session.query(Author).get(id)
def save_author(self, author):
"""
Save the Author and refresh the cache
"""
try:
- session.add(author)
- session.commit()
+ self.session.add(author)
+ self.session.commit()
return True
except:
return False
@@ -137,8 +139,8 @@ class SongManager():
Delete the author and refresh the author cache
"""
try:
- session.delete(author)
- session.commit()
+ self.session.delete(author)
+ self.session.commit()
return True
except:
return False
diff --git a/openlp/plugins/songs/lib/meta.py b/openlp/plugins/songs/lib/meta.py
index b9ba66b98..b3f02791b 100644
--- a/openlp/plugins/songs/lib/meta.py
+++ b/openlp/plugins/songs/lib/meta.py
@@ -30,4 +30,4 @@ session = None
# Global metadata. If you have multiple databases with overlapping table
# names, you'll need a metadata for each database
-metadata = MetaData()
\ No newline at end of file
+metadata = MetaData()
diff --git a/openlp/plugins/songs/lib/models.py b/openlp/plugins/songs/lib/models.py
index 81ba42e30..a609adf99 100644
--- a/openlp/plugins/songs/lib/models.py
+++ b/openlp/plugins/songs/lib/models.py
@@ -26,16 +26,16 @@ from openlp.plugins.songs.lib.classes import *
def init_models(url):
engine = create_engine(url)
+ metadata.bind = engine
session = scoped_session(sessionmaker(autoflush=True, autocommit=False,
bind=engine))
- metadata.bind = engine
-
-mapper(Author, authors_table)
-mapper(Book, song_books_table)
-mapper(Song, songs_table,
+ mapper(Author, authors_table)
+ mapper(Book, song_books_table)
+ mapper(Song, songs_table,
properties={'authors': relation(Author, backref='songs',
secondary=authors_songs_table),
'book': relation(Book, backref='songs'),
'topics': relation(Topic, backref='songs',
secondary=songs_topics_table)})
-mapper(Topic, topics_table)
+ mapper(Topic, topics_table)
+ return session
diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py
index 7f9f19c73..a5e451959 100644
--- a/openlp/plugins/songs/songsplugin.py
+++ b/openlp/plugins/songs/songsplugin.py
@@ -22,16 +22,15 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.resources import *
-from openlp.core.lib import Plugin,PluginUtils, MediaManagerItem
+from openlp.core.lib import Plugin, PluginUtils, MediaManagerItem
from forms import EditSongForm, OpenLPImportForm, OpenSongImportForm, \
OpenLPExportForm, OpenSongExportForm
from openlp.plugins.songs.lib import SongManager
-from openlp.plugins.songs.lib.songclasses import *
class SongsPlugin(Plugin, PluginUtils):
global log
log=logging.getLogger("SongsPlugin")
- log.info("Song Plugin loaded")
+ log.info("Song Plugin loaded")
def __init__(self):
# Call the parent constructor
Plugin.__init__(self, 'Songs', '1.9.0')
@@ -103,7 +102,7 @@ class SongsPlugin(Plugin, PluginUtils):
self.ClearTextButton = QtGui.QPushButton(self.SongWidget)
self.ClearTextButton.setObjectName('ClearTextButton')
self.ClearTextButton.setText('Clear')
- self.SearchLayout.addWidget(self.ClearTextButton, 3, 1, 1, 1)
+ self.SearchLayout.addWidget(self.ClearTextButton, 3, 1, 1, 1)
self.SearchTextButton = QtGui.QPushButton(self.SongWidget)
self.SearchTextButton.setObjectName('SearchTextButton')
self.SearchTextButton.setText('Search')
@@ -114,31 +113,31 @@ class SongsPlugin(Plugin, PluginUtils):
self.SongListView.setColumnCount(3)
self.SongListView.setColumnHidden(0, True)
self.SongListView.setColumnWidth(1, 200)
- self.SongListView.setColumnWidth(2, 80)
+ self.SongListView.setColumnWidth(2, 80)
self.SongListView.setShowGrid(False)
- self.SongListView.setSortingEnabled(False)
+ self.SongListView.setSortingEnabled(False)
self.SongListView.setAlternatingRowColors(True)
- self.SongListView.setHorizontalHeaderLabels(QtCore.QStringList(["","Song Name","Author"]))
+ self.SongListView.setHorizontalHeaderLabels(QtCore.QStringList(["","Song Name","Author"]))
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.onSearchTextButton)
- QtCore.QObject.connect(self.ClearTextButton, QtCore.SIGNAL("pressed()"), self.onClearTextButton)
- QtCore.QObject.connect(self.SearchTextEdit, QtCore.SIGNAL("textChanged(const QString&)"), self.onSearchTextEdit)
-
- QtCore.QObject.connect(self.SongListView, QtCore.SIGNAL("itemPressed(QTableWidgetItem * item)"), self.onSongSelected)
-
+
+ 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_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_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
def add_import_menu_item(self, import_menu):
@@ -194,35 +193,37 @@ class SongsPlugin(Plugin, PluginUtils):
QtCore.QObject.connect(self.ExportOpenSongItem, QtCore.SIGNAL("triggered()"), self.onExportOpenSongItemClicked)
def initialise(self):
- self.SearchTypeComboBox.addItem("Titles")
- self.SearchTypeComboBox.addItem("Lyrics")
- self.SearchTypeComboBox.addItem("Authors")
+ self.SearchTypeComboBox.addItem(u'Titles')
+ self.SearchTypeComboBox.addItem(u'Lyrics')
+ self.SearchTypeComboBox.addItem(u'Authors')
- def onClearTextButton(self):
+ def onClearTextButtonClick(self):
+ """
+ Clear the search text.
+ """
self.SearchTextEdit.clear()
- def onSearchTextEdit(self):
- sl = 3
- if self.SearchTypeComboBox.currentText()=="Lyrics":
- sl = 7
- if len(self.SearchTextEdit.displayText()) > sl: # only search if > 3 characters
- self.onSearchTextButton()
+ 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 onSearchTextButton(self):
- searchtext = str(self.SearchTextEdit.displayText() )
- searchresults = []
- ct = self.SearchTypeComboBox.currentText()
- if self.SearchTypeComboBox.currentText()=="Titles":
+ 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")
- searchresults = self.songmanager.get_song_from_title(searchtext)
- elif self.SearchTypeComboBox.currentText()=="Lyrics":
- log.debug("Lyrics Search")
- searchresults = self.songmanager.get_song_from_lyrics(searchtext)
- elif self.SearchTypeComboBox.currentText()=="Authors":
- log.debug("Authors Search")
- searchresults = self.songmanager.get_song_from_author(searchtext)
-
- self._display_results(searchresults)
+ search_results = self.songmanager.search_song_title(search_keywords)
+ elif search_type == u'Lyrics':
+ log.debug("Lyrics Search")
+ searchresults = 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
@@ -259,12 +260,12 @@ class SongsPlugin(Plugin, PluginUtils):
def onExportOpenSongItemClicked(self):
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(["","Song Name","Author"]))
- self.SongListView.setVerticalHeaderLabels(QtCore.QStringList([""]))
+ self.SongListView.setVerticalHeaderLabels(QtCore.QStringList([""]))
self.SongListView.setRowCount(0)
log.debug("Records returned from search %s", len(searchresults))
for song in searchresults:
@@ -272,10 +273,10 @@ class SongsPlugin(Plugin, PluginUtils):
c = self.SongListView.rowCount()
self.SongListView.setRowCount(c+1)
twi = QtGui.QTableWidgetItem(str(song.id))
- self.SongListView.setItem(c , 0, twi)
+ self.SongListView.setItem(c , 0, twi)
twi = QtGui.QTableWidgetItem(str(song.title))
- self.SongListView.setItem(c , 1, twi)
+ self.SongListView.setItem(c , 1, twi)
twi = QtGui.QTableWidgetItem(str(author.display_name))
self.SongListView.setItem(c , 2, twi)
self.SongListView.setRowHeight(c, 20)
-
+