Remote searches presentations, media and images

This commit is contained in:
Jonathan Corwin 2011-05-15 21:03:45 +01:00
parent 3f21b3e2ca
commit 2655c1b133
3 changed files with 84 additions and 48 deletions

View File

@ -47,6 +47,7 @@ class ImageMediaItem(MediaManagerItem):
self.IconPath = u'images/image' self.IconPath = u'images/image'
MediaManagerItem.__init__(self, parent, self, icon) MediaManagerItem.__init__(self, parent, self, icon)
self.quickPreviewAllowed = True self.quickPreviewAllowed = True
self.hasSearch = True
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'live_theme_changed'), self.liveThemeChanged) QtCore.SIGNAL(u'live_theme_changed'), self.liveThemeChanged)
@ -130,8 +131,12 @@ class ImageMediaItem(MediaManagerItem):
self.parent.formparent.finishedProgressBar() self.parent.formparent.finishedProgressBar()
def generateSlideData(self, service_item, item=None, xmlVersion=False): def generateSlideData(self, service_item, item=None, xmlVersion=False):
items = self.listView.selectedIndexes() if item:
if items: items = [item]
else:
items = self.listView.selectedItems()
if not items:
return False
service_item.title = unicode(self.plugin.nameStrings[u'plural']) service_item.title = unicode(self.plugin.nameStrings[u'plural'])
service_item.add_capability(ItemCapabilities.AllowsMaintain) service_item.add_capability(ItemCapabilities.AllowsMaintain)
service_item.add_capability(ItemCapabilities.AllowsPreview) service_item.add_capability(ItemCapabilities.AllowsPreview)
@ -141,8 +146,7 @@ class ImageMediaItem(MediaManagerItem):
service_item.theme = -1 service_item.theme = -1
missing_items = [] missing_items = []
missing_items_filenames = [] missing_items_filenames = []
for item in items: for bitem in items:
bitem = self.listView.item(item.row())
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
if not os.path.exists(filename): if not os.path.exists(filename):
missing_items.append(item) missing_items.append(item)
@ -167,14 +171,11 @@ class ImageMediaItem(MediaManagerItem):
QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No: QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No:
return False return False
# Continue with the existing images. # Continue with the existing images.
for item in items: for bitem in items:
bitem = self.listView.item(item.row())
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
(path, name) = os.path.split(filename) (path, name) = os.path.split(filename)
service_item.add_from_image(filename, name) service_item.add_from_image(filename, name)
return True return True
else:
return False
def onResetClick(self): def onResetClick(self):
""" """
@ -208,3 +209,14 @@ class ImageMediaItem(MediaManagerItem):
unicode(translate('ImagePlugin.MediaItem', unicode(translate('ImagePlugin.MediaItem',
'There was a problem replacing your background, ' 'There was a problem replacing your background, '
'the image file "%s" no longer exists.')) % filename) 'the image file "%s" no longer exists.')) % filename)
def search(self, string):
list = SettingsManager.load_list(self.settingsSection,
self.settingsSection)
results = []
string = string.lower()
for file in list:
filename = os.path.split(unicode(file))[1]
if filename.lower().find(string) > -1:
results.append([file, filename])
return results

View File

@ -50,6 +50,7 @@ class MediaMediaItem(MediaManagerItem):
u':/media/media_video.png').toImage() u':/media/media_video.png').toImage()
MediaManagerItem.__init__(self, parent, self, icon) MediaManagerItem.__init__(self, parent, self, icon)
self.singleServiceItem = False self.singleServiceItem = False
self.hasSearch = True
self.mediaObject = None self.mediaObject = None
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'video_background_replaced'), QtCore.SIGNAL(u'video_background_replaced'),
@ -212,3 +213,14 @@ class MediaMediaItem(MediaManagerItem):
log.debug(u'CreatePhonon') log.debug(u'CreatePhonon')
if not self.mediaObject: if not self.mediaObject:
self.mediaObject = Phonon.MediaObject(self) self.mediaObject = Phonon.MediaObject(self)
def search(self, string):
list = SettingsManager.load_list(self.settingsSection,
self.settingsSection)
results = []
string = string.lower()
for file in list:
filename = os.path.split(unicode(file))[1]
if filename.lower().find(string) > -1:
results.append([file, filename])
return results

View File

@ -53,6 +53,7 @@ class PresentationMediaItem(MediaManagerItem):
self.Automatic = u'' self.Automatic = u''
MediaManagerItem.__init__(self, parent, self, icon) MediaManagerItem.__init__(self, parent, self, icon)
self.message_listener = MessageListener(self) self.message_listener = MessageListener(self)
self.hasSearch = True
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'mediaitem_presentation_rebuild'), self.rebuild) QtCore.SIGNAL(u'mediaitem_presentation_rebuild'), self.rebuild)
@ -231,7 +232,10 @@ class PresentationMediaItem(MediaManagerItem):
in the slidecontroller. In the case of powerpoints, an image in the slidecontroller. In the case of powerpoints, an image
for each slide for each slide
""" """
items = self.listView.selectedIndexes() if item:
items = [item]
else:
items = self.listView.selectedItems()
if len(items) > 1: if len(items) > 1:
return False return False
service_item.title = unicode(self.displayTypeComboBox.currentText()) service_item.title = unicode(self.displayTypeComboBox.currentText())
@ -240,8 +244,7 @@ class PresentationMediaItem(MediaManagerItem):
service_item.add_capability(ItemCapabilities.AllowsDetailedTitleDisplay) service_item.add_capability(ItemCapabilities.AllowsDetailedTitleDisplay)
shortname = service_item.shortname shortname = service_item.shortname
if shortname: if shortname:
for item in items: for bitem in items:
bitem = self.listView.item(item.row())
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
if os.path.exists(filename): if os.path.exists(filename):
if shortname == self.Automatic: if shortname == self.Automatic:
@ -303,3 +306,12 @@ class PresentationMediaItem(MediaManagerItem):
if filetype in self.controllers[controller].alsosupports: if filetype in self.controllers[controller].alsosupports:
return controller return controller
return None return None
def search(self, string):
list = SettingsManager.load_list(self.settingsSection, u'presentations')
results = []
string = string.lower()
for file in list:
if file.lower().find(string) > -1:
results.append([file, file])
return results