Removed list with previews again

bzr-revno: 371
This commit is contained in:
Martin Thompson 2009-03-04 21:54:49 +00:00
parent bb95123534
commit cf364ae208

View File

@ -29,73 +29,6 @@ from PyQt4.QtGui import *
from listwithpreviews import ListWithPreviews from listwithpreviews import ListWithPreviews
from imageserviceitem import ImageServiceItem from imageserviceitem import ImageServiceItem
class ListWithPreviews(QtCore.QAbstractListModel):
"""
An abstract list of strings and the preview icon to go with them
"""
global log
log=logging.getLogger("ListWithPreviews")
log.info("started")
def __init__(self):
QtCore.QAbstractListModel.__init__(self)
self.items=[] # will be a list of (full filename, QPixmap, shortname) tuples
self.rowheight=50
self.maximagewidth=self.rowheight*16/9.0;
def rowCount(self, parent):
return len(self.items)
def insertRow(self, row, filename):
self.beginInsertRows(QModelIndex(),row,row)
log.info("insert row %d:%s"%(row,filename))
# get short filename to display next to image
(prefix, shortfilename) = os.path.split(str(filename))
log.info("shortfilename=%s"%(shortfilename))
# create a preview image
preview = QtGui.QPixmap(str(filename))
w=self.maximagewidth;h=self.rowheight
preview = preview.scaled(w,h, Qt.KeepAspectRatio)
realw=preview.width(); realh=preview.height()
# and move it to the centre of the preview space
p=QPixmap(w,h)
p.fill(Qt.transparent)
painter=QPainter(p)
painter.drawPixmap((w-realw)/2,(h-realh)/2,preview)
# finally create the row
self.items.insert(row, (filename, p, shortfilename))
self.endInsertRows()
def removeRow(self, row):
self.beginRemoveRows(QModelIndex(), row,row)
self.items.pop(row)
self.endRemoveRows()
def addRow(self, filename):
self.insertRow(len(self.items), filename)
def data(self, index, role):
row=index.row()
if row > len(self.items): # if the last row is selected and deleted, we then get called with an empty row!
return QVariant()
if role==Qt.DisplayRole:
retval= self.items[row][2]
elif role == Qt.DecorationRole:
retval= self.items[row][1]
elif role == Qt.ToolTipRole:
retval= self.items[row][0]
else:
retval= QVariant()
# log.info("Returning"+ str(retval))
if type(retval) is not type(QVariant):
return QVariant(retval)
else:
return retval
def get_file_list(self):
filelist=[i[0] for i in self.items];
return filelist
class ImagePlugin(Plugin, PluginUtils): class ImagePlugin(Plugin, PluginUtils):
global log global log
log=logging.getLogger("ImagePlugin") log=logging.getLogger("ImagePlugin")
@ -161,7 +94,6 @@ class ImagePlugin(Plugin, PluginUtils):
self.ImageListView.setAlternatingRowColors(True) self.ImageListView.setAlternatingRowColors(True)
# return self.MediaManagerItem # return self.MediaManagerItem
def initialise(self): def initialise(self):
log.info("Plugin Initialising") log.info("Plugin Initialising")
list = self._load_display_list() list = self._load_display_list()