7 Module implementing a model for password management. |
7 Module implementing a model for password management. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt4.QtCore import * |
10 from PyQt4.QtCore import * |
11 |
11 |
|
12 |
12 class PasswordModel(QAbstractTableModel): |
13 class PasswordModel(QAbstractTableModel): |
13 """ |
14 """ |
14 Class implementing a model for password management. |
15 Class implementing a model for password management. |
15 """ |
16 """ |
16 def __init__(self, manager, parent = None): |
17 def __init__(self, manager, parent=None): |
17 """ |
18 """ |
18 Constructor |
19 Constructor |
19 |
20 |
20 @param manager reference to the password manager (PasswordManager) |
21 @param manager reference to the password manager (PasswordManager) |
21 @param parent reference to the parent object (QObject) |
22 @param parent reference to the parent object (QObject) |
24 |
25 |
25 self.__manager = manager |
26 self.__manager = manager |
26 manager.changed.connect(self.__passwordsChanged) |
27 manager.changed.connect(self.__passwordsChanged) |
27 |
28 |
28 self.__headers = [ |
29 self.__headers = [ |
29 self.trUtf8("Website"), |
30 self.trUtf8("Website"), |
30 self.trUtf8("Username"), |
31 self.trUtf8("Username"), |
31 self.trUtf8("Password") |
32 self.trUtf8("Password") |
32 ] |
33 ] |
33 |
34 |
34 self.__showPasswords = False |
35 self.__showPasswords = False |
35 |
36 |
54 """ |
55 """ |
55 Private slot handling a change of the registered passwords. |
56 Private slot handling a change of the registered passwords. |
56 """ |
57 """ |
57 self.reset() |
58 self.reset() |
58 |
59 |
59 def removeRows(self, row, count, parent = QModelIndex()): |
60 def removeRows(self, row, count, parent=QModelIndex()): |
60 """ |
61 """ |
61 Public method to remove entries from the model. |
62 Public method to remove entries from the model. |
62 |
63 |
63 @param row start row (integer) |
64 @param row start row (integer) |
64 @param count number of rows to remove (integer) |
65 @param count number of rows to remove (integer) |
82 # removeEngine emits changed() |
83 # removeEngine emits changed() |
83 #self.endRemoveRows() |
84 #self.endRemoveRows() |
84 |
85 |
85 return True |
86 return True |
86 |
87 |
87 def rowCount(self, parent = QModelIndex()): |
88 def rowCount(self, parent=QModelIndex()): |
88 """ |
89 """ |
89 Public method to get the number of rows of the model. |
90 Public method to get the number of rows of the model. |
90 |
91 |
91 @param parent parent index (QModelIndex) |
92 @param parent parent index (QModelIndex) |
92 @return number of rows (integer) |
93 @return number of rows (integer) |
94 if parent.isValid(): |
95 if parent.isValid(): |
95 return 0 |
96 return 0 |
96 else: |
97 else: |
97 return self.__manager.sitesCount() |
98 return self.__manager.sitesCount() |
98 |
99 |
99 def columnCount(self, parent = QModelIndex()): |
100 def columnCount(self, parent=QModelIndex()): |
100 """ |
101 """ |
101 Public method to get the number of columns of the model. |
102 Public method to get the number of columns of the model. |
102 |
103 |
103 @param parent parent index (QModelIndex) |
104 @param parent parent index (QModelIndex) |
104 @return number of columns (integer) |
105 @return number of columns (integer) |
131 elif index.column() in [1, 2]: |
132 elif index.column() in [1, 2]: |
132 return siteInfo[index.column() - 1] |
133 return siteInfo[index.column() - 1] |
133 |
134 |
134 return None |
135 return None |
135 |
136 |
136 def headerData(self, section, orientation, role = Qt.DisplayRole): |
137 def headerData(self, section, orientation, role=Qt.DisplayRole): |
137 """ |
138 """ |
138 Public method to get the header data. |
139 Public method to get the header data. |
139 |
140 |
140 @param section section number (integer) |
141 @param section section number (integer) |
141 @param orientation header orientation (Qt.Orientation) |
142 @param orientation header orientation (Qt.Orientation) |