Fixes for QTreeWidget

This commit is contained in:
Arjan Schrijver 2013-01-25 12:38:48 +01:00
parent 32a77e8313
commit 5631a68c40
7 changed files with 18 additions and 18 deletions

View File

@ -367,8 +367,8 @@ class MediaManagerItem(QtGui.QWidget):
names = [] names = []
full_list = [] full_list = []
for count in range(self.listView.topLevelItemCount()): for count in range(self.listView.topLevelItemCount()):
names.append(self.listView.item(count).text()) names.append(self.listView.topLevelItem(count).text(0))
full_list.append(self.listView.item(count).data(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 in files:
@ -404,8 +404,8 @@ class MediaManagerItem(QtGui.QWidget):
count = 0 count = 0
file_list = [] file_list = []
while count < self.listView.topLevelItemCount(): while count < self.listView.topLevelItemCount():
bitem = self.listView.item(count) bitem = self.listView.topLevelItem(count)
filename = bitem.data(QtCore.Qt.UserRole) filename = bitem.data(0, QtCore.Qt.UserRole)
file_list.append(filename) file_list.append(filename)
count += 1 count += 1
return file_list return file_list
@ -498,8 +498,8 @@ class MediaManagerItem(QtGui.QWidget):
self.live_controller.addServiceItem(serviceItem) self.live_controller.addServiceItem(serviceItem)
def createItemFromId(self, item_id): def createItemFromId(self, item_id):
item = QtGui.QListWidgetItem() item = QtGui.QTreeWidgetItem()
item.setData(QtCore.Qt.UserRole, item_id) item.setData(0, QtCore.Qt.UserRole, item_id)
return item return item
def onAddClick(self): def onAddClick(self):

View File

@ -76,7 +76,7 @@ class BibleMediaItem(MediaManagerItem):
""" """
Check if the first item is a second bible item or not. Check if the first item is a second bible item or not.
""" """
bitem = self.listView.item(0) bitem = self.listView.topLevelItem(0)
if not bitem.flags() & QtCore.Qt.ItemIsSelectable: if not bitem.flags() & QtCore.Qt.ItemIsSelectable:
# The item is the "No Search Results" item. # The item is the "No Search Results" item.
self.listView.clear() self.listView.clear()
@ -972,7 +972,7 @@ class BibleMediaItem(MediaManagerItem):
return [] return []
def createItemFromId(self, item_id): def createItemFromId(self, item_id):
item = QtGui.QListWidgetItem() item = QtGui.QTreeWidgetItem()
bible = self.quickVersionComboBox.currentText() bible = self.quickVersionComboBox.currentText()
search_results = self.plugin.manager.get_verses(bible, item_id, False) search_results = self.plugin.manager.get_verses(bible, item_id, False)
items = self.buildDisplayResults(bible, u'', search_results) items = self.buildDisplayResults(bible, u'', search_results)

View File

@ -155,7 +155,7 @@ class CustomMediaItem(MediaManagerItem):
""" """
if check_item_selected(self.listView, UiStrings().SelectEdit): if check_item_selected(self.listView, UiStrings().SelectEdit):
item = self.listView.currentItem() item = self.listView.currentItem()
item_id = item.data(QtCore.Qt.UserRole) item_id = item.data(0, QtCore.Qt.UserRole)
self.edit_custom_form.loadCustom(item_id, False) self.edit_custom_form.loadCustom(item_id, False)
self.edit_custom_form.exec_() self.edit_custom_form.exec_()
self.autoSelectId = -1 self.autoSelectId = -1

View File

@ -102,10 +102,10 @@ class ImageMediaItem(MediaManagerItem):
Receiver.send_message(u'cursor_busy') Receiver.send_message(u'cursor_busy')
self.main_window.displayProgressBar(len(row_list)) self.main_window.displayProgressBar(len(row_list))
for row in row_list: for row in row_list:
text = self.listView.item(row) text = self.listView.topLevelItem(row)
if text: if text:
delete_file(os.path.join(self.servicePath, text.text())) delete_file(os.path.join(self.servicePath, text.text(0)))
self.listView.takeItem(row) self.listView.takeTopLevelItem(row)
self.main_window.incrementProgressBar() self.main_window.incrementProgressBar()
SettingsManager.setValue(self.settingsSection + u'/images files', self.getFileList()) SettingsManager.setValue(self.settingsSection + u'/images files', self.getFileList())
self.main_window.finishedProgressBar() self.main_window.finishedProgressBar()
@ -209,7 +209,7 @@ class ImageMediaItem(MediaManagerItem):
translate('ImagePlugin.MediaItem', 'You must select an image to replace the background with.')): translate('ImagePlugin.MediaItem', 'You must select an image to replace the background with.')):
background = QtGui.QColor(Settings().value(self.settingsSection + u'/background color')) background = QtGui.QColor(Settings().value(self.settingsSection + u'/background color'))
item = self.listView.selectedIndexes()[0] item = self.listView.selectedIndexes()[0]
bitem = self.listView.item(item.row()) bitem = self.listView.topLevelItem(item.row())
filename = bitem.data(QtCore.Qt.UserRole) filename = bitem.data(QtCore.Qt.UserRole)
if os.path.exists(filename): if os.path.exists(filename):
if self.plugin.liveController.display.directImage(filename, background): if self.plugin.liveController.display.directImage(filename, background):

View File

@ -147,7 +147,7 @@ class MediaMediaItem(MediaManagerItem):
if check_item_selected(self.listView, if check_item_selected(self.listView,
translate('MediaPlugin.MediaItem', 'You must select a media file to replace the background with.')): translate('MediaPlugin.MediaItem', 'You must select a media file to replace the background with.')):
item = self.listView.currentItem() item = self.listView.currentItem()
filename = item.data(QtCore.Qt.UserRole) filename = item.data(0, QtCore.Qt.UserRole)
if os.path.exists(filename): if os.path.exists(filename):
service_item = ServiceItem() service_item = ServiceItem()
service_item.title = u'webkit' service_item.title = u'webkit'
@ -171,7 +171,7 @@ class MediaMediaItem(MediaManagerItem):
item = self.listView.currentItem() item = self.listView.currentItem()
if item is None: if item is None:
return False return False
filename = item.data(QtCore.Qt.UserRole) filename = item.data(0, QtCore.Qt.UserRole)
if not os.path.exists(filename): if not os.path.exists(filename):
if not remote: if not remote:
# File is no longer present # File is no longer present
@ -253,7 +253,7 @@ class MediaMediaItem(MediaManagerItem):
row_list = [item.row() for item in self.listView.selectedIndexes()] row_list = [item.row() for item in self.listView.selectedIndexes()]
row_list.sort(reverse=True) row_list.sort(reverse=True)
for row in row_list: for row in row_list:
self.listView.takeItem(row) self.listView.takeTopLevelItem(row)
Settings().setValue(self.settingsSection + u'/media files', self.getFileList()) Settings().setValue(self.settingsSection + u'/media files', self.getFileList())
def loadList(self, media): def loadList(self, media):

View File

@ -233,7 +233,7 @@ class PresentationMediaItem(MediaManagerItem):
self.main_window.finishedProgressBar() self.main_window.finishedProgressBar()
Receiver.send_message(u'cursor_normal') Receiver.send_message(u'cursor_normal')
for row in row_list: for row in row_list:
self.listView.takeItem(row) self.listView.takeTopLevelItem(row)
Settings().setValue(self.settingsSection + u'/presentations files', self.getFileList()) Settings().setValue(self.settingsSection + u'/presentations files', self.getFileList())
def generateSlideData(self, service_item, item=None, xmlVersion=False, def generateSlideData(self, service_item, item=None, xmlVersion=False,

View File

@ -403,7 +403,7 @@ class SongMediaItem(MediaManagerItem):
log.debug(u'onCloneClick') log.debug(u'onCloneClick')
if check_item_selected(self.listView, UiStrings().SelectEdit): if check_item_selected(self.listView, UiStrings().SelectEdit):
self.editItem = self.listView.currentItem() self.editItem = self.listView.currentItem()
item_id = self.editItem.data(QtCore.Qt.UserRole) item_id = self.editItem.data(0, QtCore.Qt.UserRole)
old_song = self.plugin.manager.get_object(Song, item_id) old_song = self.plugin.manager.get_object(Song, item_id)
song_xml = self.openLyrics.song_to_xml(old_song) song_xml = self.openLyrics.song_to_xml(old_song)
new_song = self.openLyrics.xml_to_song(song_xml) new_song = self.openLyrics.xml_to_song(song_xml)