forked from qt-creator/qt-creator
Show news from the start and cycle through them.
Change-Id: I0f783148ea3e42ac4f9728a0f32c0452c041b387 Reviewed-on: http://codereview.qt.nokia.com/942 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Daniel Molkentin <daniel.molkentin@nokia.com>
This commit is contained in:
@@ -58,7 +58,6 @@ Image {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: 4
|
anchors.margins: 4
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TabWidget {
|
TabWidget {
|
||||||
|
@@ -16,7 +16,7 @@ Item {
|
|||||||
|
|
||||||
ListModel {
|
ListModel {
|
||||||
id: tempNewsModel
|
id: tempNewsModel
|
||||||
ListElement { title: "Loading news sources..."; description: "Loading..." ; blogIcon: ""; blogName: ""; link: "" }
|
ListElement { title: ""; description: "Loading news sources..." ; blogIcon: ""; blogName: ""; link: "" }
|
||||||
}
|
}
|
||||||
|
|
||||||
NewsListing {
|
NewsListing {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import Qt 4.7
|
import QtQuick 1.1
|
||||||
import "../components/" as Components
|
import "../components/" as Components
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
@@ -15,6 +15,13 @@ Item {
|
|||||||
onTriggered: repeater.incrementIndex()
|
onTriggered: repeater.incrementIndex()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: modelUpdateTimer
|
||||||
|
repeat: false
|
||||||
|
interval: 1000
|
||||||
|
onTriggered: repeater.handleModelUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: repeater
|
id: repeater
|
||||||
function incrementIndex() {
|
function incrementIndex() {
|
||||||
@@ -23,17 +30,34 @@ Item {
|
|||||||
repeater.itemAt(currentItem).active = true
|
repeater.itemAt(currentItem).active = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleModelUpdate() {
|
||||||
|
timer.stop();
|
||||||
|
currentItem = 0;
|
||||||
|
for (var i = 0; i < count; ++i) {
|
||||||
|
if (i != currentItem)
|
||||||
|
repeater.itemAt(i).active = false;
|
||||||
|
else
|
||||||
|
repeater.itemAt(i).active = true;
|
||||||
|
}
|
||||||
|
timer.start();
|
||||||
|
}
|
||||||
|
|
||||||
function handleModelChanged() {
|
function handleModelChanged() {
|
||||||
if (timer.running)
|
modelUpdateTimer.restart();
|
||||||
timer.stop();
|
}
|
||||||
currentItem = 0
|
|
||||||
//FIXME: this doesn't work
|
function handleItemRemoved(index, item) {
|
||||||
repeater.itemAt(currentItem).active = true
|
modelUpdateTimer.restart();
|
||||||
timer.start()
|
}
|
||||||
|
|
||||||
|
function handleItemAdded(index, item) {
|
||||||
|
modelUpdateTimer.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onModelChanged: handleModelChanged()
|
onModelChanged: handleModelChanged()
|
||||||
|
onItemAdded: handleItemAdded(index, item)
|
||||||
|
onItemRemoved: handleItemRemoved(index, item)
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
property bool active: false
|
property bool active: false
|
||||||
id: delegateItem
|
id: delegateItem
|
||||||
@@ -44,12 +68,30 @@ Item {
|
|||||||
spacing: 10
|
spacing: 10
|
||||||
width: parent.width
|
width: parent.width
|
||||||
id: column
|
id: column
|
||||||
Text { id: heading1; text: title; font.bold: true; wrapMode: Text.WrapAtWordBoundaryOrAnywhere; textFormat: Text.RichText; width: parent.width-icon.width-5 }
|
Text {
|
||||||
|
id: heading1;
|
||||||
|
text: title;
|
||||||
|
font.bold: true;
|
||||||
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere;
|
||||||
|
textFormat: Text.RichText;
|
||||||
|
width: parent.width-icon.width-5
|
||||||
|
}
|
||||||
Row {
|
Row {
|
||||||
spacing: 5
|
spacing: 5
|
||||||
width: parent.width
|
width: parent.width
|
||||||
Image { id: icon; source: blogIcon; asynchronous: true }
|
Image {
|
||||||
Text { id: heading2; text: blogName; font.italic: true; wrapMode: Text.WrapAtWordBoundaryOrAnywhere; textFormat: Text.RichText; width: parent.width-icon.width-5 }
|
id: icon;
|
||||||
|
source: blogIcon;
|
||||||
|
asynchronous: true
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
id: heading2;
|
||||||
|
text: blogName;
|
||||||
|
font.italic: true;
|
||||||
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere;
|
||||||
|
textFormat: Text.RichText;
|
||||||
|
width: parent.width-icon.width-5
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
id: text;
|
id: text;
|
||||||
@@ -58,16 +100,31 @@ Item {
|
|||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
width: parent.width-10
|
width: parent.width-10
|
||||||
}
|
}
|
||||||
Text { visible: link !== ""; id: readmore; text: qsTr("Click to read more..."); font.italic: true; wrapMode: Text.WrapAtWordBoundaryOrAnywhere; textFormat: Text.RichText }
|
Text { visible: link !== "";
|
||||||
|
id: readmore;
|
||||||
|
text: qsTr("Click to read more...");
|
||||||
|
font.italic: true;
|
||||||
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere;
|
||||||
|
textFormat: Text.RichText
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Components.QStyleItem {
|
||||||
|
id: styleItem;
|
||||||
|
cursor: "pointinghandcursor";
|
||||||
|
anchors.fill: column
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: column;
|
||||||
|
onClicked: Qt.openUrlExternally(link);
|
||||||
|
hoverEnabled: true;
|
||||||
|
id: mouseArea
|
||||||
}
|
}
|
||||||
Components.QStyleItem { id: styleItem; cursor: "pointinghandcursor"; anchors.fill: column }
|
|
||||||
MouseArea { anchors.fill: column; onClicked: Qt.openUrlExternally(link); hoverEnabled: true; id: mouseArea }
|
|
||||||
|
|
||||||
StateGroup {
|
StateGroup {
|
||||||
id: activeState
|
id: activeState
|
||||||
states: [ State { name: "active"; when: delegateItem.active; PropertyChanges { target: delegateItem; opacity: 1 } } ]
|
states: [ State { name: "active"; when: delegateItem.active; PropertyChanges { target: delegateItem; opacity: 1 } } ]
|
||||||
transitions: [
|
transitions: [
|
||||||
Transition { from: ""; to: "active"; reversible: true; NumberAnimation { target: delegateItem; property: "opacity"; duration: 200 } }
|
Transition { from: ""; to: "active"; reversible: true; NumberAnimation { target: delegateItem; property: "opacity"; duration: 1000 } }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,6 +133,7 @@ Item {
|
|||||||
State { name: "hovered"; when: mouseArea.containsMouse; PropertyChanges { target: text; color: "#074C1C" } }
|
State { name: "hovered"; when: mouseArea.containsMouse; PropertyChanges { target: text; color: "#074C1C" } }
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user