Beispiel #1
0
 def openContainer(self):
     dir = QDir(self.path)
     self.removeItems()
     fileItems = []
     for fi in dir.entryInfoList():
         item = None
         name = fi.fileName().ascii()
         
         if fi.isFile() and Globals.file_supported(fi.filePath()):
             item = FileItem(fi.filePath().ascii(), self)
             item.setPaletteBackgroundColor(file_color)
             fileItems.append(item)
             
         elif fi.isDir() and not name == '.' and not name == '..':
             item = DirItem(fi.filePath().ascii(), self)
             self.items.append(item)
             
         if item:
             item.show() # leave this!
             self.connect(item, PYSIGNAL('resized'), self.slotResize)
             self.connect(item, PYSIGNAL('selected'), self.slotSelected)
             
     # add file items after directories
     for fi in fileItems:
         self.items.append(fi)
     ContainerItem.openContainer(self)
Beispiel #2
0
    def setPath(self, p):
        """ Populate the view with files in a path
            An empty string will clear the view.
        """
        # clear
        for f in self.shown:
            f.hide()
            self.cache.put(f)
        self.shown = []

        # populate
        if os.path.isdir(p):
            for fn in os.listdir(p):
                fp = os.path.join(p,fn)
                if os.path.isfile(fp) and Globals.file_supported(fp):
                    f = self._getPart()
                    f.setPath(fp)
                    f.show()
                    self.shown.append(f)
        self.rearrange()