46 """ |
46 """ |
47 if role == Qt.SizeHintRole: |
47 if role == Qt.SizeHintRole: |
48 fm = QFontMetrics(QFont()) |
48 fm = QFontMetrics(QFont()) |
49 height = fm.height() + fm.height() / 3 |
49 height = fm.height() + fm.height() / 3 |
50 width = \ |
50 width = \ |
51 fm.width(self.headerData(section, orientation, Qt.DisplayRole).toString()) |
51 fm.width(self.headerData(section, orientation, Qt.DisplayRole)) |
52 return QVariant(QSize(width, height)) |
52 return QSize(width, height) |
53 |
53 |
54 if orientation == Qt.Horizontal: |
54 if orientation == Qt.Horizontal: |
55 if role == Qt.DisplayRole: |
55 if role == Qt.DisplayRole: |
56 try: |
56 try: |
57 return QVariant(self.__headers[section]) |
57 return self.__headers[section] |
58 except IndexError: |
58 except IndexError: |
59 return QVariant() |
59 return None |
60 |
60 |
61 return QVariant() |
61 return None |
62 |
62 |
63 return QAbstractTableModel.headerData(self, section, orientation, role) |
63 return QAbstractTableModel.headerData(self, section, orientation, role) |
64 |
64 |
65 def data(self, index, role): |
65 def data(self, index, role): |
66 """ |
66 """ |
67 Public method to get data from the model. |
67 Public method to get data from the model. |
68 |
68 |
69 @param index index to get data for (QModelIndex) |
69 @param index index to get data for (QModelIndex) |
70 @param role role of the data to retrieve (integer) |
70 @param role role of the data to retrieve (integer) |
71 @return requested data (QVariant) |
71 @return requested data |
72 """ |
72 """ |
73 lst = [] |
73 lst = [] |
74 if self.__cookieJar is not None: |
74 if self.__cookieJar is not None: |
75 lst = self.__cookieJar.cookies() |
75 lst = self.__cookieJar.cookies() |
76 if index.row() < 0 or index.row() >= len(lst): |
76 if index.row() < 0 or index.row() >= len(lst): |
77 return QVariant() |
77 return None |
78 |
78 |
79 if role in (Qt.DisplayRole, Qt.EditRole): |
79 if role in (Qt.DisplayRole, Qt.EditRole): |
80 cookie = lst[index.row()] |
80 cookie = lst[index.row()] |
81 col = index.column() |
81 col = index.column() |
82 if col == 0: |
82 if col == 0: |
83 return QVariant(cookie.domain()) |
83 return cookie.domain() |
84 elif col == 1: |
84 elif col == 1: |
85 return QVariant(cookie.name()) |
85 return cookie.name() |
86 elif col == 2: |
86 elif col == 2: |
87 return QVariant(cookie.path()) |
87 return cookie.path() |
88 elif col == 3: |
88 elif col == 3: |
89 return QVariant(cookie.isSecure()) |
89 return cookie.isSecure() |
90 elif col == 4: |
90 elif col == 4: |
91 return QVariant(cookie.expirationDate()) |
91 return cookie.expirationDate() |
92 elif col == 5: |
92 elif col == 5: |
93 return QVariant(cookie.value()) |
93 return cookie.value() |
94 else: |
94 else: |
95 return QVariant() |
95 return None |
96 |
96 |
97 return QVariant() |
97 return None |
98 |
98 |
99 def columnCount(self, parent = QModelIndex()): |
99 def columnCount(self, parent = QModelIndex()): |
100 """ |
100 """ |
101 Public method to get the number of columns of the model. |
101 Public method to get the number of columns of the model. |
102 |
102 |