sync with trunk

This commit is contained in:
rimach 2011-12-02 16:12:59 +01:00
commit cc2c58d9dc
3 changed files with 44 additions and 13 deletions

View File

@ -25,10 +25,11 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
import logging
import os import os
import logging
import time import time
import copy import copy
from collections import deque
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from PyQt4.phonon import Phonon from PyQt4.phonon import Phonon
@ -114,6 +115,8 @@ class SlideController(Controller):
self.typeLabel.setText(UiStrings().Live) self.typeLabel.setText(UiStrings().Live)
self.split = 1 self.split = 1
self.typePrefix = u'live' self.typePrefix = u'live'
self.keypress_queue = deque()
self.keypress_loop = False
else: else:
self.typeLabel.setText(UiStrings().Preview) self.typeLabel.setText(UiStrings().Preview)
self.split = 0 self.split = 0
@ -565,12 +568,34 @@ class SlideController(Controller):
self.mediaController.video_stop([self]) self.mediaController.video_stop([self])
def servicePrevious(self): def servicePrevious(self):
time.sleep(0.1) """
Receiver.send_message('servicemanager_previous_item') Live event to select the previous service item from the service manager.
"""
self.keypress_queue.append(u'previous')
self._process_queue()
def serviceNext(self): def serviceNext(self):
time.sleep(0.1) """
Live event to select the next service item from the service manager.
"""
self.keypress_queue.append(u'next')
self._process_queue()
def _process_queue(self):
"""
Process the service item request queue. The key presses can arrive
faster than the processing so implement a FIFO queue.
"""
if len(self.keypress_queue):
while len(self.keypress_queue) and not self.keypress_loop:
self.keypress_loop = True
if self.keypress_queue.popleft() == u'previous':
Receiver.send_message('servicemanager_previous_item')
else:
Receiver.send_message('servicemanager_next_item') Receiver.send_message('servicemanager_next_item')
self.keypress_loop = False
def screenSizeChanged(self): def screenSizeChanged(self):
""" """
@ -773,7 +798,7 @@ class SlideController(Controller):
log.debug(u'processManagerItem live = %s' % self.isLive) log.debug(u'processManagerItem live = %s' % self.isLive)
self.onStopLoop() self.onStopLoop()
old_item = self.serviceItem old_item = self.serviceItem
# take a copy not a link to the servicemeanager copy. # take a copy not a link to the servicemanager copy.
self.serviceItem = copy.copy(serviceItem) self.serviceItem = copy.copy(serviceItem)
if old_item and self.isLive and old_item.is_capable( if old_item and self.isLive and old_item.is_capable(
ItemCapabilities.ProvidesOwnDisplay): ItemCapabilities.ProvidesOwnDisplay):

View File

@ -124,7 +124,7 @@ class OpenLPSongImport(SongImport):
if has_media_files: if has_media_files:
source_media_files_table = source_meta.tables[u'media_files'] source_media_files_table = source_meta.tables[u'media_files']
source_media_files_songs_table = \ source_media_files_songs_table = \
source_meta.tables[u'media_files_songs'] source_meta.tables.get(u'media_files_songs')
try: try:
class_mapper(OldMediaFile) class_mapper(OldMediaFile)
except UnmappedClassError: except UnmappedClassError:
@ -137,8 +137,13 @@ class OpenLPSongImport(SongImport):
secondary=source_songs_topics_table) secondary=source_songs_topics_table)
} }
if has_media_files: if has_media_files:
song_props['media_files'] = relation(OldMediaFile, backref='songs', if source_media_files_songs_table:
song_props['media_files'] = relation(OldMediaFile,
backref='songs',
secondary=source_media_files_songs_table) secondary=source_media_files_songs_table)
else:
song_props['media_files'] = relation(OldMediaFile,
backref='songs')
try: try:
class_mapper(OldAuthor) class_mapper(OldAuthor)
except UnmappedClassError: except UnmappedClassError:

View File

@ -68,9 +68,9 @@ def upgrade_1(session, metadata, tables):
""" """
Table(u'media_files_songs', metadata, autoload=True).drop(checkfirst=True) Table(u'media_files_songs', metadata, autoload=True).drop(checkfirst=True)
Column(u'song_id', types.Integer(), default=None)\ Column(u'song_id', types.Integer(), default=None)\
.create(table=tables[u'media_files'], populate_default=True) .create(table=tables[u'media_files'])
Column(u'weight', types.Integer(), default=0)\ Column(u'weight', types.Integer(), default=0)\
.create(table=tables[u'media_files'], populate_default=True) .create(table=tables[u'media_files'])
if metadata.bind.url.get_dialect().name != 'sqlite': if metadata.bind.url.get_dialect().name != 'sqlite':
# SQLite doesn't support ALTER TABLE ADD CONSTRAINT # SQLite doesn't support ALTER TABLE ADD CONSTRAINT
ForeignKeyConstraint([u'song_id'], [u'songs.id'], ForeignKeyConstraint([u'song_id'], [u'songs.id'],
@ -83,6 +83,7 @@ def upgrade_2(session, metadata, tables):
This upgrade adds a create_date and last_modified date to the songs table This upgrade adds a create_date and last_modified date to the songs table
""" """
Column(u'create_date', types.DateTime(), default=func.now())\ Column(u'create_date', types.DateTime(), default=func.now())\
.create(table=tables[u'songs'], populate_default=True) .create(table=tables[u'songs'])
Column(u'last_modified', types.DateTime(), default=func.now())\ Column(u'last_modified', types.DateTime(), default=func.now())\
.create(table=tables[u'songs'], populate_default=True) .create(table=tables[u'songs'])