eric6/WebBrowser/History/HistoryTreeModel.py

changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8218
7c09585bd960
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
32 self.__sourceRowCache = [] 32 self.__sourceRowCache = []
33 self.__removingDown = False 33 self.__removingDown = False
34 34
35 self.setSourceModel(sourceModel) 35 self.setSourceModel(sourceModel)
36 36
37 def headerData(self, section, orientation, role=Qt.DisplayRole): 37 def headerData(self, section, orientation,
38 role=Qt.ItemDataRole.DisplayRole):
38 """ 39 """
39 Public method to get the header data. 40 Public method to get the header data.
40 41
41 @param section section number (integer) 42 @param section section number (integer)
42 @param orientation header orientation (Qt.Orientation) 43 @param orientation header orientation (Qt.Orientation)
43 @param role data role (integer) 44 @param role data role (Qt.ItemDataRole)
44 @return header data 45 @return header data
45 """ 46 """
46 return self.sourceModel().headerData(section, orientation, role) 47 return self.sourceModel().headerData(section, orientation, role)
47 48
48 def data(self, index, role=Qt.DisplayRole): 49 def data(self, index, role=Qt.ItemDataRole.DisplayRole):
49 """ 50 """
50 Public method to get data from the model. 51 Public method to get data from the model.
51 52
52 @param index index of history entry to get data for (QModelIndex) 53 @param index index of history entry to get data for (QModelIndex)
53 @param role data role (integer) 54 @param role data role (integer)
54 @return history entry data 55 @return history entry data
55 """ 56 """
56 if role in [Qt.DisplayRole, Qt.EditRole]: 57 if role in [Qt.ItemDataRole.DisplayRole, Qt.ItemDataRole.EditRole]:
57 start = index.internalId() 58 start = index.internalId()
58 if start == 0: 59 if start == 0:
59 offset = self.__sourceDateRow(index.row()) 60 offset = self.__sourceDateRow(index.row())
60 if index.column() == 0: 61 if index.column() == 0:
61 idx = self.sourceModel().index(offset, 0) 62 idx = self.sourceModel().index(offset, 0)
66 if index.column() == 1: 67 if index.column() == 1:
67 return self.tr( 68 return self.tr(
68 "%n item(s)", "", 69 "%n item(s)", "",
69 self.rowCount(index.sibling(index.row(), 0))) 70 self.rowCount(index.sibling(index.row(), 0)))
70 71
71 elif role == Qt.DecorationRole: 72 elif role == Qt.ItemDataRole.DecorationRole:
72 if index.column() == 0 and not index.parent().isValid(): 73 if index.column() == 0 and not index.parent().isValid():
73 return UI.PixmapCache.getIcon("history") 74 return UI.PixmapCache.getIcon("history")
74 75
75 elif role == HistoryModel.DateRole: 76 elif role == HistoryModel.DateRole:
76 if index.column() == 0 and index.internalId() == 0: 77 if index.column() == 0 and index.internalId() == 0:
224 225
225 @param index index of the item (QModelIndex) 226 @param index index of the item (QModelIndex)
226 @return flags (Qt.ItemFlags) 227 @return flags (Qt.ItemFlags)
227 """ 228 """
228 if not index.isValid(): 229 if not index.isValid():
229 return Qt.ItemFlags(Qt.NoItemFlags) 230 return Qt.ItemFlags(Qt.ItemFlag.NoItemFlags)
230 return Qt.ItemFlags( 231 return Qt.ItemFlags(
231 Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsDragEnabled) 232 Qt.ItemFlag.ItemIsSelectable |
233 Qt.ItemFlag.ItemIsEnabled |
234 Qt.ItemFlag.ItemIsDragEnabled)
232 235
233 def setSourceModel(self, sourceModel): 236 def setSourceModel(self, sourceModel):
234 """ 237 """
235 Public method to set the source model. 238 Public method to set the source model.
236 239

eric ide

mercurial