src/eric7/Project/ProjectBrowserModel.py

branch
eric7
changeset 10845
bbcad422aea7
parent 10842
d7fe0566dfa8
child 10915
80828634d6b0
equal deleted inserted replaced
10844:a7c73526f336 10845:bbcad422aea7
622 if itm.data(column) == text: 622 if itm.data(column) == text:
623 return itm 623 return itm
624 624
625 return None 625 return None
626 626
627 def addNewItem(self, typeString, name, additionalTypeStrings=None): 627 def addNewItem(self, typeString, name, additionalTypeStrings=None, simple=False):
628 """ 628 """
629 Public method to add a new item to the model. 629 Public method to add a new item to the model.
630 630
631 @param typeString string denoting the type of the new item 631 @param typeString string denoting the type of the new item
632 @type str 632 @type str
633 @param name name of the new item 633 @param name name of the new item
634 @type str 634 @type str
635 @param additionalTypeStrings names of additional types 635 @param additionalTypeStrings names of additional types (defaults to None)
636 @type list of str 636 @type list of str (optional)
637 @param simple flag indicating to create a simple directory item and/or not
638 highlight the entry (defaults to False)
639 @type bool (optional)
637 """ 640 """
638 # Show the entry in bold in the others browser to make it more 641 # Show the entry in bold in the others browser to make it more
639 # distinguishable 642 # distinguishable
640 bold = typeString == "OTHERS" 643 bold = typeString == "OTHERS" and not simple
641 644
642 fname = os.path.join(self.project.ppath, name) 645 fname = os.path.join(self.project.ppath, name)
643 parentItem, _dt = self.findParentItemByName( 646 parentItem, _dt = self.findParentItemByName(
644 self.__projectBrowser.getProjectBrowserFilter(typeString), name 647 self.__projectBrowser.getProjectBrowserFilter(typeString), name
645 ) 648 )
657 return 660 return
658 else: 661 else:
659 self.removeItem(name) 662 self.removeItem(name)
660 663
661 if os.path.isdir(fname): 664 if os.path.isdir(fname):
662 itm = ProjectBrowserDirectoryItem( 665 itm = (
663 parentItem, 666 ProjectBrowserSimpleDirectoryItem(
664 fname, 667 parentItem,
665 self.__projectBrowser.getProjectBrowserFilter(typeString), 668 self.__projectBrowser.getProjectBrowserFilter(typeString),
666 False, 669 os.path.basename(name),
667 bold, 670 fname,
668 fsInterface=self.__remotefsInterface, 671 fsInterface=self.__remotefsInterface,
672 )
673 if simple
674 else ProjectBrowserDirectoryItem(
675 parentItem,
676 fname,
677 self.__projectBrowser.getProjectBrowserFilter(typeString),
678 False,
679 bold,
680 fsInterface=self.__remotefsInterface,
681 )
669 ) 682 )
670 else: 683 else:
671 if typeString == "SOURCES": 684 if typeString == "SOURCES":
672 sourceLanguage = self.project.getProjectLanguage() 685 sourceLanguage = self.project.getProjectLanguage()
673 else: 686 else:
815 path 828 path
816 ).startswith("."): 829 ).startswith("."):
817 return 830 return
818 831
819 for itm in self.watchedDirItems[parentPath]: 832 for itm in self.watchedDirItems[parentPath]:
820 cnt = itm.childCount() 833 name = os.path.basename(path)
821 self.beginInsertRows(self.createIndex(itm.row(), 0, itm), cnt, cnt) 834 child = self.findChildItem(name, 0, parentItem=itm)
822 node = ( 835 if child is None:
823 ProjectBrowserDirectoryItem( 836 cnt = itm.childCount()
824 itm, 837 self.beginInsertRows(self.createIndex(itm.row(), 0, itm), cnt, cnt)
825 FileSystemUtilities.toNativeSeparators(path), 838 node = (
826 itm.getProjectTypes()[0], 839 ProjectBrowserDirectoryItem(
827 False, 840 itm,
828 fsInterface=self.__remotefsInterface, 841 FileSystemUtilities.toNativeSeparators(path),
842 itm.getProjectTypes()[0],
843 False,
844 fsInterface=self.__remotefsInterface,
845 )
846 if isDir
847 else ProjectBrowserFileItem(
848 itm,
849 FileSystemUtilities.toNativeSeparators(path),
850 itm.getProjectTypes()[0],
851 fsInterface=self.__remotefsInterface,
852 )
829 ) 853 )
830 if isDir 854 self._addItem(node, itm)
831 else ProjectBrowserFileItem( 855 self.endInsertRows()
832 itm,
833 FileSystemUtilities.toNativeSeparators(path),
834 itm.getProjectTypes()[0],
835 fsInterface=self.__remotefsInterface,
836 )
837 )
838 self._addItem(node, itm)
839 self.endInsertRows()
840 856
841 def entryDeleted(self, path, isDir=False): 857 def entryDeleted(self, path, isDir=False):
842 """ 858 """
843 Public method to handle the deletion of a file or directory. 859 Public method to handle the deletion of a file or directory.
844 860

eric ide

mercurial