comparison DisplayModel.py @ 21:c8bb3cee7935

pull out DisplayModel into its own file, add the scaffolding for the add feed menu entry
author Dirk Olmes <dirk@xanthippe.ping.de>
date Thu, 29 Apr 2010 05:03:38 +0200
parents
children 04a730f9d07d
comparison
equal deleted inserted replaced
20:0b8398ca6cd0 21:c8bb3cee7935
1
2 from PyQt4.QtCore import QAbstractListModel, QModelIndex, QVariant, Qt
3
4 class DisplayModel(QAbstractListModel):
5 def __init__(self, parent=None, list=None, displayFunction=None, **args):
6 QAbstractListModel.__init__(self, parent, *args)
7 self.list = list
8 self.displayFunction = displayFunction
9
10 def rowCount(self, parent=QModelIndex()):
11 return len(self.list)
12
13 def data(self, index, role):
14 if index.isValid() and role == Qt.DisplayRole:
15 row = index.row()
16 object = self.list[row]
17 displayString = self.displayFunction(object)
18 return QVariant(displayString)
19 else:
20 return QVariant()