Merged from trunk

This commit is contained in:
Martin Thompson 2009-06-24 20:46:06 +01:00
commit 726c8826b2
14 changed files with 289 additions and 282 deletions

23
cnvdb.py Normal file
View File

@ -0,0 +1,23 @@
import codecs
class Convert():
def __init__(self):
pass
def process(self, inname, outname):
infile = codecs.open(inname, 'r', encoding='iso-8859-1')
writefile = codecs.open(outname, 'w', encoding='utf-8')
count = 0
for line in infile:
writefile.write(line)
if count < 150:
print line
count += 1
infile.close()
writefile.close()
if __name__ == '__main__':
mig = Convert()
mig.process(u'/home/timali/.local/share/openlp/songs/songs.dmp',u'/home/timali/.local/share/openlp/songs/songs.dmp2')

View File

@ -16,8 +16,6 @@ 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 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 xml.dom.minidom import Document
from xml.etree.ElementTree import ElementTree, XML, dump
For XML Schema see wiki.openlp.org For XML Schema see wiki.openlp.org
""" """
@ -256,5 +254,5 @@ class ThemeXML():
s = u'' s = u''
for k in dir(self): for k in dir(self):
if k[0:1] != u'_': if k[0:1] != u'_':
s += u'%30s : %s\n' %(k,getattr(self,k)) s += u'%30s : %s\n' %(k, getattr(self, k))
return s return s

View File

@ -1,9 +1,26 @@
# -*- 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, Carsten Tinggaard
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 platform import platform
ver = platform.python_version() import types
if ver >= '2.5': from xml.etree.ElementTree import ElementTree, XML
from xml.etree.ElementTree import ElementTree, XML
else:
from elementtree import ElementTree, XML
from PyQt4 import QtGui from PyQt4 import QtGui
@ -59,7 +76,7 @@ class Theme:
FontName : name of font to use FontName : name of font to use
FontColor : color for main font FontColor : color for main font
FontProportion : size of font FontProportion : size of font
FontUnits : whether size of font is in <pixels> or <points> FontUnits : whether size of font is in <pixels> or <points>
Shadow : 0 - no shadow, non-zero use shadow Shadow : 0 - no shadow, non-zero use shadow
ShadowColor : color for drop shadow ShadowColor : color for drop shadow
@ -78,52 +95,57 @@ class Theme:
# init to defaults # init to defaults
self._set_from_XML(blankstylexml) self._set_from_XML(blankstylexml)
self._set_from_XML(xml) self._set_from_XML(xml)
# print self.__str__()
def _get_as_string(self): def _get_as_string(self):
s="" s = u''
keys=dir(self) keys=dir(self)
keys.sort() keys.sort()
for k in keys: for k in keys:
if k[0:1] != "_": if k[0:1] != u'_':
s+= "_%s_" %(getattr(self,k)) s += u'_%s_' %(getattr(self,k))
return s return s
def _set_from_XML(self, xml): def _set_from_XML(self, xml):
root=ElementTree(element=XML(xml)) root = ElementTree(element=XML(xml))
iter=root.getiterator() iter = root.getiterator()
for element in iter: for element in iter:
if element.tag != "Theme": if element.tag != u'Theme':
t=element.text t = element.text
# print element.tag, t, type(t) # print element.tag, t, type(t)
if type(t) == type(None): # easy! val = 0
val=t # easy!
if type(t) == type(u' '): # strings need special handling to sort the colours out if type(t) == type(None):
# print "str", val = t
if t[0] == "$": # might be a hex number # strings need special handling to sort the colours out
# print "hex", if type(t) is types.StringType or type(t) is types.UnicodeType:
# print u'str',
if t[0] == u'$': # might be a hex number
# print u'hex',
try: try:
val=int(t[1:], 16) val = int(t[1:], 16)
except ValueError: # nope except ValueError: # nope
# print "nope", # print u'nope'
pass pass
elif DelphiColors.has_key(t): elif DelphiColors.has_key(t):
# print "colour", # print u'colour ', t
val=DelphiColors[t] val = DelphiColors[t]
else: else:
try: try:
val=int(t) val = int(t)
except ValueError: except ValueError:
val=t val = t
if (element.tag.find(u'Color') > 0 or if (element.tag.find(u'Color') > 0 or
(element.tag.find(u'BackgroundParameter') == 0 and type(val) == type(0))): (element.tag.find(u'BackgroundParameter') == 0 and type(val) == type(0))):
# convert to a wx.Colour # convert to a wx.Colour
val= QtGui.QColor((val>>16) & 0xFF, (val>>8)&0xFF, val&0xFF) val= QtGui.QColor((val>>16) & 0xFF, (val>>8)&0xFF, val&0xFF)
# print [val] # print [val]
setattr(self,element.tag, val) # print u'>> ', element.tag, val
setattr(self, element.tag, val)
def __str__(self): def __str__(self):
s="" s = u''
for k in dir(self): for k in dir(self):
if k[0:1] != "_": if k[0:1] != u'_':
s+= "%30s : %s\n" %(k,getattr(self,k)) s += u'%30s : %s\n' %(k, getattr(self, k))
return s return s

View File

@ -104,12 +104,18 @@ class SlideList(QtGui.QListView):
def keyPressEvent(self, event): def keyPressEvent(self, event):
if type(event) == QtGui.QKeyEvent: if type(event) == QtGui.QKeyEvent:
#here accept the event and do something #here accept the event and do something
if event.key() == QtCore.Qt.Key_PageUp: if event.key() == QtCore.Qt.Key_Up:
self.parent.onSlideSelectedPrevious() self.parent.onSlideSelectedPrevious()
event.accept() event.accept()
elif event.key() == QtCore.Qt.Key_PageDown: elif event.key() == QtCore.Qt.Key_Down:
self.parent.onSlideSelectedNext() self.parent.onSlideSelectedNext()
event.accept() event.accept()
elif event.key() == QtCore.Qt.Key_PageUp:
self.parent.onSlideSelectedFirst()
event.accept()
elif event.key() == QtCore.Qt.Key_PageDown:
self.parent.onSlideSelectedLast()
event.accept()
event.ignore() event.ignore()
else: else:
event.ignore() event.ignore()
@ -225,11 +231,6 @@ class SlideController(QtGui.QWidget):
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected) QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected)
QtCore.QObject.connect(self.PreviewListView, QtCore.QObject.connect(self.PreviewListView,
QtCore.SIGNAL(u'activated(QModelIndex)'), self.onSlideSelected) 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): def onSlideSelectedFirst(self):
""" """

View File

@ -57,9 +57,9 @@ class ThemeData(QtCore.QAbstractListModel):
def insertRow(self, row, filename): def insertRow(self, row, filename):
self.beginInsertRows(QtCore.QModelIndex(), row, row) self.beginInsertRows(QtCore.QModelIndex(), row, row)
log.info(u'insert row %d:%s' % (row, filename)) log.debug(u'insert row %d:%s' % (row, filename))
(prefix, shortfilename) = os.path.split(unicode(filename)) (prefix, shortfilename) = os.path.split(unicode(filename))
log.info(u'shortfilename = %s' % shortfilename) log.debug(u'shortfilename = %s' % shortfilename)
theme = shortfilename.split(u'.') theme = shortfilename.split(u'.')
# create a preview image # create a preview image
if os.path.exists(filename): if os.path.exists(filename):
@ -81,7 +81,7 @@ class ThemeData(QtCore.QAbstractListModel):
pixmap.fill(QtCore.Qt.black) pixmap.fill(QtCore.Qt.black)
# finally create the row # finally create the row
self.items.insert(row, (filename, pixmap, shortfilename, theme[0])) self.items.insert(row, (filename, pixmap, shortfilename, theme[0]))
log.info(u'Items: %s' % self.items) log.debug(u'Items: %s' % self.items)
self.endInsertRows() self.endInsertRows()
def removeRow(self, row): def removeRow(self, row):
@ -190,8 +190,13 @@ class ThemeManager(QtGui.QWidget):
try: try:
os.remove(os.path.join(self.path, th)) os.remove(os.path.join(self.path, th))
except: except:
pass #if not present do not worry #if not present do not worry
shutil.rmtree(os.path.join(self.path, theme)) pass
try:
shutil.rmtree(os.path.join(self.path, theme))
except:
#if not present do not worry
pass
self.themeData.clearItems() self.themeData.clearItems()
self.loadThemes() self.loadThemes()
@ -201,7 +206,7 @@ class ThemeManager(QtGui.QWidget):
def onImportTheme(self): def onImportTheme(self):
files = QtGui.QFileDialog.getOpenFileNames(None, files = QtGui.QFileDialog.getOpenFileNames(None,
translate(u'ThemeManager', u'Select Theme Import File'), translate(u'ThemeManager', u'Select Theme Import File'),
self.path, u'Theme (*.theme)') self.path, u'Theme (*.*)')
log.info(u'New Themes %s', unicode(files)) log.info(u'New Themes %s', unicode(files))
if len(files) > 0: if len(files) > 0:
for file in files: for file in files:
@ -335,7 +340,7 @@ class ThemeManager(QtGui.QWidget):
outfile = open(theme_file, u'w') outfile = open(theme_file, u'w')
outfile.write(theme_xml) outfile.write(theme_xml)
outfile.close() outfile.close()
if image_from is not None and image_from is not image_to: if image_from is not None and image_from != image_to:
shutil.copyfile(image_from, image_to) shutil.copyfile(image_from, image_to)
self.generateAndSaveImage(self.path, name, theme_xml) self.generateAndSaveImage(self.path, name, theme_xml)
self.themeData.clearItems() self.themeData.clearItems()

View File

@ -22,14 +22,14 @@ class Display():
global log global log
log=logging.getLogger(u'Display Logger') log=logging.getLogger(u'Display Logger')
log.info(u'Display Class loaded') log.info(u'Display Class loaded')
@staticmethod @staticmethod
def output(string): def output(string):
log.debug(string); log.debug(string);
print (string) print (string)
@staticmethod @staticmethod
def sub_output(string): def sub_output(string):
if not string == None: if not string == None:
log.debug(u' "+string); log.debug(u' '+string);
print (u' "+string) print (u' '+string)

View File

@ -24,18 +24,18 @@ class MigrateFiles():
def process(self): def process(self):
self.display.output(u'Files process started'); self.display.output(u'Files process started');
self._initial_setup() self._initial_setup()
self.display.output(u'Files process finished'); self.display.output(u'Files process finished');
def _initial_setup(self): def _initial_setup(self):
self.display.output(u'Initial Setup started'); self.display.output(u'Initial Setup started');
ConfigHelper.get_data_path() ConfigHelper.get_data_path()
self.display.sub_output(u'Config created'); self.display.sub_output(u'Config created');
ConfigHelper.get_config(u'bible", u'data path') ConfigHelper.get_config(u'bible', u'data path')
self.display.sub_output(u'Config created'); self.display.sub_output(u'Config created');
ConfigHelper.get_config(u'videos", u'data path') ConfigHelper.get_config(u'videos', u'data path')
self.display.sub_output(u'videos created'); self.display.sub_output(u'videos created');
ConfigHelper.get_config(u'images", u'data path') ConfigHelper.get_config(u'images', u'data path')
self.display.sub_output(u'images created'); self.display.sub_output(u'images created');
ConfigHelper.get_config(u'presentations", u'data path') ConfigHelper.get_config(u'presentations', u'data path')
self.display.sub_output(u'presentations created'); self.display.sub_output(u'presentations created');
self.display.output(u'Initial Setup finished'); self.display.output(u'Initial Setup finished');

View File

@ -16,6 +16,7 @@ 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
""" """
import os import os
import sys
import logging import logging
import sqlite3 import sqlite3
from openlp.core.lib import PluginConfig from openlp.core.lib import PluginConfig
@ -24,20 +25,81 @@ from sqlalchemy import *
from sqlalchemy.sql import select from sqlalchemy.sql import select
from sqlalchemy import create_engine from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker, mapper, relation, clear_mappers from sqlalchemy.orm import scoped_session, sessionmaker, mapper, relation, clear_mappers
from openlp.plugins.songs.lib.models import metadata, session, \
engine, songs_table, Song, Author, Topic, Book
from openlp.plugins.songs.lib.tables import * from openlp.plugins.songs.lib.tables import *
from openlp.plugins.songs.lib.classes import * from openlp.plugins.songs.lib.classes import *
clear_mappers() def init_models(url):
mapper(Author, authors_table) engine = create_engine(url)
mapper(Book, song_books_table) metadata.bind = engine
mapper(Song, songs_table, properties={ session = scoped_session(sessionmaker(autoflush=True, autocommit=False,
'authors': relation(Author, backref='songs', bind=engine))
secondary=authors_songs_table), mapper(Author, authors_table)
'book': relation(Book, backref='songs'), mapper(TAuthor, temp_authors_table)
'topics': relation(Topic, backref='songs', mapper(Book, song_books_table)
secondary=songs_topics_table)}) mapper(Song, songs_table,
mapper(Topic, topics_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(TSong, temp_songs_table)
mapper(TSongAuthor, temp_authors_songs_table)
mapper(Topic, topics_table)
return session
temp_authors_table = Table(u'authors_temp', metadata,
Column(u'authorid', types.Integer, primary_key=True),
Column(u'authorname', String(40))
)
temp_songs_table = Table(u'songs_temp', metadata,
Column(u'songid', types.Integer, primary_key=True),
Column(u'songtitle', String(60)),
Column(u'lyrics', types.UnicodeText),
Column(u'copyrightinfo', String(255)),
Column(u'settingsid', types.Integer)
)
# Definition of the "authors_songs" table
temp_authors_songs_table = Table(u'songauthors_temp', metadata,
Column(u'authorid', types.Integer, primary_key=True),
Column(u'songid', types.Integer)
)
class BaseModel(object):
"""
BaseModel provides a base object with a set of generic functions
"""
@classmethod
def populate(cls, **kwargs):
"""
Creates an instance of a class and populates it, returning the instance
"""
me = cls()
keys = kwargs.keys()
for key in keys:
me.__setattr__(key, kwargs[key])
return me
class TAuthor(BaseModel):
"""
Author model
"""
pass
class TSong(BaseModel):
"""
Author model
"""
pass
class TSongAuthor(BaseModel):
"""
Author model
"""
pass
class MigrateSongs(): class MigrateSongs():
def __init__(self, display): def __init__(self, display):
@ -55,186 +117,70 @@ class MigrateSongs():
def v_1_9_0(self, database): def v_1_9_0(self, database):
self.display.output(u'Migration 1.9.0 Started for ' + database) self.display.output(u'Migration 1.9.0 Started for ' + database)
self._v1_9_0_authors(database) self._v1_9_0_old(database)
self._v1_9_0_topics(database) self._v1_9_0_new(database)
self._v1_9_0_songbook(database) self._v1_9_0_cleanup(database)
self._v1_9_0_songauthors(database)
self._v1_9_0_songtopics(database)
self._v1_9_0_songs(database)
self.display.output(u'Migration 1.9.0 Finished for ' + database) self.display.output(u'Migration 1.9.0 Finished for ' + database)
def _v1_9_0_authors(self, database): def _v1_9_0_old(self, database):
self.display.sub_output(u'Authors Started for ' + database) self.display.sub_output(u'Rename Tables ' + database)
conn = sqlite3.connect(self.data_path + os.sep + database) conn = sqlite3.connect(self.data_path + os.sep + database)
conn.execute(u'""alter table authors rename to authors_temp;""') conn.execute(u'alter table authors rename to authors_temp;')
conn.commit() conn.commit()
self.display.sub_output(u'old author renamed to author_temp') conn.execute(u'alter table songs rename to songs_temp;')
conn.execute(u'""create table authors (
id integer primary key ASC AUTOINCREMENT,
first_name varchar(128),
last_name varchar(128),
display_name varchar(255)
);""')
conn.commit() conn.commit()
self.display.sub_output(u'authors table created') conn.execute(u'alter table songauthors rename to songauthors_temp;')
conn.execute(u'""create index if not exists author1 on authors
(display_name ASC,id ASC);""')
conn.commit() conn.commit()
self.display.sub_output(u'index author1 created')
conn.execute(u'""create index if not exists author2 on authors
(last_name ASC,id ASC);""')
conn.commit()
self.display.sub_output(u'index author2 created')
conn.execute(u'""create index if not exists author3 on authors
(first_name ASC,id ASC);""')
conn.commit()
self.display.sub_output(u'index author3 created')
self.display.sub_output(u'Author Data Migration started')
conn.execute(u'""insert into authors (id, display_name)
select authorid, authorname from authors_temp;""')
conn.commit()
self.display.sub_output(u'authors populated')
c = conn.cursor()
text = c.execute(u'""select * from authors""') .fetchall()
for author in text:
dispname = author[3]
dispname = dispname.replace(u''", u'')
pos = dispname.rfind(u' ')
authorfirstname = dispname[:pos]
authorlastname = dispname[pos + 1:len(dispname)]
s = "update authors set first_name = '" \
+ authorfirstname + "', last_name = '" + authorlastname \
+ "' where id = " + unicode(author[0])
c.execute(s)
conn.commit()
self.display.sub_output(u'Author Data Migration Completed')
conn.execute(u'""drop table authors_temp;""')
conn.commit()
conn.close()
self.display.sub_output(u'author_temp dropped')
self.display.sub_output(u'Authors Completed')
def _v1_9_0_songbook(self, database): def _v1_9_0_new(self, database):
self.display.sub_output(u'SongBook Started for ' + database) self.display.sub_output(u'Create new Tables ' + database)
conn = sqlite3.connect(self.data_path + os.sep + database) self.db_url = u'sqlite:///' + self.data_path + u'/songs.sqlite'
conn.execute(u'""create table if not exists song_books ( print self.db_url
id integer Primary Key ASC AUTOINCREMENT, self.session = init_models(self.db_url)
name varchar(128), if not songs_table.exists():
publisher varchar(128) metadata.create_all()
);""') results = self.session.query(TSong).order_by(TSong.songid).all()
conn.commit() for songs_temp in results:
self.display.sub_output(u'songbook table created') song = Song()
conn.execute(u'""create index if not exists songbook1 on song_books (name ASC,id ASC);""') song.title = songs_temp.songtitle
conn.commit() song.lyrics = songs_temp.lyrics.replace(u'\r\n', u'\n')
self.display.sub_output(u'index songbook1 created') song.copyright = songs_temp.copyrightinfo
conn.execute(u'""create index if not exists songbook2 on song_books (publisher ASC,id ASC);""') song.search_title = u''
conn.commit() song.search_lyrics = u''
conn.close() print songs_temp.songtitle
self.display.sub_output(u'index songbook2 created') aa = self.session.execute(u'select * from songauthors_temp where songid =' + unicode(songs_temp.songid) )
self.display.sub_output(u'SongBook Completed') for row in aa:
a = row['authorid']
author = Author()
authors_temp = self.session.query(TAuthor).get(a)
author.display_name = authors_temp.authorname
song.authors.append(author)
try:
self.session.add(song)
self.session.commit()
except:
self.session.rollback()
print u'Errow thrown = ', sys.exc_info()[1]
def _v1_9_0_songs(self, database): def _v1_9_0_cleanup(self, database):
self.display.sub_output(u'Songs Started for ' + database) self.display.sub_output(u'Update Internal Data ' + database)
conn = sqlite3.connect(self.data_path + os.sep + database) conn = sqlite3.connect(self.data_path + os.sep + database)
conn.execute(u'""alter table songs rename to songs_temp;""') conn.execute("""update songs set search_title =
conn.commit()
conn.execute(u'""create table if not exists songs (
id integer Primary Key ASC AUTOINCREMENT,
song_book_id integer,
title varchar(255),
lyrics text,
verse_order varchar(128),
copyright varchar(255),
comments text,
ccli_number varchar(64),
song_number varchar(64),
theme_name varchar(128),
search_title varchar(255),
search_lyrics text
);""')
conn.commit()
self.display.sub_output(u'songs table created')
conn.execute(u'""create index if not exists songs1 on songs
(search_lyrics ASC,id ASC);""')
conn.commit()
self.display.sub_output(u'index songs1 created')
conn.execute(u'""create index if not exists songs2 on songs
(search_title ASC,id ASC);""')
conn.commit()
self.display.sub_output(u'index songs2 created')
conn.execute(u'""insert into songs (id, title, lyrics, copyright,
search_title, search_lyrics, song_book_id)
select songid, songtitle, lyrics, copyrightinfo,
replace(replace(replace(replace(replace(replace(replace(replace( replace(replace(replace(replace(replace(replace(replace(replace(
replace(songtitle, '&', 'and'), ',', ''), ';', ''), ':', ''), replace(title, '&', 'and'), ',', ''), ';', ''), ':', ''),
'(u', ''), ')', ''), '{', ''), '}',''),'?',''), '(u', ''), ')', ''), '{', ''), '}',''),'?','');""")
conn.execute("""update songs set search_lyrics =
replace(replace(replace(replace(replace(replace(replace(replace( replace(replace(replace(replace(replace(replace(replace(replace(
replace(lyrics, '&', 'and'), ',', ''), ';', ''), ':', ''), replace(lyrics, '&', 'and'), ',', ''), ';', ''), ':', ''),
'(u', ''), ')', ''), '{', ''), '}',''),'?',''), '(u', ''), ')', ''), '{', ''), '}',''),'?','')
0 ;""")
from songs_temp;""')
conn.commit() conn.commit()
self.display.sub_output(u'songs populated') conn.execute(u'drop table authors_temp;')
conn.execute(u'""drop table songs_temp;""')
conn.commit() conn.commit()
conn.close() conn.execute(u'drop table songs_temp;')
self.display.sub_output(u'songs_temp dropped') conn.commit()
self.display.sub_output(u'Songs Completed') conn.execute(u'drop table songauthors_temp;')
conn.commit()
conn.execute(u'drop table settings;')
def _v1_9_0_topics(self, database):
self.display.sub_output(u'Topics Started for ' + database)
conn = sqlite3.connect(self.data_path+os.sep+database)
conn.text_factory = str
conn.execute(u'""create table if not exists topics
(id integer Primary Key ASC AUTOINCREMENT,
name varchar(128));""')
conn.commit() conn.commit()
self.display.sub_output(u'Topic table created')
conn.execute(u'""create index if not exists topic1 on topics (name ASC,id ASC);""')
conn.commit()
conn.close()
self.display.sub_output(u'index topic1 created')
self.display.sub_output(u'Topics Completed')
def _v1_9_0_songauthors(self, database):
self.display.sub_output(u'SongAuthors Started for ' + database);
conn = sqlite3.connect(self.data_path + os.sep + database)
conn.execute(u'""create table if not exists authors_songs
(author_id integer,
song_id integer);""')
conn.commit()
self.display.sub_output(u'authors_songs table created')
conn.execute(u'""insert into authors_songs (author_id, song_id)
select authorid, songid from songauthors;""')
conn.commit()
self.display.sub_output(u'authors_songs populated')
conn.execute(u'""drop table songauthors;""')
conn.commit()
self.display.sub_output(u'songauthors dropped')
conn.close()
self.display.sub_output(u'SongAuthors Completed')
def _v1_9_0_songtopics(self, database):
self.display.sub_output(u'Songtopics Started for ' + database);
conn = sqlite3.connect(self.data_path+os.sep+database)
conn.execute(u'""create table if not exists song_topics
(song_id integer,
topic_id integer);""')
conn.commit()
self.display.sub_output(u'songtopics table created')
conn.execute(u'""create index if not exists songtopic1 on song_topics (topic_id ASC,song_id ASC);""')
conn.commit()
self.display.sub_output(u'index songtopic1 created')
conn.execute(u'""create index if not exists songtopic2 on song_topics (song_id ASC,topic_id ASC);""')
conn.commit()
conn.close()
self.display.sub_output(u'index songtopic2 created')
self.display.sub_output(u'SongTopics Completed')
def run_cmd(self, cmd):
filein, fileout = os.popen4(cmd)
out = fileout.readlines()
if len(out) > 0:
for o in range (0, len(out)):
self.display.sub_output(out[o])

View File

@ -45,7 +45,6 @@ class BibleList(QtGui.QListWidget):
if dropAction == QtCore.Qt.CopyAction: if dropAction == QtCore.Qt.CopyAction:
self.close() self.close()
class BibleMediaItem(MediaManagerItem): class BibleMediaItem(MediaManagerItem):
""" """
This is the custom media manager item for Bibles. This is the custom media manager item for Bibles.

View File

@ -1,4 +1,4 @@
from win32com.client import Dispatch #from win32com.client import Dispatch
# OOo API documentation: # OOo API documentation:
# http://api.openoffice.org/docs/common/ref/com/sun/star/presentation/XSlideShowController.html # http://api.openoffice.org/docs/common/ref/com/sun/star/presentation/XSlideShowController.html
@ -33,26 +33,26 @@ class ImpressCOMApp(object):
self._app.Terminate() self._app.Terminate()
self._app = None self._app = None
self._sm = None self._sm = None
class ImpressCOMPres(object): class ImpressCOMPres(object):
def __init__(self, oooApp, filename): def __init__(self, oooApp, filename):
self.oooApp = oooApp self.oooApp = oooApp
self.filename = filename self.filename = filename
self.open() self.open()
def getPres(self): def getPres(self):
if self._pres == None: if self._pres == None:
self.open() self.open()
return self._pres return self._pres
pres = property(getPres) pres = property(getPres)
def open(self): def open(self):
self.comp = self.oooApp.app.loadComponentFromURL(u'file:///" + self.filename, "_blank", 0, []) self.comp = self.oooApp.app.loadComponentFromURL(u'file:///' + self.filename, '_blank', 0, [])
self.presdoc = self.comp.getPresentation() self.presdoc = self.comp.getPresentation()
self.presdoc.start() self.presdoc.start()
self._pres = self.presdoc.getController() self._pres = self.presdoc.getController()
def close(self): def close(self):
self.pres.deactivate() self.pres.deactivate()
self.presdoc.end() self.presdoc.end()
@ -63,7 +63,7 @@ class ImpressCOMPres(object):
def isActive(self): def isActive(self):
return self.pres.isRunning() and self.pres.isActive() return self.pres.isRunning() and self.pres.isActive()
def resume(self): def resume(self):
return self.pres.resume() return self.pres.resume()
@ -72,7 +72,7 @@ class ImpressCOMPres(object):
def blankScreen(self): def blankScreen(self):
self.pres.blankScreen(0) self.pres.blankScreen(0)
def stop(self): def stop(self):
self.pres.deactivate() self.pres.deactivate()
# self.presdoc.end() # self.presdoc.end()
@ -83,7 +83,7 @@ class ImpressCOMPres(object):
def getSlideNumber(self): def getSlideNumber(self):
return self.pres.getCurrentSlideIndex return self.pres.getCurrentSlideIndex
def setSlideNumber(self, slideno): def setSlideNumber(self, slideno):
self.pres.gotoSlideIndex(slideno) self.pres.gotoSlideIndex(slideno)
@ -112,7 +112,7 @@ class ImpressCOMSlide(object):
if __name__ == '__main__': if __name__ == '__main__':
ooo = ImpressCOMApp() ooo = ImpressCOMApp()
show = ImpressCOMPres(ooo, "c:/test1.ppt') show = ImpressCOMPres(ooo, u'c:/test1.ppt')
show.go() show.go()
show.resume() show.resume()
show.nextStep() show.nextStep()

View File

@ -51,7 +51,8 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
Refresh the screen and rest fields Refresh the screen and rest fields
""" """
self.TopicsListWidget.clear() self.TopicsListWidget.clear()
self.onClearButtonClick() # tidy up screen # tidy up screen
self.onClearButtonClick()
topics = self.songmanager.get_topics() topics = self.songmanager.get_topics()
for topic in topics: for topic in topics:
topic_name = QtGui.QListWidgetItem(topic.name) topic_name = QtGui.QListWidgetItem(topic.name)
@ -77,12 +78,13 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
""" """
Sent New or update details to the database Sent New or update details to the database
""" """
if self.topic == None: if self._validate_form():
self.topic = Topic() if self.topic == None:
self.topic.name = unicode(self.TopicNameEdit.displayText()) self.topic = Topic()
self.songmanager.save_topic(self.topic) self.topic.name = unicode(self.TopicNameEdit.displayText())
self.onClearButtonClick() self.songmanager.save_topic(self.topic)
self.load_form() self.onClearButtonClick()
self.load_form()
def onClearButtonClick(self): def onClearButtonClick(self):
""" """
@ -91,7 +93,6 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
self.TopicNameEdit.setText(u'') self.TopicNameEdit.setText(u'')
self.MessageLabel.setText(u'') self.MessageLabel.setText(u'')
self.DeleteButton.setEnabled(False) self.DeleteButton.setEnabled(False)
self.AddUpdateButton.setEnabled(True)
self.topic = None self.topic = None
self._validate_form() self._validate_form()
@ -115,7 +116,10 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
def _validate_form(self): def _validate_form(self):
# We need at lease a display name # We need at lease a display name
valid = True
if len(self.TopicNameEdit.displayText()) == 0: if len(self.TopicNameEdit.displayText()) == 0:
self.AddUpdateButton.setEnabled(False) valid = False
self.TopicNameEdit.setStyleSheet(u'background-color: red; color: white')
else: else:
self.AddUpdateButton.setEnabled(True) self.TopicNameEdit.setStyleSheet(u'')
return valid

View File

@ -16,7 +16,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 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 sqlalchemy import *
from sqlalchemy import Column, Table, ForeignKey, types from sqlalchemy import Column, Table, ForeignKey, types
from openlp.plugins.songs.lib.meta import metadata from openlp.plugins.songs.lib.meta import metadata
@ -68,4 +68,13 @@ authors_songs_table = Table(u'authors_songs', metadata,
songs_topics_table = Table(u'songs_topics', metadata, songs_topics_table = Table(u'songs_topics', metadata,
Column(u'song_id', types.Integer, ForeignKey(u'songs.id'), primary_key=True), Column(u'song_id', types.Integer, ForeignKey(u'songs.id'), primary_key=True),
Column(u'topic_id', types.Integer, ForeignKey(u'topics.id'), primary_key=True) Column(u'topic_id', types.Integer, ForeignKey(u'topics.id'), primary_key=True)
) )
Index(u'authors_id',authors_table.c.id)
Index(u'authors_display_name_id',authors_table.c.display_name, authors_table.c.id)
Index(u'song_books_id',song_books_table.c.id)
Index(u'songs_id',songs_table.c.id)
Index(u'topics_id',topics_table.c.id)
Index(u'authors_songs_author',authors_songs_table.c.author_id, authors_songs_table.c.song_id)
Index(u'authors_songs_song',authors_songs_table.c.song_id, authors_songs_table.c.author_id)
Index(u'topics_song_topic', songs_topics_table.c.topic_id, songs_topics_table.c.song_id)
Index(u'topics_song_song',songs_topics_table.c.song_id, songs_topics_table.c.topic_id)

View File

@ -136,4 +136,4 @@ class SongsPlugin(Plugin):
self.media_item.onSongLiveClick() self.media_item.onSongLiveClick()
if event.event_type == EventType.LoadSongList : if event.event_type == EventType.LoadSongList :
log.debug(u'Load Load Song List Item received') log.debug(u'Load Load Song List Item received')
self.media_item.displayResults(self.songmanager.get_songs()) self.media_item.displayResultsSong(self.songmanager.get_songs())

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
import os import os
import sys import sys
import logging import logging
import time import time
@ -21,25 +21,25 @@ class Migration():
def __init__(self): def __init__(self):
""" """
""" """
self.display = Display() self.display = Display()
self.stime = time.strftime(u'%Y-%m-%d-%H%M%S", time.localtime()) self.stime = time.strftime(u'%Y-%m-%d-%H%M%S', time.localtime())
self.display.output(u'OpenLp v1.9.0 Migration Utility Started" ) self.display.output(u'OpenLp v1.9.0 Migration Utility Started')
def process(self): def process(self):
MigrateFiles(self.display).process() #MigrateFiles(self.display).process()
MigrateSongs(self.display).process() MigrateSongs(self.display).process()
MigrateBibles(self.display).process() #MigrateBibles(self.display).process()
def move_log_file(self): def move_log_file(self):
fname = 'openlp-migration.log' fname = 'openlp-migration.log'
c = os.path.splitext(fname) c = os.path.splitext(fname)
b = (c[0]+'-'+ unicode(self.stime) + c[1]) b = (c[0]+'-'+ unicode(self.stime) + c[1])
self.display.output(u'Logfile " +b + " generated') self.display.output(u'Logfile " +b + " generated')
self.display.output(u'Migration Utility Finished ') self.display.output(u'Migration Utility Finished ')
os.rename(fname, b) os.rename(fname, b)
if __name__ == '__main__': if __name__ == '__main__':
mig = Migration() mig = Migration()
mig.process() mig.process()
#mig.move_log_file() #mig.move_log_file()