Helpviewer/Passwords/PasswordModel.py

changeset 7
c679fb30c8f3
parent 0
de9c2efb9d02
child 13
1af94a91f439
equal deleted inserted replaced
6:52e8c820d0dd 7:c679fb30c8f3
112 """ 112 """
113 Public method to get data from the model. 113 Public method to get data from the model.
114 114
115 @param index index to get data for (QModelIndex) 115 @param index index to get data for (QModelIndex)
116 @param role role of the data to retrieve (integer) 116 @param role role of the data to retrieve (integer)
117 @return requested data (QVariant) 117 @return requested data
118 """ 118 """
119 if index.row() >= self.__manager.sitesCount() or index.row() < 0: 119 if index.row() >= self.__manager.sitesCount() or index.row() < 0:
120 return QVariant() 120 return None
121 121
122 site = self.__manager.allSiteNames()[index.row()] 122 site = self.__manager.allSiteNames()[index.row()]
123 siteInfo = self.__manager.siteInfo(site) 123 siteInfo = self.__manager.siteInfo(site)
124 124
125 if siteInfo is None: 125 if siteInfo is None:
126 return QVariant() 126 return None
127 127
128 if role == Qt.DisplayRole: 128 if role == Qt.DisplayRole:
129 if index.column() == 0: 129 if index.column() == 0:
130 return QVariant(site) 130 return site
131 elif index.column() in [1, 2]: 131 elif index.column() in [1, 2]:
132 return QVariant(siteInfo[index.column() - 1]) 132 return siteInfo[index.column() - 1]
133 133
134 return QVariant() 134 return None
135 135
136 def headerData(self, section, orientation, role = Qt.DisplayRole): 136 def headerData(self, section, orientation, role = Qt.DisplayRole):
137 """ 137 """
138 Public method to get the header data. 138 Public method to get the header data.
139 139
140 @param section section number (integer) 140 @param section section number (integer)
141 @param orientation header orientation (Qt.Orientation) 141 @param orientation header orientation (Qt.Orientation)
142 @param role data role (integer) 142 @param role data role (integer)
143 @return header data (QVariant) 143 @return header data
144 """ 144 """
145 if orientation == Qt.Horizontal and role == Qt.DisplayRole: 145 if orientation == Qt.Horizontal and role == Qt.DisplayRole:
146 try: 146 try:
147 return QVariant(self.__headers[section]) 147 return self.__headers[section]
148 except IndexError: 148 except IndexError:
149 pass 149 pass
150 150
151 return QVariant() 151 return None

eric ide

mercurial