From 1f277281ea853fb99a4187f30ec1ddaaf8b86ed2 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 29 Jul 2009 15:53:05 +1000 Subject: Fix layout sizing Conflicts: src/declarative/fx/qfxlayouts.cpp --- src/declarative/fx/qfxlayouts.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/declarative/fx/qfxlayouts.cpp b/src/declarative/fx/qfxlayouts.cpp index 0546845..da34b8c 100644 --- a/src/declarative/fx/qfxlayouts.cpp +++ b/src/declarative/fx/qfxlayouts.cpp @@ -354,11 +354,14 @@ void QFxBaseLayout::preLayout() d->_animated.clear(); doLayout(); //Set the layout's size to be the rect containing all children - //Also set the margin + //d->aut determines whether a dimension is sum or max + //Also sets the margin qreal width=0; qreal height=0; + qreal maxWidth=0; + qreal maxHeight=0; foreach(QFxItem *item, d->_items){ - if (item->opacity() == 0.0){ + if (item->opacity() != 0.0){ if (!d->_animated.contains(item)){ setMovingItem(item); QPointF p(item->x(), item->y()); @@ -369,6 +372,8 @@ void QFxBaseLayout::preLayout() item->setPos(p); setMovingItem(0); } + maxWidth = qMax(maxWidth, item->width()); + maxHeight = qMax(maxHeight, item->height()); width = qMax(width, item->x() + item->width()); height = qMax(height, item->y() + item->height()); } @@ -376,14 +381,19 @@ void QFxBaseLayout::preLayout() width += d->_margin; height+= d->_margin; - if (d->aut & Horizontal) - setWidth(int(width)); - else if (parentItem()) - setImplicitWidth(parentItem()->width()); - if (d->aut & Vertical) - setHeight(int(height)); - else if (parentItem()) - setImplicitHeight(parentItem()->height()); + if(d->aut & Both){ + setImplicitHeight(int(height)); + setImplicitWidth(int(width)); + }else if (d->aut & Horizontal){ + setImplicitWidth(int(width)); + setImplicitHeight(int(maxHeight)); + } else if (d->aut & Vertical){ + setImplicitHeight(int(height)); + setImplicitWidth(int(maxWidth)); + }else{ + setImplicitHeight(int(maxHeight)); + setImplicitWidth(int(maxWidth)); + } setLayoutItem(0); } @@ -656,7 +666,6 @@ void QFxVerticalLayout::doLayout() } finishApplyTransitions(); setMovingItem(this); - setHeight(voffset); setMovingItem(0); } @@ -823,7 +832,6 @@ void QFxHorizontalLayout::doLayout() hoffset += spacing(); } finishApplyTransitions(); - setWidth(hoffset); } QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,GridLayout,QFxGridLayout) -- cgit v0.12 From a915df4fa1217d2670348029d2d9fb709118ddc2 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 29 Jul 2009 16:00:33 +1000 Subject: Get rid of classComplete. componentComplete is always what is wanted. --- src/declarative/extra/qmldatetimeformatter.cpp | 12 ++++----- src/declarative/extra/qmldatetimeformatter.h | 2 +- src/declarative/extra/qmlfolderlistmodel.cpp | 2 +- src/declarative/extra/qmlfolderlistmodel.h | 2 +- src/declarative/extra/qmlnumberformatter.cpp | 12 ++++----- src/declarative/extra/qmlnumberformatter.h | 2 +- src/declarative/extra/qmlsqlconnection.cpp | 7 ----- src/declarative/extra/qmlsqlconnection.h | 2 -- src/declarative/extra/qmlsqlquery.cpp | 9 +------ src/declarative/extra/qmlsqlquery.h | 5 ++-- src/declarative/fx/qfxitem.cpp | 37 +++++--------------------- src/declarative/fx/qfxitem.h | 2 -- src/declarative/fx/qfxitem_p.h | 3 +-- src/declarative/qml/qmlcompiler.cpp | 9 ------- src/declarative/qml/qmlinstruction.cpp | 3 --- src/declarative/qml/qmlinstruction_p.h | 4 --- src/declarative/qml/qmlparserstatus.cpp | 8 ------ src/declarative/qml/qmlparserstatus.h | 1 - src/declarative/qml/qmlvme.cpp | 8 ------ src/declarative/util/qmlstategroup.cpp | 13 ++------- src/declarative/util/qmlstategroup.h | 1 - 21 files changed, 28 insertions(+), 116 deletions(-) diff --git a/src/declarative/extra/qmldatetimeformatter.cpp b/src/declarative/extra/qmldatetimeformatter.cpp index 91ebce6..3542657 100644 --- a/src/declarative/extra/qmldatetimeformatter.cpp +++ b/src/declarative/extra/qmldatetimeformatter.cpp @@ -52,7 +52,7 @@ class QmlDateTimeFormatterPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QmlDateTimeFormatter) public: - QmlDateTimeFormatterPrivate() : locale(QLocale::system()), longStyle(false), classComplete(true) {} + QmlDateTimeFormatterPrivate() : locale(QLocale::system()), longStyle(false), componentComplete(true) {} void updateText(); @@ -67,7 +67,7 @@ public: QString dateFormat; QString timeFormat; bool longStyle; - bool classComplete; + bool componentComplete; }; /*! @@ -316,7 +316,7 @@ void QmlDateTimeFormatter::setLongStyle(bool longStyle) void QmlDateTimeFormatterPrivate::updateText() { Q_Q(QmlDateTimeFormatter); - if (!classComplete) + if (!componentComplete) return; QString str; @@ -355,13 +355,13 @@ void QmlDateTimeFormatterPrivate::updateText() void QmlDateTimeFormatter::classBegin() { Q_D(QmlDateTimeFormatter); - d->classComplete = false; + d->componentComplete = false; } -void QmlDateTimeFormatter::classComplete() +void QmlDateTimeFormatter::componentComplete() { Q_D(QmlDateTimeFormatter); - d->classComplete = true; + d->componentComplete = true; d->updateText(); } diff --git a/src/declarative/extra/qmldatetimeformatter.h b/src/declarative/extra/qmldatetimeformatter.h index 71b366c..be0ae02 100644 --- a/src/declarative/extra/qmldatetimeformatter.h +++ b/src/declarative/extra/qmldatetimeformatter.h @@ -97,7 +97,7 @@ public: void setLongStyle(bool); virtual void classBegin(); - virtual void classComplete(); + virtual void componentComplete(); Q_SIGNALS: void textChanged(); diff --git a/src/declarative/extra/qmlfolderlistmodel.cpp b/src/declarative/extra/qmlfolderlistmodel.cpp index e632f72..bdea03f 100644 --- a/src/declarative/extra/qmlfolderlistmodel.cpp +++ b/src/declarative/extra/qmlfolderlistmodel.cpp @@ -222,7 +222,7 @@ void QmlFolderListModel::setNameFilters(const QStringList &filters) d->model.setNameFilters(d->nameFilters); } -void QmlFolderListModel::classComplete() +void QmlFolderListModel::componentComplete() { Q_D(QmlFolderListModel); if (!d->folderIndex.isValid()) diff --git a/src/declarative/extra/qmlfolderlistmodel.h b/src/declarative/extra/qmlfolderlistmodel.h index 8708d9a..24a3ac6 100644 --- a/src/declarative/extra/qmlfolderlistmodel.h +++ b/src/declarative/extra/qmlfolderlistmodel.h @@ -80,7 +80,7 @@ public: QStringList nameFilters() const; void setNameFilters(const QStringList &filters); - virtual void classComplete(); + virtual void componentComplete(); Q_INVOKABLE bool isFolder(int index) const; diff --git a/src/declarative/extra/qmlnumberformatter.cpp b/src/declarative/extra/qmlnumberformatter.cpp index 1818c36..e937905 100644 --- a/src/declarative/extra/qmlnumberformatter.cpp +++ b/src/declarative/extra/qmlnumberformatter.cpp @@ -53,7 +53,7 @@ class QmlNumberFormatterPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QmlNumberFormatter) public: - QmlNumberFormatterPrivate() : locale(QLocale::system()), number(0), classComplete(true) {} + QmlNumberFormatterPrivate() : locale(QLocale::system()), number(0), componentComplete(true) {} void updateText(); @@ -62,7 +62,7 @@ public: QNumberFormat numberFormat; QString text; qreal number; - bool classComplete; + bool componentComplete; }; /*! \qmlclass NumberFormatter @@ -186,7 +186,7 @@ void QmlNumberFormatter::setFormat(const QString &format) void QmlNumberFormatterPrivate::updateText() { Q_Q(QmlNumberFormatter); - if (!classComplete) + if (!componentComplete) return; QNumberFormat tempFormat; @@ -201,13 +201,13 @@ void QmlNumberFormatterPrivate::updateText() void QmlNumberFormatter::classBegin() { Q_D(QmlNumberFormatter); - d->classComplete = false; + d->componentComplete = false; } -void QmlNumberFormatter::classComplete() +void QmlNumberFormatter::componentComplete() { Q_D(QmlNumberFormatter); - d->classComplete = true; + d->componentComplete = true; d->updateText(); } QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,NumberFormatter,QmlNumberFormatter); diff --git a/src/declarative/extra/qmlnumberformatter.h b/src/declarative/extra/qmlnumberformatter.h index 6924fa5..d9abee7 100644 --- a/src/declarative/extra/qmlnumberformatter.h +++ b/src/declarative/extra/qmlnumberformatter.h @@ -73,7 +73,7 @@ public: void setFormat(const QString &); virtual void classBegin(); - virtual void classComplete(); + virtual void componentComplete(); Q_SIGNALS: void textChanged(); diff --git a/src/declarative/extra/qmlsqlconnection.cpp b/src/declarative/extra/qmlsqlconnection.cpp index 3384ccd..bed92ef 100644 --- a/src/declarative/extra/qmlsqlconnection.cpp +++ b/src/declarative/extra/qmlsqlconnection.cpp @@ -381,13 +381,6 @@ void QmlSqlConnection::setDriver(const QString &type) } /*! - \reimp -*/ -void QmlSqlConnection::classComplete() -{ -} - -/*! Returns the database object associated with this connection. If the database is not yet open, it will open the database passed on the settings specified for the SQL connection. diff --git a/src/declarative/extra/qmlsqlconnection.h b/src/declarative/extra/qmlsqlconnection.h index 88a727a..740bbc2 100644 --- a/src/declarative/extra/qmlsqlconnection.h +++ b/src/declarative/extra/qmlsqlconnection.h @@ -100,8 +100,6 @@ public: QString lastError() const; - virtual void classComplete(); - QSqlDatabase database() const; private: Q_DISABLE_COPY(QmlSqlConnection) diff --git a/src/declarative/extra/qmlsqlquery.cpp b/src/declarative/extra/qmlsqlquery.cpp index 4894de7..fe6e220 100644 --- a/src/declarative/extra/qmlsqlquery.cpp +++ b/src/declarative/extra/qmlsqlquery.cpp @@ -185,13 +185,6 @@ void QmlSqlBind::setValue(const QVariant &value) } } -/*! - \reimp -*/ -void QmlSqlBind::classComplete() -{ -} - class QmlSqlQueryPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QmlSqlQuery) @@ -510,7 +503,7 @@ QString QmlSqlQuery::lastError() const /*! \reimp */ -void QmlSqlQuery::classComplete() +void QmlSqlQuery::componentComplete() { Q_D(QmlSqlQuery); if (!d->query) diff --git a/src/declarative/extra/qmlsqlquery.h b/src/declarative/extra/qmlsqlquery.h index 8be758f..55e16ac 100644 --- a/src/declarative/extra/qmlsqlquery.h +++ b/src/declarative/extra/qmlsqlquery.h @@ -72,8 +72,6 @@ public: void setName(const QString &name); void setValue(const QVariant &); - virtual void classComplete(); - Q_SIGNALS: void valueChanged(); @@ -111,7 +109,8 @@ public: QString lastError() const; - virtual void classComplete(); + //### missing classBegin + virtual void componentComplete(); QmlList *bindings(); const QmlList *bindings() const; diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index a65b51a..1bf3140 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -499,18 +499,6 @@ QFxItem *QFxItem::parentItem() const */ /*! - Returns true if all of the attributes set via QML have been set; - otherwise returns false. - - \sa classComplete() -*/ -bool QFxItem::isClassComplete() const -{ - Q_D(const QFxItem); - return d->_classComplete; -} - -/*! Returns true if construction of the QML component is complete; otherwise returns false. @@ -1729,34 +1717,17 @@ void QFxItem::newChild(const QString &type) classBegin() is called when the item is constructed, but its properties have not yet been set. - \sa classComplete(), componentComplete(), isClassComplete(), isComponentComplete() + \sa componentComplete(), isComponentComplete() */ void QFxItem::classBegin() { Q_D(QFxItem); - d->_classComplete = false; d->_componentComplete = false; if (d->_stateGroup) d->_stateGroup->classBegin(); } /*! - classComplete() is called when all properties specified in QML - have been assigned. It is sometimes desireable to delay some - processing until all property assignments are complete. -*/ -void QFxItem::classComplete() -{ -#ifdef Q_ENABLE_PERFORMANCE_LOG - QFxPerfTimer cc; -#endif - Q_D(QFxItem); - d->_classComplete = true; - if (d->_stateGroup) - d->_stateGroup->classComplete(); -} - -/*! componentComplete() is called when all items in the component have been constructed. It is often desireable to delay some processing until the component is complete an all bindings in the @@ -1764,6 +1735,10 @@ void QFxItem::classComplete() */ void QFxItem::componentComplete() { +#ifdef Q_ENABLE_PERFORMANCE_LOG + QFxPerfTimer cc; +#endif + Q_D(QFxItem); d->_componentComplete = true; if (d->_stateGroup) @@ -1777,7 +1752,7 @@ QmlStateGroup *QFxItemPrivate::states() Q_Q(QFxItem); if (!_stateGroup) { _stateGroup = new QmlStateGroup(q); - if (!_classComplete) + if (!_componentComplete) _stateGroup->classBegin(); QObject::connect(_stateGroup, SIGNAL(stateChanged(QString)), q, SIGNAL(stateChanged(QString))); diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 4837881..5252009 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -208,7 +208,6 @@ public: QmlList *transform(); - bool isClassComplete() const; bool isComponentComplete() const; bool keepMouseGrab() const; @@ -276,7 +275,6 @@ protected: virtual void mouseUngrabEvent(); virtual void classBegin(); - virtual void classComplete(); virtual void componentComplete(); virtual void parentChanged(QFxItem *, QFxItem *); virtual void focusChanged(bool); diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index ebd77f8..c600fbf 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -77,7 +77,7 @@ public: QFxItemPrivate() : _anchors(0), _contents(0), qmlItem(0), _qmlcomp(0), _baselineOffset(0), - _classComplete(true), _componentComplete(true), _keepMouse(false), + _componentComplete(true), _keepMouse(false), _anchorLines(0), _stateGroup(0), canvas(0), origin(QFxItem::TopLeft), options(QFxItem::NoOption), @@ -158,7 +158,6 @@ public: QmlNullableValue _baselineOffset; - bool _classComplete:1; bool _componentComplete:1; bool _keepMouse:1; diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 9c9a7bd..59cf15d 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -787,15 +787,6 @@ void QmlCompiler::genObject(QmlParser::Object *obj) } genObjectBody(obj); - - // Complete the the class - if (obj->parserStatusCast != -1) { - QmlInstruction complete; - complete.type = QmlInstruction::CompleteObject; - complete.complete.castValue = obj->parserStatusCast; - complete.line = obj->location.start.line; - output->bytecode << complete; - } } void QmlCompiler::genObjectBody(QmlParser::Object *obj) diff --git a/src/declarative/qml/qmlinstruction.cpp b/src/declarative/qml/qmlinstruction.cpp index 761903c..9f77bc0 100644 --- a/src/declarative/qml/qmlinstruction.cpp +++ b/src/declarative/qml/qmlinstruction.cpp @@ -152,9 +152,6 @@ void QmlCompiledData::dump(QmlInstruction *instr, int idx) case QmlInstruction::BeginObject: qWarning() << idx << "\t" << line << "\t" << "BEGIN\t\t\t" << instr->begin.castValue; break; - case QmlInstruction::CompleteObject: - qWarning() << idx << "\t" << line << "\t" << "COMPLETE\t\t" << instr->complete.castValue; - break; case QmlInstruction::StoreObjectQmlList: qWarning() << idx << "\t" << line << "\t" << "STORE_OBJECT_QMLLIST"; break; diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h index dc118b6..d4fe68c 100644 --- a/src/declarative/qml/qmlinstruction_p.h +++ b/src/declarative/qml/qmlinstruction_p.h @@ -129,7 +129,6 @@ public: StoreValueSource, /* assignValueSource */ BeginObject, /* begin */ - CompleteObject, /* complete */ StoreObjectQmlList, /* NA */ StoreObjectQList, /* NA */ @@ -200,9 +199,6 @@ public: } fetchQmlList; struct { int castValue; - } complete; - struct { - int castValue; } begin; struct { int propertyIndex; diff --git a/src/declarative/qml/qmlparserstatus.cpp b/src/declarative/qml/qmlparserstatus.cpp index fceac05..0d262ca 100644 --- a/src/declarative/qml/qmlparserstatus.cpp +++ b/src/declarative/qml/qmlparserstatus.cpp @@ -69,14 +69,6 @@ void QmlParserStatus::classBegin() } /*! - Invoked after all properties have been set to their static values. At this - point bindings are still to be evaluated. -*/ -void QmlParserStatus::classComplete() -{ -} - -/*! Invoked after the root component that caused this instantiation has completed construction. At this point all static values and binding values have been assigned to the class. diff --git a/src/declarative/qml/qmlparserstatus.h b/src/declarative/qml/qmlparserstatus.h index 4db6d8c..f754227 100644 --- a/src/declarative/qml/qmlparserstatus.h +++ b/src/declarative/qml/qmlparserstatus.h @@ -57,7 +57,6 @@ public: virtual ~QmlParserStatus(); virtual void classBegin(); - virtual void classComplete(); virtual void componentComplete(); private: diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index 1cfd5e9..ee41fe4 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -522,14 +522,6 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, QmlCompiledData } break; - case QmlInstruction::CompleteObject: - { - QObject *target = stack.top(); - QmlParserStatus *status = reinterpret_cast(reinterpret_cast(target) + instr.complete.castValue); - status->classComplete(); - } - break; - case QmlInstruction::StoreCompiledBinding: { QObject *target = diff --git a/src/declarative/util/qmlstategroup.cpp b/src/declarative/util/qmlstategroup.cpp index 13a0023..ed9221b 100644 --- a/src/declarative/util/qmlstategroup.cpp +++ b/src/declarative/util/qmlstategroup.cpp @@ -56,8 +56,7 @@ class QmlStateGroupPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QmlStateGroup) public: QmlStateGroupPrivate(QmlStateGroup *p) - : nullState(0), states(p), classComplete(true), - componentComplete(true), ignoreTrans(false) {} + : nullState(0), states(p), componentComplete(true), ignoreTrans(false) {} QString currentState; QmlState *nullState; @@ -76,7 +75,6 @@ public: StateList states; QmlConcreteList transitions; - bool classComplete; bool componentComplete; bool ignoreTrans; @@ -133,16 +131,9 @@ void QmlStateGroup::setState(const QString &state) void QmlStateGroup::classBegin() { Q_D(QmlStateGroup); - d->classComplete = false; d->componentComplete = false; } -void QmlStateGroup::classComplete() -{ - Q_D(QmlStateGroup); - d->classComplete = true; -} - void QmlStateGroup::updateAutoState() { Q_D(QmlStateGroup); @@ -152,7 +143,7 @@ void QmlStateGroup::updateAutoState() void QmlStateGroupPrivate::updateAutoState() { Q_Q(QmlStateGroup); - if (!classComplete) + if (!componentComplete) return; bool revert = false; diff --git a/src/declarative/util/qmlstategroup.h b/src/declarative/util/qmlstategroup.h index a817bd0..cf79eb4 100644 --- a/src/declarative/util/qmlstategroup.h +++ b/src/declarative/util/qmlstategroup.h @@ -76,7 +76,6 @@ public: QmlState *findState(const QString &name) const; virtual void classBegin(); - virtual void classComplete(); virtual void componentComplete(); Q_SIGNALS: void stateChanged(const QString &); -- cgit v0.12 From c82fab2bbab69f4fa4d045eaa06925d9d075c972 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 29 Jul 2009 16:00:49 +1000 Subject: Some useful ffmpeg quality setttings. --- tools/qmlviewer/qmlviewer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index f20e8eb..d7d8b82 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -130,9 +130,9 @@ void PreviewDeviceSkin::slotPopupMenu() static struct { const char *name, *args; } ffmpegprofiles[] = { {"Maximum Quality", "-sameq"}, - {"High Quality", "-qcomp 0.75"}, - {"Medium Quality", "-qcomp 0.5"}, - {"Low Quality", "-qcomp 0.2"}, + {"High Quality", "-qmax 2"}, + {"Medium Quality", "-qmax 6"}, + {"Low Quality", "-qmax 16"}, {"Custom ffmpeg arguments", ""}, {0,0} }; -- cgit v0.12 From 10f3d112fb61f249fc7736da85ee90ef42583fb1 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 29 Jul 2009 16:25:45 +1000 Subject: Make SameGame Scalable Resize your window and hit new game This may invalidate high scores. --- demos/declarative/samegame/SameGame.qml | 13 +++---------- demos/declarative/samegame/content/samegame.js | 4 ++++ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/demos/declarative/samegame/SameGame.qml b/demos/declarative/samegame/SameGame.qml index 3b80692..9e1b1ae 100644 --- a/demos/declarative/samegame/SameGame.qml +++ b/demos/declarative/samegame/SameGame.qml @@ -9,7 +9,9 @@ Rect { Rect { id: gameCanvas property int score: 0 - z:20; y:20; width:400; height:600; color: "white"; pen.width: 1 + z:20; y:20; color: "white"; pen.width: 1 + width:parent.width - tileSize - (parent.width % tileSize); + height:parent.height - tileSize - (parent.height % tileSize); anchors.horizontalCenter: parent.horizontalCenter Image { id:background; source: "content/pics/background.png" @@ -29,13 +31,4 @@ Rect { text: "Score: " + gameCanvas.score; width:100; font.size:14 anchors.top: gameCanvas.bottom; anchors.topMargin: 4; anchors.right: gameCanvas.right; } - Text { - text: "Just over 300 lines of QML/JS code!" - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: parent.bottom; anchors.bottomMargin: 16; - opacity: SequentialAnimation{ running: true; repeat: true; - NumberAnimation { from: 0; to: 1; duration: 1000; easing: "easeInQuad" } - NumberAnimation { from: 1; to: 0; duration: 1000; easing: "easeInQuad" } - } - } } diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js index a7dd82b..f04fb4c 100755 --- a/demos/declarative/samegame/content/samegame.js +++ b/demos/declarative/samegame/content/samegame.js @@ -21,6 +21,10 @@ function initBoard() board[i].destroy(); } + maxX = Math.floor(gameCanvas.width/tileSize); + maxY = Math.floor(gameCanvas.height/tileSize); + maxIndex = maxY*maxX; + //Initialize Board board = new Array(maxIndex); gameCanvas.score = 0; -- cgit v0.12 From 20d9edfa3b7a8a648cfdb59a0e71525912f0a0a8 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Wed, 29 Jul 2009 16:52:33 +1000 Subject: KeyActions::return -> KeyActions::keyReturn --- demos/declarative/flickr/content/MediaLineEdit.qml | 2 +- demos/declarative/webbrowser/webbrowser.qml | 2 +- src/declarative/fx/qfxkeyactions.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/demos/declarative/flickr/content/MediaLineEdit.qml b/demos/declarative/flickr/content/MediaLineEdit.qml index a02f92d..b8d30ce 100644 --- a/demos/declarative/flickr/content/MediaLineEdit.qml +++ b/demos/declarative/flickr/content/MediaLineEdit.qml @@ -104,6 +104,6 @@ Item { } KeyActions { id: ReturnKey - return: "Container.state = ''" + keyReturn: "Container.state = ''" } } diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index d3a65db..28e5f16 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -126,7 +126,7 @@ Item { } KeyActions { id: keyActions - return: "WebBrowser.url = EditUrl.text; proxy.focus=false;" + keyReturn: "WebBrowser.url = EditUrl.text; proxy.focus=false;" } */ TextEdit { diff --git a/src/declarative/fx/qfxkeyactions.h b/src/declarative/fx/qfxkeyactions.h index 91c2806..d679d46 100644 --- a/src/declarative/fx/qfxkeyactions.h +++ b/src/declarative/fx/qfxkeyactions.h @@ -101,7 +101,7 @@ class Q_DECLARATIVE_EXPORT QFxKeyActions : public QFxItem Q_PROPERTY(QString digit9 READ key_9 WRITE setKey_9) Q_PROPERTY(QString asterisk READ key_Asterisk WRITE setKey_Asterisk) Q_PROPERTY(QString escape READ key_Escape WRITE setKey_Escape) - Q_PROPERTY(QString return READ key_Return WRITE setKey_Return) + Q_PROPERTY(QString keyReturn READ key_Return WRITE setKey_Return) Q_PROPERTY(QString enter READ key_Enter WRITE setKey_Enter) Q_PROPERTY(QString delete READ key_Delete WRITE setKey_Delete) Q_PROPERTY(QString space READ key_Space WRITE setKey_Space) -- cgit v0.12 From ef0f2901d4055bf53ac2bebb7fe2d5681900db19 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 30 Jul 2009 09:27:14 +1000 Subject: QFxItem cleanup. --- src/declarative/fx/qfxanchors.cpp | 14 +++++++++++++- src/declarative/fx/qfxanchors.h | 3 +++ src/declarative/fx/qfxanchors_p.h | 4 +++- src/declarative/fx/qfxitem.cpp | 26 ++++++-------------------- src/declarative/fx/qfxitem.h | 7 +------ src/declarative/fx/qfxitem_p.h | 2 ++ src/declarative/fx/qfxkeyproxy.cpp | 9 ++++++++- 7 files changed, 36 insertions(+), 29 deletions(-) diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp index 9093c8e..286a0fc 100644 --- a/src/declarative/fx/qfxanchors.cpp +++ b/src/declarative/fx/qfxanchors.cpp @@ -237,7 +237,19 @@ void QFxAnchorsPrivate::remDepend(QFxItem *item) bool QFxAnchorsPrivate::isItemComplete() const { - return item->isComponentComplete(); + return componentComplete; +} + +void QFxAnchors::classBegin() +{ + Q_D(QFxAnchors); + d->componentComplete = false; +} + +void QFxAnchors::componentComplete() +{ + Q_D(QFxAnchors); + d->componentComplete = true; } void QFxAnchorsPrivate::setItemHeight(qreal v) diff --git a/src/declarative/fx/qfxanchors.h b/src/declarative/fx/qfxanchors.h index c11080c..a1f5db8 100644 --- a/src/declarative/fx/qfxanchors.h +++ b/src/declarative/fx/qfxanchors.h @@ -147,6 +147,9 @@ public: void setItem(QFxItem *item); + void classBegin(); + void componentComplete(); + Q_SIGNALS: void leftMarginChanged(); void rightMarginChanged(); diff --git a/src/declarative/fx/qfxanchors_p.h b/src/declarative/fx/qfxanchors_p.h index a7c904b..7ce0952 100644 --- a/src/declarative/fx/qfxanchors_p.h +++ b/src/declarative/fx/qfxanchors_p.h @@ -66,7 +66,8 @@ public: : updatingMe(false), updatingHorizontalAnchor(0), updatingVerticalAnchor(0), item(0), usedAnchors(0), fill(0), centeredIn(0), leftMargin(0), rightMargin(0), topMargin(0), - bottomMargin(0), vCenterOffset(0), hCenterOffset(0) + bottomMargin(0), vCenterOffset(0), hCenterOffset(0), + componentComplete(true) { } @@ -126,6 +127,7 @@ public: qreal vCenterOffset; qreal hCenterOffset; + bool componentComplete; }; QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 1bf3140..d88b3af 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1725,6 +1725,8 @@ void QFxItem::classBegin() d->_componentComplete = false; if (d->_stateGroup) d->_stateGroup->classBegin(); + if (d->_anchors) + d->_anchors->classBegin(); } /*! @@ -1743,8 +1745,10 @@ void QFxItem::componentComplete() d->_componentComplete = true; if (d->_stateGroup) d->_stateGroup->componentComplete(); - if (d->_anchors) - d->anchors()->d_func()->updateOnComplete(); + if (d->_anchors) { + d->_anchors->componentComplete(); + d->_anchors->d_func()->updateOnComplete(); + } } QmlStateGroup *QFxItemPrivate::states() @@ -2164,22 +2168,4 @@ void QFxItemPrivate::gvAddMouseFilter() q->installSceneEventFilter(q); } -QPixmap QFxItem::string(const QString &str, const QColor &c, const QFont &f) -{ - QFontMetrics fm(f); - QSize size(fm.width(str), fm.height()*(str.count(QLatin1Char('\n'))+1)); //fm.boundingRect(str).size(); - QPixmap img(size); - img.fill(Qt::transparent); - QPainter p(&img); - p.setPen(c); - p.setFont(f); - p.drawText(img.rect(), Qt::AlignVCenter, str); - return img; -} - -QVariant QFxItem::inputMethodQuery(Qt::InputMethodQuery query) const -{ - return QGraphicsItem::inputMethodQuery(query); -} - QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 5252009..36845a2 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -208,8 +208,6 @@ public: QmlList *transform(); - bool isComponentComplete() const; - bool keepMouseGrab() const; void setKeepMouseGrab(bool); @@ -241,10 +239,6 @@ public: bool hasActiveFocus() const; - static QPixmap string(const QString &, const QColor & = Qt::black, const QFont & = QFont()); // ### remove me, make private for now - - QVariant inputMethodQuery(Qt::InputMethodQuery query) const; //### for KeyProxy - public Q_SLOTS: void newChild(const QString &url); @@ -266,6 +260,7 @@ Q_SIGNALS: void newChildCreated(const QString &url, QScriptValue); protected: + bool isComponentComplete() const; virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); virtual void childrenChanged(); virtual bool sceneEventFilter(QGraphicsItem *, QEvent *); diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index c600fbf..77d0673 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -144,6 +144,8 @@ public: Q_Q(QFxItem); _anchors = new QFxAnchors; _anchors->setItem(q); + if (!_componentComplete) + _anchors->classBegin(); } return _anchors; } diff --git a/src/declarative/fx/qfxkeyproxy.cpp b/src/declarative/fx/qfxkeyproxy.cpp index 13f4bfb..968ff09 100644 --- a/src/declarative/fx/qfxkeyproxy.cpp +++ b/src/declarative/fx/qfxkeyproxy.cpp @@ -181,10 +181,17 @@ void QFxKeyProxy::inputMethodEvent(QInputMethodEvent *e) QVariant QFxKeyProxy::inputMethodQuery(Qt::InputMethodQuery query) const { + struct QFxItemAccessor : public QFxItem { + public: + QVariant inputMethodQuery(Qt::InputMethodQuery query) const { + return QGraphicsItem::inputMethodQuery(query); + } + }; + for (int ii = 0; ii < d->targets.count(); ++ii) { QFxItem *i = qobject_cast(scene()->focusItem(d->targets.at(ii))); if (i && (i->options() & AcceptsInputMethods) && i == d->imeItem) { //### how robust is i == d->imeItem check? - QVariant v = i->inputMethodQuery(query); + QVariant v = ((QFxItemAccessor*)i)->inputMethodQuery(query); if (v.type() == QVariant::RectF) v = mapRectFromItem(i, v.toRectF()); //### cost? return v; -- cgit v0.12 From 326cc83e3677cefe230d813a89ea55cd56fc22bf Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 30 Jul 2009 09:47:56 +1000 Subject: Partially revert ef0f2901d4055bf53ac2bebb7fe2d5681900db19. Accessor method for inputMethodQuery was causing crashes. --- src/declarative/fx/qfxitem.cpp | 5 +++++ src/declarative/fx/qfxitem.h | 2 ++ src/declarative/fx/qfxkeyproxy.cpp | 9 +-------- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index d88b3af..4e66f55 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -2168,4 +2168,9 @@ void QFxItemPrivate::gvAddMouseFilter() q->installSceneEventFilter(q); } +QVariant QFxItem::inputMethodQuery(Qt::InputMethodQuery query) const +{ + return QGraphicsItem::inputMethodQuery(query); +} + QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 36845a2..cd346a7 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -239,6 +239,8 @@ public: bool hasActiveFocus() const; + QVariant inputMethodQuery(Qt::InputMethodQuery query) const; //### for KeyProxy + public Q_SLOTS: void newChild(const QString &url); diff --git a/src/declarative/fx/qfxkeyproxy.cpp b/src/declarative/fx/qfxkeyproxy.cpp index 968ff09..13f4bfb 100644 --- a/src/declarative/fx/qfxkeyproxy.cpp +++ b/src/declarative/fx/qfxkeyproxy.cpp @@ -181,17 +181,10 @@ void QFxKeyProxy::inputMethodEvent(QInputMethodEvent *e) QVariant QFxKeyProxy::inputMethodQuery(Qt::InputMethodQuery query) const { - struct QFxItemAccessor : public QFxItem { - public: - QVariant inputMethodQuery(Qt::InputMethodQuery query) const { - return QGraphicsItem::inputMethodQuery(query); - } - }; - for (int ii = 0; ii < d->targets.count(); ++ii) { QFxItem *i = qobject_cast(scene()->focusItem(d->targets.at(ii))); if (i && (i->options() & AcceptsInputMethods) && i == d->imeItem) { //### how robust is i == d->imeItem check? - QVariant v = ((QFxItemAccessor*)i)->inputMethodQuery(query); + QVariant v = i->inputMethodQuery(query); if (v.type() == QVariant::RectF) v = mapRectFromItem(i, v.toRectF()); //### cost? return v; -- cgit v0.12 From 56805f1f4d001f83f888b01076b495798378a92c Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 30 Jul 2009 09:58:56 +1000 Subject: Fix regression introduced in classComplete -> componentComplete. --- src/declarative/util/qmlstategroup.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/declarative/util/qmlstategroup.cpp b/src/declarative/util/qmlstategroup.cpp index ed9221b..3a07fbe 100644 --- a/src/declarative/util/qmlstategroup.cpp +++ b/src/declarative/util/qmlstategroup.cpp @@ -134,6 +134,18 @@ void QmlStateGroup::classBegin() d->componentComplete = false; } +void QmlStateGroup::componentComplete() +{ + Q_D(QmlStateGroup); + d->componentComplete = true; + d->updateAutoState(); + if (!d->currentState.isEmpty()) { + QString cs = d->currentState; + d->currentState = QString(); + d->setCurrentStateInternal(cs, true); + } +} + void QmlStateGroup::updateAutoState() { Q_D(QmlStateGroup); @@ -270,18 +282,6 @@ void QmlStateGroupPrivate::setCurrentStateInternal(const QString &state, newState->apply(q, transition, oldState); } -void QmlStateGroup::componentComplete() -{ - Q_D(QmlStateGroup); - d->updateAutoState(); - d->componentComplete = true; - if (!d->currentState.isEmpty()) { - QString cs = d->currentState; - d->currentState = QString(); - d->setCurrentStateInternal(cs, true); - } -} - QmlState *QmlStateGroup::findState(const QString &name) const { Q_D(const QmlStateGroup); -- cgit v0.12 From c1e8bfa87e20d16c484a3c430354081827e42e6b Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Thu, 30 Jul 2009 02:24:37 +0200 Subject: Improved the support for post-visits of the AST. --- src/declarative/qml/parser/qmljsast.cpp | 281 ++++++++++++++++---------------- src/declarative/qml/parser/qmljsast_p.h | 16 +- 2 files changed, 142 insertions(+), 155 deletions(-) diff --git a/src/declarative/qml/parser/qmljsast.cpp b/src/declarative/qml/parser/qmljsast.cpp index 1d7f09e..caf81e5 100644 --- a/src/declarative/qml/parser/qmljsast.cpp +++ b/src/declarative/qml/parser/qmljsast.cpp @@ -40,15 +40,26 @@ ****************************************************************************/ #include "qmljsast_p.h" - - - #include "qmljsastvisitor_p.h" QT_BEGIN_NAMESPACE namespace QmlJS { namespace AST { +void Node::accept(Visitor *visitor) +{ + if (visitor->preVisit(this)) { + accept0(visitor); + } + visitor->postVisit(this); +} + +void Node::accept(Node *node, Visitor *visitor) +{ + if (node) + node->accept(visitor); +} + ExpressionNode *Node::expressionCast() { return 0; @@ -82,7 +93,7 @@ Statement *Statement::statementCast() void NestedExpression::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(expression, visitor); + accept(expression, visitor); } visitor->endVisit(this); } @@ -154,8 +165,8 @@ void RegExpLiteral::accept0(Visitor *visitor) void ArrayLiteral::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(elements, visitor); - acceptChild(elision, visitor); + accept(elements, visitor); + accept(elision, visitor); } visitor->endVisit(this); @@ -164,7 +175,7 @@ void ArrayLiteral::accept0(Visitor *visitor) void ObjectLiteral::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(properties, visitor); + accept(properties, visitor); } visitor->endVisit(this); @@ -173,12 +184,10 @@ void ObjectLiteral::accept0(Visitor *visitor) void ElementList::accept0(Visitor *visitor) { if (visitor->visit(this)) { - ElementList *it = this; - do { - acceptChild(it->elision, visitor); - acceptChild(it->expression, visitor); - it = it->next; - } while (it); + for (ElementList *it = this; it; it = it->next) { + accept(it->elision, visitor); + accept(it->expression, visitor); + } } visitor->endVisit(this); @@ -196,12 +205,10 @@ void Elision::accept0(Visitor *visitor) void PropertyNameAndValueList::accept0(Visitor *visitor) { if (visitor->visit(this)) { - PropertyNameAndValueList *it = this; - do { - acceptChild(it->name, visitor); - acceptChild(it->value, visitor); - it = it->next; - } while (it); + for (PropertyNameAndValueList *it = this; it; it = it->next) { + accept(it->name, visitor); + accept(it->value, visitor); + } } visitor->endVisit(this); @@ -234,8 +241,8 @@ void NumericLiteralPropertyName::accept0(Visitor *visitor) void ArrayMemberExpression::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(base, visitor); - acceptChild(expression, visitor); + accept(base, visitor); + accept(expression, visitor); } visitor->endVisit(this); @@ -244,7 +251,7 @@ void ArrayMemberExpression::accept0(Visitor *visitor) void FieldMemberExpression::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(base, visitor); + accept(base, visitor); } visitor->endVisit(this); @@ -253,8 +260,8 @@ void FieldMemberExpression::accept0(Visitor *visitor) void NewMemberExpression::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(base, visitor); - acceptChild(arguments, visitor); + accept(base, visitor); + accept(arguments, visitor); } visitor->endVisit(this); @@ -263,7 +270,7 @@ void NewMemberExpression::accept0(Visitor *visitor) void NewExpression::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(expression, visitor); + accept(expression, visitor); } visitor->endVisit(this); @@ -272,8 +279,8 @@ void NewExpression::accept0(Visitor *visitor) void CallExpression::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(base, visitor); - acceptChild(arguments, visitor); + accept(base, visitor); + accept(arguments, visitor); } visitor->endVisit(this); @@ -282,11 +289,9 @@ void CallExpression::accept0(Visitor *visitor) void ArgumentList::accept0(Visitor *visitor) { if (visitor->visit(this)) { - ArgumentList *it = this; - do { - acceptChild(it->expression, visitor); - it = it->next; - } while (it); + for (ArgumentList *it = this; it; it = it->next) { + accept(it->expression, visitor); + } } visitor->endVisit(this); @@ -295,7 +300,7 @@ void ArgumentList::accept0(Visitor *visitor) void PostIncrementExpression::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(base, visitor); + accept(base, visitor); } visitor->endVisit(this); @@ -304,7 +309,7 @@ void PostIncrementExpression::accept0(Visitor *visitor) void PostDecrementExpression::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(base, visitor); + accept(base, visitor); } visitor->endVisit(this); @@ -313,7 +318,7 @@ void PostDecrementExpression::accept0(Visitor *visitor) void DeleteExpression::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(expression, visitor); + accept(expression, visitor); } visitor->endVisit(this); @@ -322,7 +327,7 @@ void DeleteExpression::accept0(Visitor *visitor) void VoidExpression::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(expression, visitor); + accept(expression, visitor); } visitor->endVisit(this); @@ -331,7 +336,7 @@ void VoidExpression::accept0(Visitor *visitor) void TypeOfExpression::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(expression, visitor); + accept(expression, visitor); } visitor->endVisit(this); @@ -340,7 +345,7 @@ void TypeOfExpression::accept0(Visitor *visitor) void PreIncrementExpression::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(expression, visitor); + accept(expression, visitor); } visitor->endVisit(this); @@ -349,7 +354,7 @@ void PreIncrementExpression::accept0(Visitor *visitor) void PreDecrementExpression::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(expression, visitor); + accept(expression, visitor); } visitor->endVisit(this); @@ -358,7 +363,7 @@ void PreDecrementExpression::accept0(Visitor *visitor) void UnaryPlusExpression::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(expression, visitor); + accept(expression, visitor); } visitor->endVisit(this); @@ -367,7 +372,7 @@ void UnaryPlusExpression::accept0(Visitor *visitor) void UnaryMinusExpression::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(expression, visitor); + accept(expression, visitor); } visitor->endVisit(this); @@ -376,7 +381,7 @@ void UnaryMinusExpression::accept0(Visitor *visitor) void TildeExpression::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(expression, visitor); + accept(expression, visitor); } visitor->endVisit(this); @@ -385,7 +390,7 @@ void TildeExpression::accept0(Visitor *visitor) void NotExpression::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(expression, visitor); + accept(expression, visitor); } visitor->endVisit(this); @@ -394,8 +399,8 @@ void NotExpression::accept0(Visitor *visitor) void BinaryExpression::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(left, visitor); - acceptChild(right, visitor); + accept(left, visitor); + accept(right, visitor); } visitor->endVisit(this); @@ -404,9 +409,9 @@ void BinaryExpression::accept0(Visitor *visitor) void ConditionalExpression::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(expression, visitor); - acceptChild(ok, visitor); - acceptChild(ko, visitor); + accept(expression, visitor); + accept(ok, visitor); + accept(ko, visitor); } visitor->endVisit(this); @@ -415,8 +420,8 @@ void ConditionalExpression::accept0(Visitor *visitor) void Expression::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(left, visitor); - acceptChild(right, visitor); + accept(left, visitor); + accept(right, visitor); } visitor->endVisit(this); @@ -425,7 +430,7 @@ void Expression::accept0(Visitor *visitor) void Block::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(statements, visitor); + accept(statements, visitor); } visitor->endVisit(this); @@ -434,11 +439,9 @@ void Block::accept0(Visitor *visitor) void StatementList::accept0(Visitor *visitor) { if (visitor->visit(this)) { - StatementList *it = this; - do { - acceptChild(it->statement, visitor); - it = it->next; - } while (it); + for (StatementList *it = this; it; it = it->next) { + accept(it->statement, visitor); + } } visitor->endVisit(this); @@ -447,7 +450,7 @@ void StatementList::accept0(Visitor *visitor) void VariableStatement::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(declarations, visitor); + accept(declarations, visitor); } visitor->endVisit(this); @@ -456,11 +459,9 @@ void VariableStatement::accept0(Visitor *visitor) void VariableDeclarationList::accept0(Visitor *visitor) { if (visitor->visit(this)) { - VariableDeclarationList *it = this; - do { - acceptChild(it->declaration, visitor); - it = it->next; - } while (it); + for (VariableDeclarationList *it = this; it; it = it->next) { + accept(it->declaration, visitor); + } } visitor->endVisit(this); @@ -469,7 +470,7 @@ void VariableDeclarationList::accept0(Visitor *visitor) void VariableDeclaration::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(expression, visitor); + accept(expression, visitor); } visitor->endVisit(this); @@ -486,7 +487,7 @@ void EmptyStatement::accept0(Visitor *visitor) void ExpressionStatement::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(expression, visitor); + accept(expression, visitor); } visitor->endVisit(this); @@ -495,9 +496,9 @@ void ExpressionStatement::accept0(Visitor *visitor) void IfStatement::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(expression, visitor); - acceptChild(ok, visitor); - acceptChild(ko, visitor); + accept(expression, visitor); + accept(ok, visitor); + accept(ko, visitor); } visitor->endVisit(this); @@ -506,8 +507,8 @@ void IfStatement::accept0(Visitor *visitor) void DoWhileStatement::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(statement, visitor); - acceptChild(expression, visitor); + accept(statement, visitor); + accept(expression, visitor); } visitor->endVisit(this); @@ -516,8 +517,8 @@ void DoWhileStatement::accept0(Visitor *visitor) void WhileStatement::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(expression, visitor); - acceptChild(statement, visitor); + accept(expression, visitor); + accept(statement, visitor); } visitor->endVisit(this); @@ -526,10 +527,10 @@ void WhileStatement::accept0(Visitor *visitor) void ForStatement::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(initialiser, visitor); - acceptChild(condition, visitor); - acceptChild(expression, visitor); - acceptChild(statement, visitor); + accept(initialiser, visitor); + accept(condition, visitor); + accept(expression, visitor); + accept(statement, visitor); } visitor->endVisit(this); @@ -538,10 +539,10 @@ void ForStatement::accept0(Visitor *visitor) void LocalForStatement::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(declarations, visitor); - acceptChild(condition, visitor); - acceptChild(expression, visitor); - acceptChild(statement, visitor); + accept(declarations, visitor); + accept(condition, visitor); + accept(expression, visitor); + accept(statement, visitor); } visitor->endVisit(this); @@ -550,9 +551,9 @@ void LocalForStatement::accept0(Visitor *visitor) void ForEachStatement::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(initialiser, visitor); - acceptChild(expression, visitor); - acceptChild(statement, visitor); + accept(initialiser, visitor); + accept(expression, visitor); + accept(statement, visitor); } visitor->endVisit(this); @@ -561,9 +562,9 @@ void ForEachStatement::accept0(Visitor *visitor) void LocalForEachStatement::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(declaration, visitor); - acceptChild(expression, visitor); - acceptChild(statement, visitor); + accept(declaration, visitor); + accept(expression, visitor); + accept(statement, visitor); } visitor->endVisit(this); @@ -588,7 +589,7 @@ void BreakStatement::accept0(Visitor *visitor) void ReturnStatement::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(expression, visitor); + accept(expression, visitor); } visitor->endVisit(this); @@ -597,8 +598,8 @@ void ReturnStatement::accept0(Visitor *visitor) void WithStatement::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(expression, visitor); - acceptChild(statement, visitor); + accept(expression, visitor); + accept(statement, visitor); } visitor->endVisit(this); @@ -607,8 +608,8 @@ void WithStatement::accept0(Visitor *visitor) void SwitchStatement::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(expression, visitor); - acceptChild(block, visitor); + accept(expression, visitor); + accept(block, visitor); } visitor->endVisit(this); @@ -617,9 +618,9 @@ void SwitchStatement::accept0(Visitor *visitor) void CaseBlock::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(clauses, visitor); - acceptChild(defaultClause, visitor); - acceptChild(moreClauses, visitor); + accept(clauses, visitor); + accept(defaultClause, visitor); + accept(moreClauses, visitor); } visitor->endVisit(this); @@ -628,11 +629,9 @@ void CaseBlock::accept0(Visitor *visitor) void CaseClauses::accept0(Visitor *visitor) { if (visitor->visit(this)) { - CaseClauses *it = this; - do { - acceptChild(it->clause, visitor); - it = it->next; - } while (it); + for (CaseClauses *it = this; it; it = it->next) { + accept(it->clause, visitor); + } } visitor->endVisit(this); @@ -641,8 +640,8 @@ void CaseClauses::accept0(Visitor *visitor) void CaseClause::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(expression, visitor); - acceptChild(statements, visitor); + accept(expression, visitor); + accept(statements, visitor); } visitor->endVisit(this); @@ -651,7 +650,7 @@ void CaseClause::accept0(Visitor *visitor) void DefaultClause::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(statements, visitor); + accept(statements, visitor); } visitor->endVisit(this); @@ -660,7 +659,7 @@ void DefaultClause::accept0(Visitor *visitor) void LabelledStatement::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(statement, visitor); + accept(statement, visitor); } visitor->endVisit(this); @@ -669,7 +668,7 @@ void LabelledStatement::accept0(Visitor *visitor) void ThrowStatement::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(expression, visitor); + accept(expression, visitor); } visitor->endVisit(this); @@ -678,9 +677,9 @@ void ThrowStatement::accept0(Visitor *visitor) void TryStatement::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(statement, visitor); - acceptChild(catchExpression, visitor); - acceptChild(finallyExpression, visitor); + accept(statement, visitor); + accept(catchExpression, visitor); + accept(finallyExpression, visitor); } visitor->endVisit(this); @@ -689,7 +688,7 @@ void TryStatement::accept0(Visitor *visitor) void Catch::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(statement, visitor); + accept(statement, visitor); } visitor->endVisit(this); @@ -698,7 +697,7 @@ void Catch::accept0(Visitor *visitor) void Finally::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(statement, visitor); + accept(statement, visitor); } visitor->endVisit(this); @@ -707,8 +706,8 @@ void Finally::accept0(Visitor *visitor) void FunctionDeclaration::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(formals, visitor); - acceptChild(body, visitor); + accept(formals, visitor); + accept(body, visitor); } visitor->endVisit(this); @@ -717,8 +716,8 @@ void FunctionDeclaration::accept0(Visitor *visitor) void FunctionExpression::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(formals, visitor); - acceptChild(body, visitor); + accept(formals, visitor); + accept(body, visitor); } visitor->endVisit(this); @@ -736,7 +735,7 @@ void FormalParameterList::accept0(Visitor *visitor) void FunctionBody::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(elements, visitor); + accept(elements, visitor); } visitor->endVisit(this); @@ -745,7 +744,7 @@ void FunctionBody::accept0(Visitor *visitor) void Program::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(elements, visitor); + accept(elements, visitor); } visitor->endVisit(this); @@ -754,11 +753,9 @@ void Program::accept0(Visitor *visitor) void SourceElements::accept0(Visitor *visitor) { if (visitor->visit(this)) { - SourceElements *it = this; - do { - acceptChild(it->element, visitor); - it = it->next; - } while (it); + for (SourceElements *it = this; it; it = it->next) { + accept(it->element, visitor); + } } visitor->endVisit(this); @@ -767,7 +764,7 @@ void SourceElements::accept0(Visitor *visitor) void FunctionSourceElement::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(declaration, visitor); + accept(declaration, visitor); } visitor->endVisit(this); @@ -776,7 +773,7 @@ void FunctionSourceElement::accept0(Visitor *visitor) void StatementSourceElement::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(statement, visitor); + accept(statement, visitor); } visitor->endVisit(this); @@ -794,8 +791,7 @@ void DebuggerStatement::accept0(Visitor *visitor) void UiProgram::accept0(Visitor *visitor) { if (visitor->visit(this)) { - for (UiObjectMemberList *it = members; it; it = it->next) - acceptChild(it->member, visitor); + accept(imports, visitor); } visitor->endVisit(this); @@ -804,7 +800,7 @@ void UiProgram::accept0(Visitor *visitor) void UiSignature::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(formals, visitor); + accept(formals, visitor); } visitor->endVisit(this); } @@ -813,7 +809,7 @@ void UiFormalList::accept0(Visitor *visitor) { if (visitor->visit(this)) { for (UiFormalList *it = this; it; it = it->next) { - acceptChild(it->formal, visitor); + accept(it->formal, visitor); } } visitor->endVisit(this); @@ -829,7 +825,7 @@ void UiFormal::accept0(Visitor *visitor) void UiPublicMember::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(expression, visitor); + accept(expression, visitor); } visitor->endVisit(this); @@ -838,8 +834,8 @@ void UiPublicMember::accept0(Visitor *visitor) void UiObjectDefinition::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(qualifiedTypeNameId, visitor); - acceptChild(initializer, visitor); + accept(qualifiedTypeNameId, visitor); + accept(initializer, visitor); } visitor->endVisit(this); @@ -848,8 +844,7 @@ void UiObjectDefinition::accept0(Visitor *visitor) void UiObjectInitializer::accept0(Visitor *visitor) { if (visitor->visit(this)) { - for (UiObjectMemberList *it = members; it; it = it->next) - acceptChild(it->member, visitor); + accept(members, visitor); } visitor->endVisit(this); @@ -858,9 +853,9 @@ void UiObjectInitializer::accept0(Visitor *visitor) void UiObjectBinding::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(qualifiedId, visitor); - acceptChild(qualifiedTypeNameId, visitor); - acceptChild(initializer, visitor); + accept(qualifiedId, visitor); + accept(qualifiedTypeNameId, visitor); + accept(initializer, visitor); } visitor->endVisit(this); @@ -869,8 +864,8 @@ void UiObjectBinding::accept0(Visitor *visitor) void UiScriptBinding::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(qualifiedId, visitor); - acceptChild(statement, visitor); + accept(qualifiedId, visitor); + accept(statement, visitor); } visitor->endVisit(this); @@ -879,9 +874,8 @@ void UiScriptBinding::accept0(Visitor *visitor) void UiArrayBinding::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(qualifiedId, visitor); - for (UiArrayMemberList *it = members; it; it = it->next) - acceptChild(it->member, visitor); + accept(qualifiedId, visitor); + accept(members, visitor); } visitor->endVisit(this); @@ -891,7 +885,7 @@ void UiObjectMemberList::accept0(Visitor *visitor) { if (visitor->visit(this)) { for (UiObjectMemberList *it = this; it; it = it->next) - acceptChild(it->member, visitor); + accept(it->member, visitor); } visitor->endVisit(this); @@ -901,7 +895,7 @@ void UiArrayMemberList::accept0(Visitor *visitor) { if (visitor->visit(this)) { for (UiArrayMemberList *it = this; it; it = it->next) - acceptChild(it->member, visitor); + accept(it->member, visitor); } visitor->endVisit(this); @@ -918,6 +912,7 @@ void UiQualifiedId::accept0(Visitor *visitor) void UiImport::accept0(Visitor *visitor) { if (visitor->visit(this)) { + accept(importUri, visitor); } visitor->endVisit(this); @@ -926,8 +921,8 @@ void UiImport::accept0(Visitor *visitor) void UiImportList::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(import, visitor); - acceptChild(next, visitor); + accept(import, visitor); + accept(next, visitor); } visitor->endVisit(this); @@ -936,7 +931,7 @@ void UiImportList::accept0(Visitor *visitor) void UiSourceElement::accept0(Visitor *visitor) { if (visitor->visit(this)) { - acceptChild(sourceElement, visitor); + accept(sourceElement, visitor); } visitor->endVisit(this); diff --git a/src/declarative/qml/parser/qmljsast_p.h b/src/declarative/qml/parser/qmljsast_p.h index ee2f472..3967742 100644 --- a/src/declarative/qml/parser/qmljsast_p.h +++ b/src/declarative/qml/parser/qmljsast_p.h @@ -228,19 +228,11 @@ public: virtual BinaryExpression *binaryExpressionCast(); virtual Statement *statementCast(); - inline void accept(Visitor *visitor) - { - if (visitor->preVisit(this)) { - accept0(visitor); - visitor->postVisit(this); - } - } + void accept(Visitor *visitor); + static void accept(Node *node, Visitor *visitor); - static void acceptChild(Node *node, Visitor *visitor) - { - if (node) - node->accept(visitor); - } + inline static void acceptChild(Node *node, Visitor *visitor) + { return accept(node, visitor); } // ### remove virtual void accept0(Visitor *visitor) = 0; -- cgit v0.12 From 8b168b8f969c1eafaeb0276a3c81b58a388f93d2 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Thu, 30 Jul 2009 02:40:11 +0200 Subject: Removed the (outdated) pretty printer for the JS expressions. --- src/declarative/qml/parser/parser.pri | 4 +- src/declarative/qml/parser/qmljsprettypretty.cpp | 1334 ---------------------- src/declarative/qml/parser/qmljsprettypretty_p.h | 329 ------ 3 files changed, 1 insertion(+), 1666 deletions(-) delete mode 100644 src/declarative/qml/parser/qmljsprettypretty.cpp delete mode 100644 src/declarative/qml/parser/qmljsprettypretty_p.h diff --git a/src/declarative/qml/parser/parser.pri b/src/declarative/qml/parser/parser.pri index 1ea249a..1f553f6 100644 --- a/src/declarative/qml/parser/parser.pri +++ b/src/declarative/qml/parser/parser.pri @@ -10,14 +10,12 @@ HEADERS += $$PWD/qmljsast_p.h \ $$PWD/qmljslexer_p.h \ $$PWD/qmljsmemorypool_p.h \ $$PWD/qmljsnodepool_p.h \ - $$PWD/qmljsparser_p.h \ - $$PWD/qmljsprettypretty_p.h + $$PWD/qmljsparser_p.h SOURCES += $$PWD/qmljsast.cpp \ $$PWD/qmljsastvisitor.cpp \ $$PWD/qmljsengine_p.cpp \ $$PWD/qmljsgrammar.cpp \ $$PWD/qmljslexer.cpp \ - $$PWD/qmljsprettypretty.cpp \ $$PWD/qmljsparser.cpp diff --git a/src/declarative/qml/parser/qmljsprettypretty.cpp b/src/declarative/qml/parser/qmljsprettypretty.cpp deleted file mode 100644 index b6733e5..0000000 --- a/src/declarative/qml/parser/qmljsprettypretty.cpp +++ /dev/null @@ -1,1334 +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 "qmljsprettypretty_p.h" - - - -#include "qmljsengine_p.h" - - - - -#include "qmljsast_p.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -namespace QmlJS { -QString numberToString(double value); -} - -using namespace QmlJS; - -PrettyPretty::PrettyPretty(QTextStream &o): - out(o), m_indentLevel(0) -{ -} - -PrettyPretty::~PrettyPretty() -{ -} - -void PrettyPretty::acceptAsBlock(AST::Node *node) -{ - out << "{"; - pushIndentLevel(); - newlineAndIndent(); - accept(node); - popIndentLevel(); - newlineAndIndent(); - out << "}"; -} - -int PrettyPretty::operatorPrecedenceLevel(int op) -{ - switch (op) { - case QSOperator::Div: - case QSOperator::Mod: - case QSOperator::Mul: - return 5; - case QSOperator::Add: - case QSOperator::Sub: - return 6; - case QSOperator::LShift: - case QSOperator::RShift: - case QSOperator::URShift: - return 7; - case QSOperator::Ge: - case QSOperator::Gt: - case QSOperator::In: - case QSOperator::InstanceOf: - case QSOperator::Le: - case QSOperator::Lt: - return 8; - case QSOperator::Equal: - case QSOperator::NotEqual: - case QSOperator::StrictEqual: - case QSOperator::StrictNotEqual: - return 9; - case QSOperator::BitAnd: - return 10; - case QSOperator::BitXor: - return 11; - case QSOperator::BitOr: - return 12; - case QSOperator::And: - return 13; - case QSOperator::Or: - return 14; - case QSOperator::InplaceAnd: - case QSOperator::InplaceSub: - case QSOperator::InplaceDiv: - case QSOperator::InplaceAdd: - case QSOperator::InplaceLeftShift: - case QSOperator::InplaceMod: - case QSOperator::InplaceMul: - case QSOperator::InplaceOr: - case QSOperator::InplaceRightShift: - case QSOperator::InplaceURightShift: - case QSOperator::InplaceXor: - case QSOperator::Assign: - return 16; - default: - Q_ASSERT_X(false, "PrettyPretty::operatorPrecedenceLevel()", "bad operator"); - } - return 0; -} - -int PrettyPretty::compareOperatorPrecedence(int op1, int op2) -{ - int prec1 = operatorPrecedenceLevel(op1); - int prec2 = operatorPrecedenceLevel(op2); - if (prec1 == prec2) - return 0; - if (prec1 > prec2) - return -1; - return 1; -} - -QTextStream &PrettyPretty::operator () (AST::Node *node, int level) -{ - int was = indentLevel(level); - accept(node); - indentLevel(was); - return out; -} - -QTextStream &PrettyPretty::newlineAndIndent() -{ - enum { IND = 4 }; - out << endl << QString().fill(QLatin1Char(' '), m_indentLevel * IND); - return out; -} - -void PrettyPretty::accept(AST::Node *node) -{ - AST::Node::acceptChild(node, this); -} - -bool PrettyPretty::visit(AST::ThisExpression *node) -{ - Q_UNUSED(node); - out << "this"; - return true; -} - -void PrettyPretty::endVisit(AST::ThisExpression *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::IdentifierExpression *node) -{ - out << Engine::toString(node->name); - return true; -} - -void PrettyPretty::endVisit(AST::IdentifierExpression *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::NullExpression *node) -{ - Q_UNUSED(node); - out << "null"; - return false; -} - -void PrettyPretty::endVisit(AST::NullExpression *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::TrueLiteral *node) -{ - Q_UNUSED(node); - out << "true"; - return false; -} - -void PrettyPretty::endVisit(AST::TrueLiteral *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::FalseLiteral *node) -{ - Q_UNUSED(node); - out << "false"; - return false; -} - -void PrettyPretty::endVisit(AST::FalseLiteral *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::StringLiteral *node) -{ - QString lit = Engine::toString(node->value); - lit.replace(QLatin1String("\\"), QLatin1String("\\\\")); - out << "\"" << lit << "\""; - return false; -} - -void PrettyPretty::endVisit(AST::StringLiteral *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::NumericLiteral *node) -{ - out << QmlJS::numberToString(node->value); - return true; -} - -void PrettyPretty::endVisit(AST::NumericLiteral *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::RegExpLiteral *node) -{ - out << "/" << Engine::toString(node->pattern) << "/"; - if (node->flags) - out << QmlJS::Ecma::RegExp::flagsToString(node->flags); - - return true; -} - -void PrettyPretty::endVisit(AST::RegExpLiteral *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::ArrayLiteral *node) -{ - out << "["; - accept(node->elements); - accept(node->elision); - out << "]"; - return false; -} - -void PrettyPretty::endVisit(AST::ArrayLiteral *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::ObjectLiteral *node) -{ - out << "{"; - if (node->properties) { - pushIndentLevel(); - AST::PropertyNameAndValueList *prop; - for (prop = node->properties; prop != 0; prop = prop->next) { - newlineAndIndent(); - accept(prop); - if (prop->next) - out << ","; - } - popIndentLevel(); - newlineAndIndent(); - } - out << "}"; - return false; -} - -void PrettyPretty::endVisit(AST::ObjectLiteral *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::ElementList *node) -{ - accept(node->elision); - accept(node->expression); - for (node = node->next; node != 0; node = node->next) { - out << ", "; - accept(node->elision); - accept(node->expression); - } - return false; -} - -void PrettyPretty::endVisit(AST::ElementList *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::Elision *node) -{ - out << ", "; - for (AST::Elision *eit = node->next; eit != 0; eit = eit->next) - out << ", "; - return false; -} - -void PrettyPretty::endVisit(AST::Elision *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::PropertyNameAndValueList *node) -{ - accept(node->name); - out << ": "; - accept(node->value); - return false; -} - -void PrettyPretty::endVisit(AST::PropertyNameAndValueList *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::IdentifierPropertyName *node) -{ - out << Engine::toString(node->id); - return false; -} - -void PrettyPretty::endVisit(AST::IdentifierPropertyName *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::StringLiteralPropertyName *node) -{ - QString lit = Engine::toString(node->id); - lit.replace(QLatin1String("\\"), QLatin1String("\\\\")); - out << lit; - return false; -} - -void PrettyPretty::endVisit(AST::StringLiteralPropertyName *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::NumericLiteralPropertyName *node) -{ - out << node->id; - return false; -} - -void PrettyPretty::endVisit(AST::NumericLiteralPropertyName *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::ArrayMemberExpression *node) -{ - accept(node->base); - out << "["; - accept(node->expression); - out << "]"; - return false; -} - -void PrettyPretty::endVisit(AST::ArrayMemberExpression *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::FieldMemberExpression *node) -{ - accept(node->base); - out << "." << Engine::toString(node->name); - return false; -} - -void PrettyPretty::endVisit(AST::FieldMemberExpression *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::NewMemberExpression *node) -{ - out << "new "; - accept(node->base); - out << "("; - accept(node->arguments); - out << ")"; - return false; -} - -void PrettyPretty::endVisit(AST::NewMemberExpression *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::NewExpression *node) -{ - Q_UNUSED(node); - out << "new "; - return true; -} - -void PrettyPretty::endVisit(AST::NewExpression *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::CallExpression *node) -{ - accept(node->base); - out << "("; - accept(node->arguments); - out << ")"; - return false; -} - -void PrettyPretty::endVisit(AST::CallExpression *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::ArgumentList *node) -{ - accept(node->expression); - for (node = node->next; node != 0; node = node->next) { - out << ", "; - accept(node->expression); - } - return false; -} - -void PrettyPretty::endVisit(AST::ArgumentList *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::PostIncrementExpression *node) -{ - Q_UNUSED(node); - return true; -} - -void PrettyPretty::endVisit(AST::PostIncrementExpression *node) -{ - Q_UNUSED(node); - out << "++"; -} - -bool PrettyPretty::visit(AST::PostDecrementExpression *node) -{ - Q_UNUSED(node); - return true; -} - -void PrettyPretty::endVisit(AST::PostDecrementExpression *node) -{ - Q_UNUSED(node); - out << "--"; -} - -bool PrettyPretty::visit(AST::DeleteExpression *node) -{ - Q_UNUSED(node); - out << "delete "; - return true; -} - -void PrettyPretty::endVisit(AST::DeleteExpression *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::VoidExpression *node) -{ - Q_UNUSED(node); - out << "void "; - return true; -} - -void PrettyPretty::endVisit(AST::VoidExpression *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::TypeOfExpression *node) -{ - Q_UNUSED(node); - out << "typeof "; - return true; -} - -void PrettyPretty::endVisit(AST::TypeOfExpression *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::PreIncrementExpression *node) -{ - Q_UNUSED(node); - out << "++"; - return true; -} - -void PrettyPretty::endVisit(AST::PreIncrementExpression *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::PreDecrementExpression *node) -{ - Q_UNUSED(node); - out << "--"; - return true; -} - -void PrettyPretty::endVisit(AST::PreDecrementExpression *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::UnaryPlusExpression *node) -{ - out << "+"; - bool needParens = (node->expression->binaryExpressionCast() != 0); - if (needParens) - out << "("; - accept(node->expression); - if (needParens) - out << ")"; - return false; -} - -void PrettyPretty::endVisit(AST::UnaryPlusExpression *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::UnaryMinusExpression *node) -{ - out << "-"; - bool needParens = (node->expression->binaryExpressionCast() != 0); - if (needParens) - out << "("; - accept(node->expression); - if (needParens) - out << ")"; - return false; -} - -void PrettyPretty::endVisit(AST::UnaryMinusExpression *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::TildeExpression *node) -{ - out << "~"; - bool needParens = (node->expression->binaryExpressionCast() != 0); - if (needParens) - out << "("; - accept(node->expression); - if (needParens) - out << ")"; - return false; -} - -void PrettyPretty::endVisit(AST::TildeExpression *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::NotExpression *node) -{ - out << "!"; - bool needParens = (node->expression->binaryExpressionCast() != 0); - if (needParens) - out << "("; - accept(node->expression); - if (needParens) - out << ")"; - return false; -} - -void PrettyPretty::endVisit(AST::NotExpression *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::BinaryExpression *node) -{ - bool needParens = node->left->binaryExpressionCast() - && (compareOperatorPrecedence(node->left->binaryExpressionCast()->op, node->op) < 0); - if (needParens) - out << "("; - accept(node->left); - if (needParens) - out << ")"; - QString s; - switch (node->op) { - case QSOperator::Add: - s = QLatin1String("+"); break; - case QSOperator::And: - s = QLatin1String("&&"); break; - case QSOperator::InplaceAnd: - s = QLatin1String("&="); break; - case QSOperator::Assign: - s = QLatin1String("="); break; - case QSOperator::BitAnd: - s = QLatin1String("&"); break; - case QSOperator::BitOr: - s = QLatin1String("|"); break; - case QSOperator::BitXor: - s = QLatin1String("^"); break; - case QSOperator::InplaceSub: - s = QLatin1String("-="); break; - case QSOperator::Div: - s = QLatin1String("/"); break; - case QSOperator::InplaceDiv: - s = QLatin1String("/="); break; - case QSOperator::Equal: - s = QLatin1String("=="); break; - case QSOperator::Ge: - s = QLatin1String(">="); break; - case QSOperator::Gt: - s = QLatin1String(">"); break; - case QSOperator::In: - s = QLatin1String("in"); break; - case QSOperator::InplaceAdd: - s = QLatin1String("+="); break; - case QSOperator::InstanceOf: - s = QLatin1String("instanceof"); break; - case QSOperator::Le: - s = QLatin1String("<="); break; - case QSOperator::LShift: - s = QLatin1String("<<"); break; - case QSOperator::InplaceLeftShift: - s = QLatin1String("<<="); break; - case QSOperator::Lt: - s = QLatin1String("<"); break; - case QSOperator::Mod: - s = QLatin1String("%"); break; - case QSOperator::InplaceMod: - s = QLatin1String("%="); break; - case QSOperator::Mul: - s = QLatin1String("*"); break; - case QSOperator::InplaceMul: - s = QLatin1String("*="); break; - case QSOperator::NotEqual: - s = QLatin1String("!="); break; - case QSOperator::Or: - s = QLatin1String("||"); break; - case QSOperator::InplaceOr: - s = QLatin1String("|="); break; - case QSOperator::RShift: - s = QLatin1String(">>"); break; - case QSOperator::InplaceRightShift: - s = QLatin1String(">>="); break; - case QSOperator::StrictEqual: - s = QLatin1String("==="); break; - case QSOperator::StrictNotEqual: - s = QLatin1String("!=="); break; - case QSOperator::Sub: - s = QLatin1String("-"); break; - case QSOperator::URShift: - s = QLatin1String(">>>"); break; - case QSOperator::InplaceURightShift: - s = QLatin1String(">>>="); break; - case QSOperator::InplaceXor: - s = QLatin1String("^="); break; - default: - Q_ASSERT (0); - } - out << " " << s << " "; - needParens = node->right->binaryExpressionCast() - && (compareOperatorPrecedence(node->right->binaryExpressionCast()->op, node->op) <= 0); - if (needParens) - out << "("; - accept(node->right); - if (needParens) - out << ")"; - return false; -} - -void PrettyPretty::endVisit(AST::BinaryExpression *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::ConditionalExpression *node) -{ - accept(node->expression); - out << " ? "; - accept(node->ok); - out << " : "; - accept(node->ko); - return false; -} - -void PrettyPretty::endVisit(AST::ConditionalExpression *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::Expression *node) -{ - accept(node->left); - out << ", "; - accept(node->right); - return false; -} - -void PrettyPretty::endVisit(AST::Expression *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::Block *node) -{ - Q_UNUSED(node); - return true; -} - -void PrettyPretty::endVisit(AST::Block *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::StatementList *node) -{ - accept(node->statement); - for (node = node->next; node != 0; node = node->next) { - newlineAndIndent(); - accept(node->statement); - } - return false; -} - -void PrettyPretty::endVisit(AST::StatementList *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::VariableDeclarationList *node) -{ - AST::VariableDeclarationList *it = node; - - do { - it->declaration->accept(this); - it = it->next; - if (it) - out << ", "; - } while (it); - - return false; -} - -void PrettyPretty::endVisit(AST::VariableDeclarationList *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::VariableStatement *node) -{ - out << "var "; - Q_UNUSED(node); - return true; -} - -void PrettyPretty::endVisit(AST::VariableStatement *node) -{ - Q_UNUSED(node); - out << ";"; -} - -bool PrettyPretty::visit(AST::VariableDeclaration *node) -{ - out << Engine::toString(node->name); - if (node->expression) { - out << " = "; - accept(node->expression); - } - return false; -} - -void PrettyPretty::endVisit(AST::VariableDeclaration *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::EmptyStatement *node) -{ - Q_UNUSED(node); - out << ";"; - return true; -} - -void PrettyPretty::endVisit(AST::EmptyStatement *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::ExpressionStatement *node) -{ - accept(node->expression); - out << ";"; - return false; -} - -void PrettyPretty::endVisit(AST::ExpressionStatement *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::IfStatement *node) -{ - out << "if ("; - accept(node->expression); - out << ") "; - acceptAsBlock(node->ok); - if (node->ko) { - out << " else "; - acceptAsBlock(node->ko); - } - return false; -} - -void PrettyPretty::endVisit(AST::IfStatement *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::DoWhileStatement *node) -{ - out << "do "; - acceptAsBlock(node->statement); - out << " while ("; - accept(node->expression); - out << ");"; - return false; -} - -void PrettyPretty::endVisit(AST::DoWhileStatement *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::WhileStatement *node) -{ - out << "while ("; - accept(node->expression); - out << ") "; - acceptAsBlock(node->statement); - return false; -} - -void PrettyPretty::endVisit(AST::WhileStatement *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::ForStatement *node) -{ - out << "for ("; - accept(node->initialiser); - out << "; "; - accept(node->condition); - out << "; "; - accept(node->expression); - out << ") "; - acceptAsBlock(node->statement); - return false; -} - -void PrettyPretty::endVisit(AST::ForStatement *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::LocalForStatement *node) -{ - out << "for (var "; - accept(node->declarations); - out << "; "; - accept(node->condition); - out << "; "; - accept(node->expression); - out << ") "; - acceptAsBlock(node->statement); - return false; -} - -void PrettyPretty::endVisit(AST::LocalForStatement *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::ForEachStatement *node) -{ - out << "for ("; - accept(node->initialiser); - out << " in "; - accept(node->expression); - out << ") "; - acceptAsBlock(node->statement); - return false; -} - -void PrettyPretty::endVisit(AST::ForEachStatement *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::LocalForEachStatement *node) -{ - out << "for (var "; - accept(node->declaration); - out << " in "; - accept(node->expression); - out << ") "; - acceptAsBlock(node->statement); - return false; -} - -void PrettyPretty::endVisit(AST::LocalForEachStatement *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::ContinueStatement *node) -{ - out << "continue"; - if (node->label) { - out << " " << Engine::toString(node->label); - } - out << ";"; - return false; -} - -void PrettyPretty::endVisit(AST::ContinueStatement *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::BreakStatement *node) -{ - out << "break"; - if (node->label) { - out << " " << Engine::toString(node->label); - } - out << ";"; - return false; -} - -void PrettyPretty::endVisit(AST::BreakStatement *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::ReturnStatement *node) -{ - out << "return"; - if (node->expression) { - out << " "; - accept(node->expression); - } - out << ";"; - return false; -} - -void PrettyPretty::endVisit(AST::ReturnStatement *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::WithStatement *node) -{ - out << "with ("; - accept(node->expression); - out << ") "; - acceptAsBlock(node->statement); - return false; -} - -void PrettyPretty::endVisit(AST::WithStatement *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::SwitchStatement *node) -{ - out << "switch ("; - accept(node->expression); - out << ") "; - acceptAsBlock(node->block); - return false; -} - -void PrettyPretty::endVisit(AST::SwitchStatement *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::CaseBlock *node) -{ - accept(node->clauses); - if (node->defaultClause) { - newlineAndIndent(); - accept(node->defaultClause); - } - if (node->moreClauses) { - newlineAndIndent(); - accept(node->moreClauses); - } - return false; -} - -void PrettyPretty::endVisit(AST::CaseBlock *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::CaseClauses *node) -{ - accept(node->clause); - for (node = node->next; node != 0; node = node->next) { - newlineAndIndent(); - accept(node->clause); - } - return false; -} - -void PrettyPretty::endVisit(AST::CaseClauses *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::CaseClause *node) -{ - out << "case "; - accept(node->expression); - out << ":"; - if (node->statements) { - newlineAndIndent(); - accept(node->statements); - } - return false; -} - -void PrettyPretty::endVisit(AST::CaseClause *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::DefaultClause *node) -{ - Q_UNUSED(node); - out << "default:"; - newlineAndIndent(); - return true; -} - -void PrettyPretty::endVisit(AST::DefaultClause *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::LabelledStatement *node) -{ - out << Engine::toString(node->label) << ": "; - return true; -} - -void PrettyPretty::endVisit(AST::LabelledStatement *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::ThrowStatement *node) -{ - Q_UNUSED(node); - out << "throw "; - accept(node->expression); - out << ";"; - return false; -} - -void PrettyPretty::endVisit(AST::ThrowStatement *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::TryStatement *node) -{ - out << "try "; - acceptAsBlock(node->statement); - if (node->catchExpression) { - out << " catch (" << Engine::toString(node->catchExpression->name) << ") "; - acceptAsBlock(node->catchExpression->statement); - } - if (node->finallyExpression) { - out << " finally "; - acceptAsBlock(node->finallyExpression->statement); - } - return false; -} - -void PrettyPretty::endVisit(AST::TryStatement *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::Catch *node) -{ - Q_UNUSED(node); - return true; -} - -void PrettyPretty::endVisit(AST::Catch *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::Finally *node) -{ - Q_UNUSED(node); - out << "finally "; - return true; -} - -void PrettyPretty::endVisit(AST::Finally *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::FunctionDeclaration *node) -{ - out << "function"; - - if (node->name) - out << " " << Engine::toString(node->name); - - // the arguments - out << "("; - for (AST::FormalParameterList *it = node->formals; it; it = it->next) { - if (it->name) - out << Engine::toString(it->name); - - if (it->next) - out << ", "; - } - out << ")"; - - // the function body - out << " {"; - - if (node->body) { - pushIndentLevel(); - newlineAndIndent(); - accept(node->body); - popIndentLevel(); - newlineAndIndent(); - } - - out << "}"; - - return false; -} - -void PrettyPretty::endVisit(AST::FunctionDeclaration *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::FunctionExpression *node) -{ - out << "function"; - - if (node->name) - out << " " << Engine::toString(node->name); - - // the arguments - out << "("; - for (AST::FormalParameterList *it = node->formals; it; it = it->next) { - if (it->name) - out << Engine::toString(it->name); - - if (it->next) - out << ", "; - } - out << ")"; - - // the function body - out << " {"; - - if (node->body) { - pushIndentLevel(); - newlineAndIndent(); - accept(node->body); - popIndentLevel(); - newlineAndIndent(); - } - - out << "}"; - - return false; -} - -void PrettyPretty::endVisit(AST::FunctionExpression *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::FormalParameterList *node) -{ - Q_UNUSED(node); - return true; -} - -void PrettyPretty::endVisit(AST::FormalParameterList *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::FunctionBody *node) -{ - Q_UNUSED(node); - return true; -} - -void PrettyPretty::endVisit(AST::FunctionBody *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::Program *node) -{ - Q_UNUSED(node); - return true; -} - -void PrettyPretty::endVisit(AST::Program *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::SourceElements *node) -{ - Q_UNUSED(node); - accept(node->element); - for (node = node->next; node != 0; node = node->next) { - newlineAndIndent(); - accept(node->element); - } - return false; -} - -void PrettyPretty::endVisit(AST::SourceElements *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::FunctionSourceElement *node) -{ - Q_UNUSED(node); - return true; -} - -void PrettyPretty::endVisit(AST::FunctionSourceElement *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::StatementSourceElement *node) -{ - Q_UNUSED(node); - return true; -} - -void PrettyPretty::endVisit(AST::StatementSourceElement *node) -{ - Q_UNUSED(node); -} - -bool PrettyPretty::visit(AST::DebuggerStatement *node) -{ - Q_UNUSED(node); - out << "debugger"; - return true; -} - -void PrettyPretty::endVisit(AST::DebuggerStatement *node) -{ - Q_UNUSED(node); - out << ";"; -} - -bool PrettyPretty::preVisit(AST::Node *node) -{ - Q_UNUSED(node); - return true; -} - -QT_END_NAMESPACE - - diff --git a/src/declarative/qml/parser/qmljsprettypretty_p.h b/src/declarative/qml/parser/qmljsprettypretty_p.h deleted file mode 100644 index 3227e7d..0000000 --- a/src/declarative/qml/parser/qmljsprettypretty_p.h +++ /dev/null @@ -1,329 +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 QMLJSPRETTYPRETTY_P_H -#define QMLJSPRETTYPRETTY_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -#include "qmljsastvisitor_p.h" - -QT_BEGIN_NAMESPACE - -class QTextStream; - -namespace QmlJS { - -class PrettyPretty: protected AST::Visitor -{ -public: - PrettyPretty(QTextStream &out); - virtual ~PrettyPretty(); - - QTextStream &operator () (AST::Node *node, int level = 0); - -protected: - void accept(AST::Node *node); - - virtual bool preVisit(AST::Node *node); - - virtual bool visit(AST::ThisExpression *node); - virtual void endVisit(AST::ThisExpression *node); - - virtual bool visit(AST::IdentifierExpression *node); - virtual void endVisit(AST::IdentifierExpression *node); - - virtual bool visit(AST::NullExpression *node); - virtual void endVisit(AST::NullExpression *node); - - virtual bool visit(AST::TrueLiteral *node); - virtual void endVisit(AST::TrueLiteral *node); - - virtual bool visit(AST::FalseLiteral *node); - virtual void endVisit(AST::FalseLiteral *node); - - virtual bool visit(AST::StringLiteral *node); - virtual void endVisit(AST::StringLiteral *node); - - virtual bool visit(AST::NumericLiteral *node); - virtual void endVisit(AST::NumericLiteral *node); - - virtual bool visit(AST::RegExpLiteral *node); - virtual void endVisit(AST::RegExpLiteral *node); - - virtual bool visit(AST::ArrayLiteral *node); - virtual void endVisit(AST::ArrayLiteral *node); - - virtual bool visit(AST::ObjectLiteral *node); - virtual void endVisit(AST::ObjectLiteral *node); - - virtual bool visit(AST::ElementList *node); - virtual void endVisit(AST::ElementList *node); - - virtual bool visit(AST::Elision *node); - virtual void endVisit(AST::Elision *node); - - virtual bool visit(AST::PropertyNameAndValueList *node); - virtual void endVisit(AST::PropertyNameAndValueList *node); - - virtual bool visit(AST::IdentifierPropertyName *node); - virtual void endVisit(AST::IdentifierPropertyName *node); - - virtual bool visit(AST::StringLiteralPropertyName *node); - virtual void endVisit(AST::StringLiteralPropertyName *node); - - virtual bool visit(AST::NumericLiteralPropertyName *node); - virtual void endVisit(AST::NumericLiteralPropertyName *node); - - virtual bool visit(AST::ArrayMemberExpression *node); - virtual void endVisit(AST::ArrayMemberExpression *node); - - virtual bool visit(AST::FieldMemberExpression *node); - virtual void endVisit(AST::FieldMemberExpression *node); - - virtual bool visit(AST::NewMemberExpression *node); - virtual void endVisit(AST::NewMemberExpression *node); - - virtual bool visit(AST::NewExpression *node); - virtual void endVisit(AST::NewExpression *node); - - virtual bool visit(AST::CallExpression *node); - virtual void endVisit(AST::CallExpression *node); - - virtual bool visit(AST::ArgumentList *node); - virtual void endVisit(AST::ArgumentList *node); - - virtual bool visit(AST::PostIncrementExpression *node); - virtual void endVisit(AST::PostIncrementExpression *node); - - virtual bool visit(AST::PostDecrementExpression *node); - virtual void endVisit(AST::PostDecrementExpression *node); - - virtual bool visit(AST::DeleteExpression *node); - virtual void endVisit(AST::DeleteExpression *node); - - virtual bool visit(AST::VoidExpression *node); - virtual void endVisit(AST::VoidExpression *node); - - virtual bool visit(AST::TypeOfExpression *node); - virtual void endVisit(AST::TypeOfExpression *node); - - virtual bool visit(AST::PreIncrementExpression *node); - virtual void endVisit(AST::PreIncrementExpression *node); - - virtual bool visit(AST::PreDecrementExpression *node); - virtual void endVisit(AST::PreDecrementExpression *node); - - virtual bool visit(AST::UnaryPlusExpression *node); - virtual void endVisit(AST::UnaryPlusExpression *node); - - virtual bool visit(AST::UnaryMinusExpression *node); - virtual void endVisit(AST::UnaryMinusExpression *node); - - virtual bool visit(AST::TildeExpression *node); - virtual void endVisit(AST::TildeExpression *node); - - virtual bool visit(AST::NotExpression *node); - virtual void endVisit(AST::NotExpression *node); - - virtual bool visit(AST::BinaryExpression *node); - virtual void endVisit(AST::BinaryExpression *node); - - virtual bool visit(AST::ConditionalExpression *node); - virtual void endVisit(AST::ConditionalExpression *node); - - virtual bool visit(AST::Expression *node); - virtual void endVisit(AST::Expression *node); - - virtual bool visit(AST::Block *node); - virtual void endVisit(AST::Block *node); - - virtual bool visit(AST::StatementList *node); - virtual void endVisit(AST::StatementList *node); - - virtual bool visit(AST::VariableStatement *node); - virtual void endVisit(AST::VariableStatement *node); - - virtual bool visit(AST::VariableDeclarationList *node); - virtual void endVisit(AST::VariableDeclarationList *node); - - virtual bool visit(AST::VariableDeclaration *node); - virtual void endVisit(AST::VariableDeclaration *node); - - virtual bool visit(AST::EmptyStatement *node); - virtual void endVisit(AST::EmptyStatement *node); - - virtual bool visit(AST::ExpressionStatement *node); - virtual void endVisit(AST::ExpressionStatement *node); - - virtual bool visit(AST::IfStatement *node); - virtual void endVisit(AST::IfStatement *node); - - virtual bool visit(AST::DoWhileStatement *node); - virtual void endVisit(AST::DoWhileStatement *node); - - virtual bool visit(AST::WhileStatement *node); - virtual void endVisit(AST::WhileStatement *node); - - virtual bool visit(AST::ForStatement *node); - virtual void endVisit(AST::ForStatement *node); - - virtual bool visit(AST::LocalForStatement *node); - virtual void endVisit(AST::LocalForStatement *node); - - virtual bool visit(AST::ForEachStatement *node); - virtual void endVisit(AST::ForEachStatement *node); - - virtual bool visit(AST::LocalForEachStatement *node); - virtual void endVisit(AST::LocalForEachStatement *node); - - virtual bool visit(AST::ContinueStatement *node); - virtual void endVisit(AST::ContinueStatement *node); - - virtual bool visit(AST::BreakStatement *node); - virtual void endVisit(AST::BreakStatement *node); - - virtual bool visit(AST::ReturnStatement *node); - virtual void endVisit(AST::ReturnStatement *node); - - virtual bool visit(AST::WithStatement *node); - virtual void endVisit(AST::WithStatement *node); - - virtual bool visit(AST::SwitchStatement *node); - virtual void endVisit(AST::SwitchStatement *node); - - virtual bool visit(AST::CaseBlock *node); - virtual void endVisit(AST::CaseBlock *node); - - virtual bool visit(AST::CaseClauses *node); - virtual void endVisit(AST::CaseClauses *node); - - virtual bool visit(AST::CaseClause *node); - virtual void endVisit(AST::CaseClause *node); - - virtual bool visit(AST::DefaultClause *node); - virtual void endVisit(AST::DefaultClause *node); - - virtual bool visit(AST::LabelledStatement *node); - virtual void endVisit(AST::LabelledStatement *node); - - virtual bool visit(AST::ThrowStatement *node); - virtual void endVisit(AST::ThrowStatement *node); - - virtual bool visit(AST::TryStatement *node); - virtual void endVisit(AST::TryStatement *node); - - virtual bool visit(AST::Catch *node); - virtual void endVisit(AST::Catch *node); - - virtual bool visit(AST::Finally *node); - virtual void endVisit(AST::Finally *node); - - virtual bool visit(AST::FunctionDeclaration *node); - virtual void endVisit(AST::FunctionDeclaration *node); - - virtual bool visit(AST::FunctionExpression *node); - virtual void endVisit(AST::FunctionExpression *node); - - virtual bool visit(AST::FormalParameterList *node); - virtual void endVisit(AST::FormalParameterList *node); - - virtual bool visit(AST::FunctionBody *node); - virtual void endVisit(AST::FunctionBody *node); - - virtual bool visit(AST::Program *node); - virtual void endVisit(AST::Program *node); - - virtual bool visit(AST::SourceElements *node); - virtual void endVisit(AST::SourceElements *node); - - virtual bool visit(AST::FunctionSourceElement *node); - virtual void endVisit(AST::FunctionSourceElement *node); - - virtual bool visit(AST::StatementSourceElement *node); - virtual void endVisit(AST::StatementSourceElement *node); - - virtual bool visit(AST::DebuggerStatement *node); - virtual void endVisit(AST::DebuggerStatement *node); - - int indentLevel(int level) - { - int was = m_indentLevel; - m_indentLevel = level; - return was; - } - - void pushIndentLevel() - { ++m_indentLevel; } - - void popIndentLevel() - { --m_indentLevel; } - - QTextStream &newlineAndIndent(); - - void acceptAsBlock(AST::Node *node); - - static int operatorPrecedenceLevel(int op); - static int compareOperatorPrecedence(int op1, int op2); - -private: - QTextStream &out; - int m_indentLevel; - - Q_DISABLE_COPY(PrettyPretty) -}; - -} // namespace QmlJS - -QT_END_NAMESPACE - -#endif -- cgit v0.12 From f38b9107f95fc71ae53d43678dd1163719f64631 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 30 Jul 2009 10:52:09 +1000 Subject: More QFxItem cleanup. --- doc/src/images/declarative-transformorigin.png | Bin 17468 -> 8927 bytes src/declarative/fx/qfxitem.cpp | 35 +++++++------------------ src/declarative/fx/qfxitem.h | 19 +++++--------- src/declarative/fx/qfxitem_p.h | 4 +-- 4 files changed, 17 insertions(+), 41 deletions(-) diff --git a/doc/src/images/declarative-transformorigin.png b/doc/src/images/declarative-transformorigin.png index fbb3b9b..4af320f 100644 Binary files a/doc/src/images/declarative-transformorigin.png and b/doc/src/images/declarative-transformorigin.png differ diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 4e66f55..cc86b03 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -795,7 +795,7 @@ void QFxItem::setQml(const QUrl &qml) return; if (!d->_qml.isEmpty()) { - QmlChildren::Iterator iter = d->_qmlChildren.find(d->_qml.toString()); + QHash::Iterator iter = d->_qmlChildren.find(d->_qml.toString()); if (iter != d->_qmlChildren.end()) (*iter)->setOpacity(0.); } @@ -808,7 +808,7 @@ void QFxItem::setQml(const QUrl &qml) return; } - QmlChildren::Iterator iter = d->_qmlChildren.find(d->_qml.toString()); + QHash::Iterator iter = d->_qmlChildren.find(d->_qml.toString()); if (iter != d->_qmlChildren.end()) { (*iter)->setOpacity(1.); d->qmlItem = (*iter); @@ -1793,19 +1793,19 @@ QPointF QFxItemPrivate::computeTransformOrigin() const default: case QFxItem::TopLeft: return QPointF(0, 0); - case QFxItem::TopCenter: + case QFxItem::Top: return QPointF(br.width() / 2., 0); case QFxItem::TopRight: return QPointF(br.width(), 0); - case QFxItem::MiddleLeft: + case QFxItem::Left: return QPointF(0, br.height() / 2.); case QFxItem::Center: return QPointF(br.width() / 2., br.height() / 2.); - case QFxItem::MiddleRight: + case QFxItem::Right: return QPointF(br.width(), br.height() / 2.); case QFxItem::BottomLeft: return QPointF(0, br.height()); - case QFxItem::BottomCenter: + case QFxItem::Bottom: return QPointF(br.width() / 2., br.height()); case QFxItem::BottomRight: return QPointF(br.width(), br.height()); @@ -1891,13 +1891,13 @@ void QFxItem::parentChanged(QFxItem *, QFxItem *) Controls the point about which simple transforms like scale apply. \value TopLeft The top-left corner of the item. - \value TopCenter The center point of the top of the item. + \value Top The center point of the top of the item. \value TopRight The top-right corner of the item. - \value MiddleLeft The left most point of the vertical middle. + \value Left The left most point of the vertical middle. \value Center The center of the item. - \value MiddleRight The right most point of the vertical middle. + \value Right The right most point of the vertical middle. \value BottomLeft The bottom-left corner of the item. - \value BottomCenter The center point of the bottom of the item. + \value Bottom The center point of the bottom of the item. \value BottomRight The bottom-right corner of the item. */ @@ -2085,16 +2085,6 @@ bool QFxItem::hasActiveFocus() const return QGraphicsItem::hasFocus(); } -bool QFxItem::activeFocusPanel() const -{ - return false; -} - -void QFxItem::setActiveFocusPanel(bool b) -{ - Q_UNUSED(b) -} - bool QFxItem::sceneEventFilter(QGraphicsItem *w, QEvent *e) { switch(e->type()) { @@ -2129,11 +2119,6 @@ void QFxItem::setOptions(Options options, bool set) else d->options &= ~options; - if ((d->options & IsFocusPanel) && (d->options & IsFocusRealm)) { - qWarning("QFxItem::setOptions: Cannot set both IsFocusPanel and IsFocusRealm. IsFocusRealm will be unset."); - d->options &= ~IsFocusRealm; - } - setFlag(QGraphicsItem::ItemHasNoContents, !(d->options & HasContents)); setFiltersChildEvents(d->options & ChildMouseFilter); setFlag(QGraphicsItem::ItemAcceptsInputMethod, (d->options & AcceptsInputMethods)); diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index cd346a7..0ce2a11 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -124,10 +124,10 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta Q_INTERFACES(QmlParserStatus) Q_PROPERTY(QFxItem * parent READ parentItem WRITE setParentItem NOTIFY parentChanged DESIGNABLE false FINAL) + Q_PROPERTY(QmlList *data READ data DESIGNABLE false) Q_PROPERTY(QmlList* children READ children DESIGNABLE false) Q_PROPERTY(QmlList* resources READ resources DESIGNABLE false) Q_PROPERTY(QFxAnchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL) - Q_PROPERTY(QmlList *data READ data DESIGNABLE false) Q_PROPERTY(QFxContents * contents READ contents DESIGNABLE false CONSTANT FINAL) Q_PROPERTY(QmlList* states READ states DESIGNABLE false) Q_PROPERTY(QmlList* transitions READ transitions DESIGNABLE false) @@ -147,13 +147,11 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta Q_PROPERTY(bool clip READ clip WRITE setClip) // ### move to QGI/QGO, NOTIFY Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL) Q_PROPERTY(bool activeFocus READ hasActiveFocus NOTIFY activeFocusChanged FINAL) - Q_PROPERTY(QmlList* transform READ transform DESIGNABLE false FINAL) // ## QGI/QGO - Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin) // ### move to QGI + Q_PROPERTY(QmlList* transform READ transform DESIGNABLE false FINAL) + Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin) Q_ENUMS(TransformOrigin) Q_CLASSINFO("DefaultProperty", "data") - typedef QHash QmlChildren; // ### - public: enum Option { NoOption = 0x00000000, MouseFilter = 0x00000001, @@ -162,15 +160,14 @@ public: MouseEvents = 0x00000008, HasContents = 0x00000010, SimpleItem = 0x00000020, - IsFocusPanel = 0x00000040, IsFocusRealm = 0x00000080, AcceptsInputMethods = 0x00000100 }; Q_DECLARE_FLAGS(Options, Option) enum TransformOrigin { - TopLeft, TopCenter, TopRight, - MiddleLeft, Center, MiddleRight, - BottomLeft, BottomCenter, BottomRight + TopLeft, Top, TopRight, + Left, Center, Right, + BottomLeft, Bottom, BottomRight }; QFxItem(QFxItem *parent = 0); @@ -185,7 +182,6 @@ public: QmlList *resources(); QFxAnchors *anchors(); - QFxContents *contents(); bool clip() const; @@ -234,9 +230,6 @@ public: virtual bool hasFocus() const; void setFocus(bool); - bool activeFocusPanel() const; - void setActiveFocusPanel(bool); - bool hasActiveFocus() const; QVariant inputMethodQuery(Qt::InputMethodQuery query) const; //### for KeyProxy diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index 77d0673..33200e4 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -71,8 +71,6 @@ class QFxItemPrivate : public QGraphicsItemPrivate { Q_DECLARE_PUBLIC(QFxItem) - typedef QHash QmlChildren; - public: QFxItemPrivate() : _anchors(0), _contents(0), qmlItem(0), _qmlcomp(0), @@ -163,7 +161,7 @@ public: bool _componentComplete:1; bool _keepMouse:1; - QmlChildren _qmlChildren; + QHash _qmlChildren; struct AnchorLines { AnchorLines(QFxItem *); -- cgit v0.12 From 674291cc996a10210321b64ea80cf20d0cc678d4 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 30 Jul 2009 11:14:39 +1000 Subject: Don't disconnect item size connections if the item is referenced. --- src/declarative/fx/qfxlistview.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index 5f1defd..268ced1 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -439,10 +439,6 @@ void QFxListViewPrivate::releaseItem(FxListItem *item) Q_Q(QFxListView); if (!item) return; - if (orient == Qt::Vertical) - QObject::disconnect(item->item, SIGNAL(heightChanged()), q, SLOT(itemResized())); - else - QObject::disconnect(item->item, SIGNAL(widthChanged()), q, SLOT(itemResized())); if (trackedItem == item) { const char *notifier1 = orient == Qt::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged()); const char *notifier2 = orient == Qt::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged()); @@ -453,6 +449,10 @@ void QFxListViewPrivate::releaseItem(FxListItem *item) if (model->release(item->item) == 0) { // item was not destroyed, and we no longer reference it. unrequestedItems.insert(item->item, model->indexOf(item->item, q)); + if (orient == Qt::Vertical) + QObject::disconnect(item->item, SIGNAL(heightChanged()), q, SLOT(itemResized())); + else + QObject::disconnect(item->item, SIGNAL(widthChanged()), q, SLOT(itemResized())); } delete item; } -- cgit v0.12 From 1779358f9c91119acf81278cddc275870861d600 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 30 Jul 2009 11:17:45 +1000 Subject: Removed unused code. --- src/declarative/fx/qfxlistview.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index 268ced1..62b2cf8 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -1386,19 +1386,6 @@ void QFxListView::trackedPositionChanged() d->setPosition(d->trackedItem->position() - d->snapPos); break; } - } else if (d->fixCurrentVisibility && d->currentItem && !d->pressed) { - /* - if (d->trackedItem->position() < d->position() - && d->currentItem->position() < d->position()) { - d->setPosition(d->trackedItem->position()); - } else if (d->size() && d->trackedItem->size() <= d->size() - && d->trackedItem->endPosition() > d->position() + d->size() - && d->currentItem->endPosition() > d->position() + d->size()) { - d->setPosition(d->trackedItem->endPosition() - d->size()); - } - if (d->trackedItem->position() == d->currentItem->position()) - d->fixCurrentVisibility = false; - */ } } -- cgit v0.12 From 74464120794c2f41c5c6d8d9b34b4de2d1c3635c Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 30 Jul 2009 11:18:06 +1000 Subject: More QFxItem cleanup. --- src/declarative/extra/qfxflowview.cpp | 1 - src/declarative/extra/qfxparticles.cpp | 6 +++--- src/declarative/fx/qfxflickable.cpp | 2 +- src/declarative/fx/qfximage.cpp | 6 ++---- src/declarative/fx/qfxitem.cpp | 29 ----------------------------- src/declarative/fx/qfxitem.h | 10 +--------- src/declarative/fx/qfxkeyproxy.cpp | 6 +++--- src/declarative/fx/qfxlineedit.cpp | 4 ++-- src/declarative/fx/qfxmouseregion_p.h | 2 +- src/declarative/fx/qfxpathview_p.h | 2 +- src/declarative/fx/qfxrect.cpp | 4 ++-- src/declarative/fx/qfxtext.cpp | 4 ++-- src/declarative/fx/qfxtextedit.cpp | 4 ++-- src/declarative/fx/qfxwebview.cpp | 2 +- 14 files changed, 21 insertions(+), 61 deletions(-) diff --git a/src/declarative/extra/qfxflowview.cpp b/src/declarative/extra/qfxflowview.cpp index 1757c5a..e9b836d 100644 --- a/src/declarative/extra/qfxflowview.cpp +++ b/src/declarative/extra/qfxflowview.cpp @@ -71,7 +71,6 @@ QFxFlowView::QFxFlowView() : m_columns(0), m_model(0), m_vertical(false), m_dragItem(0), m_dragIdx(-1) { setAcceptedMouseButtons(Qt::LeftButton); - setOptions(MouseEvents); } QFxVisualItemModel *QFxFlowView::model() const diff --git a/src/declarative/extra/qfxparticles.cpp b/src/declarative/extra/qfxparticles.cpp index 13c14b0..0f22165 100644 --- a/src/declarative/extra/qfxparticles.cpp +++ b/src/declarative/extra/qfxparticles.cpp @@ -343,7 +343,7 @@ public: QFxParticlesPainter(QFxParticlesPrivate *p, QFxItem* parent) : QFxItem(parent), d(p) { - setOptions(HasContents); + setFlag(QGraphicsItem::ItemHasNoContents, false); maxX = minX = maxY = minY = 0; } @@ -600,7 +600,7 @@ QFxParticles::QFxParticles(QFxItem *parent) { Q_D(QFxParticles); d->init(); - setOptions(HasContents); + setFlag(QGraphicsItem::ItemHasNoContents, false); } QFxParticles::QFxParticles(QFxParticlesPrivate &dd, QFxItem *parent) @@ -608,7 +608,7 @@ QFxParticles::QFxParticles(QFxParticlesPrivate &dd, QFxItem *parent) { Q_D(QFxParticles); d->init(); - setOptions(HasContents); + setFlag(QGraphicsItem::ItemHasNoContents, false); } QFxParticles::~QFxParticles() diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp index e73c8a4..bd0c1be 100644 --- a/src/declarative/fx/qfxflickable.cpp +++ b/src/declarative/fx/qfxflickable.cpp @@ -111,7 +111,7 @@ void QFxFlickablePrivate::init() QObject::connect(&_tl, SIGNAL(updated()), q, SLOT(ticked())); QObject::connect(&_tl, SIGNAL(completed()), q, SLOT(movementEnding())); q->setAcceptedMouseButtons(Qt::LeftButton); - q->setOptions(QFxItem::ChildMouseFilter | QFxItem::MouseEvents); + q->setOptions(QFxItem::ChildMouseFilter); QObject::connect(_flick, SIGNAL(xChanged()), q, SIGNAL(positionChanged())); QObject::connect(_flick, SIGNAL(yChanged()), q, SIGNAL(positionChanged())); QObject::connect(&elasticX, SIGNAL(updated()), q, SLOT(ticked())); diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index e54dd9b..f1be4a4 100644 --- a/src/declarative/fx/qfximage.cpp +++ b/src/declarative/fx/qfximage.cpp @@ -113,13 +113,13 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Image,QFxImage) QFxImage::QFxImage(QFxItem *parent) : QFxItem(*(new QFxImagePrivate), parent) { - setOptions(SimpleItem | HasContents, true); + setFlag(QGraphicsItem::ItemHasNoContents, false); } QFxImage::QFxImage(QFxImagePrivate &dd, QFxItem *parent) : QFxItem(dd, parent) { - setOptions(SimpleItem | HasContents, true); + setFlag(QGraphicsItem::ItemHasNoContents, false); } QFxImage::~QFxImage() @@ -561,7 +561,6 @@ void QFxImage::requestFinished() d->status = Error; } d->pix = QFxPixmap(d->url); - setOptions(QFxImage::SimpleItem, true); } setImplicitWidth(d->pix.width()); setImplicitHeight(d->pix.height()); @@ -612,7 +611,6 @@ void QFxImage::setGridScaledImage(const QFxGridScaledImage& sci) sg->setBottom(sci.gridBottom()); sg->setLeft(sci.gridLeft()); sg->setRight(sci.gridRight()); - setOptions(QFxImage::SimpleItem, false); d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl())); d->reply = QFxPixmap::get(qmlEngine(this), d->sciurl, this, SLOT(requestFinished())); diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index cc86b03..bb001c5 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1689,31 +1689,6 @@ QmlList* QFxItem::transform() } /*! - Creates a new child of the given component \a type. The - newChildCreated() signal will be emitted when and if the child is - successfully created. - - \preliminary -*/ -void QFxItem::newChild(const QString &type) -{ - Q_D(QFxItem); - - QUrl url = qmlContext(this)->resolvedUrl(QUrl(type)); - if (url.isEmpty()) - return; - - d->_qmlnewloading.append(url); - d->_qmlnewcomp.append(new QmlComponent(qmlEngine(this), url, this)); - - if (!d->_qmlnewcomp.last()->isLoading()) - qmlLoaded(); - else - connect(d->_qmlnewcomp.last(), SIGNAL(statusChanged(QmlComponent::Status)), - this, SLOT(qmlLoaded())); -} - -/*! classBegin() is called when the item is constructed, but its properties have not yet been set. @@ -2119,11 +2094,7 @@ void QFxItem::setOptions(Options options, bool set) else d->options &= ~options; - setFlag(QGraphicsItem::ItemHasNoContents, !(d->options & HasContents)); setFiltersChildEvents(d->options & ChildMouseFilter); - setFlag(QGraphicsItem::ItemAcceptsInputMethod, (d->options & AcceptsInputMethods)); - setAcceptHoverEvents(d->options & HoverEvents); - setFlag(QGraphicsItem::ItemAutoDetectsFocusProxy, d->options & IsFocusRealm); if ((old & MouseFilter) != (d->options & MouseFilter)) { diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 0ce2a11..221f057 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -156,12 +156,7 @@ public: enum Option { NoOption = 0x00000000, MouseFilter = 0x00000001, ChildMouseFilter = 0x00000002, - HoverEvents = 0x00000004, - MouseEvents = 0x00000008, - HasContents = 0x00000010, - SimpleItem = 0x00000020, - IsFocusRealm = 0x00000080, - AcceptsInputMethods = 0x00000100 }; + IsFocusRealm = 0x00000080 }; Q_DECLARE_FLAGS(Options, Option) enum TransformOrigin { @@ -234,9 +229,6 @@ public: QVariant inputMethodQuery(Qt::InputMethodQuery query) const; //### for KeyProxy -public Q_SLOTS: - void newChild(const QString &url); - Q_SIGNALS: void xChanged(); void yChanged(); diff --git a/src/declarative/fx/qfxkeyproxy.cpp b/src/declarative/fx/qfxkeyproxy.cpp index 13f4bfb..0a9a151 100644 --- a/src/declarative/fx/qfxkeyproxy.cpp +++ b/src/declarative/fx/qfxkeyproxy.cpp @@ -96,7 +96,7 @@ public: QFxKeyProxy::QFxKeyProxy(QFxItem *parent) : QFxItem(parent), d(new QFxKeyProxyPrivate) { - setOptions(AcceptsInputMethods); + setFlag(QGraphicsItem::ItemAcceptsInputMethod); } QFxKeyProxy::~QFxKeyProxy() @@ -166,7 +166,7 @@ void QFxKeyProxy::inputMethodEvent(QInputMethodEvent *e) d->inIM = true; for (int ii = 0; ii < d->targets.count(); ++ii) { QFxItem *i = qobject_cast(scene()->focusItem(d->targets.at(ii))); - if (i && (i->options() & AcceptsInputMethods)) { + if (i && (i->flags() & ItemAcceptsInputMethod)) { scene()->sendEvent(i, e); if (e->isAccepted()) { d->imeItem = i; @@ -183,7 +183,7 @@ QVariant QFxKeyProxy::inputMethodQuery(Qt::InputMethodQuery query) const { for (int ii = 0; ii < d->targets.count(); ++ii) { QFxItem *i = qobject_cast(scene()->focusItem(d->targets.at(ii))); - if (i && (i->options() & AcceptsInputMethods) && i == d->imeItem) { //### how robust is i == d->imeItem check? + if (i && (i->flags() & ItemAcceptsInputMethod) && i == d->imeItem) { //### how robust is i == d->imeItem check? QVariant v = i->inputMethodQuery(query); if (v.type() == QVariant::RectF) v = mapRectFromItem(i, v.toRectF()); //### cost? diff --git a/src/declarative/fx/qfxlineedit.cpp b/src/declarative/fx/qfxlineedit.cpp index a185383..bef77e7 100644 --- a/src/declarative/fx/qfxlineedit.cpp +++ b/src/declarative/fx/qfxlineedit.cpp @@ -475,8 +475,8 @@ void QFxLineEditPrivate::init() control->setLayoutDirection(Qt::LeftToRight); q->setSmooth(true); q->setAcceptedMouseButtons(Qt::LeftButton); - q->setOptions(QFxLineEdit::AcceptsInputMethods | QFxLineEdit::SimpleItem - | QFxLineEdit::HasContents | QFxLineEdit::MouseEvents); + q->setFlag(QGraphicsItem::ItemHasNoContents, false); + q->setFlag(QGraphicsItem::ItemAcceptsInputMethod); q->connect(control, SIGNAL(cursorPositionChanged(int,int)), q, SLOT(cursorPosChanged())); q->connect(control, SIGNAL(selectionChanged()), diff --git a/src/declarative/fx/qfxmouseregion_p.h b/src/declarative/fx/qfxmouseregion_p.h index 70d78f3..f03c334 100644 --- a/src/declarative/fx/qfxmouseregion_p.h +++ b/src/declarative/fx/qfxmouseregion_p.h @@ -74,7 +74,7 @@ public: { Q_Q(QFxMouseRegion); q->setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton); - q->setOptions(QFxItem::HoverEvents | QFxItem::MouseEvents); + q->setAcceptHoverEvents(true); } void saveEvent(QGraphicsSceneMouseEvent *event) { diff --git a/src/declarative/fx/qfxpathview_p.h b/src/declarative/fx/qfxpathview_p.h index be9509f..eeccc87 100644 --- a/src/declarative/fx/qfxpathview_p.h +++ b/src/declarative/fx/qfxpathview_p.h @@ -87,7 +87,7 @@ public: Q_Q(QFxPathView); _offset = 0; q->setAcceptedMouseButtons(Qt::NoButton); - q->setOptions(QFxItem::ChildMouseFilter | QFxItem::MouseEvents | QFxItem::IsFocusRealm); + q->setOptions(QFxItem::ChildMouseFilter | QFxItem::IsFocusRealm); q->connect(&tl, SIGNAL(updated()), q, SLOT(ticked())); } diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp index 7010ba1..58bd50c 100644 --- a/src/declarative/fx/qfxrect.cpp +++ b/src/declarative/fx/qfxrect.cpp @@ -239,7 +239,7 @@ QFxRect::QFxRect(QFxItem *parent) { Q_D(QFxRect); d->init(); - setOptions(HasContents, true); + setFlag(QGraphicsItem::ItemHasNoContents, false); } QFxRect::QFxRect(QFxRectPrivate &dd, QFxItem *parent) @@ -247,7 +247,7 @@ QFxRect::QFxRect(QFxRectPrivate &dd, QFxItem *parent) { Q_D(QFxRect); d->init(); - setOptions(HasContents, true); + setFlag(QGraphicsItem::ItemHasNoContents, false); } void QFxRect::doUpdate() diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp index e0692e9..cb8af40 100644 --- a/src/declarative/fx/qfxtext.cpp +++ b/src/declarative/fx/qfxtext.cpp @@ -110,7 +110,7 @@ QFxText::QFxText(QFxItem *parent) Q_D(QFxText); d->init(); setAcceptedMouseButtons(Qt::LeftButton); - setOptions(SimpleItem | HasContents | QFxText::MouseEvents); + setFlag(QGraphicsItem::ItemHasNoContents, false); } QFxText::QFxText(QFxTextPrivate &dd, QFxItem *parent) @@ -119,7 +119,7 @@ QFxText::QFxText(QFxTextPrivate &dd, QFxItem *parent) Q_D(QFxText); d->init(); setAcceptedMouseButtons(Qt::LeftButton); - setOptions(SimpleItem | HasContents | QFxText::MouseEvents); + setFlag(QGraphicsItem::ItemHasNoContents, false); } QFxText::~QFxText() diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp index abad7fc..b632268 100644 --- a/src/declarative/fx/qfxtextedit.cpp +++ b/src/declarative/fx/qfxtextedit.cpp @@ -1016,8 +1016,8 @@ void QFxTextEditPrivate::init() q->setSmooth(true); q->setAcceptedMouseButtons(Qt::LeftButton); - q->setOptions(QFxTextEdit::AcceptsInputMethods | QFxTextEdit::SimpleItem - | QFxTextEdit::HasContents | QFxTextEdit::MouseEvents); + q->setFlag(QGraphicsItem::ItemHasNoContents, false); + q->setFlag(QGraphicsItem::ItemAcceptsInputMethod); QObject::connect(&font, SIGNAL(updated()), q, SLOT(fontChanged())); diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp index 83f9249..75cb624 100644 --- a/src/declarative/fx/qfxwebview.cpp +++ b/src/declarative/fx/qfxwebview.cpp @@ -236,7 +236,7 @@ void QFxWebView::init() Q_D(QFxWebView); setAcceptedMouseButtons(Qt::LeftButton); - setOptions(HasContents | MouseEvents); + setFlag(QGraphicsItem::ItemHasNoContents, false); d->page = 0; } -- cgit v0.12 From ab625efe61c4bd4c59064648d75da6d46acdc762 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 30 Jul 2009 11:51:42 +1000 Subject: Move paint margin functionality to QFxRect. --- src/declarative/fx/qfxitem.cpp | 11 +---------- src/declarative/fx/qfxitem.h | 1 - src/declarative/fx/qfxitem_p.h | 4 +--- src/declarative/fx/qfxrect.cpp | 8 +++++++- src/declarative/fx/qfxrect.h | 5 +++-- src/declarative/fx/qfxrect_p.h | 16 ++++++++++++---- 6 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index bb001c5..7eaaf8e 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1836,19 +1836,10 @@ void QFxItem::childrenChanged() { } -void QFxItem::setPaintMargin(qreal margin) -{ - Q_D(QFxItem); - if (margin == d->paintmargin) - return; - prepareGeometryChange(); - d->paintmargin = margin; -} - QRectF QFxItem::boundingRect() const { Q_D(const QFxItem); - return QRectF(-d->paintmargin, -d->paintmargin, d->width+d->paintmargin*2, d->height+d->paintmargin*2); + return QRectF(0, 0, d->width, d->height); } void QFxItem::paintContents(QPainter &) diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 221f057..932d44c 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -217,7 +217,6 @@ public: TransformOrigin transformOrigin() const; void setTransformOrigin(TransformOrigin); - void setPaintMargin(qreal margin); QRectF boundingRect() const; virtual void paintContents(QPainter &); diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index 33200e4..a013897 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -79,8 +79,7 @@ public: _anchorLines(0), _stateGroup(0), canvas(0), origin(QFxItem::TopLeft), options(QFxItem::NoOption), - widthValid(false), heightValid(false), width(0), height(0), - paintmargin(0) + widthValid(false), heightValid(false), width(0), height(0) {} ~QFxItemPrivate() { delete _anchors; } @@ -194,7 +193,6 @@ public: qreal width; qreal height; - qreal paintmargin; QPointF computeTransformOrigin() const; diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp index 58bd50c..c43e034 100644 --- a/src/declarative/fx/qfxrect.cpp +++ b/src/declarative/fx/qfxrect.cpp @@ -255,7 +255,7 @@ void QFxRect::doUpdate() Q_D(QFxRect); d->rectImage = QPixmap(); const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0; - setPaintMargin((pw+1)/2); + d->setPaintMargin((pw+1)/2); update(); } @@ -605,4 +605,10 @@ void QFxRect::drawRect(QPainter &p) } } +QRectF QFxRect::boundingRect() const +{ + Q_D(const QFxRect); + return QRectF(-d->paintmargin, -d->paintmargin, d->width+d->paintmargin*2, d->height+d->paintmargin*2); +} + QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxrect.h b/src/declarative/fx/qfxrect.h index 7790af1..d438459 100644 --- a/src/declarative/fx/qfxrect.h +++ b/src/declarative/fx/qfxrect.h @@ -157,6 +157,8 @@ public: qreal radius() const; void setRadius(qreal radius); + QRectF boundingRect() const; + void paintContents(QPainter &painter); private Q_SLOTS: @@ -165,9 +167,8 @@ private Q_SLOTS: private: void generateRoundedRect(); void generateBorderedRect(); -#if defined(QFX_RENDER_QPAINTER) void drawRect(QPainter &painter); -#endif + protected: QFxRect(QFxRectPrivate &dd, QFxItem *parent); diff --git a/src/declarative/fx/qfxrect_p.h b/src/declarative/fx/qfxrect_p.h index 3544d36..25fa38d 100644 --- a/src/declarative/fx/qfxrect_p.h +++ b/src/declarative/fx/qfxrect_p.h @@ -58,14 +58,14 @@ QT_BEGIN_NAMESPACE class QFxGradient; - +class QFxRect; class QFxRectPrivate : public QFxItemPrivate { Q_DECLARE_PUBLIC(QFxRect) public: QFxRectPrivate() : - color(Qt::white), gradient(0), pen(0), radius(0) + color(Qt::white), gradient(0), pen(0), radius(0), paintmargin(0) { } @@ -92,9 +92,17 @@ public: } QFxPen *pen; qreal radius; -#if defined(QFX_RENDER_QPAINTER) + qreal paintmargin; QPixmap rectImage; -#endif + + void setPaintMargin(qreal margin) + { + Q_Q(QFxRect); + if (margin == paintmargin) + return; + q->prepareGeometryChange(); + paintmargin = margin; + } }; QT_END_NAMESPACE -- cgit v0.12 From 926f4dec5d8b55308799e016cb99a1e481a49f3c Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 30 Jul 2009 11:57:03 +1000 Subject: maxYExtent() should never be greater than minYExtent() --- src/declarative/fx/qfxlistview.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index 62b2cf8..3d97dfa 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -548,7 +548,6 @@ void QFxListViewPrivate::layout() if (!isValid()) return; q->refill(); - q->trackedPositionChanged(); updateHighlight(); if (orient == Qt::Vertical) { fixupY(); @@ -588,6 +587,8 @@ void QFxListViewPrivate::updateTrackedItem() if (highlight) item = highlight; + FxListItem *oldTracked = trackedItem; + const char *notifier1 = orient == Qt::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged()); const char *notifier2 = orient == Qt::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged()); @@ -601,9 +602,8 @@ void QFxListViewPrivate::updateTrackedItem() trackedItem = item; QObject::connect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged())); QObject::connect(trackedItem->item, notifier2, q, SLOT(trackedPositionChanged())); - q->trackedPositionChanged(); } - if (trackedItem) + if (trackedItem && trackedItem != oldTracked) q->trackedPositionChanged(); } @@ -1274,8 +1274,9 @@ qreal QFxListView::maxYExtent() const extent = -(d->positionAt(count()-1) - d->snapPos); else extent = -(d->endPosition() - height()); - if (extent > 0) - extent = 0; + qreal minY = minYExtent(); + if (extent > minY) + extent = minY; return extent; } @@ -1307,8 +1308,9 @@ qreal QFxListView::maxXExtent() const extent = -(d->positionAt(count()-1) - d->snapPos); else extent = -(d->endPosition() - width()); - if (extent > 0) - extent = 0; + qreal minX = minXExtent(); + if (extent > minX) + extent = minX; return extent; } -- cgit v0.12 From caad9036009cd68e40ae469fb978ba6122cecb12 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 30 Jul 2009 15:39:36 +1000 Subject: More QFxItem cleanup. --- src/declarative/fx/qfxitem.cpp | 14 ++------------ src/declarative/fx/qfxitem.h | 3 --- src/declarative/fx/qfxkeyproxy.cpp | 12 ++++++++++-- src/declarative/fx/qfxrepeater.cpp | 11 ++++++++--- src/declarative/fx/qfxrepeater.h | 2 +- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 7eaaf8e..569af43 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -446,8 +446,6 @@ void QFxItem::setParentItem(QFxItem *parent) QObject::setParent(parent); QGraphicsObject::setParentItem(parent); - - parentChanged(parent, oldParent); } /*! @@ -1822,6 +1820,8 @@ QVariant QFxItem::itemChange(GraphicsItemChange change, } else if (change == ItemChildAddedChange || change == ItemChildRemovedChange) { childrenChanged(); + } else if (change == ItemParentHasChanged) { + emit parentChanged(); } return QGraphicsItem::itemChange(change, value); @@ -1846,11 +1846,6 @@ void QFxItem::paintContents(QPainter &) { } -void QFxItem::parentChanged(QFxItem *, QFxItem *) -{ - emit parentChanged(); -} - /*! \enum QFxItem::TransformOrigin @@ -2115,9 +2110,4 @@ void QFxItemPrivate::gvAddMouseFilter() q->installSceneEventFilter(q); } -QVariant QFxItem::inputMethodQuery(Qt::InputMethodQuery query) const -{ - return QGraphicsItem::inputMethodQuery(query); -} - QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 932d44c..ba3ab4f 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -226,8 +226,6 @@ public: void setFocus(bool); bool hasActiveFocus() const; - QVariant inputMethodQuery(Qt::InputMethodQuery query) const; //### for KeyProxy - Q_SIGNALS: void xChanged(); void yChanged(); @@ -257,7 +255,6 @@ protected: virtual void classBegin(); virtual void componentComplete(); - virtual void parentChanged(QFxItem *, QFxItem *); virtual void focusChanged(bool); virtual void activeFocusChanged(bool); virtual void keyPressEvent(QKeyEvent *event); diff --git a/src/declarative/fx/qfxkeyproxy.cpp b/src/declarative/fx/qfxkeyproxy.cpp index 0a9a151..85ecc39 100644 --- a/src/declarative/fx/qfxkeyproxy.cpp +++ b/src/declarative/fx/qfxkeyproxy.cpp @@ -179,12 +179,20 @@ void QFxKeyProxy::inputMethodEvent(QInputMethodEvent *e) } } -QVariant QFxKeyProxy::inputMethodQuery(Qt::InputMethodQuery query) const +class QFxItemAccessor : public QFxItem { +public: + QVariant doInputMethodQuery(Qt::InputMethodQuery query) const { + return QFxItem::inputMethodQuery(query); + } +}; + +QVariant QFxKeyProxy::inputMethodQuery(Qt::InputMethodQuery query) const +{ for (int ii = 0; ii < d->targets.count(); ++ii) { QFxItem *i = qobject_cast(scene()->focusItem(d->targets.at(ii))); if (i && (i->flags() & ItemAcceptsInputMethod) && i == d->imeItem) { //### how robust is i == d->imeItem check? - QVariant v = i->inputMethodQuery(query); + QVariant v = static_cast(i)->doInputMethodQuery(query); if (v.type() == QVariant::RectF) v = mapRectFromItem(i, v.toRectF()); //### cost? return v; diff --git a/src/declarative/fx/qfxrepeater.cpp b/src/declarative/fx/qfxrepeater.cpp index a231f20..8f30324 100644 --- a/src/declarative/fx/qfxrepeater.cpp +++ b/src/declarative/fx/qfxrepeater.cpp @@ -244,10 +244,15 @@ void QFxRepeater::componentComplete() /*! \internal */ -void QFxRepeater::parentChanged(QFxItem *o, QFxItem *n) +QVariant QFxRepeater::itemChange(GraphicsItemChange change, + const QVariant &value) { - QFxItem::parentChanged(o, n); - regenerate(); + QVariant rv = QFxItem::itemChange(change, value); + if (change == ItemParentHasChanged) { + regenerate(); + } + + return rv; } /*! diff --git a/src/declarative/fx/qfxrepeater.h b/src/declarative/fx/qfxrepeater.h index 6f950d3..7fa914e 100644 --- a/src/declarative/fx/qfxrepeater.h +++ b/src/declarative/fx/qfxrepeater.h @@ -73,7 +73,7 @@ private: protected: virtual void componentComplete(); - virtual void parentChanged(QFxItem *, QFxItem *); + QVariant itemChange(GraphicsItemChange change, const QVariant &value); QFxRepeater(QFxRepeaterPrivate &dd, QFxItem *parent); private: -- cgit v0.12 From f7b08934580ddc2716fbf4ac3ecd9684158d3cf7 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 30 Jul 2009 16:03:36 +1000 Subject: Video size and aspect ratio. --- tools/qmlviewer/qmlviewer.cpp | 36 +++- tools/qmlviewer/qmlviewer.h | 1 + tools/qmlviewer/recopts.ui | 407 ++++++++++++++++++++++++++++++------------ 3 files changed, 326 insertions(+), 118 deletions(-) diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index d7d8b82..098f749 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -298,7 +298,7 @@ void QmlViewer::createMenu(QMenuBar *menu, QMenu *flatmenu) connect(recordAction, SIGNAL(triggered()), this, SLOT(toggleRecordingWithSelection())); recordMenu->addAction(recordAction); - QAction *recordOptions = new QAction(tr("Recording &Options..."), parent); + QAction *recordOptions = new QAction(tr("Video &Options..."), parent); connect(recordOptions, SIGNAL(triggered()), this, SLOT(chooseRecordingOptions())); recordMenu->addAction(recordOptions); @@ -416,7 +416,17 @@ void QmlViewer::pickRecordingFile() void QmlViewer::chooseRecordingOptions() { + // File recdlg->file->setText(record_file); + + // Size + recdlg->sizeOriginal->setText(tr("Original (%1x%2)").arg(canvas->width()).arg(canvas->height())); + if (recdlg->sizeWidth->value()<=1) { + recdlg->sizeWidth->setValue(canvas->width()); + recdlg->sizeHeight->setValue(canvas->height()); + } + + // Rate if (record_rate == 24) recdlg->hz24->setChecked(true); else if (record_rate == 25) @@ -429,9 +439,24 @@ void QmlViewer::chooseRecordingOptions() recdlg->hzCustom->setChecked(true); recdlg->hz->setText(QString::number(record_rate)); } + + // Profile recdlg->setArguments(record_args.join(" ")); if (recdlg->exec()) { + // File record_file = recdlg->file->text(); + // Size + if (recdlg->sizeOriginal->isChecked()) + record_outsize = QSize(); + else if (recdlg->size720p->isChecked()) + record_outsize = QSize(1280,720); + else if (recdlg->sizeVGA->isChecked()) + record_outsize = QSize(640,480); + else if (recdlg->sizeQVGA->isChecked()) + record_outsize = QSize(320,240); + else + record_outsize = QSize(recdlg->sizeWidth->value(),recdlg->sizeHeight->value()); + // Rate if (recdlg->hz24->isChecked()) record_rate = 24; else if (recdlg->hz25->isChecked()) @@ -443,6 +468,7 @@ void QmlViewer::chooseRecordingOptions() else { record_rate = recdlg->hz->text().toDouble(); } + // Profile record_args = recdlg->arguments().split(" ",QString::SkipEmptyParts); } } @@ -686,7 +712,7 @@ void QmlViewer::senseFfmpeg() proc.waitForFinished(2000); QString ffmpegHelp = proc.readAllStandardOutput(); ffmpegAvailable = ffmpegHelp.contains("-s "); - ffmpegHelp = tr("Video recording use ffmpeg:")+"\n\n"+ffmpegHelp; + ffmpegHelp = tr("Video recording uses ffmpeg:")+"\n\n"+ffmpegHelp; QDialog *d = new QDialog(recdlg); QVBoxLayout *l = new QVBoxLayout(d); @@ -729,6 +755,10 @@ void QmlViewer::setRecording(bool on) args << "-pix_fmt" << (frame_fmt == ".gif" ? "rgb24" : "rgb32"); args << "-s" << QString("%1x%2").arg(canvas->width()).arg(canvas->height()); args << "-i" << "-"; + if (record_outsize.isValid()) { + args << "-s" << QString("%1x%2").arg(record_outsize.width()).arg(record_outsize.height()); + args << "-aspect" << QString::number(double(canvas->width())/canvas->height()); + } args += record_args; args << record_file; proc->start("ffmpeg",args); @@ -770,6 +800,8 @@ void QmlViewer::setRecording(bool on) break; QString name; name.sprintf(framename.toLocal8Bit(),frame++); + if (record_outsize.isValid()) + *img = img->scaled(record_outsize,Qt::IgnoreAspectRatio,Qt::SmoothTransformation); if (record_dither=="ordered") img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither|Qt::OrderedDither).save(name); else if (record_dither=="threshold") diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h index e3864eb..914f77d 100644 --- a/tools/qmlviewer/qmlviewer.h +++ b/tools/qmlviewer/qmlviewer.h @@ -88,6 +88,7 @@ private: QmlTimer autoStopTimer; QString record_dither; QString record_file; + QSize record_outsize; QStringList record_args; int record_rate; int record_autotime; diff --git a/tools/qmlviewer/recopts.ui b/tools/qmlviewer/recopts.ui index 041a4c4..ce2da30 100644 --- a/tools/qmlviewer/recopts.ui +++ b/tools/qmlviewer/recopts.ui @@ -6,133 +6,194 @@ 0 0 - 290 - 297 + 316 + 436 - Recording options + Video options - - - - - - 0 - 0 - - - - File: - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - + + + + + + + + 0 + 0 + + + + File: + + + + + + + + + + ... + + + + - - - - ... + + + + Size - - - - - - 0 - - - + + - Profile: + + + + true - - + + + + VGA + + - - + + + + 720p + + - - + + - Help + QVGA + + + + + + Width: + + + + + + + 1 + + + 9999 + + + + + + + + 0 + 0 + + + + Height: + + + + + + + 1 + + + 9999 + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 40 + 20 + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 40 + 20 + + + + - - - - - 0 - + + + + Rate + + - + - + 0 0 - Rate: + 60Hz - - - - - - 24Hz + + true - + 50Hz - + 25Hz - - - - - 0 - 0 - - - - 60Hz - - - true - - - - + 0 @@ -178,6 +239,9 @@ Qt::Horizontal + + QSizePolicy::MinimumExpanding + 40 @@ -188,31 +252,110 @@ + + + + 24Hz + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + - - - - Qt::Vertical - - - - 20 - 40 - + + + + Profile - + + + + + + + + + + + Help + + + + + - + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + file + pickfile + sizeOriginal + sizeVGA + size720p + sizeQVGA + sizeCustom + sizeWidth + sizeHeight + hz60 + hz25 + hz50 + hz24 + hzCustom + hz + profile + args + ffmpegHelp + buttonBox + @@ -222,12 +365,12 @@ setFocus() - 54 - 104 + 43 + 257 - 85 - 107 + 129 + 262 @@ -238,12 +381,12 @@ toggle() - 138 - 102 + 143 + 262 - 49 - 104 + 43 + 257 @@ -254,12 +397,12 @@ toggle() - 110 - 105 + 143 + 262 - 51 - 103 + 43 + 257 @@ -270,8 +413,8 @@ accept() - 280 - 287 + 258 + 424 60 @@ -286,8 +429,8 @@ reject() - 280 - 287 + 258 + 424 92 @@ -302,8 +445,8 @@ pickProfile(int) - 72 - 132 + 92 + 329 48 @@ -318,8 +461,8 @@ storeCustomArgs(QString) - 108 - 161 + 128 + 357 102 @@ -327,6 +470,38 @@ + + sizeWidth + valueChanged(int) + sizeCustom + toggle() + + + 108 + 133 + + + 48 + 133 + + + + + sizeHeight + valueChanged(int) + sizeCustom + toggle() + + + 212 + 133 + + + 64 + 129 + + + filePicked(QString) -- cgit v0.12 From a70f8a2b0966420e1911554a117e066592b1822c Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 30 Jul 2009 16:03:49 +1000 Subject: More QFxItem cleanup. --- src/declarative/fx/qfxitem.cpp | 40 ---------------------------------------- src/declarative/fx/qfxitem.h | 3 --- src/declarative/fx/qfxitem_p.h | 3 --- 3 files changed, 46 deletions(-) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 569af43..6df538e 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1592,18 +1592,6 @@ QmlList* QFxItem::transitions() */ /*! - Returns the state with \a name. Returns 0 if no matching state is found. -*/ -QmlState *QFxItem::findState(const QString &name) const -{ - Q_D(const QFxItem); - if (!d->_stateGroup) - return 0; - else - return d->_stateGroup->findState(name); -} - -/*! \qmlproperty string Item::state This property holds the name of the current state of the item. @@ -1809,14 +1797,7 @@ QVariant QFxItem::itemChange(GraphicsItemChange change, { Q_D(QFxItem); if (change == ItemSceneHasChanged) { - if (options() & QFxItem::MouseFilter) - d->gvRemoveMouseFilter(); - d->canvas = qvariant_cast(value); - - if (options() & QFxItem::MouseFilter) - d->gvAddMouseFilter(); - } else if (change == ItemChildAddedChange || change == ItemChildRemovedChange) { childrenChanged(); @@ -2082,13 +2063,6 @@ void QFxItem::setOptions(Options options, bool set) setFiltersChildEvents(d->options & ChildMouseFilter); setFlag(QGraphicsItem::ItemAutoDetectsFocusProxy, d->options & IsFocusRealm); - - if ((old & MouseFilter) != (d->options & MouseFilter)) { - if (d->options & MouseFilter) - d->gvAddMouseFilter(); - else - d->gvRemoveMouseFilter(); - } } void QFxItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) @@ -2096,18 +2070,4 @@ void QFxItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) paintContents(*p); } -void QFxItemPrivate::gvRemoveMouseFilter() -{ - Q_Q(QFxItem); - if (q->scene()) - q->removeSceneEventFilter(q); -} - -void QFxItemPrivate::gvAddMouseFilter() -{ - Q_Q(QFxItem); - if (q->scene()) - q->installSceneEventFilter(q); -} - QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index ba3ab4f..c31b8bb 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -154,7 +154,6 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta public: enum Option { NoOption = 0x00000000, - MouseFilter = 0x00000001, ChildMouseFilter = 0x00000002, IsFocusRealm = 0x00000080 }; Q_DECLARE_FLAGS(Options, Option) @@ -183,8 +182,6 @@ public: void setClip(bool); QmlList* states(); - QmlState *findState(const QString &name) const; - QmlList* transitions(); QString state() const; diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index a013897..181c91d 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -196,9 +196,6 @@ public: QPointF computeTransformOrigin() const; - void gvRemoveMouseFilter(); - void gvAddMouseFilter(); - virtual void setPosHelper(const QPointF &pos) { Q_Q(QFxItem); -- cgit v0.12 From 136c8210cc98bc6d9b17fd4d517d9d399f30e6c2 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 30 Jul 2009 16:58:42 +1000 Subject: Don't bounce around when removing the current item. --- src/declarative/fx/qfxlistview.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index 3d97dfa..a78fed5 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -278,6 +278,18 @@ public: return -1; } + int lastVisibleIndex() const { + int lastIndex = -1; + for (int i = visibleItems.count()-1; i >= 0; --i) { + FxListItem *listItem = visibleItems.at(i); + if (listItem->index != -1) { + lastIndex = listItem->index; + break; + } + } + return lastIndex; + } + // map a model index to visibleItems index. // These may differ if removed items are still present in the visible list, // e.g. doing a removal animation @@ -542,7 +554,7 @@ void QFxListViewPrivate::layout() pos += item->size(); } // move current item if it is after the visible items. - if (currentItem && currentIndex > visibleItems.last()->index) + if (currentItem && currentIndex > lastVisibleIndex()) currentItem->setPosition(currentItem->position() + (visibleItems.last()->endPosition() - oldEnd)); } if (!isValid()) @@ -647,7 +659,8 @@ void QFxListViewPrivate::createHighlight() const QLatin1String posProp(orient == Qt::Vertical ? "y" : "x"); highlightPosAnimator = new QmlFollow(q); highlightPosAnimator->setTarget(QmlMetaProperty(highlight->item, posProp)); - highlightPosAnimator->setSpring(3); + highlightPosAnimator->setEpsilon(0.25); + highlightPosAnimator->setSpring(2.5); highlightPosAnimator->setDamping(0.3); highlightPosAnimator->setEnabled(autoHighlight); const QLatin1String sizeProp(orient == Qt::Vertical ? "height" : "width"); -- cgit v0.12 From 8358e5b93efcb119cc7dd036c8f5f4ae960f702e Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 30 Jul 2009 11:55:50 +0200 Subject: Fixed AST visiting, so UiProgram *members* are visited again. --- src/declarative/qml/parser/qmljsast.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/declarative/qml/parser/qmljsast.cpp b/src/declarative/qml/parser/qmljsast.cpp index caf81e5..11a98b6 100644 --- a/src/declarative/qml/parser/qmljsast.cpp +++ b/src/declarative/qml/parser/qmljsast.cpp @@ -792,6 +792,7 @@ void UiProgram::accept0(Visitor *visitor) { if (visitor->visit(this)) { accept(imports, visitor); + accept(members, visitor); } visitor->endVisit(this); -- cgit v0.12 From 0ce2bedf9b5da9d480b994a9b812c37d1f5caa39 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 31 Jul 2009 09:39:53 +1000 Subject: Introduce Loader item. The Loader item takes the qml/qmlItem functionality from Item and moves it to a specialized subclass. --- demos/declarative/contacts/contacts.qml | 16 +- doc/src/declarative/elements.qdoc | 1 + doc/src/tutorials/declarative.qdoc | 16 +- examples/declarative/flowview/flowview.qml | 2 +- examples/declarative/loader/loader.qml | 6 +- .../contacts/1_Drawing_and_Animation/GroupBox.qml | 8 +- .../tutorials/contacts/2_Reuse/1a/ContactField.qml | 8 +- .../tutorials/contacts/2_Reuse/GroupBox.qml | 8 +- .../contacts/3_Collections/3/ContactView.qml | 12 +- .../tutorials/contacts/3_Collections/GroupBox.qml | 8 +- src/declarative/fx/fx.pri | 3 + src/declarative/fx/qfxitem.cpp | 146 ---------------- src/declarative/fx/qfxitem.h | 12 +- src/declarative/fx/qfxitem_p.h | 9 +- src/declarative/fx/qfxloader.cpp | 188 +++++++++++++++++++++ src/declarative/fx/qfxloader.h | 85 ++++++++++ src/declarative/fx/qfxloader_p.h | 80 +++++++++ 17 files changed, 403 insertions(+), 205 deletions(-) create mode 100644 src/declarative/fx/qfxloader.cpp create mode 100644 src/declarative/fx/qfxloader.h create mode 100644 src/declarative/fx/qfxloader_p.h diff --git a/demos/declarative/contacts/contacts.qml b/demos/declarative/contacts/contacts.qml index 189a5d7..6bd7b21 100644 --- a/demos/declarative/contacts/contacts.qml +++ b/demos/declarative/contacts/contacts.qml @@ -42,7 +42,7 @@ Rect { MouseRegion { anchors.fill: parent onClicked: { - Details.qml = 'Contact.qml'; + Details.source = 'Contact.qml'; wrapper.state ='opened'; contacts.mode = 'edit'; } @@ -67,27 +67,27 @@ Rect { } ] } - Item { + Loader { id: Details anchors.fill: wrapper opacity: 0 Bind { - target: Details.qmlItem + target: Details.item property: "contactId" value: model.recid } Bind { - target: Details.qmlItem + target: Details.item property: "label" value: model.label } Bind { - target: Details.qmlItem + target: Details.item property: "phone" value: model.phone } Bind { - target: Details.qmlItem + target: Details.item property: "email" value: model.email } @@ -130,7 +130,7 @@ Rect { signal: "clicked()" script: { if (wrapper.state == 'opened' && !contacts.mouseGrabbed) { - Details.qmlItem.update(); + Details.item.update(); wrapper.state = ''; contacts.mode = 'list'; contactList.exec(); @@ -154,7 +154,7 @@ Rect { signal: "confirmed()" script: { if (wrapper.state == 'opened' && !contacts.mouseGrabbed) { - Details.qmlItem.remove(); + Details.item.remove(); wrapper.state = ''; contacts.mode = 'list'; contactList.exec(); diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index 88b5963..63cd377 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -94,6 +94,7 @@ The following table lists the Qml elements provided by the Qt Declarative module \o \list +\o \l Loader \o \l Repeater \o \l ComponentInstance \o \l GraphicsObjectContainer diff --git a/doc/src/tutorials/declarative.qdoc b/doc/src/tutorials/declarative.qdoc index 3fad672..b7a4d7d 100644 --- a/doc/src/tutorials/declarative.qdoc +++ b/doc/src/tutorials/declarative.qdoc @@ -402,9 +402,9 @@ This can be useful when the component is not complex enough to justify its own file. The third way to reuse components allows for delaying loading - of the QML until some later event. Each \l{Item}{Item} includes - a special child, qmlItem, which has its definition provided by the - contents of the qml property of its parent. + of the QML until some later event. \l{Loader}{Loader} includes + a special child, item, which has its definition provided by the + contents of the source property of the loader. \snippet declarative/tutorials/contacts/2_Reuse/1a/ContactField.qml load @@ -656,8 +656,8 @@ \snippet declarative/tutorials/contacts/3_Collections/3/ContactView.qml setting qml - Each item has a qml property that represents the filename for the contents of - a special qmlItem child of the \l{Item}{Item}. By setting the qml property of the Details + \l{Loader}{Loader} has a source property that represents the filename for the contents of + a special item child of the \l{Loader}{Loader}. By setting the source property of the Details component on clicking the mouse region, the more complex component isn't loaded until needed. The down side about this though is the properties of Contact cannot be set until the item is loaded. This requires using the Bind element. @@ -667,8 +667,8 @@ Unlike binding a value to the property of a component directly, the Bind element allows both the target and the property set to themselves be to dynamic values. - This means that when the qml property is set, it will change the - qmlItem property of the Details component. This in turn triggers the Bind - elements to set the required properties of the qmlItem, which is now + This means that when the source property is set, it will change the + item property of the Details component. This in turn triggers the Bind + elements to set the required properties of the item, which is now an instance of the Contact component. */ diff --git a/examples/declarative/flowview/flowview.qml b/examples/declarative/flowview/flowview.qml index 77b3230..ff15d96 100644 --- a/examples/declarative/flowview/flowview.qml +++ b/examples/declarative/flowview/flowview.qml @@ -45,7 +45,7 @@ Rect { delegate: Package { Item { id: List; Package.name: "list"; width:120; height: 400; } Item { id: Grid; Package.name: "grid"; width:400; height: 120; } - Item { id: MyContent; width:400; height: 120; qml: weblet } + Loader { id: MyContent; width:400; height: 120; source: weblet } StateGroup { states: [ diff --git a/examples/declarative/loader/loader.qml b/examples/declarative/loader/loader.qml index 447d73a..f507651 100644 --- a/examples/declarative/loader/loader.qml +++ b/examples/declarative/loader/loader.qml @@ -1,8 +1,10 @@ import Qt 4.6 Rect { - id: Shell width: 300 height: 400 - qml: "Browser.qml" + Loader { + anchors.fill: parent + source: "Browser.qml" + } } diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/GroupBox.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/GroupBox.qml index 42feeb1..29e00d9 100644 --- a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/GroupBox.qml +++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/GroupBox.qml @@ -17,15 +17,15 @@ FocusRealm { height: groupBox.height-20 color: "white" pen.color: "black" - Item { + Loader { id: subItem - qml: groupBox.contents + source: groupBox.contents anchors.top: parent.top anchors.topMargin: 10 anchors.right: parent.right anchors.rightMargin: 10 - width: qmlItem.width - height: qmlItem.height + width: item.width + height: item.height } } Rect { diff --git a/examples/declarative/tutorials/contacts/2_Reuse/1a/ContactField.qml b/examples/declarative/tutorials/contacts/2_Reuse/1a/ContactField.qml index e3081b9..cf50fb0 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/1a/ContactField.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/1a/ContactField.qml @@ -6,11 +6,11 @@ Item { clip: true width: 230 height: 30 - Item { + Loader { id: removeButton - qml: "RemoveButton.qml" - width: qmlItem.width - height: qmlItem.height + source: "RemoveButton.qml" + width: item.width + height: item.height anchors.right: parent.right anchors.top: parent.top anchors.bottom: parent.bottom diff --git a/examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml b/examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml index 42feeb1..29e00d9 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml @@ -17,15 +17,15 @@ FocusRealm { height: groupBox.height-20 color: "white" pen.color: "black" - Item { + Loader { id: subItem - qml: groupBox.contents + source: groupBox.contents anchors.top: parent.top anchors.topMargin: 10 anchors.right: parent.right anchors.rightMargin: 10 - width: qmlItem.width - height: qmlItem.height + width: item.width + height: item.height } } Rect { diff --git a/examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml b/examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml index 46e09a0..cc115e3 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml @@ -56,33 +56,33 @@ Item { MouseRegion { anchors.fill: label onClicked: { - Details.qml = 'Contact.qml'; + Details.source = 'Contact.qml'; wrapper.state='opened'; } } - Item { + Loader { id: Details anchors.fill: parent opacity: 0 //! [setting qml] //! [binding] Bind { - target: Details.qmlItem + target: Details.item property: "contactId" value: model.recid } Bind { - target: Details.qmlItem + target: Details.item property: "label" value: model.label } Bind { - target: Details.qmlItem + target: Details.item property: "phone" value: model.phone } Bind { - target: Details.qmlItem + target: Details.item property: "email" value: model.email } diff --git a/examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml b/examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml index 42feeb1..29e00d9 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml @@ -17,15 +17,15 @@ FocusRealm { height: groupBox.height-20 color: "white" pen.color: "black" - Item { + Loader { id: subItem - qml: groupBox.contents + source: groupBox.contents anchors.top: parent.top anchors.topMargin: 10 anchors.right: parent.right anchors.rightMargin: 10 - width: qmlItem.width - height: qmlItem.height + width: item.width + height: item.height } } Rect { diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri index 9b4b5ab..e43c0cb 100644 --- a/src/declarative/fx/fx.pri +++ b/src/declarative/fx/fx.pri @@ -19,6 +19,8 @@ HEADERS += \ fx/qfxkeyproxy.h \ fx/qfxlayouts.h \ fx/qfxlayouts_p.h \ + fx/qfxloader.h \ + fx/qfxloader_p.h \ fx/qfxmouseregion.h \ fx/qfxmouseregion_p.h \ fx/qfxpath.h \ @@ -55,6 +57,7 @@ SOURCES += \ fx/qfxkeyactions.cpp \ fx/qfxkeyproxy.cpp \ fx/qfxlayouts.cpp \ + fx/qfxloader.cpp \ fx/qfxmouseregion.cpp \ fx/qfxpath.cpp \ fx/qfxpathview.cpp \ diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 6df538e..709a243 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -51,7 +51,6 @@ #include #include -#include #include "qmlstate.h" #include "qlistmodelinterface.h" #include "qfxanchors_p.h" @@ -743,151 +742,6 @@ void QFxItem::setClip(bool c) } /*! - \internal - \property QFxItem::qmlItem -*/ - -/*! \fn QFxItem *QFxItem::qmlItem() const - \internal - */ -QFxItem *QFxItem::qmlItem() const -{ - Q_D(const QFxItem); - return d->qmlItem; -} - -/*! - \qmlproperty url Item::qml - This property holds the dynamic URL of the QML for the item. - - This property is used for dynamically loading QML into the - item. Querying for the QML only has meaning if the QML has been - dynamically set; otherwise an empty URL is returned. -*/ - -/*! \fn void QFxItem::qmlChanged() - This signal is emitted whenever the item's dynamic QML - string changes. - - \sa setQml() - */ - -/*! - \property QFxItem::qml - This property holds the dynamic URL of the QML for the item. - - This property is used for dynamically loading QML into the - item. Querying for the QML only has meaning if the QML has been - dynamically set; otherwise an empty URL is returned. -*/ -QUrl QFxItem::qml() const -{ - Q_D(const QFxItem); - return d->_qml; -} - -void QFxItem::setQml(const QUrl &qml) -{ - Q_D(QFxItem); - if (d->_qml == qml) - return; - - if (!d->_qml.isEmpty()) { - QHash::Iterator iter = d->_qmlChildren.find(d->_qml.toString()); - if (iter != d->_qmlChildren.end()) - (*iter)->setOpacity(0.); - } - - d->_qml = qml; - d->qmlItem = 0; - - if (d->_qml.isEmpty()) { - emit qmlChanged(); - return; - } - - QHash::Iterator iter = d->_qmlChildren.find(d->_qml.toString()); - if (iter != d->_qmlChildren.end()) { - (*iter)->setOpacity(1.); - d->qmlItem = (*iter); - emit qmlChanged(); - } else { - d->_qmlcomp = - new QmlComponent(qmlEngine(this), d->_qml, this); - if (!d->_qmlcomp->isLoading()) - qmlLoaded(); - else - QObject::connect(d->_qmlcomp, SIGNAL(statusChanged(QmlComponent::Status)), - this, SLOT(qmlLoaded())); - } -} - -/*! \fn void QFxItem::newChildCreated(const QString &url, QScriptValue v) - This signal is emitted with the \a url and the script value \a v, - when a new child is created. - */ - -/*! - \internal - */ -void QFxItem::qmlLoaded() -{ - Q_D(QFxItem); - - { // newChild... - // ### - for (int i=0; i_qmlnewloading.length(); ++i) { - QmlComponent *c = d->_qmlnewcomp.at(i); - if (c->isLoading()) - continue; - - QmlContext *ctxt = new QmlContext(qmlContext(this)); - QObject* o = c ? c->create(ctxt):0; - QFxItem* ret = qobject_cast(o); - if (ret) { - ret->setParentItem(this); - QScriptValue v = QmlEnginePrivate::getScriptEngine(qmlEngine(this))->newQObject(ret); - emit newChildCreated(d->_qmlnewloading.at(i).toString(),v); - } - - delete c; - d->_qmlnewloading.removeAt(i); - d->_qmlnewcomp.removeAt(i); - --i; - } - } - - // setQml... - if (d->_qmlcomp) { - QmlContext *ctxt = new QmlContext(qmlContext(this)); - ctxt->addDefaultObject(this); - - if (!d->_qmlcomp->errors().isEmpty()) { - qWarning() << d->_qmlcomp->errors(); - delete d->_qmlcomp; - d->_qmlcomp = 0; - emit qmlChanged(); - return; - } - QObject *obj = d->_qmlcomp->create(ctxt); - if (!d->_qmlcomp->errors().isEmpty()) - qWarning() << d->_qmlcomp->errors(); - QFxItem *qmlChild = qobject_cast(obj); - if (qmlChild) { - qmlChild->setParentItem(this); - d->_qmlChildren.insert(d->_qml.toString(), qmlChild); - d->qmlItem = qmlChild; - } else { - delete qmlChild; - d->_qml = QUrl(); - } - delete d->_qmlcomp; - d->_qmlcomp = 0; - emit qmlChanged(); - } -} - -/*! \qmlproperty real Item::x \qmlproperty real Item::y \qmlproperty real Item::width diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index c31b8bb..884a6d8 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -127,15 +127,13 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta Q_PROPERTY(QmlList *data READ data DESIGNABLE false) Q_PROPERTY(QmlList* children READ children DESIGNABLE false) Q_PROPERTY(QmlList* resources READ resources DESIGNABLE false) - Q_PROPERTY(QFxAnchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL) - Q_PROPERTY(QFxContents * contents READ contents DESIGNABLE false CONSTANT FINAL) Q_PROPERTY(QmlList* states READ states DESIGNABLE false) Q_PROPERTY(QmlList* transitions READ transitions DESIGNABLE false) Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged) - Q_PROPERTY(QUrl qml READ qml WRITE setQml NOTIFY qmlChanged) // ### name? Move to own class? - Q_PROPERTY(QFxItem *qmlItem READ qmlItem NOTIFY qmlChanged) // ### see above Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged FINAL) Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged FINAL) + Q_PROPERTY(QFxContents * contents READ contents DESIGNABLE false CONSTANT FINAL) + Q_PROPERTY(QFxAnchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL) Q_PROPERTY(QFxAnchorLine left READ left CONSTANT FINAL) Q_PROPERTY(QFxAnchorLine right READ right CONSTANT FINAL) Q_PROPERTY(QFxAnchorLine horizontalCenter READ horizontalCenter CONSTANT FINAL) @@ -187,10 +185,6 @@ public: QString state() const; void setState(const QString &); - QFxItem *qmlItem() const; - QUrl qml() const; - void setQml(const QUrl &); - qreal baselineOffset() const; void setBaselineOffset(qreal); @@ -238,7 +232,6 @@ Q_SIGNALS: void rotationChanged(); void scaleChanged(); void qmlChanged(); - void newChildCreated(const QString &url, QScriptValue); protected: bool isComponentComplete() const; @@ -261,7 +254,6 @@ protected: private Q_SLOTS: void doUpdate(); - void qmlLoaded(); protected: QFxItem(QFxItemPrivate &dd, QFxItem *parent = 0); diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index 181c91d..862171b 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -73,7 +73,7 @@ class QFxItemPrivate : public QGraphicsItemPrivate public: QFxItemPrivate() - : _anchors(0), _contents(0), qmlItem(0), _qmlcomp(0), + : _anchors(0), _contents(0), _baselineOffset(0), _componentComplete(true), _keepMouse(false), _anchorLines(0), @@ -149,19 +149,12 @@ public: QList dependantAnchors; QFxAnchors *_anchors; QFxContents *_contents; - QFxItem *qmlItem; - QmlComponent *_qmlcomp; - QUrl _qml; - QList _qmlnewloading; - QList _qmlnewcomp; QmlNullableValue _baselineOffset; bool _componentComplete:1; bool _keepMouse:1; - QHash _qmlChildren; - struct AnchorLines { AnchorLines(QFxItem *); QFxAnchorLine left; diff --git a/src/declarative/fx/qfxloader.cpp b/src/declarative/fx/qfxloader.cpp new file mode 100644 index 0000000..7cf85af --- /dev/null +++ b/src/declarative/fx/qfxloader.cpp @@ -0,0 +1,188 @@ +/**************************************************************************** +** +** 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 "qfxloader_p.h" +#include + +QT_BEGIN_NAMESPACE + +QFxLoaderPrivate::QFxLoaderPrivate() +: item(0), qmlcomp(0) +{ +} + +QFxLoaderPrivate::~QFxLoaderPrivate() +{ +} + +QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Loader,QFxLoader) + +/*! + \qmlclass Loader + \inherits Item + + \brief The Loader item allows you to dynamically load an Item-based + subtree from a QML URL. + */ + +/*! + \internal + \class QFxLoader + \qmlclass Loader + */ + +/*! + Create a new QFxLoader instance. + */ +QFxLoader::QFxLoader(QFxItem *parent) + : QFxItem(*(new QFxLoaderPrivate), parent) +{ +} + +/*! + Destroy the loader instance. + */ +QFxLoader::~QFxLoader() +{ +} + +/*! + \internal + \fn void QFxItem::sourceChanged() + This signal is emitted whenever the item's dynamic QML + source url changes. + */ + +/*! + \qmlproperty url Loader::source + This property holds the dynamic URL of the QML for the item. + + This property is used for dynamically loading QML into the + item. +*/ +QUrl QFxLoader::source() const +{ + Q_D(const QFxLoader); + return d->source; +} + +void QFxLoader::setSource(const QUrl &url) +{ + Q_D(QFxLoader); + if (d->source == url) + return; + + if (!d->source.isEmpty()) { + QHash::Iterator iter = d->cachedChildren.find(d->source.toString()); + if (iter != d->cachedChildren.end()) + (*iter)->setOpacity(0.); + } + + d->source = url; + d->item = 0; + + if (d->source.isEmpty()) { + emit sourceChanged(); + return; + } + + QHash::Iterator iter = d->cachedChildren.find(d->source.toString()); + if (iter != d->cachedChildren.end()) { + (*iter)->setOpacity(1.); + d->item = (*iter); + emit sourceChanged(); + } else { + d->qmlcomp = + new QmlComponent(qmlEngine(this), d->source, this); + if (!d->qmlcomp->isLoading()) + d->_q_sourceLoaded(); + else + connect(d->qmlcomp, SIGNAL(statusChanged(QmlComponent::Status)), + this, SLOT(_q_sourceLoaded())); + } +} + +void QFxLoaderPrivate::_q_sourceLoaded() +{ + Q_Q(QFxLoader); + + if (qmlcomp) { + QmlContext *ctxt = new QmlContext(qmlContext(q)); + ctxt->addDefaultObject(q); + + if (!qmlcomp->errors().isEmpty()) { + qWarning() << qmlcomp->errors(); + delete qmlcomp; + qmlcomp = 0; + emit q->sourceChanged(); + return; + } + QObject *obj = qmlcomp->create(ctxt); + if (!qmlcomp->errors().isEmpty()) + qWarning() << qmlcomp->errors(); + QFxItem *qmlChild = qobject_cast(obj); + if (qmlChild) { + qmlChild->setParentItem(q); + cachedChildren.insert(source.toString(), qmlChild); + item = qmlChild; + } else { + delete qmlChild; + source = QUrl(); + } + delete qmlcomp; + qmlcomp = 0; + emit q->sourceChanged(); + } +} + +/*! + \qmlproperty url Loader::item + This property holds the top-level item created from source. +*/ +QFxItem *QFxLoader::item() const +{ + Q_D(const QFxLoader); + return d->item; +} + +QT_END_NAMESPACE + +#include "moc_qfxloader.cpp" diff --git a/src/declarative/fx/qfxloader.h b/src/declarative/fx/qfxloader.h new file mode 100644 index 0000000..f11d116 --- /dev/null +++ b/src/declarative/fx/qfxloader.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** 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 QFXLOADER_H +#define QFXLOADER_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QFxLoaderPrivate; +class Q_DECLARATIVE_EXPORT QFxLoader : public QFxItem +{ + Q_OBJECT + + Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) + Q_PROPERTY(QFxItem *item READ item) + +public: + QFxLoader(QFxItem *parent=0); + virtual ~QFxLoader(); + + QUrl source() const; + void setSource(const QUrl &); + + QFxItem *item() const; + +Q_SIGNALS: + void sourceChanged(); + +private: + Q_DISABLE_COPY(QFxLoader) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxLoader) + Q_PRIVATE_SLOT(d_func(), void _q_sourceLoaded()) +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QFxLoader) + +QT_END_HEADER + +#endif // QFXLOADER_H diff --git a/src/declarative/fx/qfxloader_p.h b/src/declarative/fx/qfxloader_p.h new file mode 100644 index 0000000..13f3b53 --- /dev/null +++ b/src/declarative/fx/qfxloader_p.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** 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 QFXLOADER_P_H +#define QFXLOADER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qfxitem_p.h" +#include "qfxloader.h" + +QT_BEGIN_NAMESPACE + +class QmlContext; +class QFxLoaderPrivate : public QFxItemPrivate +{ + Q_DECLARE_PUBLIC(QFxLoader) + +public: + QFxLoaderPrivate(); + ~QFxLoaderPrivate(); + + QUrl source; + QFxItem *item; + QmlComponent *qmlcomp; + QHash cachedChildren; + + void _q_sourceLoaded(); +}; + +QT_END_NAMESPACE + +#endif // QFXLOADER_P_H -- cgit v0.12 From 8d9690cca4a13d4951b3d303eb57dbe4e25ce21c Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 31 Jul 2009 10:09:33 +1000 Subject: More QFxItem cleanup. --- src/declarative/fx/qfxflickable.cpp | 6 ++++-- src/declarative/fx/qfxitem.cpp | 16 ---------------- src/declarative/fx/qfxitem.h | 15 ++++++--------- src/declarative/fx/qfxpathview.cpp | 5 +++-- 4 files changed, 13 insertions(+), 29 deletions(-) diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp index bd0c1be..4b504cb 100644 --- a/src/declarative/fx/qfxflickable.cpp +++ b/src/declarative/fx/qfxflickable.cpp @@ -1022,7 +1022,9 @@ bool QFxFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event) Q_D(QFxFlickable); QGraphicsSceneMouseEvent mouseEvent(event->type()); QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect(); - QFxItem *grabber = static_cast(mouseGrabberItem()); + + QGraphicsScene *s = scene(); + QFxItem *grabber = s ? qobject_cast(s->mouseGrabberItem()) : 0; if ((d->stealMouse || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) { mouseEvent.setAccepted(false); for (int i = 0x1; i <= 0x10; i <<= 1) { @@ -1049,7 +1051,7 @@ bool QFxFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event) default: break; } - grabber = static_cast(mouseGrabberItem()); + grabber = qobject_cast(s->mouseGrabberItem()); if (grabber && d->stealMouse && !grabber->keepMouseGrab() && grabber != this) grabMouse(); diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 709a243..46bef3c 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1201,12 +1201,6 @@ void QFxItem::setBaselineOffset(qreal offset) \endtable */ -/*! \fn void QFxItem::rotationChanged() - This signal is emitted when the rotation property is changed. - - \sa setRotation() - */ - /*! \qmlproperty real Item::scale This property holds the scale of the item. @@ -1808,16 +1802,6 @@ bool QFxItem::heightValid() const return d->heightValid; } -QFxItem *QFxItem::mouseGrabberItem() const -{ - QGraphicsScene *s = scene(); - if (s) { - QGraphicsItem *item = s->mouseGrabberItem(); - return static_cast(item); // ### - } - return 0; -} - /*! \qmlproperty bool Item::focus This property indicates whether the item has has an active focus request. Set this diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 884a6d8..2050ab9 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -198,12 +198,9 @@ public: qreal width() const; void setWidth(qreal); - void setImplicitWidth(qreal); - bool widthValid() const; // ### better name? + qreal height() const; void setHeight(qreal); - void setImplicitHeight(qreal); - bool heightValid() const; // ### better name? TransformOrigin transformOrigin() const; void setTransformOrigin(TransformOrigin); @@ -211,8 +208,6 @@ public: QRectF boundingRect() const; virtual void paintContents(QPainter &); - QFxItem *mouseGrabberItem() const; - virtual bool hasFocus() const; void setFocus(bool); bool hasActiveFocus() const; @@ -229,9 +224,6 @@ Q_SIGNALS: void parentChanged(); void keyPress(QFxKeyEvent *event); void keyRelease(QFxKeyEvent *event); - void rotationChanged(); - void scaleChanged(); - void qmlChanged(); protected: bool isComponentComplete() const; @@ -243,6 +235,11 @@ protected: virtual bool mouseFilter(QGraphicsSceneMouseEvent *); virtual void mouseUngrabEvent(); + void setImplicitWidth(qreal); + bool widthValid() const; // ### better name? + void setImplicitHeight(qreal); + bool heightValid() const; // ### better name? + virtual void classBegin(); virtual void componentComplete(); virtual void focusChanged(bool); diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp index 98121e6..6546f69 100644 --- a/src/declarative/fx/qfxpathview.cpp +++ b/src/declarative/fx/qfxpathview.cpp @@ -496,7 +496,8 @@ bool QFxPathView::sendMouseEvent(QGraphicsSceneMouseEvent *event) Q_D(QFxPathView); QGraphicsSceneMouseEvent mouseEvent(event->type()); QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect(); - QFxItem *grabber = static_cast(mouseGrabberItem()); + QGraphicsScene *s = scene(); + QFxItem *grabber = s ? qobject_cast(s->mouseGrabberItem()) : 0; if ((d->stealMouse || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) { mouseEvent.setAccepted(false); for (int i = 0x1; i <= 0x10; i <<= 1) { @@ -523,7 +524,7 @@ bool QFxPathView::sendMouseEvent(QGraphicsSceneMouseEvent *event) default: break; } - grabber = static_cast(mouseGrabberItem()); + grabber = qobject_cast(s->mouseGrabberItem()); if (grabber && d->stealMouse && !grabber->keepMouseGrab() && grabber != this) grabMouse(); -- cgit v0.12 From a80468f33d8216ab06c23551b9f6a7b2722ddc14 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Fri, 31 Jul 2009 10:51:42 +1000 Subject: Docs --- src/declarative/util/qmlpalette.cpp | 34 +++++++++++++++++++++++++--------- src/declarative/util/qmlpalette.h | 10 +++++----- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/declarative/util/qmlpalette.cpp b/src/declarative/util/qmlpalette.cpp index 3a6dadc..25576f1 100644 --- a/src/declarative/util/qmlpalette.cpp +++ b/src/declarative/util/qmlpalette.cpp @@ -55,10 +55,24 @@ public: QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Palette,QmlPalette) /*! - \internal - \class QmlPalette + \qmlclass Palette QmlPalette \ingroup group_utility - \brief The QmlPalette class gives access to the Qt palettes. + \brief The Palette item gives access to the Qt palettes. + \sa QPalette + + + \code + Palette { id: MyPalette; colorGroup: "Active" } + + Rect { + width: 640; height: 480 + color: MyPalette.window + Text { + anchors.fill: parent + text: "Hello!"; color: MyPalette.windowText + } + } + \endcode */ QmlPalette::QmlPalette(QObject *parent) : QObject(*(new QmlPalettePrivate), parent) @@ -73,12 +87,20 @@ QmlPalette::~QmlPalette() { } +/*! + \qmlproperty Palette::window + \brief The window (general background) color of the current color group. +*/ QColor QmlPalette::window() const { Q_D(const QmlPalette); return d->palette.color(d->group, QPalette::Window); } +/*! + \qmlproperty Palette::windowText + \brief The window text (general foreground) color of the current color group. +*/ QColor QmlPalette::windowText() const { Q_D(const QmlPalette); @@ -174,12 +196,6 @@ void QmlPalette::setColorGroup(ColorGroup colorGroup) emit paletteChanged(); } -QPalette QmlPalette::palette() const -{ - Q_D(const QmlPalette); - return d->palette; -} - bool QmlPalette::eventFilter(QObject *watched, QEvent *event) { if (watched == qApp) { diff --git a/src/declarative/util/qmlpalette.h b/src/declarative/util/qmlpalette.h index 3030557..b601881 100644 --- a/src/declarative/util/qmlpalette.h +++ b/src/declarative/util/qmlpalette.h @@ -99,19 +99,19 @@ public: QColor highlight() const; QColor highlightedText() const; - QPalette palette() const; - ColorGroup colorGroup() const; void setColorGroup(ColorGroup); - bool virtual eventFilter(QObject *watched, QEvent *event); - bool virtual event(QEvent *event); - Q_INVOKABLE QColor lighter(const QColor&) const; Q_INVOKABLE QColor darker(const QColor&) const; Q_SIGNALS: void paletteChanged(); + +private: + bool eventFilter(QObject *watched, QEvent *event); + bool event(QEvent *event); + }; QT_END_NAMESPACE -- cgit v0.12 From 62b79ded0e4267d06ecf26ae7fc6b73d8b335df8 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Fri, 31 Jul 2009 11:16:44 +1000 Subject: QmlFontFamily improvements Add a 'status' property instead of 'loading'. Improve documentaion. --- src/declarative/util/qmlfontfamily.cpp | 33 +++++++++++++++++++++++++-------- src/declarative/util/qmlfontfamily.h | 10 +++++++--- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/declarative/util/qmlfontfamily.cpp b/src/declarative/util/qmlfontfamily.cpp index e539085..a82527b 100644 --- a/src/declarative/util/qmlfontfamily.cpp +++ b/src/declarative/util/qmlfontfamily.cpp @@ -57,14 +57,14 @@ class QmlFontFamilyPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QmlFontFamily); public: - QmlFontFamilyPrivate() : reply(0), loading(false) {} + QmlFontFamilyPrivate() : reply(0), status(QmlFontFamily::Null) {} void addFontToDatabase(const QByteArray &); QUrl url; QString name; QNetworkReply *reply; - bool loading; + QmlFontFamily::Status status; }; QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,FontFamily,QmlFontFamily) @@ -72,6 +72,15 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,FontFamily,QmlFontFamily) /*! \qmlclass FontFamily QmlFontFamily \ingroup group_utility + \brief This item allows using fonts by name or url. + + \code + FontFamily { id: FixedFont; name: "Courier" } + FontFamily { id: WebFont; source: "http://www.mysite.com/myfont.ttf" } + + Text { text: "Fixed-size font"; font.family: FixedFont.name } + Text { text: "Fancy font"; font.family: WebFont.name } + \endcode */ QmlFontFamily::QmlFontFamily(QObject *parent) : QObject(*(new QmlFontFamilyPrivate), parent) @@ -82,6 +91,10 @@ QmlFontFamily::~QmlFontFamily() { } +/*! + \qmlproperty FontFamily::source + The source for the font. +*/ QUrl QmlFontFamily::source() const { Q_D(const QmlFontFamily); @@ -95,8 +108,8 @@ void QmlFontFamily::setSource(const QUrl &url) return; d->url = qmlContext(this)->resolvedUrl(url); - d->loading = true; - emit loadingChanged(); + d->status = Loading; + emit statusChanged(); #ifndef QT_NO_LOCALFILE_OPTIMIZED_QML if (d->url.scheme() == QLatin1String("file")) { QFile file(d->url.toLocalFile()); @@ -128,10 +141,10 @@ void QmlFontFamily::setName(const QString &name) emit nameChanged(); } -bool QmlFontFamily::isLoading() const +QmlFontFamily::Status QmlFontFamily::status() const { Q_D(const QmlFontFamily); - return d->loading; + return d->status; } void QmlFontFamily::replyFinished() @@ -140,6 +153,9 @@ void QmlFontFamily::replyFinished() if (!d->reply->error()) { QByteArray ba = d->reply->readAll(); d->addFontToDatabase(ba); + } else { + d->status = Error; + emit statusChanged(); } d->reply->deleteLater(); d->reply = 0; @@ -153,11 +169,12 @@ void QmlFontFamilyPrivate::addFontToDatabase(const QByteArray &ba) if (id != -1) { name = QFontDatabase::applicationFontFamilies(id).at(0); emit q->nameChanged(); - loading = false; - emit q->loadingChanged(); + status = QmlFontFamily::Ready; } else { + status = QmlFontFamily::Error; qWarning() << "Cannot load font: " << name << url; } + emit q->statusChanged(); } QT_END_NAMESPACE diff --git a/src/declarative/util/qmlfontfamily.h b/src/declarative/util/qmlfontfamily.h index c647f67..17b6635 100644 --- a/src/declarative/util/qmlfontfamily.h +++ b/src/declarative/util/qmlfontfamily.h @@ -56,12 +56,15 @@ class Q_DECLARATIVE_EXPORT QmlFontFamily : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QmlFontFamily) + Q_ENUMS(Status) Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(bool loading READ isLoading NOTIFY loadingChanged) + Q_PROPERTY(Status status READ status NOTIFY statusChanged) public: + enum Status { Null = 0, Ready, Loading, Error }; + QmlFontFamily(QObject *parent = 0); ~QmlFontFamily(); @@ -71,14 +74,14 @@ public: QString name() const; void setName(const QString &name); - bool isLoading() const; + Status status() const; private Q_SLOTS: void replyFinished(); Q_SIGNALS: void nameChanged(); - void loadingChanged(); + void statusChanged(); }; QT_END_NAMESPACE @@ -88,3 +91,4 @@ QML_DECLARE_TYPE(QmlFontFamily) QT_END_HEADER #endif // QMLFONTFAMILY_H + -- cgit v0.12 From 56f67f2fdf84fe5e7660552c52b67c4e474054dd Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 31 Jul 2009 11:34:36 +1000 Subject: Rename centeredIn to centerIn. --- demos/declarative/calculator/CalcButton.qml | 2 +- demos/declarative/flickr/content/ImageDetails.qml | 4 +- demos/declarative/flickr/content/MediaButton.qml | 2 +- demos/declarative/flickr/flickr.qml | 2 +- demos/declarative/samegame/SameGame.qml | 2 +- demos/declarative/samegame/content/BoomBlock.qml | 2 +- demos/declarative/samegame/content/Button.qml | 2 +- demos/declarative/samegame/content/Dialog.qml | 2 +- doc/src/declarative/extending.qdoc | 8 ++-- doc/src/declarative/qmlintro.qdoc | 2 +- examples/declarative/flowview/flickr.qml | 2 +- examples/declarative/flowview/flowview.qml | 2 +- .../declarative/listview/content/MediaButton.qml | 2 +- examples/declarative/loader/Browser.qml | 4 +- examples/declarative/loader/Button.qml | 2 +- examples/declarative/mouseregion/mouse.qml | 4 +- examples/declarative/slideswitch/display.qml | 2 +- examples/declarative/snow/ImageBatch.qml | 2 +- examples/declarative/snow/snow.qml | 2 +- src/declarative/fx/qfxanchors.cpp | 48 +++++++++++----------- src/declarative/fx/qfxanchors.h | 6 +-- src/declarative/fx/qfxanchors_p.h | 6 +-- src/declarative/fx/qfxitem.cpp | 2 +- 23 files changed, 56 insertions(+), 56 deletions(-) diff --git a/demos/declarative/calculator/CalcButton.qml b/demos/declarative/calculator/CalcButton.qml index db8ae7c..5eb7fe1 100644 --- a/demos/declarative/calculator/CalcButton.qml +++ b/demos/declarative/calculator/CalcButton.qml @@ -37,7 +37,7 @@ Item { } Text { - anchors.centeredIn: Image + anchors.centerIn: Image text: Button.operation color: "white" font.bold: true diff --git a/demos/declarative/flickr/content/ImageDetails.qml b/demos/declarative/flickr/content/ImageDetails.qml index 26bac32..2be0e4d 100644 --- a/demos/declarative/flickr/content/ImageDetails.qml +++ b/demos/declarative/flickr/content/ImageDetails.qml @@ -79,7 +79,7 @@ Flipable { Rect { anchors.fill: parent; color: "black"; opacity: 0.4; pen.color: "white"; pen.width: 2 } - Progress { anchors.centeredIn: parent; width: 200; height: 18; progress: BigImage.progress; visible: BigImage.status } + Progress { anchors.centerIn: parent; width: 200; height: 18; progress: BigImage.progress; visible: BigImage.status } Flickable { id: Flick; width: Container.width - 10; height: Container.height - 10 x: 5; y: 5; clip: true; @@ -114,7 +114,7 @@ Flipable { Text { text: "Image Unavailable" visible: BigImage.status == 'Error' - anchors.centeredIn: parent; color: "white"; font.bold: true + anchors.centerIn: parent; color: "white"; font.bold: true } Slider { diff --git a/demos/declarative/flickr/content/MediaButton.qml b/demos/declarative/flickr/content/MediaButton.qml index cbe4265..2a6dbae 100644 --- a/demos/declarative/flickr/content/MediaButton.qml +++ b/demos/declarative/flickr/content/MediaButton.qml @@ -24,7 +24,7 @@ Item { Text { font.bold: true color: "white" - anchors.centeredIn: Image + anchors.centerIn: Image text: Container.text } width: Image.width diff --git a/demos/declarative/flickr/flickr.qml b/demos/declarative/flickr/flickr.qml index eba65c0..21ac284 100644 --- a/demos/declarative/flickr/flickr.qml +++ b/demos/declarative/flickr/flickr.qml @@ -124,7 +124,7 @@ Item { Image { source: "content/pics/background.png"; anchors.fill: parent } - Loading { anchors.centeredIn: parent; visible: FeedModel.status != 0 } + Loading { anchors.centerIn: parent; visible: FeedModel.status != 0 } GridView { id: PhotoGridView; model: FeedModel; delegate: PhotoDelegate; cacheBuffer: 100 diff --git a/demos/declarative/samegame/SameGame.qml b/demos/declarative/samegame/SameGame.qml index 9e1b1ae..cb4737a 100644 --- a/demos/declarative/samegame/SameGame.qml +++ b/demos/declarative/samegame/SameGame.qml @@ -22,7 +22,7 @@ Rect { } } - Dialog { id: dialog; anchors.centeredIn: parent; z: 21} + Dialog { id: dialog; anchors.centerIn: parent; z: 21} Button { id: btnA; text: "New Game"; onClicked: {initBoard();} anchors.top: gameCanvas.bottom; anchors.topMargin: 4; anchors.left: gameCanvas.left; diff --git a/demos/declarative/samegame/content/BoomBlock.qml b/demos/declarative/samegame/content/BoomBlock.qml index a4f4fe9..8a505da 100644 --- a/demos/declarative/samegame/content/BoomBlock.qml +++ b/demos/declarative/samegame/content/BoomBlock.qml @@ -26,7 +26,7 @@ Item { id:block } Particles { id: particles - width:1; height:1; anchors.centeredIn: parent; opacity: 0 + width:1; height:1; anchors.centerIn: parent; opacity: 0 lifeSpan: 700; lifeSpanDeviation: 600; count:0; streamIn: false angle: 0; angleDeviation: 360; velocity: 100; velocityDeviation:30 source: { diff --git a/demos/declarative/samegame/content/Button.qml b/demos/declarative/samegame/content/Button.qml index 2f38a52..152c996 100644 --- a/demos/declarative/samegame/content/Button.qml +++ b/demos/declarative/samegame/content/Button.qml @@ -12,7 +12,7 @@ Rect { } MouseRegion { id:mr; anchors.fill: parent; onClicked: page.clicked() } Text { - id: txtItem; text: page.text; anchors.centeredIn: page; color: activePalette.buttonText + id: txtItem; text: page.text; anchors.centerIn: page; color: activePalette.buttonText font.size: 14; } } diff --git a/demos/declarative/samegame/content/Dialog.qml b/demos/declarative/samegame/content/Dialog.qml index 6d12b48..939f66f 100644 --- a/demos/declarative/samegame/content/Dialog.qml +++ b/demos/declarative/samegame/content/Dialog.qml @@ -11,5 +11,5 @@ Rect { NumberAnimation {property: "opacity"; to: 0; duration: 1500 } } } - Text { anchors.centeredIn: parent; text: parent.text } + Text { anchors.centerIn: parent; text: parent.text } } diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc index 88abfe6..27c473e 100644 --- a/doc/src/declarative/extending.qdoc +++ b/doc/src/declarative/extending.qdoc @@ -616,7 +616,7 @@ controls the color of the inner rectangle. color: "red"; width: 100; height: 100 Rect { - anchors.centeredIn: parent + anchors.centerIn: parent width: parent.width - 10 height: parent.height - 10 color: innerColor @@ -661,7 +661,7 @@ Rect { color: "red"; width: 100; height: 100 Rect { id: InnerRect - anchors.centeredIn: parent + anchors.centerIn: parent width: parent.width - 10 height: parent.height - 10 color: "black" @@ -696,7 +696,7 @@ Rect { color: "red"; width: 100; height: 100 Rect { id: InnerRect - anchors.centeredIn: parent + anchors.centerIn: parent width: parent.width - 10 height: parent.height - 10 color: "black" @@ -863,7 +863,7 @@ Rect { color: "blue" Text { id: MyText - anchors.centeredIn: parent + anchors.centerIn: parent } } \endcode diff --git a/doc/src/declarative/qmlintro.qdoc b/doc/src/declarative/qmlintro.qdoc index c507e75..783d077 100644 --- a/doc/src/declarative/qmlintro.qdoc +++ b/doc/src/declarative/qmlintro.qdoc @@ -29,7 +29,7 @@ Rect { color: "white" Image { source: "pics/logo.png" - anchors.centeredIn: parent + anchors.centerIn: parent } } \endcode diff --git a/examples/declarative/flowview/flickr.qml b/examples/declarative/flowview/flickr.qml index 6c47b82..1cf0f73 100644 --- a/examples/declarative/flowview/flickr.qml +++ b/examples/declarative/flowview/flickr.qml @@ -35,7 +35,7 @@ Rect { delegate: Item { width: 90; height: 86 Rect { - anchors.centeredIn: parent + anchors.centerIn: parent width: 86; height: 86; color: "white"; radius: 5 Image { source: imagePath; x: 5; y: 5 } diff --git a/examples/declarative/flowview/flowview.qml b/examples/declarative/flowview/flowview.qml index ff15d96..99f5c1e 100644 --- a/examples/declarative/flowview/flowview.qml +++ b/examples/declarative/flowview/flowview.qml @@ -8,7 +8,7 @@ Rect { Rect { id: MyPhone transformOrigin: "Center" - anchors.centeredIn: parent + anchors.centerIn: parent width: 800 height: 480 clip: true diff --git a/examples/declarative/listview/content/MediaButton.qml b/examples/declarative/listview/content/MediaButton.qml index 23ae466..8fff22b 100644 --- a/examples/declarative/listview/content/MediaButton.qml +++ b/examples/declarative/listview/content/MediaButton.qml @@ -22,7 +22,7 @@ Item { Text { font.bold: true color: "white" - anchors.centeredIn: Image + anchors.centerIn: Image text: Container.text } width: Image.width diff --git a/examples/declarative/loader/Browser.qml b/examples/declarative/loader/Browser.qml index 007b998..64df830 100644 --- a/examples/declarative/loader/Browser.qml +++ b/examples/declarative/loader/Browser.qml @@ -30,7 +30,7 @@ Rect { } Item { width: 32; height: 32 - Image { source: "images/fileopen.png"; anchors.centeredIn: parent; visible: folders.isFolder(index)} + Image { source: "images/fileopen.png"; anchors.centerIn: parent; visible: folders.isFolder(index)} } Text { id: NameText @@ -90,7 +90,7 @@ Rect { height: TitleBar.height pen.color: activePalette.mid; color: "transparent" MouseRegion { anchors.fill: parent; onClicked: folders.folder = up(folders.folder) } - Image { anchors.centeredIn: parent; source: "images/up.png" } + Image { anchors.centerIn: parent; source: "images/up.png" } } Text { diff --git a/examples/declarative/loader/Button.qml b/examples/declarative/loader/Button.qml index 7a17601..562e04c 100644 --- a/examples/declarative/loader/Button.qml +++ b/examples/declarative/loader/Button.qml @@ -12,5 +12,5 @@ Rect { radius: 4 color: "grey" MouseRegion { anchors.fill: parent; onClicked: Container.clicked() } - Text { id: Text; anchors.centeredIn:parent; font.size: 10; text: parent.text } + Text { id: Text; anchors.centerIn:parent; font.size: 10; text: parent.text } } diff --git a/examples/declarative/mouseregion/mouse.qml b/examples/declarative/mouseregion/mouse.qml index 0948a32..d9db106 100644 --- a/examples/declarative/mouseregion/mouse.qml +++ b/examples/declarative/mouseregion/mouse.qml @@ -6,7 +6,7 @@ Rect { Rect { width: 50; height: 50 color: "red" - Text { text: "Click"; anchors.centeredIn: parent } + Text { text: "Click"; anchors.centerIn: parent } MouseRegion { onPressed: { print('press (x: ' + mouse.x + ' y: ' + mouse.y + ' button: ' + (mouse.button == Qt.RightButton ? 'right' : 'left') + ' Shift: ' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')') } onReleased: { print('release (x: ' + mouse.x + ' y: ' + mouse.y + ' isClick: ' + mouse.isClick + ' wasHeld: ' + mouse.wasHeld + ')') } @@ -21,7 +21,7 @@ Rect { Rect { y: 100; width: 50; height: 50 color: "blue" - Text { text: "Drag"; anchors.centeredIn: parent } + Text { text: "Drag"; anchors.centerIn: parent } MouseRegion { drag.target: parent drag.axis: "x" diff --git a/examples/declarative/slideswitch/display.qml b/examples/declarative/slideswitch/display.qml index db67dab..bd9b122 100644 --- a/examples/declarative/slideswitch/display.qml +++ b/examples/declarative/slideswitch/display.qml @@ -5,6 +5,6 @@ Rect { width: 150 height: 150 Switch { - anchors.centeredIn: parent + anchors.centerIn: parent } } diff --git a/examples/declarative/snow/ImageBatch.qml b/examples/declarative/snow/ImageBatch.qml index 77bacab..4b52991 100644 --- a/examples/declarative/snow/ImageBatch.qml +++ b/examples/declarative/snow/ImageBatch.qml @@ -43,7 +43,7 @@ GridView { Image { id: Image; source: url; preserveAspect: true; smooth: true; anchors.fill: parent; opacity: (status == 0)?1:0; opacity: Behavior { NumberAnimation { properties: "opacity" } } } - Loading { anchors.centeredIn: parent; visible: Image.status } + Loading { anchors.centerIn: parent; visible: Image.status } states: State { name: "selected" diff --git a/examples/declarative/snow/snow.qml b/examples/declarative/snow/snow.qml index aa5185f..aed426f 100644 --- a/examples/declarative/snow/snow.qml +++ b/examples/declarative/snow/snow.qml @@ -21,7 +21,7 @@ Rect { property int selectedY: selectedItemRow * imageHeight Item { - anchors.centeredIn: parent + anchors.centerIn: parent HorizontalLayout { id: MyLayout property real targetX: -(selectedX + imageWidth / 2) diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp index 286a0fc..a22aeb3 100644 --- a/src/declarative/fx/qfxanchors.cpp +++ b/src/declarative/fx/qfxanchors.cpp @@ -137,7 +137,7 @@ QFxAnchors::~QFxAnchors() { Q_D(QFxAnchors); d->remDepend(d->fill); - d->remDepend(d->centeredIn); + d->remDepend(d->centerIn); d->remDepend(d->left.item); d->remDepend(d->right.item); d->remDepend(d->top.item); @@ -161,20 +161,20 @@ void QFxAnchorsPrivate::fillChanged() setItemHeight(fill->height()-topMargin-bottomMargin); } -void QFxAnchorsPrivate::centeredInChanged() +void QFxAnchorsPrivate::centerInChanged() { - if (!centeredIn || fill || !isItemComplete()) + if (!centerIn || fill || !isItemComplete()) return; - if (centeredIn == item->parentItem()) { + if (centerIn == item->parentItem()) { QPointF p((item->parentItem()->width() - item->width()) / 2., (item->parentItem()->height() - item->height()) / 2.); setItemPos(p); - } else if (centeredIn->parentItem() == item->parentItem()) { + } else if (centerIn->parentItem() == item->parentItem()) { - QPointF p(centeredIn->x() + (centeredIn->width() - item->width()) / 2., - centeredIn->y() + (centeredIn->height() - item->height()) / 2.); + QPointF p(centerIn->x() + (centerIn->width() - item->width()) / 2., + centerIn->y() + (centerIn->height() - item->height()) / 2.); setItemPos(p); } } @@ -183,8 +183,8 @@ void QFxAnchorsPrivate::clearItem(QFxItem *item) { if (fill == item) fill = 0; - if (centeredIn == item) - centeredIn = 0; + if (centerIn == item) + centerIn = 0; if (left.item == item) { left.item = 0; usedAnchors &= ~QFxAnchors::HasLeftAnchor; @@ -295,7 +295,7 @@ void QFxAnchorsPrivate::updateMe() } fillChanged(); - centeredInChanged(); + centerInChanged(); updateHorizontalAnchors(); updateVerticalAnchors(); } @@ -303,7 +303,7 @@ void QFxAnchorsPrivate::updateMe() void QFxAnchorsPrivate::updateOnComplete() { fillChanged(); - centeredInChanged(); + centerInChanged(); updateHorizontalAnchors(); updateVerticalAnchors(); } @@ -311,7 +311,7 @@ void QFxAnchorsPrivate::updateOnComplete() void QFxAnchorsPrivate::update(QFxItem *, const QRectF &newG, const QRectF &oldG) { fillChanged(); - centeredInChanged(); + centerInChanged(); if (newG.x() != oldG.x() || newG.width() != oldG.width()) updateHorizontalAnchors(); @@ -352,24 +352,24 @@ void QFxAnchors::setFill(QFxItem *f) } /*! - \property QFxAnchors::centeredIn + \property QFxAnchors::centerIn \brief which item the item should stay centered in. This is a convenience property. It is the same as anchoring the horizontalCenter and verticalCenter to another item's horizontalCenter and verticalCenter. */ -QFxItem *QFxAnchors::centeredIn() const +QFxItem *QFxAnchors::centerIn() const { Q_D(const QFxAnchors); - return d->centeredIn; + return d->centerIn; } -void QFxAnchors::setCenteredIn(QFxItem* c) +void QFxAnchors::setCenterIn(QFxItem* c) { Q_D(QFxAnchors); if (!c) { - d->remDepend(d->centeredIn); - d->centeredIn = c; + d->remDepend(d->centerIn); + d->centerIn = c; return; } if (c != d->item->parentItem() && c->parentItem() != d->item->parentItem()){ @@ -377,11 +377,11 @@ void QFxAnchors::setCenteredIn(QFxItem* c) return; } - d->remDepend(d->centeredIn); - d->centeredIn = c; - d->addDepend(d->centeredIn); + d->remDepend(d->centerIn); + d->centerIn = c; + d->addDepend(d->centerIn); - d->centeredInChanged(); + d->centerInChanged(); } bool QFxAnchorsPrivate::calcStretch(const QFxAnchorLine &edge1, @@ -415,7 +415,7 @@ bool QFxAnchorsPrivate::calcStretch(const QFxAnchorLine &edge1, void QFxAnchorsPrivate::updateVerticalAnchors() { - if (fill || centeredIn || !isItemComplete()) + if (fill || centerIn || !isItemComplete()) return; if (updatingVerticalAnchor < 2) { @@ -480,7 +480,7 @@ void QFxAnchorsPrivate::updateVerticalAnchors() void QFxAnchorsPrivate::updateHorizontalAnchors() { - if (fill || centeredIn || !isItemComplete()) + if (fill || centerIn || !isItemComplete()) return; if (updatingHorizontalAnchor < 2) { diff --git a/src/declarative/fx/qfxanchors.h b/src/declarative/fx/qfxanchors.h index a1f5db8..7ff4c35 100644 --- a/src/declarative/fx/qfxanchors.h +++ b/src/declarative/fx/qfxanchors.h @@ -72,7 +72,7 @@ class Q_DECLARATIVE_EXPORT QFxAnchors : public QObject Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged) Q_PROPERTY(qreal verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged()) Q_PROPERTY(QFxItem *fill READ fill WRITE setFill) - Q_PROPERTY(QFxItem *centeredIn READ centeredIn WRITE setCenteredIn) + Q_PROPERTY(QFxItem *centerIn READ centerIn WRITE setCenterIn) public: QFxAnchors(QObject *parent=0); @@ -140,8 +140,8 @@ public: QFxItem *fill() const; void setFill(QFxItem *); - QFxItem *centeredIn() const; - void setCenteredIn(QFxItem *); + QFxItem *centerIn() const; + void setCenterIn(QFxItem *); UsedAnchors usedAnchors() const; diff --git a/src/declarative/fx/qfxanchors_p.h b/src/declarative/fx/qfxanchors_p.h index 7ce0952..1827324 100644 --- a/src/declarative/fx/qfxanchors_p.h +++ b/src/declarative/fx/qfxanchors_p.h @@ -65,7 +65,7 @@ public: QFxAnchorsPrivate() : updatingMe(false), updatingHorizontalAnchor(0), updatingVerticalAnchor(0), item(0), usedAnchors(0), fill(0), - centeredIn(0), leftMargin(0), rightMargin(0), topMargin(0), + centerIn(0), leftMargin(0), rightMargin(0), topMargin(0), bottomMargin(0), vCenterOffset(0), hCenterOffset(0), componentComplete(true) { @@ -104,13 +104,13 @@ public: void updateHorizontalAnchors(); void updateVerticalAnchors(); void fillChanged(); - void centeredInChanged(); + void centerInChanged(); QFxItem *item; QFxAnchors::UsedAnchors usedAnchors; QFxItem *fill; - QFxItem *centeredIn; + QFxItem *centerIn; QFxAnchorLine left; QFxAnchorLine right; diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 46bef3c..617e479 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1079,7 +1079,7 @@ QFxAnchorLine QFxItem::baseline() const \qmlproperty AnchorLine Item::anchors.baseline \qmlproperty Item Item::anchors.fill - \qmlproperty Item Item::anchors.centeredIn + \qmlproperty Item Item::anchors.centerIn \qmlproperty real Item::anchors.topMargin \qmlproperty real Item::anchors.bottomMargin -- cgit v0.12 From 2411b42ff4638bc1a707ab9ebe9fbadf2a4a0292 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 31 Jul 2009 11:52:29 +1000 Subject: Rename Rect.pen to Rect.border --- demos/declarative/calculator/calculator.qml | 2 +- demos/declarative/contacts/contacts.qml | 2 +- demos/declarative/flickr/content/ImageDetails.qml | 4 +- demos/declarative/flickr/content/Progress.qml | 2 +- demos/declarative/flickr/content/ScrollBar.qml | 4 +- demos/declarative/flickr/content/Slider.qml | 2 +- demos/declarative/samegame/SameGame.qml | 2 +- demos/declarative/samegame/content/Button.qml | 2 +- demos/declarative/samegame/content/Dialog.qml | 2 +- examples/declarative/behaviours/MyRect.qml | 2 +- examples/declarative/flowview/flickr.qml | 2 +- examples/declarative/flowview/rect.qml | 2 +- examples/declarative/listview/recipes.qml | 2 +- examples/declarative/loader/Browser.qml | 4 +- examples/declarative/loader/Button.qml | 2 +- examples/declarative/states/states.qml | 6 +- examples/declarative/states/transitions.qml | 6 +- .../contacts/1_Drawing_and_Animation/GroupBox.qml | 2 +- .../tutorials/contacts/2_Reuse/GroupBox.qml | 2 +- .../tutorials/contacts/3_Collections/GroupBox.qml | 2 +- examples/declarative/velocity/Day.qml | 2 +- src/declarative/fx/qfxrect.cpp | 73 ++++++---------------- src/declarative/fx/qfxrect.h | 4 +- 23 files changed, 48 insertions(+), 85 deletions(-) diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml index 1cc8fa8..576fea9 100644 --- a/demos/declarative/calculator/calculator.qml +++ b/demos/declarative/calculator/calculator.qml @@ -12,7 +12,7 @@ Rect { Rect { id: Container width: 316; height: 60; z: 2 - pen.color: "white"; color: "#343434" + border.color: "white"; color: "#343434" Text { id: CurNum diff --git a/demos/declarative/contacts/contacts.qml b/demos/declarative/contacts/contacts.qml index 6bd7b21..ecafd20 100644 --- a/demos/declarative/contacts/contacts.qml +++ b/demos/declarative/contacts/contacts.qml @@ -213,7 +213,7 @@ Rect { highlight: [ Rect { id: contactHighlight - pen.width: 0 + border.width: 0 color: 'white' opacity: contacts.mode == 'list' ? 1 : 0 opacity: Behavior { diff --git a/demos/declarative/flickr/content/ImageDetails.qml b/demos/declarative/flickr/content/ImageDetails.qml index 2be0e4d..9d5f069 100644 --- a/demos/declarative/flickr/content/ImageDetails.qml +++ b/demos/declarative/flickr/content/ImageDetails.qml @@ -30,7 +30,7 @@ Flipable { Rect { anchors.fill: parent color: "black"; opacity: 0.4 - pen.color: "white"; pen.width: 2 + border.color: "white"; border.width: 2 } MediaButton { @@ -77,7 +77,7 @@ Flipable { back: Item { anchors.fill: Container - Rect { anchors.fill: parent; color: "black"; opacity: 0.4; pen.color: "white"; pen.width: 2 } + Rect { anchors.fill: parent; color: "black"; opacity: 0.4; border.color: "white"; border.width: 2 } Progress { anchors.centerIn: parent; width: 200; height: 18; progress: BigImage.progress; visible: BigImage.status } Flickable { diff --git a/demos/declarative/flickr/content/Progress.qml b/demos/declarative/flickr/content/Progress.qml index 4b092ca..ae6bb18 100644 --- a/demos/declarative/flickr/content/Progress.qml +++ b/demos/declarative/flickr/content/Progress.qml @@ -7,7 +7,7 @@ Item { Rect { id: Container; anchors.fill: parent - pen.color: "white"; pen.width: 0; radius: height/2 - 2 + border.color: "white"; border.width: 0; radius: height/2 - 2 gradient: Gradient { GradientStop { position: 0; color: "#66343434" } GradientStop { position: 1.0; color: "#66000000" } diff --git a/demos/declarative/flickr/content/ScrollBar.qml b/demos/declarative/flickr/content/ScrollBar.qml index 25dca98..e9a461c 100644 --- a/demos/declarative/flickr/content/ScrollBar.qml +++ b/demos/declarative/flickr/content/ScrollBar.qml @@ -9,8 +9,8 @@ Item { radius: 5 color: "black" opacity: 0.3 - pen.color: "white" - pen.width: 2 + border.color: "white" + border.width: 2 x: 0 y: flickableArea.pageYPosition * Container.height width: parent.width diff --git a/demos/declarative/flickr/content/Slider.qml b/demos/declarative/flickr/content/Slider.qml index 4e88c1e..0c15ec6 100644 --- a/demos/declarative/flickr/content/Slider.qml +++ b/demos/declarative/flickr/content/Slider.qml @@ -12,7 +12,7 @@ Item { Rect { id: Container; anchors.fill: parent - pen.color: "white"; pen.width: 0; radius: 8 + border.color: "white"; border.width: 0; radius: 8 gradient: Gradient { GradientStop { position: 0.0; color: "#66343434" } GradientStop { position: 1.0; color: "#66000000" } diff --git a/demos/declarative/samegame/SameGame.qml b/demos/declarative/samegame/SameGame.qml index cb4737a..e74646d 100644 --- a/demos/declarative/samegame/SameGame.qml +++ b/demos/declarative/samegame/SameGame.qml @@ -9,7 +9,7 @@ Rect { Rect { id: gameCanvas property int score: 0 - z:20; y:20; color: "white"; pen.width: 1 + z:20; y:20; color: "white"; border.width: 1 width:parent.width - tileSize - (parent.width % tileSize); height:parent.height - tileSize - (parent.height % tileSize); anchors.horizontalCenter: parent.horizontalCenter diff --git a/demos/declarative/samegame/content/Button.qml b/demos/declarative/samegame/content/Button.qml index 152c996..c7a49f1 100644 --- a/demos/declarative/samegame/content/Button.qml +++ b/demos/declarative/samegame/content/Button.qml @@ -2,7 +2,7 @@ import Qt 4.6 Rect { id: page; color: activePalette.button; width: txtItem.width+20; height: txtItem.height+4 - pen.width: 1; pen.color: activePalette.mid; radius: 10; + border.width: 1; border.color: activePalette.mid; radius: 10; signal clicked property string text: "Button" gradient: Gradient { diff --git a/demos/declarative/samegame/content/Dialog.qml b/demos/declarative/samegame/content/Dialog.qml index 939f66f..7326d73 100644 --- a/demos/declarative/samegame/content/Dialog.qml +++ b/demos/declarative/samegame/content/Dialog.qml @@ -2,7 +2,7 @@ import Qt 4.6 Rect { id: page - color: "white"; pen.width: 1; width: 200; height: 60; + color: "white"; border.width: 1; width: 200; height: 60; property string text: "Hello World!" opacity: 0 opacity: Behavior { diff --git a/examples/declarative/behaviours/MyRect.qml b/examples/declarative/behaviours/MyRect.qml index 1ccf4db..199b33b 100644 --- a/examples/declarative/behaviours/MyRect.qml +++ b/examples/declarative/behaviours/MyRect.qml @@ -2,7 +2,7 @@ import Qt 4.6 Rect { radius: 15 - pen.color: "black" + border.color: "black" width: 100 height: 100 id: Page diff --git a/examples/declarative/flowview/flickr.qml b/examples/declarative/flowview/flickr.qml index 1cf0f73..2abf7a1 100644 --- a/examples/declarative/flowview/flickr.qml +++ b/examples/declarative/flowview/flickr.qml @@ -2,7 +2,7 @@ import Qt 4.6 Rect { radius: 5; - pen.width: 1; + border.width: 1; width:400; height: 120; color: background; diff --git a/examples/declarative/flowview/rect.qml b/examples/declarative/flowview/rect.qml index 9d81fa4..3fecf17 100644 --- a/examples/declarative/flowview/rect.qml +++ b/examples/declarative/flowview/rect.qml @@ -1,4 +1,4 @@ import Qt 4.6 -Rect { radius: 5; pen.width: 1; width:400; height: 120; color: background; } +Rect { radius: 5; border.width: 1; width:400; height: 120; color: background; } diff --git a/examples/declarative/listview/recipes.qml b/examples/declarative/listview/recipes.qml index 788e067..8b12527 100644 --- a/examples/declarative/listview/recipes.qml +++ b/examples/declarative/listview/recipes.qml @@ -24,7 +24,7 @@ Rect { Rect { id: background x: 1; y: 2; width: parent.width-2; height: parent.height-4 - color: "#FEFFEE"; pen.color: "#FFBE4F"; radius: 5 + color: "#FEFFEE"; border.color: "#FFBE4F"; radius: 5 } // This mouse region covers the entire delegate. // When clicked it changes mode to 'Details'. If we are already diff --git a/examples/declarative/loader/Browser.qml b/examples/declarative/loader/Browser.qml index 64df830..96c2a76 100644 --- a/examples/declarative/loader/Browser.qml +++ b/examples/declarative/loader/Browser.qml @@ -82,13 +82,13 @@ Rect { id: TitleBar width: parent.width height: 32 - color: activePalette.button; pen.color: activePalette.mid + color: activePalette.button; border.color: activePalette.mid Rect { id: UpButton width: 30 height: TitleBar.height - pen.color: activePalette.mid; color: "transparent" + border.color: activePalette.mid; color: "transparent" MouseRegion { anchors.fill: parent; onClicked: folders.folder = up(folders.folder) } Image { anchors.centerIn: parent; source: "images/up.png" } } diff --git a/examples/declarative/loader/Button.qml b/examples/declarative/loader/Button.qml index 562e04c..999e180 100644 --- a/examples/declarative/loader/Button.qml +++ b/examples/declarative/loader/Button.qml @@ -8,7 +8,7 @@ Rect { height: Text.height + 10 width: Text.width + 20 - pen.width: 1 + border.width: 1 radius: 4 color: "grey" MouseRegion { anchors.fill: parent; onClicked: Container.clicked() } diff --git a/examples/declarative/states/states.qml b/examples/declarative/states/states.qml index 431f0bc..c4c71b5 100644 --- a/examples/declarative/states/states.qml +++ b/examples/declarative/states/states.qml @@ -6,19 +6,19 @@ Rect { // A target region. Clicking in here sets the state to '' - the default state Rect { x: 0; y: 0; width: 50; height: 50 - color: "transparent"; pen.color: "black" + color: "transparent"; border.color: "black" MouseRegion { anchors.fill: parent; onClicked: { Page.state='' } } } // Another target region. Clicking in here sets the state to 'Position1' Rect { x: 150; y: 50; width: 50; height: 50 - color: "transparent"; pen.color: "black" + color: "transparent"; border.color: "black" MouseRegion { anchors.fill: parent; onClicked: { Page.state='Position1' } } } // Another target region. Clicking in here sets the state to 'Position2' Rect { x: 0; y: 200; width: 50; height: 50 - color: "transparent"; pen.color: "black" + color: "transparent"; border.color: "black" MouseRegion { anchors.fill: parent; onClicked: { Page.state='Position2' } } } // Rect which will be moved when my state changes diff --git a/examples/declarative/states/transitions.qml b/examples/declarative/states/transitions.qml index 7bc7f6c..63ed4d9 100644 --- a/examples/declarative/states/transitions.qml +++ b/examples/declarative/states/transitions.qml @@ -6,19 +6,19 @@ Rect { // A target region. Clicking in here sets the state to '' - the default state Rect { x: 0; y: 0; width: 50; height: 50 - color: "transparent"; pen.color: "black" + color: "transparent"; border.color: "black" MouseRegion { anchors.fill: parent; onClicked: { Page.state='' } } } // Another target region. Clicking in here sets the state to 'Position1' Rect { x: 150; y: 50; width: 50; height: 50 - color: "transparent"; pen.color: "black" + color: "transparent"; border.color: "black" MouseRegion { anchors.fill: parent; onClicked: { Page.state='Position1' } } } // Another target region. Clicking in here sets the state to 'Position2' Rect { x: 0; y: 200; width: 50; height: 50 - color: "transparent"; pen.color: "black" + color: "transparent"; border.color: "black" MouseRegion { anchors.fill: parent; onClicked: { Page.state='Position2' } } } // Rect which will be moved when my state changes diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/GroupBox.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/GroupBox.qml index 29e00d9..d3f626f 100644 --- a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/GroupBox.qml +++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/GroupBox.qml @@ -16,7 +16,7 @@ FocusRealm { width: groupBox.width-20 height: groupBox.height-20 color: "white" - pen.color: "black" + border.color: "black" Loader { id: subItem source: groupBox.contents diff --git a/examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml b/examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml index 29e00d9..d3f626f 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml @@ -16,7 +16,7 @@ FocusRealm { width: groupBox.width-20 height: groupBox.height-20 color: "white" - pen.color: "black" + border.color: "black" Loader { id: subItem source: groupBox.contents diff --git a/examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml b/examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml index 29e00d9..d3f626f 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml @@ -16,7 +16,7 @@ FocusRealm { width: groupBox.width-20 height: groupBox.height-20 color: "white" - pen.color: "black" + border.color: "black" Loader { id: subItem source: groupBox.contents diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml index 05e1f07..f7a5a47 100644 --- a/examples/declarative/velocity/Day.qml +++ b/examples/declarative/velocity/Day.qml @@ -7,7 +7,7 @@ Rect { width: 400 height: 500 radius: 7 - pen.color: "black" + border.color: "black" id: Page Image { x: 10 diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp index c43e034..93a2997 100644 --- a/src/declarative/fx/qfxrect.cpp +++ b/src/declarative/fx/qfxrect.cpp @@ -52,7 +52,6 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Gradient,QFxGradient) /*! \internal \class QFxPen - \ingroup group_utility \brief The QFxPen class provides a pen used for drawing rect borders on a QFxView. By default, the pen is invalid and nothing is drawn. You must either set a color (then the default @@ -62,12 +61,12 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Gradient,QFxGradient) Example: \qml - Rect { pen.width: 2; pen.color: "red" ... } + Rect { border.width: 2; border.color: "red" ... } \endqml */ /*! \property QFxPen::width - \brief the width of the pen. + \brief the width of the border. A width of 1 is a single-pixel line on the border of the item being painted. @@ -76,17 +75,17 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Gradient,QFxGradient) /*! \property QFxPen::color - \brief the color of the pen. + \brief the color of the border. color is most commonly specified in hexidecimal notation (#RRGGBB) or as an \l {http://www.w3.org/TR/SVG/types.html#ColorKeywords}{SVG color keyword name} (as defined by the World Wide Web Consortium). For example: \qml // rect with green border using hexidecimal notation - Rect { pen.color: "#00FF00" } + Rect { border.color: "#00FF00" } // rect with steelblue border using SVG color name - Rect { pen.color: "steelblue" } + Rect { border.color: "steelblue" } \endqml For the full set of ways to specify color, see Qt's QColor::setNamedColor documentation. @@ -101,10 +100,10 @@ void QFxPen::setColor(const QColor &c) /*! \property QFxPen::width - \brief the width of the pen. + \brief the width of the border. \qml - Rect { pen.width: 4 } + Rect { border.width: 4 } \endqml A width of 1 creates a thin line. For no line, use a width of 0 or a transparent color. @@ -200,8 +199,8 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rect,QFxRect) width: 100 height: 100 color: "red" - pen.color: "black" - pen.width: 5 + border.color: "black" + border.width: 5 radius: 10 } \endqml @@ -213,26 +212,6 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rect,QFxRect) \internal \class QFxRect \brief The QFxRect class provides a rect item that you can add to a QFxView. - - A Rect is painted having a solid fill (color) and an optional border (pen). - You can also create rounded rectangles using the radius property. - - \qml - Rect { - width: 100 - height: 100 - color: "red" - pen.color: "black" - pen.width: 5 - radius: 10 - } - \endqml - - \image declarative-rect.png - - A QFxRect object can be instantiated in Qml using the tag \l Rect. - - \ingroup group_coreitems */ QFxRect::QFxRect(QFxItem *parent) : QFxItem(*(new QFxRectPrivate), parent) @@ -260,16 +239,17 @@ void QFxRect::doUpdate() } /*! - \qmlproperty int Rect::pen.width - \qmlproperty color Rect::pen.color + \qmlproperty int Rect::border.width + \qmlproperty color Rect::border.color - The pen used to draw the border of the rect. -*/ -/*! - \property QFxRect::pen - \brief the pen used to draw the border of the rect. + The width and color used to draw the border of the rect. + + A width of 1 creates a thin line. For no line, use a width of 0 or a transparent color. + + To keep the border smooth (rather than blurry), odd widths cause the rect to be painted at + a half-pixel offset; */ -QFxPen *QFxRect::pen() +QFxPen *QFxRect::border() { Q_D(QFxRect); return d->getPen(); @@ -335,11 +315,6 @@ void QFxRect::setGradient(QFxGradient *gradient) painted as a normal rectangle. The same radius is used by all 4 corners; there is currently no way to specify different radii for different corners. */ - -/*! - \property QFxRect::radius - \brief the corner radius used to draw a rounded rect. -*/ qreal QFxRect::radius() const { Q_D(const QFxRect); @@ -371,11 +346,6 @@ void QFxRect::setRadius(qreal radius) The default color is white. */ - -/*! - \property QFxRect::color - \brief the color used to fill the rect. -*/ QColor QFxRect::color() const { Q_D(const QFxRect); @@ -393,8 +363,6 @@ void QFxRect::setColor(const QColor &c) update(); } - - /*! \qmlproperty color Rect::tintColor This property holds The color to tint the rectangle. @@ -409,11 +377,6 @@ void QFxRect::setColor(const QColor &c) This attribute is not intended to be used with a single color over the lifetime of an user interface. It is most useful when a subtle change is intended to be conveyed due to some event; you can then use the tint color to more effectively tune the visible color. */ - -/*! - \property QFxRect::tintColor - \brief The color to tint the rectangle. -*/ QColor QFxRect::tintColor() const { Q_D(const QFxRect); diff --git a/src/declarative/fx/qfxrect.h b/src/declarative/fx/qfxrect.h index d438459..98f5e67 100644 --- a/src/declarative/fx/qfxrect.h +++ b/src/declarative/fx/qfxrect.h @@ -138,7 +138,7 @@ class Q_DECLARATIVE_EXPORT QFxRect : public QFxItem Q_PROPERTY(QColor color READ color WRITE setColor) Q_PROPERTY(QColor tintColor READ tintColor WRITE setTintColor) Q_PROPERTY(QFxGradient *gradient READ gradient WRITE setGradient) - Q_PROPERTY(QFxPen * pen READ pen) + Q_PROPERTY(QFxPen * border READ border) Q_PROPERTY(qreal radius READ radius WRITE setRadius) public: QFxRect(QFxItem *parent=0); @@ -149,7 +149,7 @@ public: QColor tintColor() const; void setTintColor(const QColor &); - QFxPen *pen(); + QFxPen *border(); QFxGradient *gradient() const; void setGradient(QFxGradient *gradient); -- cgit v0.12 From d603edf69f49336bc832b6ee4bb12fbd99d2e50f Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 31 Jul 2009 12:01:27 +1000 Subject: Docs: Make precedence clear. --- src/declarative/fx/qfxrect.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp index 93a2997..955eb61 100644 --- a/src/declarative/fx/qfxrect.cpp +++ b/src/declarative/fx/qfxrect.cpp @@ -285,6 +285,8 @@ QFxPen *QFxRect::border() \endqml \endtable + If both a gradient and a color are specified, the gradient will be used. + \sa Gradient, color */ QFxGradient *QFxRect::gradient() const @@ -345,6 +347,8 @@ void QFxRect::setRadius(qreal radius) \endqml The default color is white. + + If both a gradient and a color are specified, the gradient will be used. */ QColor QFxRect::color() const { -- cgit v0.12