8 """ |
8 """ |
9 |
9 |
10 from PyQt4.QtCore import * |
10 from PyQt4.QtCore import * |
11 from PyQt4.QtGui import * |
11 from PyQt4.QtGui import * |
12 |
12 |
|
13 |
13 class CookieModel(QAbstractTableModel): |
14 class CookieModel(QAbstractTableModel): |
14 """ |
15 """ |
15 Class implementing the cookie model. |
16 Class implementing the cookie model. |
16 """ |
17 """ |
17 def __init__(self, cookieJar, parent = None): |
18 def __init__(self, cookieJar, parent=None): |
18 """ |
19 """ |
19 Constructor |
20 Constructor |
20 |
21 |
21 @param cookieJar reference to the cookie jar (CookieJar) |
22 @param cookieJar reference to the cookie jar (CookieJar) |
22 @param parent reference to the parent object (QObject) |
23 @param parent reference to the parent object (QObject) |
23 """ |
24 """ |
24 QAbstractTableModel.__init__(self, parent) |
25 QAbstractTableModel.__init__(self, parent) |
25 |
26 |
26 self.__headers = [ |
27 self.__headers = [ |
27 self.trUtf8("Website"), |
28 self.trUtf8("Website"), |
28 self.trUtf8("Name"), |
29 self.trUtf8("Name"), |
29 self.trUtf8("Path"), |
30 self.trUtf8("Path"), |
30 self.trUtf8("Secure"), |
31 self.trUtf8("Secure"), |
31 self.trUtf8("Expires"), |
32 self.trUtf8("Expires"), |
32 self.trUtf8("Contents"), |
33 self.trUtf8("Contents"), |
33 ] |
34 ] |
34 self.__cookieJar = cookieJar |
35 self.__cookieJar = cookieJar |
35 self.__cookieJar.cookiesChanged.connect(self.__cookiesChanged) |
36 self.__cookieJar.cookiesChanged.connect(self.__cookiesChanged) |
36 self.__cookieJar.load() |
37 self.__cookieJar.load() |
37 |
38 |
106 if parent.isValid(): |
107 if parent.isValid(): |
107 return 0 |
108 return 0 |
108 else: |
109 else: |
109 return len(self.__headers) |
110 return len(self.__headers) |
110 |
111 |
111 def rowCount(self, parent = QModelIndex()): |
112 def rowCount(self, parent=QModelIndex()): |
112 """ |
113 """ |
113 Public method to get the number of rows of the model. |
114 Public method to get the number of rows of the model. |
114 |
115 |
115 @param parent parent index (QModelIndex) |
116 @param parent parent index (QModelIndex) |
116 @return number of columns (integer) |
117 @return number of columns (integer) |
118 if parent.isValid() or self.__cookieJar is None: |
119 if parent.isValid() or self.__cookieJar is None: |
119 return 0 |
120 return 0 |
120 else: |
121 else: |
121 return len(self.__cookieJar.cookies()) |
122 return len(self.__cookieJar.cookies()) |
122 |
123 |
123 def removeRows(self, row, count, parent = QModelIndex()): |
124 def removeRows(self, row, count, parent=QModelIndex()): |
124 """ |
125 """ |
125 Public method to remove entries from the model. |
126 Public method to remove entries from the model. |
126 |
127 |
127 @param row start row (integer) |
128 @param row start row (integer) |
128 @param count number of rows to remove (integer) |
129 @param count number of rows to remove (integer) |