QML ui: Album list is clickable
authorIvan Frade <ivan.frade@nokia.com>
Mon, 4 Apr 2011 11:12:09 +0000 (14:12 +0300)
committerIvan Frade <ivan.frade@nokia.com>
Mon, 4 Apr 2011 11:13:52 +0000 (14:13 +0300)
src/mussorgsky-qml.py
src/qml/controller.py
ui/AlbumList.qml
ui/Alternatives.qml [new file with mode: 0644]
ui/main.qml

index a78f09e..54b5d3d 100644 (file)
@@ -8,6 +8,7 @@ from PySide.QtDeclarative import QDeclarativeView
 
 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)
@@ -27,8 +28,11 @@ logic = MussorgskyLogic ()
 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')
index 48cabf6..a703eb2 100644 (file)
@@ -6,9 +6,9 @@ from PySide import QtGui
 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
 
index aae9fa4..ea673d7 100644 (file)
@@ -4,6 +4,8 @@ ListView {
     id: albumListView
     anchors.fill: parent
 
+    signal rowSelected (variant albumitem)
+
     delegate: Component {
           Rectangle {
               width: albumListView.width
@@ -46,6 +48,11 @@ ListView {
                  verticalAlignment: Text.AlignTop
                  anchors.leftMargin: 10
               }
+              
+              MouseArea {
+                   anchors.fill: parent
+                   onClicked: { albumListView.rowSelected (model.album) }
+              }
           }
     }
 
diff --git a/ui/Alternatives.qml b/ui/Alternatives.qml
new file mode 100644 (file)
index 0000000..628a9bd
--- /dev/null
@@ -0,0 +1,30 @@
+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"
+           }
+}
+
+*/
index 1bdb170..ab5c2c5 100644 (file)
@@ -6,6 +6,7 @@ Rectangle {
     height: 480
     color: "black"
     state: "in_initPage"
+    //state: "in_albumsPage"
      
     Row {
         id: initPage
@@ -31,6 +32,14 @@ Rectangle {
     AlbumList {
         id: albumsPage
         model: albumModel
+        onRowSelected: {
+            screen.state = "in_alternativesPage"
+            missionControl.albumSelected (albumitem)
+        }
+    }
+
+    Alternatives {
+        id:alternativesPage
     }
 
     states: [
@@ -38,12 +47,21 @@ Rectangle {
            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 }
        }
     ]