| 51 | |
| 52 | |
| 53 | class ClassifyWidget(QTreeWidget): |
| 54 | fileSelected = pyqtSignal(str) |
| 55 | |
| 56 | def __init__(self, *args, **kwargs): |
| 57 | super(ClassifyWidget, self).__init__(*args, **kwargs) |
| 58 | self.setHeaderHidden(True) |
| 59 | self.setColumnCount(1) |
| 60 | self.itemDoubleClicked.connect(self.onItemDoubleClicked) |
| 61 | baseDir = "分类" |
| 62 | for name in os.listdir(baseDir): |
| 63 | path = os.path.join(baseDir, name) |
| 64 | if os.path.isdir(path): |
| 65 | item = QTreeWidgetItem(self) |
| 66 | item.setText(0, name) |
| 67 | for file in os.listdir(path): |
| 68 | path = os.path.join(path, file) |
| 69 | if os.path.isfile(path) and file.endswith(".json"): |
| 70 | item = QTreeWidgetItem(item) |
| 71 | item.setText(0, os.path.splitext(file)[0]) |
| 72 | item.setToolTip(0, path) |
| 73 | self.expandAll() |
| 74 | |
| 75 | def onItemDoubleClicked(self, item): |
| 76 | file = item.toolTip(0) |
| 77 | if file: |
| 78 | self.fileSelected.emit(file) |
| 79 | |
| 80 | |
| 81 | class CodeScintilla(QsciScintilla): |