From 1206e9fb0c9a21e60b1e6841bb3071daa1f0da8a Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 1 May 2009 11:21:44 +1000 Subject: More format conversion. --- src/declarative/extra/qmlnumberformatter.cpp | 4 ++-- src/declarative/extra/qmlxmllistmodel.cpp | 13 ++++++++----- src/declarative/util/qbindablemap.cpp | 4 ++-- src/declarative/util/qmlbind.cpp | 4 ++-- src/declarative/util/qmldatetimeformatter.cpp | 28 +++++++++++++-------------- src/declarative/util/qmlscript.cpp | 6 +++--- 6 files changed, 31 insertions(+), 28 deletions(-) diff --git a/src/declarative/extra/qmlnumberformatter.cpp b/src/declarative/extra/qmlnumberformatter.cpp index 8772305..1549525 100644 --- a/src/declarative/extra/qmlnumberformatter.cpp +++ b/src/declarative/extra/qmlnumberformatter.cpp @@ -72,8 +72,8 @@ public: In the following example, the text element will display the text "1,234.57". \code - - + NumberFormatter { id: Formatter; number: 1234.5678; format: "##,##0.##" } + Text { text: Formatter.text } \endcode */ diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp index 91c8139..6b8f285 100644 --- a/src/declarative/extra/qmlxmllistmodel.cpp +++ b/src/declarative/extra/qmlxmllistmodel.cpp @@ -74,11 +74,14 @@ QML_DEFINE_TYPE(QmlXmlListModel, XmlListModel); The following is an example of a model containing news from a Yahoo RSS feed: \qml - - - - - + XmlListModel { + id: FeedModel + source: "http://rss.news.yahoo.com/rss/oceania" + query: "doc($src)/rss/channel/item" + Role { name: "title"; query: "title/string()" } + Role { name: "link"; query: "link/string()" } + Role { name: "description"; query: "description/string()"; isCData: true } + } \endqml \note The model is currently static, so the above is really just a snapshot of an RSS feed. */ diff --git a/src/declarative/util/qbindablemap.cpp b/src/declarative/util/qbindablemap.cpp index 341dd31..c8c8ced 100644 --- a/src/declarative/util/qbindablemap.cpp +++ b/src/declarative/util/qbindablemap.cpp @@ -87,8 +87,8 @@ private: Then, in QML: \code - - + Text { text: owner.name } + Text { text: owner.phone } \endcode The binding is dynamic - whenever a key's value is updated, anything bound to that diff --git a/src/declarative/util/qmlbind.cpp b/src/declarative/util/qmlbind.cpp index 3b51c6a..59bfd75 100644 --- a/src/declarative/util/qmlbind.cpp +++ b/src/declarative/util/qmlbind.cpp @@ -77,8 +77,8 @@ QML_DEFINE_TYPE(QmlBind,Bind); property into QML. You could use Bind to update the enteredText property like this. \code - - + TextEdit { id: myTextField; text: "Please type here..." } + Bind { target: app; property: "enteredText"; value: myTextField.text /> \endcode Whenever the text in the TextEdit is updated, the C++ property will be updated also. diff --git a/src/declarative/util/qmldatetimeformatter.cpp b/src/declarative/util/qmldatetimeformatter.cpp index efddd81..94b87ee 100644 --- a/src/declarative/util/qmldatetimeformatter.cpp +++ b/src/declarative/util/qmldatetimeformatter.cpp @@ -74,8 +74,8 @@ public: \brief The DateTimeFormatter allows you to control the format of a date string. \code - - + DateTimeFormatter { id: Formatter; date: System.date } + Text { text: Formatter.dateText } \endcode By default, the text properties (dateText, timeText, and dateTimeText) will return the @@ -110,18 +110,18 @@ QmlDateTimeFormatter::~QmlDateTimeFormatter() will use the system locale's default 'short' setting. \code - - + // specify source date (assuming today is February 19, 2009) + DateTimeFormatter { id: formatter; dateTime: Today.date } - - + // display the full date and time + Text { text: formatter.dateText } \endcode Would be equivalent to the following for a US English locale: \code - - + // display the date + Text { text: "2/19/09" } \endcode */ QString QmlDateTimeFormatter::dateTimeText() const @@ -150,14 +150,14 @@ QString QmlDateTimeFormatter::timeText() const The source date and time to be used by the formatter. \code - - + // setting the date and time + DateTimeFormatter { date: System.date; time: System.time } \endcode For convienience it is possible to set the datetime property to set both the date and the time. \code - - + // setting the datetime + DateTimeFormatter { dateTime: System.dateTime } \endcode There can only be one instance of date and time per formatter; if date, time, and dateTime are all @@ -208,8 +208,8 @@ QDateTime QmlDateTimeFormatter::dateTime() const Syntax for the format is based on the QDateTime::toString() formatting options. \code -