247 if project['master']: |
251 if project['master']: |
248 itm.setIcon(0, UI.PixmapCache.getIcon("masterProject.png")) |
252 itm.setIcon(0, UI.PixmapCache.getIcon("masterProject.png")) |
249 else: |
253 else: |
250 itm.setIcon(0, UI.PixmapCache.getIcon("empty.png")) |
254 itm.setIcon(0, UI.PixmapCache.getIcon("empty.png")) |
251 itm.setToolTip(0, project['file']) |
255 itm.setToolTip(0, project['file']) |
252 itm.setData(0, Qt.UserRole, project['file']) |
256 itm.setData(0, MultiProjectBrowser.ProjectFileNameRole, |
|
257 project['file']) |
|
258 itm.setData(0, MultiProjectBrowser.ProjectUidRole, project['uid']) |
253 |
259 |
254 def __findProjectItem(self, project): |
260 def __findProjectItem(self, project): |
255 """ |
261 """ |
256 Private method to search a specific project item. |
262 Private method to search a specific project item. |
257 |
263 |
258 @param project reference to the project data dictionary |
264 @param project reference to the project data dictionary |
259 @return reference to the item (QTreeWidgetItem) or None |
265 @return reference to the item (QTreeWidgetItem) or None |
260 """ |
266 """ |
|
267 if project["uid"]: |
|
268 compareData = project["uid"] |
|
269 compareRole = MultiProjectBrowser.ProjectUidRole |
|
270 else: |
|
271 compareData = project["file"] |
|
272 compareRole = MultiProjectBrowser.ProjectFileNameRole |
|
273 |
261 for topIndex in range(self.topLevelItemCount()): |
274 for topIndex in range(self.topLevelItemCount()): |
262 topItm = self.topLevelItem(topIndex) |
275 topItm = self.topLevelItem(topIndex) |
263 for childIndex in range(topItm.childCount()): |
276 for childIndex in range(topItm.childCount()): |
264 itm = topItm.child(childIndex) |
277 itm = topItm.child(childIndex) |
265 data = itm.data(0, Qt.UserRole) |
278 data = itm.data(0, compareRole) |
266 if data == project['file']: |
279 if data == compareData: |
267 return itm |
280 return itm |
268 |
281 |
269 return None |
282 return None |
270 |
283 |
271 def __removeProject(self): |
284 def __removeProject(self): |
272 """ |
285 """ |
273 Private method to handle the Remove context menu entry. |
286 Private method to handle the Remove context menu entry. |
274 """ |
287 """ |
275 itm = self.currentItem() |
288 itm = self.currentItem() |
276 if itm is not None and itm.parent() is not None: |
289 if itm is not None and itm.parent() is not None: |
277 filename = itm.data(0, Qt.UserRole) |
290 uid = itm.data(0, MultiProjectBrowser.ProjectUidRole) |
278 if filename: |
291 if uid: |
279 self.multiProject.removeProject(filename) |
292 self.multiProject.removeProject(uid) |
280 |
293 |
281 def __showProjectProperties(self): |
294 def __showProjectProperties(self): |
282 """ |
295 """ |
283 Private method to show the data of a project entry. |
296 Private method to show the data of a project entry. |
284 """ |
297 """ |
285 itm = self.currentItem() |
298 itm = self.currentItem() |
286 if itm is not None and itm.parent() is not None: |
299 if itm is not None and itm.parent() is not None: |
287 filename = itm.data(0, Qt.UserRole) |
300 uid = itm.data(0, MultiProjectBrowser.ProjectUidRole) |
288 if filename: |
301 if uid: |
289 project = self.multiProject.getProject(filename) |
302 project = self.multiProject.getProject(uid) |
290 if project is not None: |
303 if project is not None: |
291 from .AddProjectDialog import AddProjectDialog |
304 from .AddProjectDialog import AddProjectDialog |
292 dlg = AddProjectDialog( |
305 dlg = AddProjectDialog( |
293 self, project=project, |
306 self, project=project, |
294 categories=self.multiProject.getCategories()) |
307 categories=self.multiProject.getCategories()) |