Mercurial > hg > Feedworm
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DisplayModel.py Thu Apr 29 05:03:38 2010 +0200 @@ -0,0 +1,20 @@ + +from PyQt4.QtCore import QAbstractListModel, QModelIndex, QVariant, Qt + +class DisplayModel(QAbstractListModel): + def __init__(self, parent=None, list=None, displayFunction=None, **args): + QAbstractListModel.__init__(self, parent, *args) + self.list = list + self.displayFunction = displayFunction + + def rowCount(self, parent=QModelIndex()): + return len(self.list) + + def data(self, index, role): + if index.isValid() and role == Qt.DisplayRole: + row = index.row() + object = self.list[row] + displayString = self.displayFunction(object) + return QVariant(displayString) + else: + return QVariant()