forked from openlp/openlp
Pre merge from SVN
bzr-revno: 367
This commit is contained in:
parent
bef8369e86
commit
2be33e6c66
@ -26,8 +26,8 @@ from event import Event
|
|||||||
from xmlrootclass import XmlRootClass
|
from xmlrootclass import XmlRootClass
|
||||||
from serviceitem import ServiceItem
|
from serviceitem import ServiceItem
|
||||||
from eventreceiver import Receiver
|
from eventreceiver import Receiver
|
||||||
from imageserviceitem import ImageServiceItem
|
from serviceitem import ServiceItem
|
||||||
from toolbar import OpenLPToolbar
|
from toolbar import OpenLPToolbar
|
||||||
|
|
||||||
__all__ = ['PluginConfig', 'Plugin', 'PluginUtils', 'SettingsTabItem', 'MediaManagerItem', 'Event',
|
__all__ = ['PluginConfig', 'Plugin', 'PluginUtils', 'SettingsTab', 'MediaManagerItem', 'Event',
|
||||||
'XmlRootClass', 'ServiceItem', 'Receiver', 'ImageServiceItem', 'OpenLPToolbar']
|
'XmlRootClass', 'ServiceItem', 'Receiver', 'OpenLPToolbar']
|
||||||
|
@ -32,12 +32,57 @@ from openlp.core.lib import ServiceItem
|
|||||||
# from openlp.core import PluginManager
|
# from openlp.core import PluginManager
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
class ServiceData(QAbstractListModel):
|
class ServiceData(QAbstractItemModel):
|
||||||
"""
|
"""
|
||||||
Tree of items for an order of service.
|
Tree of items for an order of service.
|
||||||
Includes methods for reading and writing the contents to an OOS file
|
Includes methods for reading and writing the contents to an OOS file
|
||||||
Root contains a list of ServiceItems
|
Root contains a list of ServiceItems
|
||||||
"""
|
"""
|
||||||
|
global log
|
||||||
|
log=logging.getLogger("ServiceData")
|
||||||
|
def __init__(self):
|
||||||
|
self.items=[]
|
||||||
|
log.info("Starting")
|
||||||
|
def rowCount(self, parent):
|
||||||
|
return len(self.items)
|
||||||
|
def insertRow(self, row, service_item):
|
||||||
|
self.beginInsertRows(QModelIndex(),row,row)
|
||||||
|
log.info("insert row %d:%s"%(row,filename))
|
||||||
|
self.items.insert(row, service_item)
|
||||||
|
self.endInsertRows()
|
||||||
|
def removeRow(self, row):
|
||||||
|
self.beginRemoveRows(QModelIndex(), row,row)
|
||||||
|
self.items.pop(row)
|
||||||
|
self.endRemoveRows()
|
||||||
|
def addRow(self, filename):
|
||||||
|
self.insertRow(len(self.items), filename)
|
||||||
|
|
||||||
|
|
||||||
|
def data(self, index, role):
|
||||||
|
"""
|
||||||
|
Called by the service manager to draw us in the service window
|
||||||
|
"""
|
||||||
|
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 QVariant()
|
||||||
|
item=self.items[row]
|
||||||
|
if role==Qt.DisplayRole:
|
||||||
|
retval= item.pluginname + ":" + item.shortname
|
||||||
|
elif role == Qt.DecorationRole:
|
||||||
|
retval = item.iconic_representation
|
||||||
|
elif role == Qt.ToolTipRole:
|
||||||
|
retval= None
|
||||||
|
else:
|
||||||
|
retval= None
|
||||||
|
if retval == None:
|
||||||
|
retval=QVariant()
|
||||||
|
# log.info("Returning"+ str(retval))
|
||||||
|
if type(retval) is not type(QVariant):
|
||||||
|
return QVariant(retval)
|
||||||
|
else:
|
||||||
|
return retval
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ServiceManager(QWidget):
|
class ServiceManager(QWidget):
|
||||||
|
|
||||||
@ -69,14 +114,18 @@ class ServiceManager(QWidget):
|
|||||||
self.ThemeWidget = QtGui.QWidgetAction(self.Toolbar)
|
self.ThemeWidget = QtGui.QWidgetAction(self.Toolbar)
|
||||||
self.ThemeWidget.setDefaultWidget(self.ThemeComboBox)
|
self.ThemeWidget.setDefaultWidget(self.ThemeComboBox)
|
||||||
self.Toolbar.addAction(self.ThemeWidget)
|
self.Toolbar.addAction(self.ThemeWidget)
|
||||||
self.Layout.addWidget(self.Toolbar)
|
|
||||||
self.ListView = QtGui.QListView(self)
|
|
||||||
self.Layout.addWidget(self.ListView)
|
|
||||||
|
|
||||||
|
self.Layout.addWidget(self.Toolbar)
|
||||||
|
|
||||||
|
self.TreeView = QtGui.QTreeView(self)
|
||||||
|
self.service_data=ServiceData()
|
||||||
|
# self.TreeView.setModel(self.service_data)
|
||||||
|
self.Layout.addWidget(self.TreeView)
|
||||||
|
|
||||||
def addServiceItem(self, item):
|
def addServiceItem(self, item):
|
||||||
"""Adds service item"""
|
"""Adds service item"""
|
||||||
|
pass
|
||||||
|
|
||||||
def removeServiceItem(self):
|
def removeServiceItem(self):
|
||||||
"""Remove currently selected item"""
|
"""Remove currently selected item"""
|
||||||
|
pass
|
||||||
|
@ -22,10 +22,12 @@ import os.path
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
from openlp.core.resources import *
|
from openlp.core.resources import *
|
||||||
from openlp.core.lib import Plugin, PluginUtils, MediaManagerItem, ImageServiceItem
|
from openlp.core.lib import Plugin, PluginUtils, MediaManagerItem
|
||||||
import logging
|
import logging
|
||||||
from PyQt4.QtCore import *
|
from PyQt4.QtCore import *
|
||||||
from PyQt4.QtGui import *
|
from PyQt4.QtGui import *
|
||||||
|
from listwithpreviews import ListWithPreviews
|
||||||
|
from imageserviceitem import ImageServiceItem
|
||||||
|
|
||||||
class ListWithPreviews(QtCore.QAbstractListModel):
|
class ListWithPreviews(QtCore.QAbstractListModel):
|
||||||
"""
|
"""
|
||||||
@ -185,10 +187,12 @@ class ImagePlugin(Plugin, PluginUtils):
|
|||||||
self._save_display_list(self.ImageListData.get_file_list())
|
self._save_display_list(self.ImageListData.get_file_list())
|
||||||
|
|
||||||
def onImageClick(self, where):
|
def onImageClick(self, where):
|
||||||
cr = self.ImageListView.currentRow()
|
indexes=self.ImageListView.selectedIndexes()
|
||||||
filename = self.ImageListView.item(cr, 0).text()
|
for i in indexes:
|
||||||
|
filename = self.ImageListData.get_filename(i)
|
||||||
log.info("Click %s:%s"%(str(where), filename))
|
log.info("Click %s:%s"%(str(where), filename))
|
||||||
where.add(filename)
|
where.add(filename)
|
||||||
|
|
||||||
where.render()
|
where.render()
|
||||||
|
|
||||||
def onImagePreviewClick(self):
|
def onImagePreviewClick(self):
|
||||||
@ -198,5 +202,6 @@ class ImagePlugin(Plugin, PluginUtils):
|
|||||||
self.onImageClick(self.live_service_item)
|
self.onImageClick(self.live_service_item)
|
||||||
|
|
||||||
def onImageAddClick(self):
|
def onImageAddClick(self):
|
||||||
|
"""Add this item to the OOS"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -19,8 +19,10 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
"""
|
"""
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
import logging
|
import logging
|
||||||
|
from openlp.core.lib import ServiceItem
|
||||||
|
from listwithpreviews import ListWithPreviews
|
||||||
|
|
||||||
class ImageServiceItem():
|
class ImageServiceItem(ServiceItem):
|
||||||
"""
|
"""
|
||||||
The service item is a base class for the plugins to use to interact with
|
The service item is a base class for the plugins to use to interact with
|
||||||
the service manager, the slide controller, and the renderer.
|
the service manager, the slide controller, and the renderer.
|
||||||
@ -32,20 +34,13 @@ class ImageServiceItem():
|
|||||||
"""
|
"""
|
||||||
Init Method
|
Init Method
|
||||||
"""
|
"""
|
||||||
self.imgs=[]
|
self.imgs=ListWithPreviews()
|
||||||
self.slide_controller=controller
|
self.slide_controller=controller
|
||||||
self.slide_controller.ControllerContents=QtGui.QTableWidget()
|
self.slide_controller.ControllerContents=QtGui.QListView()
|
||||||
c=self.slide_controller.ControllerContents
|
c=self.slide_controller.ControllerContents
|
||||||
c.setColumnCount(2)
|
c.uniformItemSizes=True
|
||||||
c.setColumnHidden(0, True)
|
c.setModel(self.imgs)
|
||||||
c.setColumnWidth(1, 275)
|
c.setGeometry(0,0,200,200)
|
||||||
c.setShowGrid(False)
|
|
||||||
c.setSortingEnabled(False)
|
|
||||||
c.setAlternatingRowColors(True)
|
|
||||||
c.setHorizontalHeaderLabels(QtCore.QStringList(["","Name"]))
|
|
||||||
c.setAlternatingRowColors(True)
|
|
||||||
c.setGeometry(QtCore.QRect(10, 100, 256, 591))
|
|
||||||
pass
|
|
||||||
|
|
||||||
def render(self):
|
def render(self):
|
||||||
"""
|
"""
|
||||||
@ -53,15 +48,15 @@ class ImageServiceItem():
|
|||||||
screen.
|
screen.
|
||||||
"""
|
"""
|
||||||
# render the "image chooser first"
|
# render the "image chooser first"
|
||||||
for f in self.imgs:
|
# for f in self.imgs:
|
||||||
fl , nm = os.path.split(str(f))
|
# fl , nm = os.path.split(str(f))
|
||||||
c = self.slide_controller.rowCount()
|
# c = self.slide_controller.rowCount()
|
||||||
self.slide_controller.setRowCount(c+1)
|
# self.slide_controller.setRowCount(c+1)
|
||||||
twi = QtGui.QTableWidgetItem(str(f))
|
# twi = QtGui.QTableWidgetItem(str(f))
|
||||||
self.slide_controller.setItem(c , 0, twi)
|
# self.slide_controller.setItem(c , 0, twi)
|
||||||
twi = QtGui.QTableWidgetItem(str(nm))
|
# twi = QtGui.QTableWidgetItem(str(nm))
|
||||||
self.slide_controller.setItem(c , 1, twi)
|
# self.slide_controller.setItem(c , 1, twi)
|
||||||
self.slide_controller.setRowHeight(c, 80)
|
# self.slide_controller.setRowHeight(c, 80)
|
||||||
|
|
||||||
# render the preview screen here
|
# render the preview screen here
|
||||||
|
|
||||||
@ -76,18 +71,20 @@ class ImageServiceItem():
|
|||||||
append an image to the list
|
append an image to the list
|
||||||
"""
|
"""
|
||||||
log.info("add:"+filename)
|
log.info("add:"+filename)
|
||||||
self.imgs.append(filename)
|
self.imgs.addRow(filename)
|
||||||
|
|
||||||
def get_oos_text(self):
|
def get_oos_text(self):
|
||||||
"""
|
"""
|
||||||
Turn the image list into a set of filenames for storage in the oos file
|
Turn the image list into a set of filenames for storage in the oos file
|
||||||
"""
|
"""
|
||||||
return str(self.imgs)
|
return '\n'.join(self.imgs.get_file_list())
|
||||||
|
|
||||||
def set_from_oos(self, text):
|
def set_from_oos(self, text):
|
||||||
"""
|
"""
|
||||||
get text from the OOS file and setup the internal structure
|
get text from the OOS file and setup the internal structure
|
||||||
"""
|
"""
|
||||||
log.info("Set from OOS:"+text)
|
log.info("Set from OOS:"+text)
|
||||||
self.imgs=eval(text)
|
files=text.split('\n')
|
||||||
|
for f in files:
|
||||||
|
self.imgs.addRow(f)
|
||||||
|
|
70
openlp/plugins/images/listwithpreviews.py
Normal file
70
openlp/plugins/images/listwithpreviews.py
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
import os
|
||||||
|
import logging
|
||||||
|
from PyQt4.QtCore import *
|
||||||
|
from PyQt4.QtGui import *
|
||||||
|
class ListWithPreviews(QAbstractListModel):
|
||||||
|
"""
|
||||||
|
An abstract list of strings and the preview icon to go with them
|
||||||
|
"""
|
||||||
|
global log
|
||||||
|
log=logging.getLogger("ListWithPreviews")
|
||||||
|
log.info("started")
|
||||||
|
def __init__(self):
|
||||||
|
QAbstractListModel.__init__(self)
|
||||||
|
self.items=[] # will be a list of (full filename, QPixmap, shortname) tuples
|
||||||
|
self.rowheight=50
|
||||||
|
self.maximagewidth=self.rowheight*16/9.0;
|
||||||
|
def rowCount(self, parent):
|
||||||
|
return len(self.items)
|
||||||
|
def insertRow(self, row, filename):
|
||||||
|
self.beginInsertRows(QModelIndex(),row,row)
|
||||||
|
log.info("insert row %d:%s"%(row,filename))
|
||||||
|
# get short filename to display next to image
|
||||||
|
(prefix, shortfilename) = os.path.split(str(filename))
|
||||||
|
log.info("shortfilename=%s"%(shortfilename))
|
||||||
|
# create a preview image
|
||||||
|
preview = QPixmap(str(filename))
|
||||||
|
w=self.maximagewidth;h=self.rowheight
|
||||||
|
preview = preview.scaled(w,h, Qt.KeepAspectRatio)
|
||||||
|
realw=preview.width(); realh=preview.height()
|
||||||
|
# and move it to the centre of the preview space
|
||||||
|
p=QPixmap(w,h)
|
||||||
|
p.fill(Qt.transparent)
|
||||||
|
painter=QPainter(p)
|
||||||
|
painter.drawPixmap((w-realw)/2,(h-realh)/2,preview)
|
||||||
|
# finally create the row
|
||||||
|
self.items.insert(row, (filename, p, shortfilename))
|
||||||
|
self.endInsertRows()
|
||||||
|
def removeRow(self, row):
|
||||||
|
self.beginRemoveRows(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 QVariant()
|
||||||
|
|
||||||
|
if role==Qt.DisplayRole:
|
||||||
|
retval= self.items[row][2]
|
||||||
|
elif role == Qt.DecorationRole:
|
||||||
|
retval= self.items[row][1]
|
||||||
|
elif role == Qt.ToolTipRole:
|
||||||
|
retval= self.items[row][0]
|
||||||
|
else:
|
||||||
|
retval= QVariant()
|
||||||
|
|
||||||
|
# log.info("Returning"+ str(retval))
|
||||||
|
if type(retval) is not type(QVariant):
|
||||||
|
return QVariant(retval)
|
||||||
|
else:
|
||||||
|
return retval
|
||||||
|
def get_file_list(self):
|
||||||
|
filelist=[i[0] for i in self.items];
|
||||||
|
return filelist
|
||||||
|
|
||||||
|
def get_filename(self, index):
|
||||||
|
row=index.row()
|
||||||
|
return self.items[row][0]
|
Loading…
Reference in New Issue
Block a user