Variable fixes

bzr-revno: 2010
This commit is contained in:
Andreas Preikschat 2012-07-02 19:31:12 +02:00 committed by Raoul Snyman
commit c6e7a297ad
1 changed files with 24 additions and 27 deletions

View File

@ -352,24 +352,23 @@ class MediaManagerItem(QtGui.QWidget):
``files`` ``files``
The list of files to be loaded The list of files to be loaded
""" """
#FIXME: change local variables to words_separated_by_underscores. new_files = []
newFiles = [] error_shown = False
errorShown = False
for file in files: for file in files:
type = file.split(u'.')[-1] type = file.split(u'.')[-1]
if type.lower() not in self.onNewFileMasks: if type.lower() not in self.onNewFileMasks:
if not errorShown: if not error_shown:
critical_error_message_box( critical_error_message_box(
translate('OpenLP.MediaManagerItem', translate('OpenLP.MediaManagerItem',
'Invalid File Type'), 'Invalid File Type'),
unicode(translate('OpenLP.MediaManagerItem', unicode(translate('OpenLP.MediaManagerItem',
'Invalid File %s.\nSuffix not supported')) 'Invalid File %s.\nSuffix not supported'))
% file) % file)
errorShown = True error_shown = True
else: else:
newFiles.append(file) new_files.append(file)
if files: if new_files:
self.validateAndLoad(newFiles) self.validateAndLoad(new_files)
def validateAndLoad(self, files): def validateAndLoad(self, files):
""" """
@ -379,30 +378,29 @@ class MediaManagerItem(QtGui.QWidget):
``files`` ``files``
The files to be loaded. The files to be loaded.
""" """
#FIXME: change local variables to words_separated_by_underscores.
names = [] names = []
fullList = [] full_list = []
for count in range(self.listView.count()): for count in range(self.listView.count()):
names.append(unicode(self.listView.item(count).text())) names.append(unicode(self.listView.item(count).text()))
fullList.append(unicode(self.listView.item(count). full_list.append(unicode(self.listView.item(count).
data(QtCore.Qt.UserRole).toString())) data(QtCore.Qt.UserRole).toString()))
duplicatesFound = False duplicates_found = False
filesAdded = False files_added = False
for file in files: for file in files:
filename = os.path.split(unicode(file))[1] filename = os.path.split(unicode(file))[1]
if filename in names: if filename in names:
duplicatesFound = True duplicates_found = True
else: else:
filesAdded = True files_added = True
fullList.append(file) full_list.append(file)
if fullList and filesAdded: if full_list and files_added:
self.listView.clear() self.listView.clear()
self.loadList(fullList) self.loadList(full_list)
lastDir = os.path.split(unicode(files[0]))[0] last_dir = os.path.split(unicode(files[0]))[0]
SettingsManager.set_last_dir(self.settingsSection, lastDir) SettingsManager.set_last_dir(self.settingsSection, last_dir)
SettingsManager.set_list(self.settingsSection, SettingsManager.set_list(self.settingsSection,
self.settingsSection, self.getFileList()) self.settingsSection, self.getFileList())
if duplicatesFound: if duplicates_found:
critical_error_message_box( critical_error_message_box(
UiStrings().Duplicate, UiStrings().Duplicate,
unicode(translate('OpenLP.MediaManagerItem', unicode(translate('OpenLP.MediaManagerItem',
@ -422,13 +420,13 @@ class MediaManagerItem(QtGui.QWidget):
Return the current list of files Return the current list of files
""" """
count = 0 count = 0
filelist = [] file_list = []
while count < self.listView.count(): while count < self.listView.count():
bitem = self.listView.item(count) bitem = self.listView.item(count)
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
filelist.append(filename) file_list.append(filename)
count += 1 count += 1
return filelist return file_list
def loadList(self, list): def loadList(self, list):
raise NotImplementedError(u'MediaManagerItem.loadList needs to be ' raise NotImplementedError(u'MediaManagerItem.loadList needs to be '
@ -477,9 +475,8 @@ class MediaManagerItem(QtGui.QWidget):
Allows the change of current item in the list to be actioned Allows the change of current item in the list to be actioned
""" """
if Settings().value(u'advanced/single click preview', if Settings().value(u'advanced/single click preview',
QtCore.QVariant(False)).toBool() and self.quickPreviewAllowed \ QtCore.QVariant(False)).toBool() and self.quickPreviewAllowed and \
and self.listView.selectedIndexes() \ self.listView.selectedIndexes() and self.autoSelectId == -1:
and self.autoSelectId == -1:
self.onPreviewClick(True) self.onPreviewClick(True)
def onPreviewClick(self, keepFocus=False): def onPreviewClick(self, keepFocus=False):