diff options
-rw-r--r-- | framework/qml/ModelIndexRetriever.qml | 13 | ||||
-rw-r--r-- | views/inboxcrusher/qml/View.qml | 18 |
2 files changed, 27 insertions, 4 deletions
diff --git a/framework/qml/ModelIndexRetriever.qml b/framework/qml/ModelIndexRetriever.qml index d01ceb71..080012aa 100644 --- a/framework/qml/ModelIndexRetriever.qml +++ b/framework/qml/ModelIndexRetriever.qml | |||
@@ -22,6 +22,19 @@ Repeater { | |||
22 | id: root | 22 | id: root |
23 | property var currentData | 23 | property var currentData |
24 | property int currentIndex: 0 | 24 | property int currentIndex: 0 |
25 | |||
26 | function increaseCurrentIndex() { | ||
27 | if (currentIndex < count - 1) { | ||
28 | currentIndex = currentIndex + 1 | ||
29 | } | ||
30 | } | ||
31 | |||
32 | function decreaseCurrentIndex() { | ||
33 | if (currentIndex > 0) { | ||
34 | currentIndex = currentIndex - 1 | ||
35 | } | ||
36 | } | ||
37 | |||
25 | onCurrentIndexChanged: { | 38 | onCurrentIndexChanged: { |
26 | currentData = itemAt(currentIndex).currentData | 39 | currentData = itemAt(currentIndex).currentData |
27 | } | 40 | } |
diff --git a/views/inboxcrusher/qml/View.qml b/views/inboxcrusher/qml/View.qml index 7059a8eb..cb662c33 100644 --- a/views/inboxcrusher/qml/View.qml +++ b/views/inboxcrusher/qml/View.qml | |||
@@ -26,12 +26,10 @@ FocusScope { | |||
26 | property variant currentMail: null | 26 | property variant currentMail: null |
27 | 27 | ||
28 | Keys.onRightPressed: { | 28 | Keys.onRightPressed: { |
29 | modelIndexRetriever.currentIndex = modelIndexRetriever.currentIndex + 1 | 29 | modelIndexRetriever.increaseCurrentIndex() |
30 | } | 30 | } |
31 | Keys.onLeftPressed: { | 31 | Keys.onLeftPressed: { |
32 | if (modelIndexRetriever.currentIndex > 0) { | 32 | modelIndexRetriever.decreaseCurrentIndex() |
33 | modelIndexRetriever.currentIndex = modelIndexRetriever.currentIndex - 1 | ||
34 | } | ||
35 | } | 33 | } |
36 | Kube.ModelIndexRetriever { | 34 | Kube.ModelIndexRetriever { |
37 | id: modelIndexRetriever | 35 | id: modelIndexRetriever |
@@ -97,6 +95,18 @@ FocusScope { | |||
97 | onClicked: { | 95 | onClicked: { |
98 | } | 96 | } |
99 | } | 97 | } |
98 | Kube.Button { | ||
99 | text: qsTr("Previous") | ||
100 | onClicked: { | ||
101 | modelIndexRetriever.decreaseCurrentIndex() | ||
102 | } | ||
103 | } | ||
104 | Kube.Button { | ||
105 | text: qsTr("Next") | ||
106 | onClicked: { | ||
107 | modelIndexRetriever.increaseCurrentIndex() | ||
108 | } | ||
109 | } | ||
100 | } | 110 | } |
101 | } | 111 | } |
102 | } | 112 | } |