Example #1
0
class FileSystemModel(QObject):
    """
    A representation of the file system with <rootpath> as the root.
    """

    updated = pyqtSignal()


    def __init__(self):
        super(FileSystemModel, self).__init__()
        self.rootpath = None
        self.rootitem = None
        self.settings = QlrBrowserSettings()
        self.validSortDelimitChars = ['~','!','#','$','%','&','+','-',';','=','@','^','_']

    def setRootPath(self, path):
        self.rootpath = path.rstrip('/\\')
        # Start filling
        self.update()

    def update(self):
        self.rootitem = FileSystemItem(self.rootpath, True, FileSystemRecursionCounter(), namingregex=self.namingregex())
        self.updated.emit()

    def namingregex(self):
        if not self.settings.value("useSortDelimitChar"):
            return None
        else:
            char = self.settings.value("sortDelimitChar")
            if char not in self.validSortDelimitChars:
                raise Exception("sortDelimitChar is not valid: '" + char + "'. Should be one of: " + ",".join(self.validSortDelimitChars))
            # Like ^(?:[0-9]{1,3}\~)?(.*)$ for char='~'
            strRex = '^(?:[0-9]{1,3}\\' + char + ')?(.*)$'
            return re.compile(strRex)
Example #2
0
 def __init__(self):
     self.count = 0
     settings = QlrBrowserSettings()
     self.maxcount = settings.value("maxFileSystemObjects")
Example #3
0
 def __init__(self):
     super(FileSystemModel, self).__init__()
     self.rootpath = None
     self.rootitem = None
     self.settings = QlrBrowserSettings()
     self.validSortDelimitChars = ['~','!','#','$','%','&','+','-',';','=','@','^','_']