from qml.albumModel import AlbumModel
from qml.logic import MussorgskyLogic
+from qml.controller import MussorgskyController
# Create Qt application and the QDeclarative view
app = QApplication(sys.argv)
albumModel = AlbumModel (logic.get_all_albums())
print "Model with", albumModel.rowCount(), "rows"
+controller = MussorgskyController ()
+
rc = view.rootContext ()
rc.setContextProperty ('albumModel', albumModel)
+rc.setContextProperty ('missionControl', controller)
# Create an URL to the QML file
#url = QUrl('view.qml')
from PySide import QtDeclarative
-class Controller (QtCore.QObject):
+class MussorgskyController (QtCore.QObject):
@QtCore.Slot (QtCore.QObject)
- def albumSelected (self, wrapper):
- print "Called controller, but nothing to do here yet"
+ def albumSelected (self, album):
+ print "clicked on", album.title
id: albumListView
anchors.fill: parent
+ signal rowSelected (variant albumitem)
+
delegate: Component {
Rectangle {
width: albumListView.width
verticalAlignment: Text.AlignTop
anchors.leftMargin: 10
}
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { albumListView.rowSelected (model.album) }
+ }
}
}
--- /dev/null
+import Qt 4.7
+
+Item {
+ anchors.fill: parent
+ Text { text: "hola oh"; color: "white" }
+}
+/*
+
+Row {
+ id: coversAlternatives
+
+ width: parent.width
+ height: parent.height
+ spacing: 10
+
+ Image {
+ source: "images/button-blue.png"
+ }
+ Image {
+ source: "images/button-red.png"
+ }
+ Image {
+ source: "images/button-blue.png"
+ }
+ Image {
+ source: "images/button-red.png"
+ }
+}
+
+*/
height: 480
color: "black"
state: "in_initPage"
+ //state: "in_albumsPage"
Row {
id: initPage
AlbumList {
id: albumsPage
model: albumModel
+ onRowSelected: {
+ screen.state = "in_alternativesPage"
+ missionControl.albumSelected (albumitem)
+ }
+ }
+
+ Alternatives {
+ id:alternativesPage
}
states: [
name: "in_initPage"
PropertyChanges {target: initPage; visible: true }
PropertyChanges {target: albumsPage; visible: false }
+ PropertyChanges {target: alternativesPage; visible: false }
},
State {
name: "in_albumsPage"
PropertyChanges {target: initPage; visible: false }
PropertyChanges {target: albumsPage; visible: true }
+ PropertyChanges {target: alternativesPage; visible: false }
+ },
+
+ State {
+ name: "in_alternativesPage"
+ PropertyChanges {target: initPage; visible: false }
+ PropertyChanges {target: albumsPage; visible: false }
+ PropertyChanges {target: alternativesPage; visible: true }
}
]