QML ui: Album list is clickable
[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 from qml.controller import MussorgskyController
12
13 # Create Qt application and the QDeclarative view
14 app = QApplication(sys.argv)
15 view = QDeclarativeView()
16
17
18 #MOCK_DATA = [
19 #     AlbumItem ("Are you experienced?", "Jimy Hendrix", None),
20 #     AlbumItem ("Bring them all back home", "Bob dylan", None),
21 #     AlbumItem ("OK computer", "Radiohead", None),
22 #     AlbumItem ("Absolution", "Muse", None),
23 #     AlbumItem ("Come with us", "Chemical brothers", None)
24 #    ]
25
26 logic = MussorgskyLogic ()
27
28 albumModel = AlbumModel (logic.get_all_albums())
29 print "Model with", albumModel.rowCount(), "rows"
30
31 controller = MussorgskyController ()
32
33 rc = view.rootContext ()
34 rc.setContextProperty ('albumModel', albumModel)
35 rc.setContextProperty ('missionControl', controller)
36
37 # Create an URL to the QML file
38 #url = QUrl('view.qml')
39 url = QUrl ("../ui/main.qml")
40 # Set the QML file and show
41 view.setSource(url)
42
43
44 view.show()
45 # Enter Qt main loop
46 sys.exit(app.exec_())