Lots of code style fixes

This commit is contained in:
Arjan Schrijver 2013-01-30 11:57:06 +01:00
parent dbcd1080ea
commit 260a6815c2
11 changed files with 109 additions and 102 deletions

View File

@ -43,6 +43,7 @@ from openlp.core.lib.ui import create_widget_action, critical_error_message_box
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class MediaManagerItem(QtGui.QWidget): class MediaManagerItem(QtGui.QWidget):
""" """
MediaManagerItem is a helper widget for plugins. MediaManagerItem is a helper widget for plugins.
@ -344,19 +345,19 @@ class MediaManagerItem(QtGui.QWidget):
""" """
new_files = [] new_files = []
error_shown = False error_shown = False
for file in data['files']: for file_name in data['files']:
type = file.split(u'.')[-1] type = file_name.split(u'.')[-1]
if type.lower() not in self.onNewFileMasks: if type.lower() not in self.onNewFileMasks:
if not error_shown: if not error_shown:
critical_error_message_box(translate('OpenLP.MediaManagerItem', 'Invalid File Type'), critical_error_message_box(translate('OpenLP.MediaManagerItem', 'Invalid File Type'),
translate('OpenLP.MediaManagerItem', 'Invalid File %s.\nSuffix not supported') % file) translate('OpenLP.MediaManagerItem', 'Invalid File %s.\nSuffix not supported') % file_name)
error_shown = True error_shown = True
else: else:
new_files.append(file) new_files.append(file_name)
if new_files: if new_files:
self.validateAndLoad(new_files, data['target']) self.validateAndLoad(new_files, data['target'])
def dndMoveInternal(self, target): def dnd_move_internal(self, target):
""" """
Handle internal moving of media manager items Handle internal moving of media manager items
""" """
@ -377,8 +378,8 @@ class MediaManagerItem(QtGui.QWidget):
full_list.append(self.listView.topLevelItem(count).data(0, QtCore.Qt.UserRole)) full_list.append(self.listView.topLevelItem(count).data(0, QtCore.Qt.UserRole))
duplicates_found = False duplicates_found = False
files_added = False files_added = False
for file in files: for file_path in files:
filename = os.path.split(unicode(file))[1] filename = os.path.split(unicode(file_path))[1]
if filename in names: if filename in names:
duplicates_found = True duplicates_found = True
else: else:

View File

@ -35,6 +35,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import Receiver from openlp.core.lib import Receiver
class TreeWidgetWithDnD(QtGui.QTreeWidget): class TreeWidgetWithDnD(QtGui.QTreeWidget):
""" """
Provide a tree widget to store objects and handle drag and drop events Provide a tree widget to store objects and handle drag and drop events
@ -60,7 +61,7 @@ class TreeWidgetWithDnD(QtGui.QTreeWidget):
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_dnd' % self.mimeDataText), QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_dnd' % self.mimeDataText),
self.parent().loadFile) self.parent().loadFile)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_dnd_internal' % self.mimeDataText), QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_dnd_internal' % self.mimeDataText),
self.parent().dndMoveInternal) self.parent().dnd_move_internal)
def doInternalDnD(self, accept): def doInternalDnD(self, accept):
self.allowInternalDnD = accept self.allowInternalDnD = accept
@ -118,9 +119,9 @@ class TreeWidgetWithDnD(QtGui.QTreeWidget):
files.append(localFile) files.append(localFile)
elif os.path.isdir(localFile): elif os.path.isdir(localFile):
listing = os.listdir(localFile) listing = os.listdir(localFile)
for file in listing: for file_name in listing:
files.append(os.path.join(localFile, file)) files.append(os.path.join(localFile, file_name))
Receiver.send_message(u'%s_dnd' % self.mimeDataText, {'files':files, 'target':self.itemAt(event.pos())}) Receiver.send_message(u'%s_dnd' % self.mimeDataText, {'files': files, 'target': self.itemAt(event.pos())})
elif self.allowInternalDnD: elif self.allowInternalDnD:
event.setDropAction(QtCore.Qt.CopyAction) event.setDropAction(QtCore.Qt.CopyAction)
event.accept() event.accept()

View File

@ -55,4 +55,3 @@ from the .ui files later if necessary.
from addgroupform import AddGroupForm from addgroupform import AddGroupForm
from choosegroupform import ChooseGroupForm from choosegroupform import ChooseGroupForm

View File

@ -32,32 +32,33 @@ from PyQt4 import QtGui
from openlp.core.lib import translate from openlp.core.lib import translate
from openlp.core.lib.ui import create_button_box from openlp.core.lib.ui import create_button_box
class Ui_AddGroupDialog(object):
def setupUi(self, addGroupDialog):
addGroupDialog.setObjectName(u'addGroupDialog')
addGroupDialog.resize(300, 10)
self.dialogLayout = QtGui.QVBoxLayout(addGroupDialog)
self.dialogLayout.setObjectName(u'dialogLayout')
self.nameLayout = QtGui.QFormLayout()
self.nameLayout.setObjectName(u'nameLayout')
self.parentGroupLabel = QtGui.QLabel(addGroupDialog)
self.parentGroupLabel.setObjectName(u'parentGroupLabel')
self.parentGroupComboBox = QtGui.QComboBox(addGroupDialog)
self.parentGroupComboBox.setObjectName(u'parentGroupComboBox')
self.nameLayout.addRow(self.parentGroupLabel, self.parentGroupComboBox)
self.nameLabel = QtGui.QLabel(addGroupDialog)
self.nameLabel.setObjectName(u'nameLabel')
self.nameEdit = QtGui.QLineEdit(addGroupDialog)
self.nameEdit.setObjectName(u'nameEdit')
self.nameLabel.setBuddy(self.nameEdit)
self.nameLayout.addRow(self.nameLabel, self.nameEdit)
self.dialogLayout.addLayout(self.nameLayout)
self.buttonBox = create_button_box(addGroupDialog, u'buttonBox', [u'cancel', u'save'])
self.dialogLayout.addWidget(self.buttonBox)
self.retranslateUi(addGroupDialog)
addGroupDialog.setMaximumHeight(addGroupDialog.sizeHint().height())
def retranslateUi(self, addGroupDialog): class Ui_AddGroupDialog(object):
addGroupDialog.setWindowTitle(translate('ImagePlugin.AddGroupForm', 'Add group')) def setupUi(self, add_group_dialog):
self.parentGroupLabel.setText(translate('ImagePlugin.AddGroupForm', 'Parent group:')) add_group_dialog.setObjectName(u'add_group_dialog')
self.nameLabel.setText(translate('ImagePlugin.AddGroupForm', 'Group name:')) add_group_dialog.resize(300, 10)
self.dialog_layout = QtGui.QVBoxLayout(add_group_dialog)
self.dialog_layout.setObjectName(u'dialog_layout')
self.name_layout = QtGui.QFormLayout()
self.name_layout.setObjectName(u'name_layout')
self.parent_group_label = QtGui.QLabel(add_group_dialog)
self.parent_group_label.setObjectName(u'parent_group_label')
self.parent_group_combobox = QtGui.QComboBox(add_group_dialog)
self.parent_group_combobox.setObjectName(u'parent_group_combobox')
self.name_layout.addRow(self.parent_group_label, self.parent_group_combobox)
self.name_label = QtGui.QLabel(add_group_dialog)
self.name_label.setObjectName(u'name_label')
self.name_edit = QtGui.QLineEdit(add_group_dialog)
self.name_edit.setObjectName(u'name_edit')
self.name_label.setBuddy(self.name_edit)
self.name_layout.addRow(self.name_label, self.name_edit)
self.dialog_layout.addLayout(self.name_layout)
self.button_box = create_button_box(add_group_dialog, u'button_box', [u'cancel', u'save'])
self.dialog_layout.addWidget(self.button_box)
self.retranslateUi(add_group_dialog)
add_group_dialog.setMaximumHeight(add_group_dialog.sizeHint().height())
def retranslateUi(self, add_group_dialog):
add_group_dialog.setWindowTitle(translate('ImagePlugin.AddGroupForm', 'Add group'))
self.parent_group_label.setText(translate('ImagePlugin.AddGroupForm', 'Parent group:'))
self.name_label.setText(translate('ImagePlugin.AddGroupForm', 'Group name:'))

View File

@ -33,6 +33,7 @@ from openlp.core.lib import translate
from openlp.core.lib.ui import critical_error_message_box from openlp.core.lib.ui import critical_error_message_box
from openlp.plugins.images.forms.addgroupdialog import Ui_AddGroupDialog from openlp.plugins.images.forms.addgroupdialog import Ui_AddGroupDialog
class AddGroupForm(QtGui.QDialog, Ui_AddGroupDialog): class AddGroupForm(QtGui.QDialog, Ui_AddGroupDialog):
""" """
Class documentation goes here. Class documentation goes here.
@ -44,20 +45,20 @@ class AddGroupForm(QtGui.QDialog, Ui_AddGroupDialog):
QtGui.QDialog.__init__(self, parent) QtGui.QDialog.__init__(self, parent)
self.setupUi(self) self.setupUi(self)
def exec_(self, clear=True, showTopLevelGroup=False): def exec_(self, clear=True, show_top_level_group=False):
if clear: if clear:
self.nameEdit.clear() self.name_edit.clear()
self.nameEdit.setFocus() self.name_edit.setFocus()
if showTopLevelGroup and not self.parentGroupComboBox.topLevelGroupAdded: if show_top_level_group and not self.parent_group_combobox.top_level_group_added:
self.parentGroupComboBox.insertItem(0, translate('ImagePlugin.MediaItem', '-- Top-level group --'), 0) self.parent_group_combobox.insertItem(0, translate('ImagePlugin.MediaItem', '-- Top-level group --'), 0)
self.parentGroupComboBox.topLevelGroupAdded = True self.parent_group_combobox.top_level_group_added = True
return QtGui.QDialog.exec_(self) return QtGui.QDialog.exec_(self)
def accept(self): def accept(self):
if not self.nameEdit.text(): if not self.name_edit.text():
critical_error_message_box(message=translate('ImagePlugin.AddGroupForm', critical_error_message_box(message=translate('ImagePlugin.AddGroupForm',
'You need to type in a group name.')) 'You need to type in a group name.'))
self.nameEdit.setFocus() self.name_edit.setFocus()
return False return False
else: else:
return QtGui.QDialog.accept(self) return QtGui.QDialog.accept(self)

View File

@ -32,30 +32,30 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate from openlp.core.lib import translate
from openlp.core.lib.ui import create_button_box from openlp.core.lib.ui import create_button_box
class Ui_ChooseGroupDialog(object): class Ui_ChooseGroupDialog(object):
def setupUi(self, chooseGroupDialog): def setupUi(self, choose_group_dialog):
chooseGroupDialog.setObjectName(u'chooseGroupDialog') choose_group_dialog.setObjectName(u'choose_group_dialog')
chooseGroupDialog.resize(440, 119) choose_group_dialog.resize(440, 119)
self.chooseGroupLayout = QtGui.QFormLayout(chooseGroupDialog) self.choose_group_layout = QtGui.QFormLayout(choose_group_dialog)
self.chooseGroupLayout.setFieldGrowthPolicy(QtGui.QFormLayout.ExpandingFieldsGrow) self.choose_group_layout.setFieldGrowthPolicy(QtGui.QFormLayout.ExpandingFieldsGrow)
self.chooseGroupLayout.setMargin(8) self.choose_group_layout.setMargin(8)
self.chooseGroupLayout.setSpacing(8) self.choose_group_layout.setSpacing(8)
self.chooseGroupLayout.setObjectName(u'chooseGroupLayout') self.choose_group_layout.setObjectName(u'choose_group_layout')
self.groupQuestionLabel = QtGui.QLabel(chooseGroupDialog) self.group_question_label = QtGui.QLabel(choose_group_dialog)
self.groupQuestionLabel.setWordWrap(True) self.group_question_label.setWordWrap(True)
self.groupQuestionLabel.setObjectName(u'groupQuestionLabel') self.group_question_label.setObjectName(u'group_question_label')
self.chooseGroupLayout.setWidget(1, QtGui.QFormLayout.SpanningRole, self.groupQuestionLabel) self.choose_group_layout.setWidget(1, QtGui.QFormLayout.SpanningRole, self.group_question_label)
self.groupComboBox = QtGui.QComboBox(chooseGroupDialog) self.group_combobox = QtGui.QComboBox(choose_group_dialog)
self.groupComboBox.setObjectName(u'groupComboBox') self.group_combobox.setObjectName(u'group_combobox')
self.chooseGroupLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.groupComboBox) self.choose_group_layout.setWidget(2, QtGui.QFormLayout.FieldRole, self.group_combobox)
self.groupButtonBox = create_button_box(chooseGroupDialog, u'buttonBox', [u'ok']) self.group_button_box = create_button_box(choose_group_dialog, u'buttonBox', [u'ok'])
self.chooseGroupLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.groupButtonBox) self.choose_group_layout.setWidget(3, QtGui.QFormLayout.FieldRole, self.group_button_box)
self.retranslateUi(chooseGroupDialog) self.retranslateUi(choose_group_dialog)
QtCore.QMetaObject.connectSlotsByName(chooseGroupDialog) QtCore.QMetaObject.connectSlotsByName(choose_group_dialog)
def retranslateUi(self, chooseGroupDialog): def retranslateUi(self, choose_group_dialog):
chooseGroupDialog.setWindowTitle(translate('ImagePlugin.ChooseGroupForm', 'Choose group')) choose_group_dialog.setWindowTitle(translate('ImagePlugin.ChooseGroupForm', 'Choose group'))
self.groupQuestionLabel.setText(translate('ImagePlugin.ChooseGroupForm', self.group_question_label.setText(translate('ImagePlugin.ChooseGroupForm',
'To which group do you want these images to be added?')) 'To which group do you want these images to be added?'))

View File

@ -33,6 +33,7 @@ from openlp.core.lib import translate
from openlp.core.lib.ui import critical_error_message_box from openlp.core.lib.ui import critical_error_message_box
from openlp.plugins.images.forms.choosegroupdialog import Ui_ChooseGroupDialog from openlp.plugins.images.forms.choosegroupdialog import Ui_ChooseGroupDialog
class ChooseGroupForm(QtGui.QDialog, Ui_ChooseGroupDialog): class ChooseGroupForm(QtGui.QDialog, Ui_ChooseGroupDialog):
""" """
Class documentation goes here. Class documentation goes here.
@ -43,4 +44,3 @@ class ChooseGroupForm(QtGui.QDialog, Ui_ChooseGroupDialog):
""" """
QtGui.QDialog.__init__(self, parent) QtGui.QDialog.__init__(self, parent)
self.setupUi(self) self.setupUi(self)

View File

@ -39,10 +39,10 @@ from openlp.plugins.images.lib.db import init_schema
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
__default_settings__ = { __default_settings__ = {
u'images/db type': u'sqlite', u'images/db type': u'sqlite',
u'images/background color': u'#000000', u'images/background color': u'#000000',
u'images/images files': [] u'images/images files': []
} }
class ImagePlugin(Plugin): class ImagePlugin(Plugin):
@ -80,8 +80,7 @@ class ImagePlugin(Plugin):
u'plural': translate('ImagePlugin', 'Images', 'name plural') u'plural': translate('ImagePlugin', 'Images', 'name plural')
} }
## Name for MediaDockManager, SettingsManager ## ## Name for MediaDockManager, SettingsManager ##
self.textStrings[StringContent.VisibleName] = {u'title': translate('ImagePlugin', 'Images', 'container title') self.textStrings[StringContent.VisibleName] = {u'title': translate('ImagePlugin', 'Images', 'container title')}
}
# Middle Header Bar # Middle Header Bar
tooltips = { tooltips = {
u'load': translate('ImagePlugin', 'Load a new image.'), u'load': translate('ImagePlugin', 'Load a new image.'),

View File

@ -42,12 +42,14 @@ class ImageGroups(BaseModel):
""" """
pass pass
class ImageFilenames(BaseModel): class ImageFilenames(BaseModel):
""" """
ImageFilenames model ImageFilenames model
""" """
pass pass
def init_schema(url): def init_schema(url):
""" """
Setup the images database connection and initialise the database schema. Setup the images database connection and initialise the database schema.

View File

@ -31,6 +31,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import SettingsTab, translate, Receiver, Settings, UiStrings from openlp.core.lib import SettingsTab, translate, Receiver, Settings, UiStrings
class ImageTab(SettingsTab): class ImageTab(SettingsTab):
""" """
ImageTab is the images settings tab in the settings dialog. ImageTab is the images settings tab in the settings dialog.
@ -92,4 +93,3 @@ class ImageTab(SettingsTab):
settings.endGroup() settings.endGroup()
if self.initial_color != self.bg_color: if self.initial_color != self.bg_color:
Receiver.send_message(u'image_updated') Receiver.send_message(u'image_updated')

View File

@ -42,6 +42,7 @@ from openlp.plugins.images.lib.db import ImageFilenames, ImageGroups
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class ImageMediaItem(MediaManagerItem): class ImageMediaItem(MediaManagerItem):
""" """
This is the custom media manager item for images. This is the custom media manager item for images.
@ -56,8 +57,8 @@ class ImageMediaItem(MediaManagerItem):
self.manager = plugin.manager self.manager = plugin.manager
self.choosegroupform = ChooseGroupForm(self) self.choosegroupform = ChooseGroupForm(self)
self.addgroupform = AddGroupForm(self) self.addgroupform = AddGroupForm(self)
self.fillGroupsComboBox(self.choosegroupform.groupComboBox) self.fill_groups_combo_box(self.choosegroupform.group_combobox)
self.fillGroupsComboBox(self.addgroupform.parentGroupComboBox) self.fill_groups_combo_box(self.addgroupform.parent_group_combobox)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_theme_changed'), self.liveThemeChanged) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_theme_changed'), self.liveThemeChanged)
# Allow DnD from the desktop # Allow DnD from the desktop
self.listView.activateDnD() self.listView.activateDnD()
@ -90,7 +91,7 @@ class ImageMediaItem(MediaManagerItem):
self.servicePath = os.path.join(AppLocation.get_section_data_path(self.settingsSection), u'thumbnails') self.servicePath = os.path.join(AppLocation.get_section_data_path(self.settingsSection), u'thumbnails')
check_directory_exists(self.servicePath) check_directory_exists(self.servicePath)
# Import old images list # Import old images list
images_old = Settings().value(self.settingsSection + u'/images files') images_old = Settings().value(self.settingsSection + u'/images files')
if len(images_old) > 0: if len(images_old) > 0:
for imageFile in images_old: for imageFile in images_old:
imagefilename = ImageFilenames() imagefilename = ImageFilenames()
@ -136,7 +137,8 @@ class ImageMediaItem(MediaManagerItem):
""" """
# Turn off auto preview triggers. # Turn off auto preview triggers.
self.listView.blockSignals(True) self.listView.blockSignals(True)
if check_item_selected(self.listView, translate('ImagePlugin.MediaItem','You must select an image to delete.')): if check_item_selected(self.listView, translate('ImagePlugin.MediaItem',
'You must select an image to delete.')):
item_list = self.listView.selectedItems() item_list = self.listView.selectedItems()
Receiver.send_message(u'cursor_busy') Receiver.send_message(u'cursor_busy')
self.main_window.displayProgressBar(len(item_list)) self.main_window.displayProgressBar(len(item_list))
@ -160,8 +162,8 @@ class ImageMediaItem(MediaManagerItem):
self.listView.takeTopLevelItem(self.listView.indexOfTopLevelItem(row_item)) self.listView.takeTopLevelItem(self.listView.indexOfTopLevelItem(row_item))
else: else:
row_item.parent().removeChild(row_item) row_item.parent().removeChild(row_item)
self.fillGroupsComboBox(self.choosegroupform.groupComboBox) self.fill_groups_combo_box(self.choosegroupform.group_combobox)
self.fillGroupsComboBox(self.addgroupform.parentGroupComboBox) self.fill_groups_combo_box(self.addgroupform.parent_group_combobox)
self.main_window.incrementProgressBar() self.main_window.incrementProgressBar()
self.main_window.finishedProgressBar() self.main_window.finishedProgressBar()
Receiver.send_message(u'cursor_normal') Receiver.send_message(u'cursor_normal')
@ -184,18 +186,18 @@ class ImageMediaItem(MediaManagerItem):
groupList[image_group.id] = group groupList[image_group.id] = group
self.addSubGroups(groupList, image_group.id) self.addSubGroups(groupList, image_group.id)
def fillGroupsComboBox(self, comboBox, parentGroupId=0, prefix=''): def fill_groups_combo_box(self, comboBox, parentGroupId=0, prefix=''):
""" """
Recursively add groups to the combobox in the 'Add group' dialog Recursively add groups to the combobox in the 'Add group' dialog
""" """
if parentGroupId is 0: if parentGroupId is 0:
comboBox.clear() comboBox.clear()
comboBox.topLevelGroupAdded = False comboBox.top_level_group_added = False
image_groups = self.manager.get_all_objects(ImageGroups, ImageGroups.parent_id == parentGroupId) image_groups = self.manager.get_all_objects(ImageGroups, ImageGroups.parent_id == parentGroupId)
image_groups.sort(cmp=locale_compare, key=lambda group_object: group_object.group_name) image_groups.sort(cmp=locale_compare, key=lambda group_object: group_object.group_name)
for image_group in image_groups: for image_group in image_groups:
comboBox.addItem(prefix+image_group.group_name, image_group.id) comboBox.addItem(prefix + image_group.group_name, image_group.id)
self.fillGroupsComboBox(comboBox, image_group.id, prefix+' ') self.fill_groups_combo_box(comboBox, image_group.id, prefix + ' ')
def loadFullList(self, images, initialLoad=False): def loadFullList(self, images, initialLoad=False):
""" """
@ -249,8 +251,8 @@ class ImageMediaItem(MediaManagerItem):
if target_group is None: if target_group is None:
# Ask which group the images should be saved in # Ask which group the images should be saved in
if self.choosegroupform.exec_(): if self.choosegroupform.exec_():
group_id = self.choosegroupform.groupComboBox.itemData( group_id = self.choosegroupform.group_combobox.itemData(
self.choosegroupform.groupComboBox.currentIndex(), QtCore.Qt.UserRole) self.choosegroupform.group_combobox.currentIndex(), QtCore.Qt.UserRole)
parent_group = self.manager.get_object_filtered(ImageGroups, ImageGroups.id == group_id) parent_group = self.manager.get_object_filtered(ImageGroups, ImageGroups.id == group_id)
else: else:
parent_group = target_group.data(0, QtCore.Qt.UserRole) parent_group = target_group.data(0, QtCore.Qt.UserRole)
@ -271,7 +273,7 @@ class ImageMediaItem(MediaManagerItem):
self.loadFullList(self.manager.get_all_objects(ImageFilenames, order_by_ref=ImageFilenames.filename), self.loadFullList(self.manager.get_all_objects(ImageFilenames, order_by_ref=ImageFilenames.filename),
initialLoad) initialLoad)
def dndMoveInternal(self, target): def dnd_move_internal(self, target):
""" """
Handle drag-and-drop moving of images within the media manager Handle drag-and-drop moving of images within the media manager
""" """
@ -386,16 +388,16 @@ class ImageMediaItem(MediaManagerItem):
""" """
Called to add a new group Called to add a new group
""" """
if self.addgroupform.exec_(showTopLevelGroup=True): if self.addgroupform.exec_(show_top_level_group=True):
new_group = ImageGroups.populate(parent_id=self.addgroupform.parentGroupComboBox.itemData( new_group = ImageGroups.populate(parent_id=self.addgroupform.parent_group_combobox.itemData(
self.addgroupform.parentGroupComboBox.currentIndex(), QtCore.Qt.UserRole), self.addgroupform.parent_group_combobox.currentIndex(), QtCore.Qt.UserRole),
group_name=self.addgroupform.nameEdit.text()) group_name=self.addgroupform.name_edit.text())
if self.checkGroupName(new_group): if self.checkGroupName(new_group):
if self.manager.save_object(new_group): if self.manager.save_object(new_group):
self.loadFullList(self.manager.get_all_objects(ImageFilenames, self.loadFullList(self.manager.get_all_objects(ImageFilenames,
order_by_ref=ImageFilenames.filename)) order_by_ref=ImageFilenames.filename))
self.fillGroupsComboBox(self.choosegroupform.groupComboBox) self.fill_groups_combo_box(self.choosegroupform.group_combobox)
self.fillGroupsComboBox(self.addgroupform.parentGroupComboBox) self.fill_groups_combo_box(self.addgroupform.parent_group_combobox)
else: else:
critical_error_message_box( critical_error_message_box(
message=translate('ImagePlugin.AddGroupForm', 'Could not add the new group.')) message=translate('ImagePlugin.AddGroupForm', 'Could not add the new group.'))
@ -437,9 +439,10 @@ class ImageMediaItem(MediaManagerItem):
'the image file "%s" no longer exists.') % filename) 'the image file "%s" no longer exists.') % filename)
def search(self, string, showError): def search(self, string, showError):
files = self.manager.get_all_objects(ImageFilenames, filter_clause=ImageFilenames.filename.contains(string), order_by_ref=ImageFilenames.filename) files = self.manager.get_all_objects(ImageFilenames, filter_clause=ImageFilenames.filename.contains(string),
order_by_ref=ImageFilenames.filename)
results = [] results = []
for file in files: for file_object in files:
filename = os.path.split(unicode(file.filename))[1] filename = os.path.split(unicode(file_object.filename))[1]
results.append([file.filename, filename]) results.append([file_object.filename, filename])
return results return results