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.margins: 4
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TabWidget {
|
||||
|
@@ -16,7 +16,7 @@ Item {
|
||||
|
||||
ListModel {
|
||||
id: tempNewsModel
|
||||
ListElement { title: "Loading news sources..."; description: "Loading..." ; blogIcon: ""; blogName: ""; link: "" }
|
||||
ListElement { title: ""; description: "Loading news sources..." ; blogIcon: ""; blogName: ""; link: "" }
|
||||
}
|
||||
|
||||
NewsListing {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import Qt 4.7
|
||||
import QtQuick 1.1
|
||||
import "../components/" as Components
|
||||
|
||||
Item {
|
||||
@@ -15,6 +15,13 @@ Item {
|
||||
onTriggered: repeater.incrementIndex()
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: modelUpdateTimer
|
||||
repeat: false
|
||||
interval: 1000
|
||||
onTriggered: repeater.handleModelUpdate();
|
||||
}
|
||||
|
||||
Repeater {
|
||||
id: repeater
|
||||
function incrementIndex() {
|
||||
@@ -23,17 +30,34 @@ Item {
|
||||
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() {
|
||||
if (timer.running)
|
||||
timer.stop();
|
||||
currentItem = 0
|
||||
//FIXME: this doesn't work
|
||||
repeater.itemAt(currentItem).active = true
|
||||
timer.start()
|
||||
modelUpdateTimer.restart();
|
||||
}
|
||||
|
||||
function handleItemRemoved(index, item) {
|
||||
modelUpdateTimer.restart();
|
||||
}
|
||||
|
||||
function handleItemAdded(index, item) {
|
||||
modelUpdateTimer.restart();
|
||||
}
|
||||
|
||||
anchors.fill: parent
|
||||
onModelChanged: handleModelChanged()
|
||||
onItemAdded: handleItemAdded(index, item)
|
||||
onItemRemoved: handleItemRemoved(index, item)
|
||||
delegate: Item {
|
||||
property bool active: false
|
||||
id: delegateItem
|
||||
@@ -44,12 +68,30 @@ Item {
|
||||
spacing: 10
|
||||
width: parent.width
|
||||
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 {
|
||||
spacing: 5
|
||||
width: parent.width
|
||||
Image { 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 }
|
||||
Image {
|
||||
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 {
|
||||
id: text;
|
||||
@@ -58,16 +100,31 @@ Item {
|
||||
textFormat: Text.RichText
|
||||
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 {
|
||||
id: activeState
|
||||
states: [ State { name: "active"; when: delegateItem.active; PropertyChanges { target: delegateItem; opacity: 1 } } ]
|
||||
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" } }
|
||||
]
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user