UI/BrowserModel.py

changeset 103
59137afca666
parent 15
f6ccc31d6e72
child 231
2e4eb047ae93
equal deleted inserted replaced
102:85fc2a5cddb4 103:59137afca666
84 # doesn't have a value for all the columns 84 # doesn't have a value for all the columns
85 return "" 85 return ""
86 elif role == Qt.DecorationRole: 86 elif role == Qt.DecorationRole:
87 if index.column() == 0: 87 if index.column() == 0:
88 return index.internalPointer().getIcon() 88 return index.internalPointer().getIcon()
89 elif role == Qt.FontRole:
90 item = index.internalPointer()
91 if item.isSymlink():
92 font = QFont(QApplication.font("QTreeView"))
93 font.setItalic(True)
94 return font
89 95
90 return None 96 return None
91 97
92 def flags(self, index): 98 def flags(self, index):
93 """ 99 """
565 self.itemData = [data] 571 self.itemData = [data]
566 self.type_ = BrowserItemRoot 572 self.type_ = BrowserItemRoot
567 self.icon = UI.PixmapCache.getIcon("empty.png") 573 self.icon = UI.PixmapCache.getIcon("empty.png")
568 self._populated = True 574 self._populated = True
569 self._lazyPopulation = False 575 self._lazyPopulation = False
576 self.symlink = False
570 577
571 def appendChild(self, child): 578 def appendChild(self, child):
572 """ 579 """
573 Public method to add a child to this item. 580 Public method to add a child to this item.
574 581
703 """ 710 """
704 try: 711 try:
705 return self.itemData[column] < other.itemData[column] 712 return self.itemData[column] < other.itemData[column]
706 except IndexError: 713 except IndexError:
707 return False 714 return False
715
716 def isSymlink(self):
717 """
718 Public method to check, if the items is a symbolic link.
719
720 @return flag indicating a symbolic link (boolean)
721 """
722 return self.symlink
708 723
709 class BrowserDirectoryItem(BrowserItem): 724 class BrowserDirectoryItem(BrowserItem):
710 """ 725 """
711 Class implementing the data structure for browser directory items. 726 Class implementing the data structure for browser directory items.
712 """ 727 """
726 dn = os.path.basename(self._dirName) 741 dn = os.path.basename(self._dirName)
727 742
728 BrowserItem.__init__(self, parent, dn) 743 BrowserItem.__init__(self, parent, dn)
729 744
730 self.type_ = BrowserItemDirectory 745 self.type_ = BrowserItemDirectory
731 self.icon = UI.PixmapCache.getIcon("dirClosed.png") 746 if os.path.lexists(self._dirName) and os.path.islink(self._dirName):
747 self.symlink = True
748 self.icon = UI.PixmapCache.getSymlinkIcon("dirClosed.png")
749 else:
750 self.icon = UI.PixmapCache.getIcon("dirClosed.png")
732 self._populated = False 751 self._populated = False
733 self._lazyPopulation = True 752 self._lazyPopulation = True
734 753
735 def setName(self, dinfo, full = True): 754 def setName(self, dinfo, full = True):
736 """ 755 """
737 Public method to set the directory name. 756 Public method to set the directory name.
738 757
739 @param dinfo dinfo is the string for the directory (string) 758 @param dinfo dinfo is the string for the directory (string)
808 self._dirName = os.path.dirname(finfo) 827 self._dirName = os.path.dirname(finfo)
809 self.sourceLanguage = sourceLanguage 828 self.sourceLanguage = sourceLanguage
810 829
811 self._moduleName = '' 830 self._moduleName = ''
812 831
832 pixName = ""
813 if self.isPythonFile(): 833 if self.isPythonFile():
814 if self.fileext == '.py': 834 if self.fileext == '.py':
815 self.icon = UI.PixmapCache.getIcon("filePython.png") 835 pixName = "filePython.png"
816 else: 836 else:
817 self.icon = UI.PixmapCache.getIcon("filePython2.png") 837 pixName = "filePython2.png"
818 self._populated = False 838 self._populated = False
819 self._lazyPopulation = True 839 self._lazyPopulation = True
820 self._moduleName = os.path.basename(finfo) 840 self._moduleName = os.path.basename(finfo)
821 elif self.isPython3File(): 841 elif self.isPython3File():
822 self.icon = UI.PixmapCache.getIcon("filePython.png") 842 pixName = "filePython.png"
823 self._populated = False 843 self._populated = False
824 self._lazyPopulation = True 844 self._lazyPopulation = True
825 self._moduleName = os.path.basename(finfo) 845 self._moduleName = os.path.basename(finfo)
826 elif self.isRubyFile(): 846 elif self.isRubyFile():
827 self.icon = UI.PixmapCache.getIcon("fileRuby.png") 847 pixName = "fileRuby.png"
828 self._populated = False 848 self._populated = False
829 self._lazyPopulation = True 849 self._lazyPopulation = True
830 self._moduleName = os.path.basename(finfo) 850 self._moduleName = os.path.basename(finfo)
831 elif self.isDesignerFile(): 851 elif self.isDesignerFile():
832 self.icon = UI.PixmapCache.getIcon("fileDesigner.png") 852 pixName = "fileDesigner.png"
833 elif self.isLinguistFile(): 853 elif self.isLinguistFile():
834 if self.fileext == '.ts': 854 if self.fileext == '.ts':
835 self.icon = UI.PixmapCache.getIcon("fileLinguist.png") 855 pixName = "fileLinguist.png"
836 else: 856 else:
837 self.icon = UI.PixmapCache.getIcon("fileLinguist2.png") 857 pixName = "fileLinguist2.png"
838 elif self.isResourcesFile(): 858 elif self.isResourcesFile():
839 self.icon = UI.PixmapCache.getIcon("fileResource.png") 859 pixName = "fileResource.png"
840 elif self.isProjectFile(): 860 elif self.isProjectFile():
841 self.icon = UI.PixmapCache.getIcon("fileProject.png") 861 pixName = "fileProject.png"
842 elif self.isMultiProjectFile(): 862 elif self.isMultiProjectFile():
843 self.icon = UI.PixmapCache.getIcon("fileMultiProject.png") 863 pixName = "fileMultiProject.png"
844 elif self.isIdlFile(): 864 elif self.isIdlFile():
845 self.icon = UI.PixmapCache.getIcon("fileIDL.png") 865 pixName = "fileIDL.png"
846 self._populated = False 866 self._populated = False
847 self._lazyPopulation = True 867 self._lazyPopulation = True
848 self._moduleName = os.path.basename(finfo) 868 self._moduleName = os.path.basename(finfo)
849 elif self.isPixmapFile(): 869 elif self.isPixmapFile():
850 self.icon = UI.PixmapCache.getIcon("filePixmap.png") 870 pixName = "filePixmap.png"
851 elif self.isSvgFile(): 871 elif self.isSvgFile():
852 self.icon = UI.PixmapCache.getIcon("fileSvg.png") 872 pixName = "fileSvg.png"
853 elif self.isDFile(): 873 elif self.isDFile():
854 self.icon = UI.PixmapCache.getIcon("fileD.png") 874 pixName = "fileD.png"
855 else: 875 else:
856 self.icon = UI.PixmapCache.getIcon("fileMisc.png") 876 pixName = "fileMisc.png"
877
878 if os.path.lexists(self._filename) and os.path.islink(self._filename):
879 self.symlink = True
880 self.icon = UI.PixmapCache.getSymlinkIcon(pixName)
881 else:
882 self.icon = UI.PixmapCache.getIcon(pixName)
857 883
858 def setName(self, finfo, full = True): 884 def setName(self, finfo, full = True):
859 """ 885 """
860 Public method to set the directory name. 886 Public method to set the directory name.
861 887

eric ide

mercurial