]> git.tdb.fi Git - xinema.git/blobdiff - remote/qml/components/ChannelSelect.qml
Move non-page qml components to a separate subdirectory
[xinema.git] / remote / qml / components / ChannelSelect.qml
diff --git a/remote/qml/components/ChannelSelect.qml b/remote/qml/components/ChannelSelect.qml
new file mode 100644 (file)
index 0000000..43c6cf7
--- /dev/null
@@ -0,0 +1,78 @@
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+ValueButton
+{
+       id: channelSelect
+
+       property var channels: null
+       property int currentChannel: -1
+       property bool _channelsAvailable: channels && channels.length
+       enabled: _channelsAvailable
+
+       value: (_channelsAvailable ? currentChannel>=0 ? (currentChannel+1)+": "+channels[currentChannel] : "0: (off)" : "(not available)")
+
+       onClicked:
+       {
+               if(_channelsAvailable)
+                       pageStack.push(selectDialog);
+       }
+
+       Component
+       {
+               id: selectDialog
+
+               Page
+               {
+                       id: page
+
+                       function selectChannel(index)
+                       {
+                               channelSelect.currentChannel = index;
+                               pageStack.pop();
+                       }
+
+                       SilicaFlickable
+                       {
+                               width: parent.width
+                               contentHeight: column.height
+
+                               Column
+                               {
+                                       id: column
+                                       width: parent.width
+                                       spacing: Theme.paddingLarge
+
+                                       PageHeader
+                                       {
+                                               id: header
+                                               title: channelSelect.label
+                                       }
+
+                                       ChannelItem
+                                       {
+                                               channelIndex: 0
+                                               channelName: "(off)"
+                                               down: channelSelect.currentChannel+1==channelIndex
+
+                                               onClicked: page.selectChannel(channelIndex-1);
+                                       }
+                                       Repeater
+                                       {
+                                               id: repeater
+                                               model: channelSelect.channels
+
+                                               ChannelItem
+                                               {
+                                                       channelIndex: index+1
+                                                       channelName: modelData
+                                                       down: channelSelect.currentChannel+1==channelIndex
+
+                                                       onClicked: page.selectChannel(channelIndex-1);
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+}