comparison FeedEntryTableModel.py @ 225:f6dcc85cd8ca

use SIP API v2
author Dirk Olmes <dirk@xanthippe.ping.de>
date Thu, 22 May 2014 05:49:46 +0200
parents bb3c851b18b1
children 6ce0e081094a
comparison
equal deleted inserted replaced
224:218c2b376169 225:f6dcc85cd8ca
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 from PyQt4.QtCore import QAbstractTableModel, QVariant, Qt 2 from PyQt4.QtCore import QAbstractTableModel, Qt
3 3
4 class TableModel(QAbstractTableModel): 4 class TableModel(QAbstractTableModel):
5 ''' 5 '''
6 This is the abstract super class for table models in Python. It deals with the Qt specifics so 6 This is the abstract super class for table models in Python. It deals with the Qt specifics so
7 that subclasses only need to care about implementing the functionality 7 that subclasses only need to care about implementing the functionality
10 QAbstractTableModel.__init__(self, None, *args) 10 QAbstractTableModel.__init__(self, None, *args)
11 11
12 def headerData(self, section, orientation, role): 12 def headerData(self, section, orientation, role):
13 if orientation == Qt.Horizontal and role == Qt.DisplayRole: 13 if orientation == Qt.Horizontal and role == Qt.DisplayRole:
14 value = self.headerDataForColumn(section) 14 value = self.headerDataForColumn(section)
15 return QVariant(value) 15 value
16 else: 16 else:
17 return QVariant() 17 return None
18 18
19 def data(self, index, role): 19 def data(self, index, role):
20 if not index.isValid(): 20 if not index.isValid():
21 return QVariant() 21 return None
22 elif role != Qt.DisplayRole: 22 elif role != Qt.DisplayRole:
23 return QVariant() 23 return None
24 else: 24 else:
25 value = self.dataForRowAndColumn(index.row(), index.column()) 25 value = self.dataForRowAndColumn(index.row(), index.column())
26 return QVariant(value) 26 return value
27 27
28 28
29 class FeedEntryTableModel(TableModel): 29 class FeedEntryTableModel(TableModel):
30 def __init__(self, feedEntries, *args): 30 def __init__(self, feedEntries, *args):
31 TableModel.__init__(self, *args) 31 TableModel.__init__(self, *args)