Mercurial > hg > Feedworm
view FeedEntryTableModel.py @ 227:6ce0e081094a
fix the column title display
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Wed, 28 May 2014 02:47:40 +0200 |
parents | f6dcc85cd8ca |
children |
line wrap: on
line source
# -*- coding: utf-8 -*- from PyQt4.QtCore import QAbstractTableModel, Qt class TableModel(QAbstractTableModel): ''' This is the abstract super class for table models in Python. It deals with the Qt specifics so that subclasses only need to care about implementing the functionality ''' def __init__(self, *args): QAbstractTableModel.__init__(self, None, *args) def headerData(self, section, orientation, role): if orientation == Qt.Horizontal and role == Qt.DisplayRole: return self.headerDataForColumn(section) else: return None def data(self, index, role): if not index.isValid(): return None elif role != Qt.DisplayRole: return None else: value = self.dataForRowAndColumn(index.row(), index.column()) return value class FeedEntryTableModel(TableModel): def __init__(self, feedEntries, *args): TableModel.__init__(self, *args) self.feedEntries = feedEntries def rowCount(self, parent): return len(self.feedEntries) def columnCount(self, parent): return 2 def dataForRowAndColumn(self, row, column): feedEntry = self.feedEntries[row] if column == 0: return feedEntry.title else: return str(feedEntry.updated) def headerDataForColumn(self, column): if column == 0: return "Title" else: return "Date"