Project/ProjectBrowserModel.py

changeset 500
c3abc7895a01
parent 427
6af5d12cfecb
child 501
5c615a85241a
equal deleted inserted replaced
499:622ab17a68d5 500:c3abc7895a01
203 203
204 class ProjectBrowserModel(BrowserModel): 204 class ProjectBrowserModel(BrowserModel):
205 """ 205 """
206 Class implementing the project browser model. 206 Class implementing the project browser model.
207 207
208 @signal vcsStateChanged(QString) emitted after the VCS state has changed 208 @signal vcsStateChanged(string) emitted after the VCS state has changed
209 """ 209 """
210 vcsStateChanged = pyqtSignal(str)
211
210 def __init__(self, parent): 212 def __init__(self, parent):
211 """ 213 """
212 Constructor 214 Constructor
213 215
214 @param parent reference to parent object (Project.Project) 216 @param parent reference to parent object (Project.Project)
463 self.addItem(itm, oldindex) 465 self.addItem(itm, oldindex)
464 else: 466 else:
465 if type_ and type_ not in itm.getProjectTypes(): 467 if type_ and type_ not in itm.getProjectTypes():
466 itm.addProjectType(type_) 468 itm.addProjectType(type_)
467 index = self.createIndex(itm.row(), 0, itm) 469 index = self.createIndex(itm.row(), 0, itm)
468 self.emit(SIGNAL(\ 470 self.dataChanged.emit(index, index)
469 "dataChanged(const QModelIndex &, const QModelIndex &)"),
470 index, index)
471 olditem = itm 471 olditem = itm
472 return (itm, pathlist[-1]) 472 return (itm, pathlist[-1])
473 else: 473 else:
474 return (self.rootItem, name) 474 return (self.rootItem, name)
475 475
541 if itm is None: 541 if itm is None:
542 return 542 return
543 543
544 index = self.createIndex(itm.row(), 0, itm) 544 index = self.createIndex(itm.row(), 0, itm)
545 itm.setName(newFilename) 545 itm.setName(newFilename)
546 self.emit(SIGNAL("dataChanged(const QModelIndex &, const QModelIndex &)"), 546 self.dataChanged.emit(index, index)
547 index, index)
548 self.repopulateItem(newFilename) 547 self.repopulateItem(newFilename)
549 548
550 def findItem(self, name): 549 def findItem(self, name):
551 """ 550 """
552 Public method to find an item given it's name. 551 Public method to find an item given it's name.
696 self.__updateVCSStatus(parentItem, name, recursive) 695 self.__updateVCSStatus(parentItem, name, recursive)
697 else: 696 else:
698 item.setVcsStatus("") 697 item.setVcsStatus("")
699 698
700 index = self.createIndex(item.row(), 0, item) 699 index = self.createIndex(item.row(), 0, item)
701 self.emit(SIGNAL("dataChanged(const QModelIndex &, const QModelIndex &)"), 700 self.dataChanged.emit(index, index)
702 index, index)
703 701
704 def updateVCSStatus(self, name, recursive = True): 702 def updateVCSStatus(self, name, recursive = True):
705 """ 703 """
706 Public method used to update the vcs status of a node. 704 Public method used to update the vcs status of a node.
707 705
806 if itm: 804 if itm:
807 itm.setVcsState(state) 805 itm.setVcsState(state)
808 index1 = self.createIndex(itm.row(), 0, itm) 806 index1 = self.createIndex(itm.row(), 0, itm)
809 index2 = self.createIndex(itm.row(), 807 index2 = self.createIndex(itm.row(),
810 self.rootItem.columnCount(), itm) 808 self.rootItem.columnCount(), itm)
811 self.emit(\ 809 self.dataChanged.emit(index1, index2)
812 SIGNAL("dataChanged(const QModelIndex &, const QModelIndex &)"),
813 index1, index2)
814 810
815 head, tail = os.path.split(name) 811 head, tail = os.path.split(name)
816 if head != lastHead: 812 if head != lastHead:
817 if lastHead: 813 if lastHead:
818 self.__changeParentsVCSState(lastHead, itemCache) 814 self.__changeParentsVCSState(lastHead, itemCache)
821 self.__changeParentsVCSState(lastHead, itemCache) 817 self.__changeParentsVCSState(lastHead, itemCache)
822 try: 818 try:
823 globalVcsStatus = sorted(self.__vcsStatus.values())[-1] 819 globalVcsStatus = sorted(self.__vcsStatus.values())[-1]
824 except IndexError: 820 except IndexError:
825 globalVcsStatus = ' ' 821 globalVcsStatus = ' '
826 self.emit(SIGNAL("vcsStateChanged"), globalVcsStatus) 822 self.vcsStateChanged.emit(globalVcsStatus)
827 823
828 def __changeParentsVCSState(self, path, itemCache): 824 def __changeParentsVCSState(self, path, itemCache):
829 """ 825 """
830 Private method to recursively change the parents VCS state. 826 Private method to recursively change the parents VCS state.
831 827
848 if state != itm.vcsState: 844 if state != itm.vcsState:
849 itm.setVcsState(state) 845 itm.setVcsState(state)
850 index1 = self.createIndex(itm.row(), 0, itm) 846 index1 = self.createIndex(itm.row(), 0, itm)
851 index2 = self.createIndex(itm.row(), 847 index2 = self.createIndex(itm.row(),
852 self.rootItem.columnCount(), itm) 848 self.rootItem.columnCount(), itm)
853 self.emit(\ 849 self.dataChanged.emit(index1, index2)
854 SIGNAL("dataChanged(const QModelIndex &, const QModelIndex &)"),
855 index1, index2)
856 path, tail = os.path.split(path) 850 path, tail = os.path.split(path)
857 851
858 def preferencesChanged(self): 852 def preferencesChanged(self):
859 """ 853 """
860 Public method used to handle a change in preferences. 854 Public method used to handle a change in preferences.

eric ide

mercurial