a78f09e969b9b736974ad4ab969c3d7947851416
[mussorgsky] / src / mussorgsky-qml.py
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3  
4 import sys
5 from PySide.QtCore import *
6 from PySide.QtGui import *
7 from PySide.QtDeclarative import QDeclarativeView
8
9 from qml.albumModel import AlbumModel
10 from qml.logic import MussorgskyLogic
11
12 # Create Qt application and the QDeclarative view
13 app = QApplication(sys.argv)
14 view = QDeclarativeView()
15
16
17 #MOCK_DATA = [
18 #     AlbumItem ("Are you experienced?", "Jimy Hendrix", None),
19 #     AlbumItem ("Bring them all back home", "Bob dylan", None),
20 #     AlbumItem ("OK computer", "Radiohead", None),
21 #     AlbumItem ("Absolution", "Muse", None),
22 #     AlbumItem ("Come with us", "Chemical brothers", None)
23 #    ]
24
25 logic = MussorgskyLogic ()
26
27 albumModel = AlbumModel (logic.get_all_albums())
28 print "Model with", albumModel.rowCount(), "rows"
29
30 rc = view.rootContext ()
31 rc.setContextProperty ('albumModel', albumModel)
32
33 # Create an URL to the QML file
34 #url = QUrl('view.qml')
35 url = QUrl ("../ui/main.qml")
36 # Set the QML file and show
37 view.setSource(url)
38
39
40 view.show()
41 # Enter Qt main loop
42 sys.exit(app.exec_())