python - PyQt: QFileSystemModel checkbox filter -
i trying make utility using python/pyqt create *.tar archive qfilesystemmodel
(including items checked). want control of qfilesystemmodel
checkboxes filter filename / filetype / filesize.
how can check/uncheck qfilesystemmodel
checkboxes outside of class wildcard search on filename / filetype / filesize?
class checkabledirmodel(qtgui.qfilesystemmodel): def __init__(self, parent=none): qtgui.qfilesystemmodel.__init__(self, none) self.checks = {} def data(self, index, role=qtcore.qt.displayrole): if role != qtcore.qt.checkstaterole: return qtgui.qfilesystemmodel.data(self, index, role) else: if index.column() == 0: return self.checkstate(index) def flags(self, index): return qtgui.qfilesystemmodel.flags(self, index) | qtcore.qt.itemisusercheckable def checkstate(self, index): if index in self.checks: return self.checks[index] else: return qtcore.qt.checked def setdata(self, index, value, role): if (role == qtcore.qt.checkstaterole , index.column() == 0): self.checks[index] = value self.emit(qtcore.signal("datachanged(qmodelindex,qmodelindex)"), index, index) return true return qtgui.qfilesystemmodel.setdata(self, index, value, role) self.dirtreeview = qtgui.qtreeview(self.centralwidget) self.dirmodel = checkabledirmodel() self.dirtreeview.setmodel(self.dirmodel)
Comments
Post a Comment