diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-08-18 08:01:12 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-08-18 08:01:12 (GMT) |
commit | a71898895ea04fe58f77a9fa8601aa1072a76fc8 (patch) | |
tree | ddf3e6ca9ff860506b159974268ea0b8dce68ab3 /src | |
parent | 223746067a9a1b3f5c6195868b5e510311608ca1 (diff) | |
parent | 1ab70725f76433a0f601fdfd70abc55bd6228ac3 (diff) | |
download | Qt-a71898895ea04fe58f77a9fa8601aa1072a76fc8.zip Qt-a71898895ea04fe58f77a9fa8601aa1072a76fc8.tar.gz Qt-a71898895ea04fe58f77a9fa8601aa1072a76fc8.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/fx/qfxlineedit.h | 14 | ||||
-rw-r--r-- | src/declarative/fx/qfxtext.cpp | 15 | ||||
-rw-r--r-- | src/declarative/fx/qfxtext.h | 17 | ||||
-rw-r--r-- | src/declarative/fx/qfxtextedit.h | 21 | ||||
-rw-r--r-- | src/declarative/qml/qmlcontext.cpp | 3 | ||||
-rw-r--r-- | src/declarative/qml/qmlexpression.cpp | 13 | ||||
-rw-r--r-- | src/declarative/qml/qmlmetatype.cpp | 23 | ||||
-rw-r--r-- | src/declarative/qml/qmlmetatype.h | 5 | ||||
-rw-r--r-- | src/declarative/util/qmlanimation.cpp | 45 | ||||
-rw-r--r-- | src/declarative/util/qmlanimation.h | 13 | ||||
-rw-r--r-- | src/declarative/util/qmlanimation_p.h | 5 | ||||
-rw-r--r-- | src/declarative/util/qmlscript.cpp | 21 |
12 files changed, 85 insertions, 110 deletions
diff --git a/src/declarative/fx/qfxlineedit.h b/src/declarative/fx/qfxlineedit.h index 0218fb0..1f4a5c6 100644 --- a/src/declarative/fx/qfxlineedit.h +++ b/src/declarative/fx/qfxlineedit.h @@ -55,6 +55,7 @@ QT_MODULE(Declarative) class QFxLineEditPrivate; class QValidator; +//### class QFxTextInput?? class Q_DECLARATIVE_EXPORT QFxLineEdit : public QFxPaintedItem { Q_OBJECT @@ -62,10 +63,10 @@ class Q_DECLARATIVE_EXPORT QFxLineEdit : public QFxPaintedItem Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(QColor highlightColor READ highlightColor WRITE setHighlightColor) - Q_PROPERTY(QColor highlightedTextColor READ highlightedTextColor WRITE setHighlightedTextColor) + Q_PROPERTY(QColor highlightColor READ highlightColor WRITE setHighlightColor) //### selectionColor + Q_PROPERTY(QColor highlightedTextColor READ highlightedTextColor WRITE setHighlightedTextColor) //### selectedTextColor Q_PROPERTY(QFont font READ font WRITE setFont) - Q_PROPERTY(HAlignment hAlign READ hAlign WRITE setHAlign) + Q_PROPERTY(HAlignment hAlign READ hAlign WRITE setHAlign) //### horizontalAlignment Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly) Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible) @@ -75,11 +76,12 @@ class Q_DECLARATIVE_EXPORT QFxLineEdit : public QFxPaintedItem Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged) Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged) - Q_PROPERTY(int maxLength READ maxLength WRITE setMaxLength) - Q_PROPERTY(QObject* validator READ validator WRITE setValidator) + Q_PROPERTY(int maxLength READ maxLength WRITE setMaxLength) //### maximumLength + Q_PROPERTY(QObject* validator READ validator WRITE setValidator) //### QValidator * Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask) Q_PROPERTY(bool acceptableInput READ hasAcceptableInput NOTIFY acceptableInputChanged) - Q_PROPERTY(uint echoMode READ echoMode WRITE setEchoMode) + Q_PROPERTY(uint echoMode READ echoMode WRITE setEchoMode) //### enum + //### Q_PROPERTY(bool focusOnPress READ focusOnPress WRITE setFocusOnPress) public: QFxLineEdit(QFxItem* parent=0); diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp index 11fef69..cd34aa0 100644 --- a/src/declarative/fx/qfxtext.cpp +++ b/src/declarative/fx/qfxtext.cpp @@ -107,7 +107,6 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Text,QFxText) QFxText::QFxText(QFxItem *parent) : QFxItem(*(new QFxTextPrivate), parent) { - Q_D(QFxText); setAcceptedMouseButtons(Qt::LeftButton); setFlag(QGraphicsItem::ItemHasNoContents, false); } @@ -115,7 +114,6 @@ QFxText::QFxText(QFxItem *parent) QFxText::QFxText(QFxTextPrivate &dd, QFxItem *parent) : QFxItem(dd, parent) { - Q_D(QFxText); setAcceptedMouseButtons(Qt::LeftButton); setFlag(QGraphicsItem::ItemHasNoContents, false); } @@ -480,13 +478,6 @@ void QFxText::setElideMode(Qt::TextElideMode mode) d->updateSize(); } - -QString QFxText::activeLink() const -{ - Q_D(const QFxText); - return d->activeLink; -} - void QFxText::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { @@ -854,6 +845,12 @@ void QFxText::mousePressEvent(QGraphicsSceneMouseEvent *event) } /*! + \qmlsignal Text::linkActivated(link) + + This handler is called when the user clicks on a link embedded in the text. +*/ + +/*! \overload Handles the given mouse \a event. */ diff --git a/src/declarative/fx/qfxtext.h b/src/declarative/fx/qfxtext.h index edf6031..63fb3e9 100644 --- a/src/declarative/fx/qfxtext.h +++ b/src/declarative/fx/qfxtext.h @@ -63,12 +63,11 @@ class Q_DECLARATIVE_EXPORT QFxText : public QFxItem Q_PROPERTY(QColor color READ color WRITE setColor) Q_PROPERTY(TextStyle style READ style WRITE setStyle) Q_PROPERTY(QColor styleColor READ styleColor WRITE setStyleColor) - Q_PROPERTY(HAlignment hAlign READ hAlign WRITE setHAlign) - Q_PROPERTY(VAlignment vAlign READ vAlign WRITE setVAlign) - Q_PROPERTY(bool wrap READ wrap WRITE setWrap) + Q_PROPERTY(HAlignment hAlign READ hAlign WRITE setHAlign) // ### horizontalAlignment? + Q_PROPERTY(VAlignment vAlign READ vAlign WRITE setVAlign) // ### verticalAlignment? + Q_PROPERTY(bool wrap READ wrap WRITE setWrap) //### there are several wrap modes in Qt Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat) - Q_PROPERTY(Qt::TextElideMode elide READ elideMode WRITE setElideMode) - Q_PROPERTY(QString activeLink READ activeLink) + Q_PROPERTY(Qt::TextElideMode elide READ elideMode WRITE setElideMode) //### elideMode? public: QFxText(QFxItem *parent=0); @@ -84,9 +83,9 @@ public: Outline, Raised, Sunken }; - enum TextFormat { AutoText, - PlainText, - RichText }; + enum TextFormat { PlainText = Qt::PlainText, + RichText = Qt::RichText, + AutoText = Qt::AutoText }; QString text() const; void setText(const QString &); @@ -118,8 +117,6 @@ public: Qt::TextElideMode elideMode() const; void setElideMode(Qt::TextElideMode); - QString activeLink() const; - void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); virtual void componentComplete(); diff --git a/src/declarative/fx/qfxtextedit.h b/src/declarative/fx/qfxtextedit.h index f2f163b..8c402b0 100644 --- a/src/declarative/fx/qfxtextedit.h +++ b/src/declarative/fx/qfxtextedit.h @@ -56,9 +56,8 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -/*! -WARNING: SHORT TERM CLASS. INTENDED TO MERGE INTO QFxTextItem -*/ + + class QFxTextEditPrivate; class Q_DECLARATIVE_EXPORT QFxTextEdit : public QFxPaintedItem { @@ -69,12 +68,12 @@ class Q_DECLARATIVE_EXPORT QFxTextEdit : public QFxPaintedItem Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(QColor highlightColor READ highlightColor WRITE setHighlightColor) - Q_PROPERTY(QColor highlightedTextColor READ highlightedTextColor WRITE setHighlightedTextColor) + Q_PROPERTY(QColor highlightColor READ highlightColor WRITE setHighlightColor) //### selectionColor + Q_PROPERTY(QColor highlightedTextColor READ highlightedTextColor WRITE setHighlightedTextColor) //### selectedTextColor Q_PROPERTY(QFont font READ font WRITE setFont) - Q_PROPERTY(HAlignment hAlign READ hAlign WRITE setHAlign) - Q_PROPERTY(VAlignment vAlign READ vAlign WRITE setVAlign) - Q_PROPERTY(bool wrap READ wrap WRITE setWrap) + Q_PROPERTY(HAlignment hAlign READ hAlign WRITE setHAlign) //### horizontalAlignment + Q_PROPERTY(VAlignment vAlign READ vAlign WRITE setVAlign) //### verticalAlignment + Q_PROPERTY(bool wrap READ wrap WRITE setWrap) //### other wrap modes Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat) Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly) Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible) @@ -103,9 +102,9 @@ public: }; enum TextFormat { - AutoText, - PlainText, - RichText, + PlainText = Qt::PlainText, + RichText = Qt::RichText, + AutoText = Qt::AutoText }; QString text() const; diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp index b73471a..365c0e8 100644 --- a/src/declarative/qml/qmlcontext.cpp +++ b/src/declarative/qml/qmlcontext.cpp @@ -105,6 +105,9 @@ void QmlContextPrivate::init() QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); QScriptValue scopeObj = scriptEngine->newObject(QmlEnginePrivate::get(engine)->contextClass, scriptEngine->newVariant(QVariant::fromValue((QObject*)q))); + //### no longer need to push global object once we switch to JSC (test with objects added to globalObject) + //if (parent) + // scopeChain = parent->d_func()->scopeChain; if (!parent) scopeChain.append(scriptEngine->globalObject()); else diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp index f8e78d7..00454a1 100644 --- a/src/declarative/qml/qmlexpression.cpp +++ b/src/declarative/qml/qmlexpression.cpp @@ -225,13 +225,9 @@ QVariant QmlExpressionPrivate::evalQtScript() ctxtPriv->defaultObjects.insert(ctxtPriv->highPriorityCount, me); QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); - QScriptValueList oldScopeChain = - scriptEngine->currentContext()->scopeChain(); - - for (int i = 0; i < oldScopeChain.size(); ++i) - scriptEngine->currentContext()->popScope(); + QScriptContext *scriptContext = scriptEngine->pushContext(); for (int i = ctxtPriv->scopeChain.size() - 1; i > -1; --i) - scriptEngine->currentContext()->pushScope(ctxtPriv->scopeChain.at(i)); + scriptContext->pushScope(ctxtPriv->scopeChain.at(i)); if (!expressionFunctionValid) { @@ -305,10 +301,7 @@ QVariant QmlExpressionPrivate::evalQtScript() if (rv.isNull()) rv = svalue.toVariant(); - for (int i = 0; i < ctxtPriv->scopeChain.size(); ++i) - scriptEngine->currentContext()->popScope(); - for (int i = oldScopeChain.size() - 1; i > -1; --i) - scriptEngine->currentContext()->pushScope(oldScopeChain.at(i)); + scriptEngine->popContext(); return rv; } diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp index 5ebe970..091bd1b 100644 --- a/src/declarative/qml/qmlmetatype.cpp +++ b/src/declarative/qml/qmlmetatype.cpp @@ -190,6 +190,21 @@ QmlType::~QmlType() delete d; } +int QmlType::majorVersion() const +{ + return d->m_version_maj; +} + +int QmlType::minMinorVersion() const +{ + return d->m_version_min_from; +} + +int QmlType::maxMinorVersion() const +{ + return d->m_version_min_to; +} + bool QmlType::availableInVersion(int vmajor, int vminor) const { return vmajor == d->m_version_maj && vminor >= d->m_version_min_from && vminor <= d->m_version_min_to; @@ -879,6 +894,14 @@ QList<QByteArray> QmlMetaType::qmlTypeNames() return data->nameToType.keys(); } +QList<QmlType*> QmlMetaType::qmlTypes() +{ + QReadLocker lock(metaTypeDataLock()); + QmlMetaTypeData *data = metaTypeData(); + + return data->nameToType.values(); +} + /*! Copies \a copy into \a data, assuming they both are of type \a type. If \a copy is zero, a default type is copied. Returns true if the copy was diff --git a/src/declarative/qml/qmlmetatype.h b/src/declarative/qml/qmlmetatype.h index 94029ce..c388b1a 100644 --- a/src/declarative/qml/qmlmetatype.h +++ b/src/declarative/qml/qmlmetatype.h @@ -65,6 +65,7 @@ public: static bool copy(int type, void *data, const void *copy = 0); static QList<QByteArray> qmlTypeNames(); + static QList<QmlType*> qmlTypes(); static QmlType *qmlType(const QByteArray &, int, int); static QmlType *qmlType(const QMetaObject *); @@ -111,6 +112,10 @@ class Q_DECLARATIVE_EXPORT QmlType public: QByteArray typeName() const; QByteArray qmlTypeName() const; + + int majorVersion() const; + int minMinorVersion() const; + int maxMinorVersion() const; bool availableInVersion(int vmajor, int vminor) const; QByteArray hash() const; diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 224f668..ee16fae 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -823,35 +823,10 @@ void QmlRunScriptAction::setScript(const QString &script) emit scriptChanged(script); } -/*! - \qmlproperty QString RunScript::script - This property holds the file containing the script to run. -*/ -QString QmlRunScriptAction::file() const -{ - Q_D(const QmlRunScriptAction); - return d->file; -} - -void QmlRunScriptAction::setFile(const QString &file) -{ - Q_D(QmlRunScriptAction); - if (file == d->file) - return; - d->file = file; - emit fileChanged(file); -} - void QmlRunScriptActionPrivate::execute() { Q_Q(QmlRunScriptAction); QString scriptStr = script; - if (!file.isEmpty()){ - QFile scriptFile(file); - if (scriptFile.open(QIODevice::ReadOnly | QIODevice::Text)){ - scriptStr = QString::fromUtf8(scriptFile.readAll()); - } - } if (!scriptStr.isEmpty()) { QmlExpression expr(qmlContext(q), scriptStr, q); @@ -932,20 +907,20 @@ void QmlSetPropertyAction::setProperties(const QString &p) } /*! - \qmlproperty list<Item> SetPropertyAction::filter + \qmlproperty list<Item> SetPropertyAction::targets This property holds the items selected to be affected by this animation (all if not set). \sa exclude */ -QList<QObject *> *QmlSetPropertyAction::filter() +QList<QObject *> *QmlSetPropertyAction::targets() { Q_D(QmlSetPropertyAction); - return &d->filter; + return &d->targets; } /*! \qmlproperty list<Item> SetPropertyAction::exclude This property holds the items not to be affected by this animation. - \sa filter + \sa targets */ QList<QObject *> *QmlSetPropertyAction::exclude() { @@ -1040,7 +1015,7 @@ void QmlSetPropertyAction::transition(QmlStateActions &actions, QString sPropertyName = action.specifiedProperty; bool same = (obj == sObj); - if ((d->filter.isEmpty() || d->filter.contains(obj) || (!same && d->filter.contains(sObj))) && + if ((d->targets.isEmpty() || d->targets.contains(obj) || (!same && d->targets.contains(sObj))) && (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) && (props.contains(propertyName) || (!same && props.contains(sPropertyName))) && (!target() || target() == obj || (!same && target() == sObj))) { @@ -1692,20 +1667,20 @@ void QmlPropertyAnimation::setProperties(const QString &prop) } /*! - \qmlproperty list<Item> PropertyAnimation::filter + \qmlproperty list<Item> PropertyAnimation::targets This property holds the items selected to be affected by this animation (all if not set). \sa exclude */ -QList<QObject *> *QmlPropertyAnimation::filter() +QList<QObject *> *QmlPropertyAnimation::targets() { Q_D(QmlPropertyAnimation); - return &d->filter; + return &d->targets; } /*! \qmlproperty list<Item> PropertyAnimation::exclude This property holds the items not to be affected by this animation. - \sa filter + \sa targets */ QList<QObject *> *QmlPropertyAnimation::exclude() { @@ -1836,7 +1811,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, QString sPropertyName = action.specifiedProperty; bool same = (obj == sObj); - if ((d->filter.isEmpty() || d->filter.contains(obj) || (!same && d->filter.contains(sObj))) && + if ((d->targets.isEmpty() || d->targets.contains(obj) || (!same && d->targets.contains(sObj))) && (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) && (props.contains(propertyName) || (!same && props.contains(sPropertyName)) || (useType && action.property.propertyType() == d->interpolatorType)) && diff --git a/src/declarative/util/qmlanimation.h b/src/declarative/util/qmlanimation.h index 91c1898..ef7842c 100644 --- a/src/declarative/util/qmlanimation.h +++ b/src/declarative/util/qmlanimation.h @@ -163,7 +163,6 @@ class QmlRunScriptAction : public QmlAbstractAnimation Q_DECLARE_PRIVATE(QmlRunScriptAction) Q_PROPERTY(QString script READ script WRITE setScript NOTIFY scriptChanged) - Q_PROPERTY(QString file READ file WRITE setFile NOTIFY fileChanged) public: QmlRunScriptAction(QObject *parent=0); @@ -172,11 +171,7 @@ public: QString script() const; void setScript(const QString &); - QString file() const; - void setFile(const QString &); - Q_SIGNALS: - void fileChanged(const QString &); void scriptChanged(const QString &); protected: @@ -190,7 +185,7 @@ class QmlSetPropertyAction : public QmlAbstractAnimation Q_DECLARE_PRIVATE(QmlSetPropertyAction) Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged) - Q_PROPERTY(QList<QObject *>* filter READ filter) + Q_PROPERTY(QList<QObject *>* targets READ targets) Q_PROPERTY(QList<QObject *>* exclude READ exclude) Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) @@ -201,7 +196,7 @@ public: QString properties() const; void setProperties(const QString &); - QList<QObject *> *filter(); + QList<QObject *> *targets(); QList<QObject *> *exclude(); QVariant value() const; @@ -250,7 +245,7 @@ class QmlPropertyAnimation : public QmlAbstractAnimation Q_PROPERTY(QVariant to READ to WRITE setTo NOTIFY toChanged) Q_PROPERTY(QString easing READ easing WRITE setEasing NOTIFY easingChanged) Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged) - Q_PROPERTY(QList<QObject *>* filter READ filter) + Q_PROPERTY(QList<QObject *>* targets READ targets) Q_PROPERTY(QList<QObject *>* exclude READ exclude) public: @@ -272,7 +267,7 @@ public: QString properties() const; void setProperties(const QString &); - QList<QObject *> *filter(); + QList<QObject *> *targets(); QList<QObject *> *exclude(); protected: diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h index 87d480f..3868255 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qmlanimation_p.h @@ -230,7 +230,6 @@ public: void init(); QString script; - QString file; void execute(); @@ -249,7 +248,7 @@ public: void init(); QString properties; - QList<QObject *> filter; + QList<QObject *> targets; QList<QObject *> exclude; QmlNullableValue<QVariant> value; @@ -330,7 +329,7 @@ public: QString easing; QString properties; - QList<QObject *> filter; + QList<QObject *> targets; QList<QObject *> exclude; bool fromSourced; diff --git a/src/declarative/util/qmlscript.cpp b/src/declarative/util/qmlscript.cpp index 5651981..6bc21a2 100644 --- a/src/declarative/util/qmlscript.cpp +++ b/src/declarative/util/qmlscript.cpp @@ -187,18 +187,11 @@ void QmlScriptPrivate::addScriptToEngine(const QString &script, const QString &s QmlContext *context = qmlContext(q); QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); - QScriptContext *currentContext = scriptEngine->currentContext(); - QScriptValueList oldScopeChain = currentContext->scopeChain(); - QScriptValue oldact = currentContext->activationObject(); - - for (int i = 0; i < oldScopeChain.size(); ++i) { - currentContext->popScope(); - } + QScriptContext *scriptContext = scriptEngine->pushContext(); for (int i = context->d_func()->scopeChain.size() - 1; i > -1; --i) { - currentContext->pushScope(context->d_func()->scopeChain.at(i)); + scriptContext->pushScope(context->d_func()->scopeChain.at(i)); } - - currentContext->setActivationObject(context->d_func()->scopeChain.at(0)); + scriptContext->setActivationObject(context->d_func()->scopeChain.at(0)); QScriptValue val = scriptEngine->evaluate(script, source); if (scriptEngine->hasUncaughtException()) { @@ -215,13 +208,7 @@ void QmlScriptPrivate::addScriptToEngine(const QString &script, const QString &s } } - currentContext->setActivationObject(oldact); - - for (int i = 0; i < context->d_func()->scopeChain.size(); ++i) - currentContext->popScope(); - - for (int i = oldScopeChain.size() - 1; i > -1; --i) - currentContext->pushScope(oldScopeChain.at(i)); + scriptEngine->popContext(); } QT_END_NAMESPACE |