openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #00402
[Merge] lp:~trb143/openlp/audit into lp:openlp
Tim Bentley has proposed merging lp:~trb143/openlp/audit into lp:openlp.
Requested reviews:
Tim Bentley (trb143)
Test merge only do not approve
--
https://code.launchpad.net/~trb143/openlp/audit/+merge/12249
Your team openlp.org Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py 2009-09-21 18:59:35 +0000
+++ openlp/core/lib/__init__.py 2009-09-21 19:23:51 +0000
@@ -127,7 +127,6 @@
from rendermanager import RenderManager
from mediamanageritem import MediaManagerItem
from baselistwithdnd import BaseListWithDnD
-from listwithpreviews import ListWithPreviews
__all__ = [ 'translate', 'file_to_xml', 'str_to_bool',
'contextMenuAction', 'contextMenuSeparator','ServiceItem']
=== removed file 'openlp/core/lib/listwithpreviews.py'
--- openlp/core/lib/listwithpreviews.py 2009-09-08 19:58:05 +0000
+++ openlp/core/lib/listwithpreviews.py 1970-01-01 00:00:00 +0000
@@ -1,122 +0,0 @@
-# -*- coding: utf-8 -*-
-# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
-
-###############################################################################
-# OpenLP - Open Source Lyrics Projection #
-# --------------------------------------------------------------------------- #
-# Copyright (c) 2008-2009 Raoul Snyman #
-# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten #
-# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri #
-# --------------------------------------------------------------------------- #
-# 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 os
-import logging
-from PyQt4 import QtCore, QtGui
-
-class ListWithPreviews(QtCore.QAbstractListModel):
- """
- An abstract list of unicodeings and the preview icon to go with them
- """
- global log
- log = logging.getLogger(u'ListWithPreviews')
- log.info(u'started')
-
- def __init__(self, new_preview_function=None):
- QtCore.QAbstractListModel.__init__(self)
- # will be a list of (full filename, QPixmap, shortname) tuples
- self.items = []
- self.rowheight = 50
- self.maximagewidth = self.rowheight * 16 / 9.0;
- self.preview_function = new_preview_function
-
- def make_preview(self, filename):
- if os.path.exists(filename):
- if self.preview_function is not None:
- preview=self.preview_function(filename)
- else:
- preview = QtGui.QImage(filename)
- else:
- preview = None
-
- if preview is not None:
- w = self.maximagewidth;
- h = self.rowheight
- preview = preview.scaled(w, h, QtCore.Qt.KeepAspectRatio,
- QtCore.Qt.SmoothTransformation)
- realw = preview.width();
- realh = preview.height()
- # and move it to the centre of the preview space
- p = QtGui.QImage(w, h, QtGui.QImage.Format_ARGB32_Premultiplied)
- p.fill(QtCore.Qt.transparent)
- painter = QtGui.QPainter(p)
- painter.drawImage((w-realw) / 2, (h-realh) / 2, preview)
- else:
- w = self.maximagewidth;
- h = self.rowheight
- p = QtGui.QImage(w, h, QtGui.QImage.Format_ARGB32_Premultiplied)
- p.fill(QtCore.Qt.transparent)
- return p
-
- def rowCount(self, parent):
- return len(self.items)
-
- def insertRow(self, row, filename):
- self.beginInsertRows(QtCore.QModelIndex(), row, row)
- #log.info(u'insert row %d:%s' % (row,filename))
- # get short filename to display next to image
- filename = unicode(filename)
- (prefix, shortfilename) = os.path.split(filename)
- #log.info(u'shortfilename=%s' % (shortfilename))
- # create a preview image
- p=self.make_preview(filename)
- # finally create the row
- self.items.insert(row, (filename, p, shortfilename))
- self.endInsertRows()
-
- def removeRow(self, row):
- self.beginRemoveRows(QtCore.QModelIndex(), row, row)
- self.items.pop(row)
- self.endRemoveRows()
-
- def addRow(self, filename):
- self.insertRow(len(self.items), filename)
-
- 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][2]
- elif role == QtCore.Qt.DecorationRole:
- retval = self.items[row][1]
- elif role == QtCore.Qt.ToolTipRole:
- retval = self.items[row][0]
- else:
- retval = QtCore.QVariant()
- if type(retval) is not type(QtCore.QVariant):
- return QtCore.QVariant(retval)
- else:
- return retval
-
- def getFileList(self):
- filelist = [item[0] for item in self.items];
- return filelist
-
- def getFilename(self, index):
- row = index.row()
- return self.items[row][0]
=== modified file 'openlp/plugins/audit/auditplugin.py'
--- openlp/plugins/audit/auditplugin.py 2009-09-21 17:56:36 +0000
+++ openlp/plugins/audit/auditplugin.py 2009-09-22 19:36:25 +0000
@@ -28,7 +28,7 @@
from datetime import date
from openlp.core.lib import Plugin, Receiver, translate, str_to_bool
-from openlp.plugins.audit.lib import AuditTab
+from openlp.plugins.audit.lib import AuditTab, AuditManager
class AuditPlugin(Plugin):
global log
@@ -97,16 +97,10 @@
QtCore.SIGNAL(u'audit_live'), self.onReceiveAudit)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'audit_changed'), self.onUpdateAudit)
- self.auditFileName = self.config.get_config(u'audit file', u'')
self.auditActive = str_to_bool(
self.config.get_config(u'audit active', False))
- if self.auditFileName == u'':
- self.auditActive = False
- self.ToolsAuditItem.setEnabled(False)
- self.auditFile = None
- else:
- self.auditFile = open(self.auditFileName, u'a')
self.ToolsAuditItem.setChecked(self.auditActive)
+ self.auditmanager = AuditManager()
def toggleAuditState(self):
self.auditActive = not self.auditActive
=== modified file 'openlp/plugins/audit/lib/__init__.py'
--- openlp/plugins/audit/lib/__init__.py 2009-09-17 18:24:13 +0000
+++ openlp/plugins/audit/lib/__init__.py 2009-09-22 19:36:25 +0000
@@ -23,3 +23,4 @@
###############################################################################
from audittab import AuditTab
+from manager import AuditManager
=== modified file 'openlp/plugins/audit/lib/audittab.py'
--- openlp/plugins/audit/lib/audittab.py 2009-09-21 17:56:36 +0000
+++ openlp/plugins/audit/lib/audittab.py 2009-09-22 19:23:12 +0000
@@ -39,18 +39,6 @@
self.AuditModeGroupBox.setObjectName(u'AuditModeGroupBox')
self.verticalLayout = QtGui.QVBoxLayout(self.AuditModeGroupBox)
self.verticalLayout.setObjectName("verticalLayout")
- self.horizontalLayout = QtGui.QHBoxLayout()
- self.horizontalLayout.setObjectName("horizontalLayout")
- self.AuditFileName = QtGui.QLineEdit(self)
- self.AuditFileName.setObjectName("AuditFileName")
- self.horizontalLayout.addWidget(self.AuditFileName)
- icon1 = QtGui.QIcon()
- icon1.addPixmap(QtGui.QPixmap(u':/imports/import_load.png'),
- QtGui.QIcon.Normal, QtGui.QIcon.Off)
- self.AuditFileButton = QtGui.QPushButton(self)
- self.AuditFileButton.setObjectName("AuditFileButton")
- self.AuditFileButton.setIcon(icon1)
- self.horizontalLayout.addWidget(self.AuditFileButton)
self.verticalLayout.addLayout(self.horizontalLayout)
self.AuditActive = QtGui.QCheckBox(self)
self.AuditActive.setObjectName("AuditActive")
@@ -58,8 +46,6 @@
self.WarningLabel = QtGui.QLabel(self)
self.WarningLabel.setObjectName("WarningLabel")
self.verticalLayout.addWidget(self.WarningLabel)
- QtCore.QObject.connect(self.AuditFileButton,
- QtCore.SIGNAL(u'pressed()'), self.onAuditFileButtonClicked)
def retranslateUi(self):
self.AuditModeGroupBox.setTitle(translate(u'AuditTab', u'Audit File'))
@@ -71,13 +57,6 @@
self.AuditFileName.setText(self.config.get_config(u'Audit file', u''))
self.AuditActive.setChecked(int(self.config.get_config(u'startup', 0)))
- def onAuditFileButtonClicked(self):
- filename = QtGui.QFileDialog.getOpenFileName(
- self, u'Audit File',self.AuditFileName.text())
- if filename != u'':
- filename = unicode(filename)
- self.AuditFileName.setText(filename)
-
def save(self):
self.config.set_config(
u'Audit file', unicode(self.AuditFileName.text()))
=== added file 'openlp/plugins/audit/lib/manager.py'
--- openlp/plugins/audit/lib/manager.py 1970-01-01 00:00:00 +0000
+++ openlp/plugins/audit/lib/manager.py 2009-09-22 19:37:36 +0000
@@ -0,0 +1,104 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2009 Raoul Snyman #
+# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten #
+# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri #
+# --------------------------------------------------------------------------- #
+# 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 os, os.path
+import sys
+
+from sqlalchemy import asc, desc
+from openlp.plugins.audit.lib.models import init_models, metadata, session, \
+ engine, audit_table, Audit
+
+import logging
+
+class AuditManager():
+ """
+ The Song Manager provides a central location for all database code. This
+ class takes care of connecting to the database and running all the queries.
+ """
+
+ global log
+ log = logging.getLogger(u'AuditManager')
+ log.info(u'Audit manager loaded')
+
+ def __init__(self, config):
+ """
+ Creates the connection to the database, and creates the tables if they
+ don't exist.
+ """
+ self.config = config
+ log.debug(u'Audit Initialising')
+ self.db_url = u''
+ db_type = self.config.get_config(u'db type', u'sqlite')
+ if db_type == u'sqlite':
+ self.db_url = u'sqlite:///%s/Audit.sqlite' % \
+ self.config.get_data_path()
+ 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')
+ self.session = init_models(self.db_url)
+ metadata.create_all(checkfirst=True)
+ log.debug(u'AuditInitialised')
+
+ def get_audits(self):
+ """
+ Returns a list of all the audits
+ """
+ return self.session.query(audit).order_by(audit.whensung).all()
+
+ def get_audit(self, id):
+ """
+ Details of the audit
+ """
+ return self.session.query(audit).get(id)
+
+ def save_audit(self, audit):
+ """
+ Save the audit and refresh the cache
+ """
+ try:
+ self.session.add(audit)
+ self.session.commit()
+ return True
+ except:
+ self.session.rollback()
+ log.exception(u'Could not save audit to song database')
+ return False
+
+ def delete_audit(self, auditid):
+ """
+ Delete the audit
+ """
+ audit = self.get_audit(auditid)
+ try:
+ self.session.delete(audit)
+ self.session.commit()
+ return True
+ except:
+ self.session.rollback()
+ log.exception(u'Could not delete audit from song database')
+ return False
+
=== added file 'openlp/plugins/audit/lib/meta.py'
--- openlp/plugins/audit/lib/meta.py 1970-01-01 00:00:00 +0000
+++ openlp/plugins/audit/lib/meta.py 2009-09-22 19:37:36 +0000
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2009 Raoul Snyman #
+# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten #
+# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri #
+# --------------------------------------------------------------------------- #
+# 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 sqlalchemy import MetaData
+from sqlalchemy.orm import scoped_session, sessionmaker
+
+__all__ = ['session', 'metadata', 'engine']
+
+# SQLAlchemy database engine. Updated by model.init_model()
+engine = None
+
+# SQLAlchemy session manager. Updated by model.init_model()
+session = None
+
+# Global metadata. If you have multiple databases with overlapping table
+# names, you'll need a metadata for each database
+metadata = MetaData()
=== added file 'openlp/plugins/audit/lib/models.py'
--- openlp/plugins/audit/lib/models.py 1970-01-01 00:00:00 +0000
+++ openlp/plugins/audit/lib/models.py 2009-09-22 19:37:36 +0000
@@ -0,0 +1,37 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2009 Raoul Snyman #
+# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten #
+# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri #
+# --------------------------------------------------------------------------- #
+# 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 sqlalchemy import create_engine
+from sqlalchemy.orm import scoped_session, sessionmaker, mapper, relation
+
+from openlp.plugins.audit.lib.meta import session, metadata, engine
+from openlp.plugins.audit.lib.tables import *
+
+def init_models(url):
+ engine = create_engine(url)
+ metadata.bind = engine
+ session = scoped_session(sessionmaker(autoflush=False,
+ autocommit=False, bind=engine))
+ mapper(Audit, audit_table)
+ return session
=== added file 'openlp/plugins/audit/lib/tables.py'
--- openlp/plugins/audit/lib/tables.py 1970-01-01 00:00:00 +0000
+++ openlp/plugins/audit/lib/tables.py 2009-09-22 19:37:36 +0000
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2009 Raoul Snyman #
+# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten #
+# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri #
+# --------------------------------------------------------------------------- #
+# 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 datetime import now
+
+from sqlalchemy import *
+from sqlalchemy import Column, Table, ForeignKey, types
+
+from openlp.plugins.audit.lib.meta import metadata
+
+# Definition of the "audits" table
+audit_table = Table(u'audits', metadata,
+ Column(u'id', types.Integer, primary_key=True),
+ Column('whensung', types.DateTime, nullable=False, default=datetime.now()),
+ Column(u'authors', types.Unicode(255)),
+ Column(u'ccli_number', types.Unicode(64)),
+)
+
+Index(u'audits_id',audit_table.c.timestamp, audit_table.c.id)
=== modified file 'openlp/plugins/images/imageplugin.py'
--- openlp/plugins/images/imageplugin.py 2009-09-21 17:56:36 +0000
+++ openlp/plugins/images/imageplugin.py 2009-09-22 19:23:12 +0000
@@ -51,6 +51,3 @@
# Create the MediaManagerItem object
self.media_item = ImageMediaItem(self, self.icon, u'Images')
return self.media_item
-
- def initialise(self):
- log.info(u'Plugin Initialising')
=== modified file 'openlp/plugins/images/lib/imagetab.py'
--- openlp/plugins/images/lib/imagetab.py 2009-09-21 17:56:36 +0000
+++ openlp/plugins/images/lib/imagetab.py 2009-09-22 19:36:25 +0000
@@ -37,16 +37,16 @@
self.setObjectName(u'ImageTab')
self.ImageLayout = QtGui.QFormLayout(self)
self.ImageLayout.setObjectName(u'ImageLayout')
- self.ImageModeGroupBox = QtGui.QGroupBox(self)
- self.ImageModeGroupBox.setObjectName(u'ImageModeGroupBox')
- self.TimeoutLayout = QtGui.QHBoxLayout(self.ImageModeGroupBox)
+ self.ImageSettingsGroupBox = QtGui.QGroupBox(self)
+ self.ImageSettingsGroupBox.setObjectName(u'ImageSettingsGroupBox')
+ self.TimeoutLayout = QtGui.QHBoxLayout(self.ImageSettingsGroupBox)
self.TimeoutLayout.setSpacing(8)
self.TimeoutLayout.setMargin(0)
self.TimeoutLayout.setObjectName(u'TimeoutLayout')
- self.TimeoutLabel = QtGui.QLabel(self.ImageModeGroupBox)
+ self.TimeoutLabel = QtGui.QLabel(self.ImageSettingsGroupBox)
self.TimeoutLabel.setObjectName(u'TimeoutLabel')
self.TimeoutLayout.addWidget(self.TimeoutLabel)
- self.TimeoutSpinBox = QtGui.QSpinBox(self.ImageModeGroupBox)
+ self.TimeoutSpinBox = QtGui.QSpinBox(self.ImageSettingsGroupBox)
self.TimeoutSpinBox.setMaximum(180)
self.TimeoutSpinBox.setObjectName(u'TimeoutSpinBox')
self.TimeoutLayout.addWidget(self.TimeoutSpinBox)
@@ -54,12 +54,13 @@
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.TimeoutLayout.addItem(self.TimeoutSpacer)
self.ImageLayout.setWidget(
- 0, QtGui.QFormLayout.LabelRole, self.ImageModeGroupBox)
+ 0, QtGui.QFormLayout.LabelRole, self.ImageSettingsGroupBox)
# Signals and slots
QtCore.QObject.connect(self.TimeoutSpinBox,
QtCore.SIGNAL(u'valueChanged(int)'), self.onTimeoutSpinBoxChanged)
def retranslateUi(self):
+ self.ImageSettingsGroupBox.setTitle(translate(u'ImageTab', u'Image Settings'))
self.TimeoutLabel.setText(translate(u'ImageTab', u'Slide Loop Delay:'))
self.TimeoutSpinBox.setSuffix(translate(u'ImageTab', u's'))
=== modified file 'openlp/plugins/media/lib/mediaitem.py'
--- openlp/plugins/media/lib/mediaitem.py 2009-09-21 17:56:36 +0000
+++ openlp/plugins/media/lib/mediaitem.py 2009-09-22 19:23:12 +0000
@@ -118,7 +118,3 @@
item_name.setIcon(buildIcon(img))
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
self.ListView.addItem(item_name)
-
-# def onMediaAddClick(self):
-# log.debug(u'Media Add Button pressed')
-# pass
=== modified file 'openlp/plugins/media/mediaplugin.py'
--- openlp/plugins/media/mediaplugin.py 2009-09-08 19:58:05 +0000
+++ openlp/plugins/media/mediaplugin.py 2009-09-21 19:23:51 +0000
@@ -27,6 +27,7 @@
from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab
from openlp.plugins.media.lib import MediaTab,MediaMediaItem
+
class MediaPlugin(Plugin):
def __init__(self, plugin_helpers):
Follow ups