def __init__(self): QCompleter.__init__(self) self.vfs = vfs() self.__model = CompleterModel() self.currentNode = self.vfs.getnode("/") self.currentPath = self.currentNode self.setCompletionPrefix(QString.fromUtf8(self.currentNode.absolute())) self.__model.setRootPath(self.currentNode) self.__model.setCurrentPath("/") self.setModel(self.__model) QObject.connect(self, SIGNAL("activated(const QString &)"), self.updatePath)
class Completer(QCompleter): def __init__(self): QCompleter.__init__(self) self.vfs = vfs() self.__model = CompleterModel() self.currentNode = self.vfs.getnode("/") self.currentPath = self.currentNode self.setCompletionPrefix(QString.fromUtf8(self.currentNode.absolute())) self.__model.setRootPath(self.currentNode) self.__model.setCurrentPath("/") self.setModel(self.__model) QObject.connect(self, SIGNAL("activated(const QString &)"), self.updatePath) def pathChanged(self, path): self.currentPath = self.vfs.getnode(path) def updatePath(self, path): path = unicode(path) self.curpath = path if path == "": abspath = "/" else: if path[0] == "/": self.__model.setCurrentPath("") idx = path.rfind("/") abspath = path[:idx] else: abspath = self.currentPath.absolute() self.__model.setCurrentPath(abspath) idx = path.rfind("/") if idx != -1: abspath += path[:idx] self.currentNode = self.vfs.getnode(unicode(abspath).encode('utf-8')) self.__model.setRootPath(self.currentNode) self.setCompletionPrefix(QString.fromUtf8(self.currentNode.absolute()))