diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-06-29 01:23:22 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-06-29 01:23:22 (GMT) |
commit | 16a8e075e09323b3e77f8faa58bfc9e9a3bf310f (patch) | |
tree | d51df8e75b1d81fbecd15553744a768956a7992a /src/declarative/util | |
parent | 13086523d7181d5628872c74030b460e5f7388a5 (diff) | |
download | Qt-16a8e075e09323b3e77f8faa58bfc9e9a3bf310f.zip Qt-16a8e075e09323b3e77f8faa58bfc9e9a3bf310f.tar.gz Qt-16a8e075e09323b3e77f8faa58bfc9e9a3bf310f.tar.bz2 |
Move some non-essential classes to extra.
Diffstat (limited to 'src/declarative/util')
-rw-r--r-- | src/declarative/util/qbindablemap.cpp | 182 | ||||
-rw-r--r-- | src/declarative/util/qbindablemap.h | 87 | ||||
-rw-r--r-- | src/declarative/util/qmlbehaviour.cpp | 259 | ||||
-rw-r--r-- | src/declarative/util/qmlbehaviour.h | 95 | ||||
-rw-r--r-- | src/declarative/util/qmldatetimeformatter.cpp | 368 | ||||
-rw-r--r-- | src/declarative/util/qmldatetimeformatter.h | 115 | ||||
-rw-r--r-- | src/declarative/util/util.pri | 6 |
7 files changed, 0 insertions, 1112 deletions
diff --git a/src/declarative/util/qbindablemap.cpp b/src/declarative/util/qbindablemap.cpp deleted file mode 100644 index c8c8ced..0000000 --- a/src/declarative/util/qbindablemap.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qbindablemap.h" -#include <qmlopenmetaobject.h> -#include <QDebug> - -QT_BEGIN_NAMESPACE - -//QBindableMapMetaObject lets us listen for changes coming from QML -//so we can emit the changed signal. -class QBindableMapMetaObject : public QmlOpenMetaObject -{ -public: - QBindableMapMetaObject(QBindableMap *obj) : QmlOpenMetaObject(obj) - { - map = obj; - } - -protected: - virtual void propertyWrite(int index) - { - map->emitChanged(QLatin1String(name(index))); - } - -private: - QBindableMap *map; -}; - -/*! - \class QBindableMap - \brief The QBindableMap class allows you to set key-value pairs that can be used in bindings. - - QBindableMap provides a convenient way to expose domain data to the UI layer. - The following example shows how you might declare data in C++ and then - access it in QML. - - Setup in C++: - \code - //create our data - QBindableMap ownerData; - ownerData.setValue("name", QVariant(QString("John Smith"))); - ownerData.setValue("phone", QVariant(QString("555-5555"))); - - //expose it to the UI layer - QmlContext *ctxt = view->bindContext(); - ctxt->setProperty("owner", &data); - \endcode - - 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 - key will be updated as well. - - To detect value changes made in the UI layer you can connect to the changed() signal. - However, note that changed() is \b NOT emitted when changes are made by calling setValue() - or clearValue() - it is only emitted when a value is updated from QML. -*/ - -// is there a more efficient way to store/return keys? -// (or should we just provide an iterator or something else instead?) -// can we provide a way to clear keys? -// do we want to make any claims regarding key ordering? -// should we have signals for insertion and and deletion -- becoming more model like -// should we emit change for our own changes as well? -// Bug or Feature?: values can be created in QML (owner.somethingElse = "Hello") will create somethingElse property. (need to verify if this is actually the case) -// Bug or Feature?: all values are read-write (there are no read-only values) - -/*! - Constructs a bindable map with parent object \a parent. -*/ -QBindableMap::QBindableMap(QObject *parent) -: QObject(parent) -{ - m_mo = new QBindableMapMetaObject(this); -} - -/*! - Destroys the bindable map. -*/ -QBindableMap::~QBindableMap() -{ -} - -/*! - Clears the value (if any) associated with \a key. -*/ -void QBindableMap::clearValue(const QString &key) -{ - //m_keys.remove(); //### - m_mo->setValue(key.toLatin1(), QVariant()); - //emit changed(key); -} - -/*! - Returns the value associated with \a key. - - If no value has been set for this key (or if the value has been cleared), - an invalid QVariant is returned. -*/ -QVariant QBindableMap::value(const QString &key) const -{ - return m_mo->value(key.toLatin1()); -} - -/*! - Sets the value associated with \a key to \a value. - - If the key doesn't exist, it is automatically created. -*/ -void QBindableMap::setValue(const QString &key, QVariant value) -{ - if (!m_keys.contains(key)) - m_keys.append(key); - m_mo->setValue(key.toLatin1(), value); - //emit changed(key); -} - -/*! - Returns the list of keys. - - Keys that have been cleared will still appear in this list, even though their - associated values are invalid QVariants. -*/ -QStringList QBindableMap::keys() const -{ - return m_keys; -} - -/*! - \fn void QBindableMap::changed(const QString &key) - This signal is emitted whenever one of the values in the map is changed. \a key - is the key corresponding to the value that was changed. - */ - -void QBindableMap::emitChanged(const QString &key) -{ - emit changed(key); -} -QT_END_NAMESPACE diff --git a/src/declarative/util/qbindablemap.h b/src/declarative/util/qbindablemap.h deleted file mode 100644 index c76928d..0000000 --- a/src/declarative/util/qbindablemap.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QBINDABLEMAP_H -#define QBINDABLEMAP_H - -#include <QtDeclarative/qfxglobal.h> -#include <QtCore/QObject> -#include <QtCore/QHash> -#include <QtCore/QStringList> -#include <QtCore/QVariant> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QBindableMapMetaObject; -class Q_DECLARATIVE_EXPORT QBindableMap : public QObject -{ - Q_OBJECT -public: - QBindableMap(QObject *parent = 0); - virtual ~QBindableMap(); - - QVariant value(const QString &key) const; - void setValue(const QString &key, QVariant value); - void clearValue(const QString &key); - - Q_INVOKABLE QStringList keys() const; - -Q_SIGNALS: - void changed(const QString &key); - -private: - Q_DISABLE_COPY(QBindableMap) - void emitChanged(const QString &key); - QBindableMapMetaObject *m_mo; - QStringList m_keys; - friend class QBindableMapMetaObject; -}; - - -QT_END_NAMESPACE - -QT_END_HEADER -#endif diff --git a/src/declarative/util/qmlbehaviour.cpp b/src/declarative/util/qmlbehaviour.cpp deleted file mode 100644 index 4beca5e..0000000 --- a/src/declarative/util/qmlbehaviour.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <private/qobject_p.h> -#include "qmlanimation.h" -#include "qmltransition.h" -#include "qmlbehaviour.h" -#include <QtDeclarative/qmlcontext.h> -#include <QtCore/qparallelanimationgroup.h> - -QT_BEGIN_NAMESPACE - -QML_DEFINE_TYPE(QmlBehaviour,Behavior) - -class QmlBehaviourData : public QObject -{ -Q_OBJECT -public: - QmlBehaviourData(QObject *parent) - : QObject(parent) {} - - Q_PROPERTY(QVariant endValue READ endValue NOTIFY valuesChanged); - Q_PROPERTY(QVariant startValue READ startValue NOTIFY valuesChanged); - QVariant endValue() const { return e; } - QVariant startValue() const { return s; } - - QVariant e; - QVariant s; - -Q_SIGNALS: - void valuesChanged(); - -private: - friend class QmlBehaviour; -}; - -class QmlBehaviourPrivate : public QObjectPrivate -{ -public: - QmlBehaviourPrivate() - : context(0), valueData(0), operations(this) {} - QmlMetaProperty property; - QVariant currentValue; - - QVariant fromValue; - QVariant toValue; - QmlContext *context; - QmlBehaviourData *valueData; - class AnimationList : public QmlConcreteList<QmlAbstractAnimation *> - { - public: - AnimationList(QmlBehaviourPrivate *parent) : _parent(parent) {} - virtual void append(QmlAbstractAnimation *a) - { - QmlConcreteList<QmlAbstractAnimation *>::append(a); - _parent->group->addAnimation(a->qtAnimation()); - if (_parent->property.isValid()) { - a->setTarget(_parent->property); - } - } - virtual void clear() { QmlConcreteList<QmlAbstractAnimation *>::clear(); } //### - private: - QmlBehaviourPrivate *_parent; - }; - AnimationList operations; - QParallelAnimationGroup *group; -}; - -/*! - \qmlclass Behavior QmlBehaviour - \brief The Behavior element allows you to specify a default animation for a property change. - - In example below, the rect will use a bounce easing curve over 200 millisecond for any changes to its y property: - \code - Rect { - width: 20; height: 20 - color: "#00ff00" - y: 200 //initial value - y: Behavior { - NumberAnimation { - easing: "easeOutBounce(amplitude:100)" - duration: 200 - } - } - } - \endcode -*/ - -QmlBehaviour::QmlBehaviour(QObject *parent) -: QmlPropertyValueSource(*(new QmlBehaviourPrivate), parent) -{ - Q_D(QmlBehaviour); - d->valueData = new QmlBehaviourData(this); - d->group = new QParallelAnimationGroup(this); -} - -/*! - \qmlproperty QVariant Behavior::fromValue - This property holds a selector specifying a starting value for the behavior - - If you only want the behavior to apply when the change starts at a - specific value you can specify fromValue. This selector is used in conjunction - with the toValue selector. -*/ - -QVariant QmlBehaviour::fromValue() const -{ - Q_D(const QmlBehaviour); - return d->fromValue; -} - -void QmlBehaviour::setFromValue(const QVariant &v) -{ - Q_D(QmlBehaviour); - d->fromValue = v; -} - -/*! - \qmlproperty QVariant Behavior::toValue - This property holds a selector specifying a ending value for the behavior - - If you only want the behavior to apply when the change ends at a - specific value you can specify toValue. This selector is used in conjunction - with the fromValue selector. -*/ - -QVariant QmlBehaviour::toValue() const -{ - Q_D(const QmlBehaviour); - return d->toValue; -} - -void QmlBehaviour::setToValue(const QVariant &v) -{ - Q_D(QmlBehaviour); - d->toValue = v; -} - -QmlList<QmlAbstractAnimation *>* QmlBehaviour::operations() -{ - Q_D(QmlBehaviour); - return &d->operations; -} - -QmlBehaviour::~QmlBehaviour() -{ - //### do we need any other cleanup here? -} - -bool QmlBehaviour::_ignore = false; -void QmlBehaviour::propertyValueChanged() -{ - Q_D(QmlBehaviour); - if (_ignore) - return; - - QVariant newValue = d->property.read(); - - if ((!fromValue().isValid() || fromValue() == d->currentValue) && - (!toValue().isValid() || toValue() == newValue)) { - - //### does this clean up everything needed? - d->group->stop(); - - d->valueData->e = newValue; - d->valueData->s = d->currentValue; - emit d->valueData->valuesChanged(); - - QmlStateOperation::ActionList actions; - Action action; - action.property = d->property; - action.fromValue = d->currentValue; - action.toValue = newValue; - actions << action; - - _ignore = true; - d->property.write(d->currentValue); - - QList<QmlMetaProperty> after; - for (int ii = 0; ii < d->operations.count(); ++ii) { - d->operations.at(ii)->transition(actions, after, QmlAbstractAnimation::Forward); - } - d->group->start(); - if (!after.contains(d->property)) - d->property.write(newValue); - _ignore = false; - } - - d->currentValue = newValue; -} - -void QmlBehaviour::setTarget(const QmlMetaProperty &property) -{ - Q_D(QmlBehaviour); - d->property = property; - d->currentValue = property.read(); - d->property.connectNotifier(this, SLOT(propertyValueChanged())); - for (int ii = 0; ii < d->operations.count(); ++ii) { - d->operations.at(ii)->setTarget(property); - } -} - -void QmlBehaviour::classBegin() -{ - Q_D(QmlBehaviour); - if (!d->context) { - d->context = new QmlContext(qmlContext(this), this); - d->context->addDefaultObject(d->valueData); - } - d->context->activate(); -} - -void QmlBehaviour::classComplete() -{ - Q_D(QmlBehaviour); - d->context->deactivate(); -} - -#include "qmlbehaviour.moc" - -QT_END_NAMESPACE diff --git a/src/declarative/util/qmlbehaviour.h b/src/declarative/util/qmlbehaviour.h deleted file mode 100644 index 7cc83b2..0000000 --- a/src/declarative/util/qmlbehaviour.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLBEHAVIOUR_H -#define QMLBEHAVIOUR_H - -#include <QtDeclarative/qmlpropertyvaluesource.h> -#include <QtDeclarative/qml.h> -#include <QtDeclarative/qmlstate.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) -class QmlAbstractAnimation; -class QmlBehaviourPrivate; -class Q_DECLARATIVE_EXPORT QmlBehaviour : public QmlPropertyValueSource, - public QmlParserStatus -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QmlBehaviour) - Q_INTERFACES(QmlParserStatus) - - Q_PROPERTY(QVariant from READ fromValue WRITE setFromValue) - Q_PROPERTY(QVariant to READ toValue WRITE setToValue) - Q_CLASSINFO("DefaultProperty", "operations") - Q_PROPERTY(QmlList<QmlAbstractAnimation *>* operations READ operations) - -public: - QmlBehaviour(QObject *parent=0); - ~QmlBehaviour(); - - QVariant fromValue() const; - void setFromValue(const QVariant &); - QVariant toValue() const; - void setToValue(const QVariant &); - virtual void setTarget(const QmlMetaProperty &); - - QmlList<QmlAbstractAnimation *>* operations(); - - static bool _ignore; - -protected: - virtual void classBegin(); - virtual void classComplete(); - -private Q_SLOTS: - void propertyValueChanged(); -}; -QML_DECLARE_TYPE(QmlBehaviour) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMLBEHAVIOUR_H diff --git a/src/declarative/util/qmldatetimeformatter.cpp b/src/declarative/util/qmldatetimeformatter.cpp deleted file mode 100644 index ad0e473..0000000 --- a/src/declarative/util/qmldatetimeformatter.cpp +++ /dev/null @@ -1,368 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmldatetimeformatter.h" -#include "private/qobject_p.h" -#include <QtCore/qlocale.h> - -QT_BEGIN_NAMESPACE -//TODO: may need optimisation as the QDateTime member may not be needed? -// be able to set a locale? - -class QmlDateTimeFormatterPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QmlDateTimeFormatter) -public: - QmlDateTimeFormatterPrivate() : locale(QLocale::system()), longStyle(false), classComplete(true) {} - - void updateText(); - - QDateTime dateTime; - QDate date; - QTime time; - QLocale locale; - QString dateTimeText; - QString dateText; - QString timeText; - QString dateTimeFormat; //set for convienience? - QString dateFormat; - QString timeFormat; - bool longStyle; - bool classComplete; -}; - -/*! - \qmlclass DateTimeFormatter QmlDateTimeFormatter - \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 - date and time using the current system locale's format. -*/ - -/*! - \internal - \class QmlDateTimeFormatter - \ingroup group_utility - \brief The QmlDateTimeFormatter class allows you to format a date string. -*/ - -QmlDateTimeFormatter::QmlDateTimeFormatter(QObject *parent) -: QObject(*(new QmlDateTimeFormatterPrivate), parent) -{ -} - -QmlDateTimeFormatter::~QmlDateTimeFormatter() -{ -} - -/*! - \qmlproperty string DateTimeFormatter::dateText - \qmlproperty string DateTimeFormatter::timeText - \qmlproperty string DateTimeFormatter::dateTimeText - - Formatted text representations of the \c date, \c time, - and \c {date and time}, respectively. - - If there is no explictly specified format the DateTimeFormatter - 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 -{ - Q_D(const QmlDateTimeFormatter); - return d->dateTimeText; -} - -QString QmlDateTimeFormatter::dateText() const -{ - Q_D(const QmlDateTimeFormatter); - return d->dateText; -} - -QString QmlDateTimeFormatter::timeText() const -{ - Q_D(const QmlDateTimeFormatter); - return d->timeText; -} - -/*! - \qmlproperty date DateTimeFormatter::date - \qmlproperty time DateTimeFormatter::time - \qmlproperty datetime DateTimeFormatter::dateTime - - 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 - set the actual date and time used is not guaranteed. - - \note If no date is set, dateTimeText will be just the date; - If no time is set, the dateTimeText will be just the time. - -*/ -QDate QmlDateTimeFormatter::date() const -{ - Q_D(const QmlDateTimeFormatter); - return d->date; -} - -QTime QmlDateTimeFormatter::time() const -{ - Q_D(const QmlDateTimeFormatter); - return d->time; -} - -QDateTime QmlDateTimeFormatter::dateTime() const -{ - Q_D(const QmlDateTimeFormatter); - return d->dateTime; -} - -/*! - \qmlproperty string DateTimeFormatter::dateFormat - \qmlproperty string DateTimeFormatter::timeFormat - \qmlproperty string DateTimeFormatter::dateTimeFormat - - Specifies a custom format which the DateTime Formatter can use. - - If there is no explictly specified format the DateTimeFormatter - will use the system locale's default 'short' setting. - - The text's format may be modified by setting: - \list - \i \c dateFormat - \i \c timeFormat - \i \c dateTimeFormat - \endlist - - If only the format for date is defined, the time and dateTime formats will be defined - as the system locale default and likewise for the others. - - Syntax for the format is based on the QDateTime::toString() formatting options. - - \code - // Format the date such that the dateText is: '1997-12-12' - DateTimeFormatter { id: formatter; dateTime: Today.dateTime; formatDate: "yyyy-MM-d" } - \endcode - - Assigning an empty string to a particular format will reset it. -*/ -QString QmlDateTimeFormatter::dateTimeFormat() const -{ - Q_D(const QmlDateTimeFormatter); - return d->dateTimeFormat; -} - -QString QmlDateTimeFormatter::dateFormat() const -{ - Q_D(const QmlDateTimeFormatter); - return d->dateFormat; -} - -QString QmlDateTimeFormatter::timeFormat() const -{ - Q_D(const QmlDateTimeFormatter); - return d->timeFormat; -} - -/*! - \qmlproperty bool DateTimeFormatter::longStyle - - This property causes the formatter to use the system locale's long format rather than short format - by default. - - This setting is off by default. -*/ -bool QmlDateTimeFormatter::longStyle() const -{ - Q_D(const QmlDateTimeFormatter); - return d->longStyle; -} - -void QmlDateTimeFormatter::setDateTime(const QDateTime &dateTime) -{ - Q_D(QmlDateTimeFormatter); - if (d->dateTime == dateTime) - return; - d->dateTime = dateTime; - d->date = d->dateTime.date(); - d->time = d->dateTime.time(); - d->updateText(); -} - -void QmlDateTimeFormatter::setTime(const QTime &time) -{ - Q_D(QmlDateTimeFormatter); - if (d->dateTime.time() == time) - return; - d->time = time; - d->dateTime.setTime(time); - d->updateText(); -} - -void QmlDateTimeFormatter::setDate(const QDate &date) -{ - Q_D(QmlDateTimeFormatter); - if (d->dateTime.date() == date) - return; - d->date = date; - bool clearTime = d->dateTime.time().isValid() ? false : true; //because setting date generates default time - d->dateTime.setDate(date); - if (clearTime) - d->dateTime.setTime(QTime()); - d->updateText(); -} - -//DateTime formatting may be a combination of date and time? -void QmlDateTimeFormatter::setDateTimeFormat(const QString &format) -{ - Q_D(QmlDateTimeFormatter); - //no format checking - d->dateTimeFormat = format; - d->updateText(); -} - -void QmlDateTimeFormatter::setDateFormat(const QString &format) -{ - Q_D(QmlDateTimeFormatter); - //no format checking - d->dateFormat = format; - d->updateText(); -} - -void QmlDateTimeFormatter::setTimeFormat(const QString &format) -{ - Q_D(QmlDateTimeFormatter); - //no format checking - d->timeFormat = format; - d->updateText(); -} - -void QmlDateTimeFormatter::setLongStyle(bool longStyle) -{ - Q_D(QmlDateTimeFormatter); - d->longStyle = longStyle; - d->updateText(); -} - -void QmlDateTimeFormatterPrivate::updateText() -{ - Q_Q(QmlDateTimeFormatter); - if (!classComplete) - return; - - QString str; - QString str1; - QString str2; - - Qt::DateFormat defaultFormat = longStyle ? Qt::SystemLocaleLongDate : Qt::SystemLocaleShortDate; - - if (dateFormat.isEmpty()) - str1 = date.toString(defaultFormat); - else - str1 = date.toString(dateFormat); - - if (timeFormat.isEmpty()) - str2 = time.toString(defaultFormat); - else - str2 = time.toString(timeFormat); - - if (dateTimeFormat.isEmpty()) - str = dateTime.toString(defaultFormat); - //else if (!formatTime.isEmpty() && !formatDate.isEmpty()) - // str = str1 + QLatin1Char(' ') + str2; - else - str = dateTime.toString(dateTimeFormat); - - if (dateTimeText == str && dateText == str1 && timeText == str2) - return; - - dateTimeText = str; - dateText = str1; - timeText = str2; - - emit q->textChanged(); -} - -void QmlDateTimeFormatter::classBegin() -{ - Q_D(QmlDateTimeFormatter); - d->classComplete = false; -} - -void QmlDateTimeFormatter::classComplete() -{ - Q_D(QmlDateTimeFormatter); - d->classComplete = true; - d->updateText(); -} - -QML_DEFINE_TYPE(QmlDateTimeFormatter, DateTimeFormatter) -QT_END_NAMESPACE diff --git a/src/declarative/util/qmldatetimeformatter.h b/src/declarative/util/qmldatetimeformatter.h deleted file mode 100644 index 84b27e3..0000000 --- a/src/declarative/util/qmldatetimeformatter.h +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLDATETIMEFORMATTER_H -#define QMLDATETIMEFORMATTER_H - -#include <QtCore/qdatetime.h> -#include <QtDeclarative/qml.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) -class QmlDateTimeFormatterPrivate; -class Q_DECLARATIVE_EXPORT QmlDateTimeFormatter : public QObject, public QmlParserStatus -{ - Q_OBJECT - Q_INTERFACES(QmlParserStatus) - - Q_PROPERTY(QString dateText READ dateText NOTIFY textChanged) - Q_PROPERTY(QString timeText READ timeText NOTIFY textChanged) - Q_PROPERTY(QString dateTimeText READ dateTimeText NOTIFY textChanged) - Q_PROPERTY(QDate date READ date WRITE setDate) - Q_PROPERTY(QTime time READ time WRITE setTime) - Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime) - Q_PROPERTY(QString dateFormat READ dateFormat WRITE setDateFormat) - Q_PROPERTY(QString timeFormat READ timeFormat WRITE setTimeFormat) - Q_PROPERTY(QString dateTimeFormat READ dateTimeFormat WRITE setDateTimeFormat) - Q_PROPERTY(bool longStyle READ longStyle WRITE setLongStyle) -public: - QmlDateTimeFormatter(QObject *parent=0); - ~QmlDateTimeFormatter(); - - QString dateTimeText() const; - QString dateText() const; - QString timeText() const; - - QDate date() const; - void setDate(const QDate &); - - QTime time() const; - void setTime(const QTime &); - - QDateTime dateTime() const; - void setDateTime(const QDateTime &); - - QString dateTimeFormat() const; - void setDateTimeFormat(const QString &); - - QString dateFormat() const; - void setDateFormat(const QString &); - - QString timeFormat() const; - void setTimeFormat(const QString &); - - bool longStyle() const; - void setLongStyle(bool); - - virtual void classBegin(); - virtual void classComplete(); - -Q_SIGNALS: - void textChanged(); - -private: - Q_DISABLE_COPY(QmlDateTimeFormatter) - Q_DECLARE_PRIVATE(QmlDateTimeFormatter) -}; - -QML_DECLARE_TYPE(QmlDateTimeFormatter) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri index 030a44e..f35812c 100644 --- a/src/declarative/util/util.pri +++ b/src/declarative/util/util.pri @@ -6,7 +6,6 @@ SOURCES += \ util/qmlpackage.cpp \ util/qmlscript.cpp \ util/qmlanimation.cpp \ - util/qmlbehaviour.cpp \ util/qmlfont.cpp \ util/qmlfollow.cpp \ util/qmlstate.cpp\ @@ -14,8 +13,6 @@ SOURCES += \ util/qmlsetproperties.cpp \ util/qmlstategroup.cpp \ util/qmltransition.cpp \ - util/qbindablemap.cpp \ - util/qmldatetimeformatter.cpp \ util/qmllistmodel.cpp\ util/qmllistaccessor.cpp \ util/qmlopenmetaobject.cpp \ @@ -31,7 +28,6 @@ HEADERS += \ util/qmlscript.h \ util/qmlanimation.h \ util/qmlanimation_p.h \ - util/qmlbehaviour.h \ util/qmlfont.h \ util/qmlfollow.h \ util/qmlstate.h\ @@ -40,8 +36,6 @@ HEADERS += \ util/qmlstate_p.h\ util/qmlstategroup.h \ util/qmltransition.h \ - util/qbindablemap.h \ - util/qmldatetimeformatter.h \ util/qmllistmodel.h\ util/qmllistaccessor.h \ util/qmlopenmetaobject.h \ |