19 |
19 |
20 def __init__(self, manager, parent=None): |
20 def __init__(self, manager, parent=None): |
21 """ |
21 """ |
22 Constructor |
22 Constructor |
23 |
23 |
24 @param manager reference to the password manager (PasswordManager) |
24 @param manager reference to the password manager |
25 @param parent reference to the parent object (QObject) |
25 @type PasswordManager |
|
26 @param parent reference to the parent object |
|
27 @type QObject |
26 """ |
28 """ |
27 super().__init__(parent) |
29 super().__init__(parent) |
28 |
30 |
29 self.__manager = manager |
31 self.__manager = manager |
30 manager.changed.connect(self.__passwordsChanged) |
32 manager.changed.connect(self.__passwordsChanged) |
35 |
37 |
36 def setShowPasswords(self, on): |
38 def setShowPasswords(self, on): |
37 """ |
39 """ |
38 Public methods to show passwords. |
40 Public methods to show passwords. |
39 |
41 |
40 @param on flag indicating if passwords shall be shown (boolean) |
42 @param on flag indicating if passwords shall be shown |
|
43 @type bool |
41 """ |
44 """ |
42 self.__showPasswords = on |
45 self.__showPasswords = on |
43 self.beginResetModel() |
46 self.beginResetModel() |
44 self.endResetModel() |
47 self.endResetModel() |
45 |
48 |
46 def showPasswords(self): |
49 def showPasswords(self): |
47 """ |
50 """ |
48 Public method to indicate, if passwords shall be shown. |
51 Public method to indicate, if passwords shall be shown. |
49 |
52 |
50 @return flag indicating if passwords shall be shown (boolean) |
53 @return flag indicating if passwords shall be shown |
|
54 @rtype bool |
51 """ |
55 """ |
52 return self.__showPasswords |
56 return self.__showPasswords |
53 |
57 |
54 def __passwordsChanged(self): |
58 def __passwordsChanged(self): |
55 """ |
59 """ |
60 |
64 |
61 def removeRows(self, row, count, parent=None): |
65 def removeRows(self, row, count, parent=None): |
62 """ |
66 """ |
63 Public method to remove entries from the model. |
67 Public method to remove entries from the model. |
64 |
68 |
65 @param row start row (integer) |
69 @param row start row |
66 @param count number of rows to remove (integer) |
70 @type int |
67 @param parent parent index (QModelIndex) |
71 @param count number of rows to remove |
68 @return flag indicating success (boolean) |
72 @type int |
|
73 @param parent parent index |
|
74 @type QModelIndex |
|
75 @return flag indicating success |
|
76 @rtype bool |
69 """ |
77 """ |
70 if parent is None: |
78 if parent is None: |
71 parent = QModelIndex() |
79 parent = QModelIndex() |
72 |
80 |
73 if parent.isValid(): |
81 if parent.isValid(): |
88 |
96 |
89 def rowCount(self, parent=None): |
97 def rowCount(self, parent=None): |
90 """ |
98 """ |
91 Public method to get the number of rows of the model. |
99 Public method to get the number of rows of the model. |
92 |
100 |
93 @param parent parent index (QModelIndex) |
101 @param parent parent index |
94 @return number of rows (integer) |
102 @type QModelIndex |
|
103 @return number of rows |
|
104 @rtype int |
95 """ |
105 """ |
96 if parent is None: |
106 if parent is None: |
97 parent = QModelIndex() |
107 parent = QModelIndex() |
98 |
108 |
99 if parent.isValid(): |
109 if parent.isValid(): |
103 |
113 |
104 def columnCount(self, parent=None): # noqa: U100 |
114 def columnCount(self, parent=None): # noqa: U100 |
105 """ |
115 """ |
106 Public method to get the number of columns of the model. |
116 Public method to get the number of columns of the model. |
107 |
117 |
108 @param parent parent index (QModelIndex) (Unused) |
118 @param parent parent index (Unused) |
109 @return number of columns (integer) |
119 @type QModelIndex |
|
120 @return number of columns |
|
121 @rtype int |
110 """ |
122 """ |
111 if self.__showPasswords: |
123 if self.__showPasswords: |
112 return 3 |
124 return 3 |
113 else: |
125 else: |
114 return 2 |
126 return 2 |
115 |
127 |
116 def data(self, index, role): |
128 def data(self, index, role): |
117 """ |
129 """ |
118 Public method to get data from the model. |
130 Public method to get data from the model. |
119 |
131 |
120 @param index index to get data for (QModelIndex) |
132 @param index index to get data for |
121 @param role role of the data to retrieve (integer) |
133 @type QModelIndex |
|
134 @param role role of the data to retrieve |
|
135 @type int |
122 @return requested data |
136 @return requested data |
|
137 @rtype Any |
123 """ |
138 """ |
124 if index.row() >= self.__manager.sitesCount() or index.row() < 0: |
139 if index.row() >= self.__manager.sitesCount() or index.row() < 0: |
125 return None |
140 return None |
126 |
141 |
127 site = self.__manager.allSiteNames()[index.row()] |
142 site = self.__manager.allSiteNames()[index.row()] |
140 |
155 |
141 def headerData(self, section, orientation, role=Qt.ItemDataRole.DisplayRole): |
156 def headerData(self, section, orientation, role=Qt.ItemDataRole.DisplayRole): |
142 """ |
157 """ |
143 Public method to get the header data. |
158 Public method to get the header data. |
144 |
159 |
145 @param section section number (integer) |
160 @param section section number |
146 @param orientation header orientation (Qt.Orientation) |
161 @type int |
147 @param role data role (Qt.ItemDataRole) |
162 @param orientation header orientation |
|
163 @type Qt.Orientation |
|
164 @param role data role |
|
165 @type Qt.ItemDataRole |
148 @return header data |
166 @return header data |
|
167 @rtype Any |
149 """ |
168 """ |
150 if ( |
169 if ( |
151 orientation == Qt.Orientation.Horizontal |
170 orientation == Qt.Orientation.Horizontal |
152 and role == Qt.ItemDataRole.DisplayRole |
171 and role == Qt.ItemDataRole.DisplayRole |
153 ): |
172 ): |