-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfs.py
executable file
·70 lines (52 loc) · 1.76 KB
/
fs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python3
import sys
from PySide import QtCore
from PySide.QtGui import *
#class MyProxyModel(QAbstractProxyModel):
class MyProxyModel(QSortFilterProxyModel):
"""A hack towards a proxy model"""
def __init__(self, parent=None):
#QAbstractProxyModel.__init__(self, parent)
QSortFilterProxyModel.__init__(self, parent)
#def mapFromSource(self, sourceIndex):
# """return QModelIndex
# arg: QModelIndex"""
# return sourceIndex
#def mapToSource(self, proxyIndex):
# """return QModelIndex
# arg: QModelIndex"""
# return proxyIndex
#def mapSelectionFromSource(self, sourceSelection):
# """return QItemSelection
# arg: QItemSelection"""
# return sourceSelection
#def mapSelectionToSource(self, proxySelection):
# """return QItemSelection
# arg: QItemSelection"""
# return proxySelection
#def setSourceModel(self, sourceModel):
# QSortFilterProxyModel.setSourceModel(self, sourceModel)
# self.srcModel = sourceModel
#def sourceModel(self):
# return self.srcModel
startPath = '/'
app = QApplication(sys.argv)
splitter = QSplitter()
model = QFileSystemModel(app)
model.setRootPath(startPath)
#proxy = QSortFilterProxyModel(app)
proxy = MyProxyModel(app)
proxy.setSourceModel(model)
cmodel = proxy
treeView = QTreeView(splitter)
treeView.setModel(cmodel)
#treeView.setRootIndex(model.index(startPath))
listView = QListView(splitter)
listView.setModel(cmodel)
#listView.setRootIndex(model.index(startPath))
selection = QItemSelectionModel(cmodel)
treeView.setSelectionModel(selection)
listView.setSelectionModel(selection)
splitter.setWindowTitle('Two way viewer')
splitter.show()
sys.exit(app.exec_())