Project/ProjectBrowserModel.py

changeset 7
c679fb30c8f3
parent 0
de9c2efb9d02
child 12
1d8dd9706f46
equal deleted inserted replaced
6:52e8c820d0dd 7:c679fb30c8f3
53 53
54 def getTextColor(self): 54 def getTextColor(self):
55 """ 55 """
56 Public method to get the items text color. 56 Public method to get the items text color.
57 57
58 @return text color (QVariant(QColor)) 58 @return text color (QColor)
59 """ 59 """
60 if self.bold: 60 if self.bold:
61 return QVariant(Preferences.getProjectBrowserColour("Highlighted")) 61 return Preferences.getProjectBrowserColour("Highlighted")
62 else: 62 else:
63 return QVariant() 63 return None
64 64
65 def setVcsState(self, state): 65 def setVcsState(self, state):
66 """ 66 """
67 Public method to set the items VCS state. 67 Public method to set the items VCS state.
68 68
200 200
201 @param parent reference to parent object (Project.Project) 201 @param parent reference to parent object (Project.Project)
202 """ 202 """
203 QAbstractItemModel.__init__(self, parent) 203 QAbstractItemModel.__init__(self, parent)
204 204
205 rootData = QVariant(self.trUtf8("Name")) 205 rootData = self.trUtf8("Name")
206 self.rootItem = BrowserItem(None, rootData) 206 self.rootItem = BrowserItem(None, rootData)
207 self.rootItem.itemData.append(QVariant(self.trUtf8("VCS Status"))) 207 self.rootItem.itemData.append(self.trUtf8("VCS Status"))
208 208
209 self.progDir = None 209 self.progDir = None
210 self.project = parent 210 self.project = parent
211 211
212 self.inRefresh = False 212 self.inRefresh = False
245 """ 245 """
246 Public method to get data of an item. 246 Public method to get data of an item.
247 247
248 @param index index of the data to retrieve (QModelIndex) 248 @param index index of the data to retrieve (QModelIndex)
249 @param role role of data (Qt.ItemDataRole) 249 @param role role of data (Qt.ItemDataRole)
250 @return requested data (QVariant) 250 @return requested data
251 """ 251 """
252 if not index.isValid(): 252 if not index.isValid():
253 return QVariant() 253 return None
254 254
255 if role == Qt.TextColorRole: 255 if role == Qt.TextColorRole:
256 if index.column() == 0: 256 if index.column() == 0:
257 try: 257 try:
258 return index.internalPointer().getTextColor() 258 return index.internalPointer().getTextColor()
259 except AttributeError: 259 except AttributeError:
260 return QVariant() 260 return None
261 elif role == Qt.BackgroundColorRole: 261 elif role == Qt.BackgroundColorRole:
262 try: 262 try:
263 col = self.itemBackgroundColors[index.internalPointer().vcsState] 263 col = self.itemBackgroundColors[index.internalPointer().vcsState]
264 if col.isValid(): 264 if col.isValid():
265 return QVariant(col) 265 return col
266 else: 266 else:
267 return QVariant() 267 return None
268 except AttributeError: 268 except AttributeError:
269 return QVariant() 269 return None
270 except KeyError: 270 except KeyError:
271 return QVariant() 271 return None
272 272
273 return BrowserModel.data(self, index, role) 273 return BrowserModel.data(self, index, role)
274 274
275 def populateItem(self, parentItem, repopulate = False): 275 def populateItem(self, parentItem, repopulate = False):
276 """ 276 """

eric ide

mercurial