eric6/WebBrowser/History/HistoryModel.py

changeset 8243
cc717c2ae956
parent 8227
349308e84eeb
equal deleted inserted replaced
8242:aa713ac50c0d 8243:cc717c2ae956
4 # 4 #
5 5
6 """ 6 """
7 Module implementing the history model. 7 Module implementing the history model.
8 """ 8 """
9
10 import contextlib
9 11
10 from PyQt5.QtCore import Qt, QAbstractTableModel, QModelIndex, QUrl 12 from PyQt5.QtCore import Qt, QAbstractTableModel, QModelIndex, QUrl
11 13
12 import WebBrowser.WebBrowserWindow 14 import WebBrowser.WebBrowserWindow
13 15
82 """ 84 """
83 if ( 85 if (
84 orientation == Qt.Orientation.Horizontal and 86 orientation == Qt.Orientation.Horizontal and
85 role == Qt.ItemDataRole.DisplayRole 87 role == Qt.ItemDataRole.DisplayRole
86 ): 88 ):
87 try: 89 with contextlib.suppress(IndexError):
88 return self.__headers[section] 90 return self.__headers[section]
89 except IndexError:
90 pass
91 return QAbstractTableModel.headerData(self, section, orientation, role) 91 return QAbstractTableModel.headerData(self, section, orientation, role)
92 92
93 def data(self, index, role=Qt.ItemDataRole.DisplayRole): 93 def data(self, index, role=Qt.ItemDataRole.DisplayRole):
94 """ 94 """
95 Public method to get data from the model. 95 Public method to get data from the model.

eric ide

mercurial