38 """ |
38 """ |
39 Public method to get header data from the model. |
39 Public method to get header data from the model. |
40 |
40 |
41 @param section section number (integer) |
41 @param section section number (integer) |
42 @param orientation orientation (Qt.Orientation) |
42 @param orientation orientation (Qt.Orientation) |
43 @param role role of the data to retrieve (integer) |
43 @param role role of the data to retrieve (Qt.ItemDataRole) |
44 @return requested data |
44 @return requested data |
45 """ |
45 """ |
46 if role == Qt.SizeHintRole: |
46 if role == Qt.ItemDataRole.SizeHintRole: |
47 fm = QFontMetrics(QFont()) |
47 fm = QFontMetrics(QFont()) |
48 height = fm.height() + fm.height() // 3 |
48 height = fm.height() + fm.height() // 3 |
49 try: |
49 try: |
50 width = fm.horizontalAdvance( |
50 width = fm.horizontalAdvance( |
51 self.headerData(section, orientation, Qt.DisplayRole)) |
51 self.headerData(section, orientation, |
|
52 Qt.ItemDataRole.DisplayRole)) |
52 except AttributeError: |
53 except AttributeError: |
53 width = fm.width( |
54 width = fm.width( |
54 self.headerData(section, orientation, Qt.DisplayRole)) |
55 self.headerData(section, orientation, |
|
56 Qt.ItemDataRole.DisplayRole)) |
55 return QSize(width, height) |
57 return QSize(width, height) |
56 |
58 |
57 if orientation == Qt.Horizontal and role == Qt.DisplayRole: |
59 if ( |
|
60 orientation == Qt.Orientation.Horizontal and |
|
61 role == Qt.ItemDataRole.DisplayRole |
|
62 ): |
58 try: |
63 try: |
59 return self.__headers[section] |
64 return self.__headers[section] |
60 except IndexError: |
65 except IndexError: |
61 return None |
66 return None |
62 |
67 |
71 @return requested data |
76 @return requested data |
72 """ |
77 """ |
73 if index.row() < 0 or index.row() >= self.rowCount(): |
78 if index.row() < 0 or index.row() >= self.rowCount(): |
74 return None |
79 return None |
75 |
80 |
76 if role in (Qt.DisplayRole, Qt.EditRole): |
81 if role in (Qt.ItemDataRole.DisplayRole, Qt.ItemDataRole.EditRole): |
77 row = index.row() |
82 row = index.row() |
78 if row < len(self.__allowedCookies): |
83 if row < len(self.__allowedCookies): |
79 if index.column() == 0: |
84 if index.column() == 0: |
80 return self.__allowedCookies[row] |
85 return self.__allowedCookies[row] |
81 elif index.column() == 1: |
86 elif index.column() == 1: |