4 # |
4 # |
5 |
5 |
6 """ |
6 """ |
7 Module implementing the bookmark model class. |
7 Module implementing the bookmark model class. |
8 """ |
8 """ |
|
9 |
|
10 import contextlib |
9 |
11 |
10 from PyQt5.QtCore import ( |
12 from PyQt5.QtCore import ( |
11 Qt, QAbstractItemModel, QModelIndex, QUrl, QByteArray, QDataStream, |
13 Qt, QAbstractItemModel, QModelIndex, QUrl, QByteArray, QDataStream, |
12 QIODevice, QBuffer, QMimeData |
14 QIODevice, QBuffer, QMimeData |
13 ) |
15 ) |
152 """ |
154 """ |
153 if ( |
155 if ( |
154 orientation == Qt.Orientation.Horizontal and |
156 orientation == Qt.Orientation.Horizontal and |
155 role == Qt.ItemDataRole.DisplayRole |
157 role == Qt.ItemDataRole.DisplayRole |
156 ): |
158 ): |
157 try: |
159 with contextlib.suppress(IndexError): |
158 return self.__headers[section] |
160 return self.__headers[section] |
159 except IndexError: |
|
160 pass |
|
161 return QAbstractItemModel.headerData(self, section, orientation, role) |
161 return QAbstractItemModel.headerData(self, section, orientation, role) |
162 |
162 |
163 def data(self, index, role=Qt.ItemDataRole.DisplayRole): |
163 def data(self, index, role=Qt.ItemDataRole.DisplayRole): |
164 """ |
164 """ |
165 Public method to get data from the model. |
165 Public method to get data from the model. |