20
20
from elisa.core import common
22
from elisa.core.media_uri import MediaUri
22
from elisa.core import media_uri
24
24
from elisa.core.utils.cancellable_defer import cancellable_deferred_iterator, \
25
25
CancellableDeferred
29
29
from elisa.plugins.poblesec.actions import Action, LinkAction
30
30
from elisa.plugins.poblesec.actions import PlayAllAction, ShuffleAction
31
31
from elisa.plugins.poblesec.actions import AddToFavoritesAction, AddToPlaylistAction
32
from elisa.plugins.poblesec.actions import ViewSlideshowAction
32
from elisa.plugins.poblesec.actions import PlaySlideshowAction
34
34
from elisa.plugins.favorites.models import FavoritesItem
35
35
from elisa.plugins.database.models import Image, File
234
233
raise NotImplementedError()
237
class ViewPhotoAlbumSlideshowAction(ViewSlideshowAction):
239
def order_photos(self, rs):
235
class ViewPhotoAlbumSlideshowAction(PlaySlideshowAction):
237
def _order_photos(self, rs):
240
238
# copied and pasted the ordering from database.PhotosController
241
239
rs.order_by(Image.shot_time, Image.file_path)
244
def get_items(self, item):
245
dfr = common.application.store.find(Image, Image.album_name == item.name)
246
dfr.addCallback(self.order_photos)
242
def _get_photos_from_album(self, album):
243
dfr = common.application.store.find(Image, Image.album_name == album.name)
244
dfr.addCallback(self._order_photos)
249
class ViewPhotoDateSlideshowAction(ViewSlideshowAction):
247
def _load_images_from_database(self):
248
items = [item for item in self.controller.model if not isinstance(item, Action)]
252
dfr = self._get_photos_from_album(item)
253
dfr.addCallback(lambda the_images: images.extend(the_images))
257
return defer.fail(None)
259
def return_images(result):
262
dfr_list = defer.DeferredList(dfrs)
263
dfr_list.addCallback(return_images)
267
self.controller.stop_loading_animation()
270
dfr = self._load_images_from_database()
271
dfr.addCallbacks(self._play_slideshow, self._cleanup)
273
class ViewPhotoDateSlideshowAction(PlaySlideshowAction):
251
275
def order_photos(self, rs):
252
276
# copied and pasted the ordering from database.PhotosController
257
281
dfr = common.application.store.find(Image, Image.shot_time != None)
258
282
dfr.addCallback(self.order_photos)
259
dfr.addCallback(self.play)
283
dfr.addCallback(self._play_slideshow)
262
286
class RemoveAction(Action):
299
323
elif hasattr(self.controller, 'file_path'):
300
324
playable_model = PlayableModel()
301
playable_model.uri = MediaUri("file://%s" %
302
self.controller.file_path)
325
playable_model.uri = media_uri.MediaUri({'scheme' : 'file',
326
'path' : self.controller.file_path})
303
327
videos.append(playable_model)