Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qt_aafmodel.py: add pane for item properties #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 43 additions & 10 deletions example/qt_aafmodel.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from PyQt4 import QtCore
from PyQt4 import QtCore, QtGui

import aaf
import aaf.storage
Expand Down Expand Up @@ -238,12 +238,32 @@ def getItem(self,index):
if item:
return item
return self.rootItem



def aaf_item_model(item):
if isinstance(item, DummyItem):
keys = []
values = []
elif isinstance(item, basestring):
keys = ['']
values = [item]
else:
keys = item.keys()
keys.sort()
values = [str(item[k].value) for k in keys]

model = QtGui.QStandardItemModel(len(keys), 1)
model.setVerticalHeaderLabels(keys)
model.setHorizontalHeaderLabels(['Value'])
for i, value in enumerate(values):
modelItem = QtGui.QStandardItem(value)
modelItem.setEditable(False)
model.setItem(i, 0, modelItem)

return model


if __name__ == "__main__":

from PyQt4 import QtGui

from optparse import OptionParser

parser = OptionParser()
Expand Down Expand Up @@ -289,12 +309,25 @@ def getItem(self,index):
model = AAFModel(root)

tree = QtGui.QTreeView()

tree.setModel(model)

tree.resize(700,600)
tree.expandToDepth(5)
tree.resizeColumnToContents(0)
tree.show()

table = QtGui.QTableView()

splitter = QtGui.QSplitter()
splitter.addWidget(tree)
splitter.addWidget(table)
splitter.setWindowTitle(args[0])
splitter.resize(700, 600)
splitter.show()

def onCurrentSelectionChanged(current, previous):
item = model.getItem(current).item
table.setModel(aaf_item_model(item))
table.resizeColumnsToContents()


tree.selectionModel().currentChanged.connect(onCurrentSelectionChanged)

sys.exit(app.exec_())
sys.exit(app.exec_())