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

View File

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