diff --git a/bin/rename-qtdeclarative-symbols.sh b/bin/rename-qtdeclarative-symbols.sh new file mode 100755 index 0000000000..0d521dd5a8 --- /dev/null +++ b/bin/rename-qtdeclarative-symbols.sh @@ -0,0 +1,642 @@ +#!/bin/sh +############################################################################# +## +## Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +## Contact: http://www.qt-project.org/ +## +## This file is part of the QtQml module of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:LGPL$ +## GNU Lesser General Public License Usage +## 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.1, 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. +## +## Other Usage +## Alternatively, this file may be used in accordance with the terms and +## conditions contained in a signed written agreement between you and Nokia. +## +## +## +## +## +## +## $QT_END_LICENSE$ +## +############################################################################# + +# Replaces deprecated QDeclarative symbol names with their replacements +# +# Changes instances in all regular files under the specified directory; +# use on a clean source tree! + +if [ "$#" -lt "1" ] +then + echo " Usage: $0 " + exit 1; +fi + +MODIFY_DIR="$1" + +QML_SYMBOLS="\ + QDeclarativeAbstractBinding + QDeclarativeAbstractBoundSignal + QDeclarativeAbstractExpression + QDeclarativeAccessible + QDeclarativeAccessors + QDeclarativeAccessorProperties + QDeclarativeAnimationTimer + QDeclarativeAssociationList + QDeclarativeAttachedPropertiesFunc + QDeclarativeBinding + QDeclarativeBindingPrivate + QDeclarativeBindingProfiler + QDeclarativeBoundSignal + QDeclarativeBoundSignalParameters + QDeclarativeBoundSignalProxy + QDeclarativeBuiltinFunctions + QDeclarativeCleanup + QDeclarativeColorValueType + QDeclarativeCompiledData + QDeclarativeCompiler + QDeclarativeCompilerTypes + QDeclarativeCompilingProfiler + QDeclarativeComponent + QDeclarativeComponentAttached + QDeclarativeComponentExtension + QDeclarativeComponentPrivate + QDeclarativeComponent_setQmlParent + QDeclarativeCompositeTypeData + QDeclarativeConnectionsParser + QDeclarativeContext + QDeclarativeContextData + QDeclarativeContextPrivate + QDeclarativeCustomParser + QDeclarativeCustomParserNode + QDeclarativeCustomParserNodePrivate + QDeclarativeCustomParserProperty + QDeclarativeCustomParserPropertyPrivate + QDeclarativeData + QDeclarativeDataBlob + QDeclarativeDataExtended + QDeclarativeDataLoader + QDeclarativeDataLoaderNetworkReplyProxy + QDeclarativeDataLoaderThread + QDeclarativeDateExtension + QDeclarativeDataTest + QDeclarativeDebug + QDeclarativeDebugClient + QDeclarativeDebugClientPrivate + QDeclarativeDebugConnection + QDeclarativeDebugConnectionPrivate + QDeclarativeDebugContextReference + QDeclarativeDebugData + QDeclarativeDebugEngineReference + QDeclarativeDebugEnginesQuery + QDeclarativeDebugExpressionQuery + QDeclarativeDebugFileReference + QDeclarativeDebugger + QDeclarativeDebuggingEnabler + QDeclarativeDebugHelper + QDeclarativeDebugObjectExpressionWatch + QDeclarativeDebugObjectQuery + QDeclarativeDebugObjectReference + QDeclarativeDebugPropertyReference + QDeclarativeDebugPropertyWatch + QDeclarativeDebugQuery + QDeclarativeDebugRootContextQuery + QDeclarativeDebugServer + QDeclarativeDebugServerConnection + QDeclarativeDebugServerPrivate + QDeclarativeDebugServerThread + QDeclarativeDebugService + QDeclarativeDebugServicePrivate + QDeclarativeDebugStatesDelegate + QDeclarativeDebugTrace + QDeclarativeDebugWatch + QDeclarativeDelayedError + QDeclarativeDirComponents + QDeclarativeDirParser + QDeclarativeDirScripts + QDeclarativeDOMNodeResource + QDeclarativeEasingValueType + QDeclarativeElement + QDeclarativeEngine + QDeclarativeEngineDebug + QDeclarativeEngineDebugClient + QDeclarativeEngineDebugService + QDeclarativeEngineDebugPrivate + QDeclarativeEnginePrivate + QDeclarativeError + QDeclarativeErrorPrivate + QDeclarativeExpression + QDeclarativeExpressionPrivate + QDeclarativeExtensionInterface + QDeclarativeExtensionPlugin + QDeclarativeFontValueType + QDeclarativeGraphics_DerivedObject + QDeclarativeGuard + QDeclarativeGuardedContextData + QDeclarativeGuardImpl + QDeclarativeHandlingSignalProfiler + QDeclarativeImageProvider + QDeclarativeImageProviderPrivate + QDeclarativeImportDatabase + QDeclarativeImportedNamespace + QDeclarativeImports + QDeclarativeImportsPrivate + QDeclarativeIncubationController + QDeclarativeIncubator + QDeclarativeIncubatorController + QDeclarativeIncubatorPrivate + QDeclarativeIncubators + QDeclarativeInfo + QDeclarativeInfoPrivate + QDeclarativeInspector + QDeclarativeInspectorInterface + QDeclarativeInspectorService + QDeclarativeInstruction + QDeclarativeInstructionData + QDeclarativeInstructionMeta + QDeclarativeIntegerCache + QDeclarativeJavaScriptExpression + QDeclarativeJavaScriptExpressionGuard + QDeclarativeJS + QDeclarativeJSGrammar + QDeclarativeListProperty + QDeclarativeListReference + QDeclarativeListReferencePrivate + QDeclarativeLocale + QDeclarativeLocalStoragePlugin + QDeclarativeMatrix4x4ValueType + QDeclarativeMetaType + QDeclarativeMetaTypeData + QDeclarativeNetworkAccessManagerFactory + QDeclarativeNotifier + QDeclarativeNotifierEndpoint + QDeclarativeNullableValue + QDeclarativeNumberExtension + QDeclarativeObjectCreatingProfiler + QDeclarativeObjectData + QDeclarativeObjectProperty + QDeclarativeObserverMode + QDeclarativeOpenMetaObject + QDeclarativeOpenMetaObjectPrivate + QDeclarativeOpenMetaObjectType + QDeclarativeOpenMetaObjectTypePrivate + QDeclarativeParser + QDeclarativeParserStatus + QDeclarativePointFValueType + QDeclarativePointValueType + QDeclarativePool + QDeclarativePrivate + QDeclarativeProfilerData + QDeclarativeProfilerService + QDeclarativeProperties + QDeclarativeProperty + QDeclarativePropertyCache + QDeclarativePropertyCacheMethodArguments + QDeclarativePropertyData + QDeclarativePropertyMap + QDeclarativePropertyMapMetaObject + QDeclarativePropertyMapPrivate + QDeclarativePropertyPrivate + QDeclarativePropertyRawData + QDeclarativePropertyValueInterceptor + QDeclarativePropertyValueSource + QDeclarativeProxyMetaObject + QDeclarativeQmldirData + QDeclarativeQtQuick1Module + QDeclarativeQtQuick2Module + QDeclarativeQtQuick2DebugStatesDelegate + QDeclarativeQuaternionValueType + QDeclarativeRectFValueType + QDeclarativeRectValueType + QDeclarativeRefCount + QDeclarativeRefPointer + QDeclarativeRegisterType + QDeclarativeRewrite + QDeclarativeScript + QDeclarativeScriptBlob + QDeclarativeScriptData + QDeclarativeScriptPrivate + QDeclarativeScriptString + QDeclarativeScriptStringPrivate + QDeclarativeSizeFValueType + QDeclarativeSizeValueType + QDeclarativeSqlDatabaseData + QDeclarativeStringConverters + QDeclarativeThread + QDeclarativeThreadPrivate + QDeclarativeTrace + QDeclarativeType + QDeclarativeTypeData + QDeclarativeTypeInfo + QDeclarativeTypeLoader + QDeclarativeTypeModule + QDeclarativeTypeModulePrivate + QDeclarativeTypeModuleVersion + QDeclarativeTypeNameCache + QDeclarativeTypeNotAvailable + QDeclarativeTypePrivate + QDeclarativeTypesExtensionInterface + QDeclarativeV8Function + QDeclarativeV8Handle + QDeclarativeValueType + QDeclarativeValueTypeProxyBinding + QDeclarativeValueTypeFactory + QDeclarativeVector2DValueType + QDeclarativeVector3DValueType + QDeclarativeVector4DValueType + QDeclarativeVME + QDeclarativeVMEGuard + QDeclarativeVMEMetaData + QDeclarativeVMEMetaObject + QDeclarativeVMEMetaObjectEndpoint + QDeclarativeVMEVariant + QDeclarativeVMETypes + QDeclarativeWatcher + QDeclarativeWatchProxy + QDeclarativeXMLHttpRequest + QDeclarativeXMLHttpRequestData + QDeclarative_isFileCaseCorrect + QDeclarative_setParent_noEvent + QQuickProperties + QQuickPropertyCacheMethodArguments + QQuickPropertyData +" + +QUICK_SYMBOLS="\ + QDeclarativeAbstractAnimation + QDeclarativeAbstractAnimationAction + QDeclarativeAbstractAnimationPrivate + QDeclarativeAction + QDeclarativeActionEvent + QDeclarativeAnchors + QDeclarativeAnimationController + QDeclarativeAnimationControllerPrivate + QDeclarativeAnimationGroup + QDeclarativeAnimationGroupPrivate + QDeclarativeAnimationPropertyUpdater + QDeclarativeApplication + QDeclarativeApplicationPrivate + QDeclarativeBehavior + QDeclarativeBehaviorPrivate + QDeclarativeBind + QDeclarativeBindPrivate + QDeclarativeBulkValueAnimator + QDeclarativeBulkValueUpdater + QDeclarativeCachedBezier + QDeclarativeChangeSet + QDeclarativeColorAnimation + QDeclarativeConnections + QDeclarativeConnectionsPrivate + QDeclarativeCurve + QDeclarativeDefaultTextureFactory + QDeclarativeFlick + QDeclarativeFocusPanel + QDeclarativeFolderListModel + QDeclarativeFolderListModelPrivate + QDeclarativeFontLoader + QDeclarativeFontLoaderPrivate + QDeclarativeFontObject + QDeclarativeGestureArea + QDeclarativeGestureAreaParser + QDeclarativeGestureAreaPrivate + QDeclarativeGraphics + QDeclarativeItem + QDeclarativeItemAccessor + QDeclarativeItemChangeListener + QDeclarativeItemKeyFilter + QDeclarativeItemPrivate + QDeclarativeListAccessor + QDeclarativeListCompositor + QDeclarativeListElement + QDeclarativeListModel + QDeclarativeListModelParser + QDeclarativeListModelWorkerAgent + QDeclarativeListView + QDeclarativeNumberAnimation + QDeclarativePackage + QDeclarativePackageAttached + QDeclarativePackagePrivate + QDeclarativeParallelAnimation + QDeclarativeParticle + QDeclarativeParticleMotion + QDeclarativeParticleMotionGravity + QDeclarativeParticleMotionLinear + QDeclarativeParticleMotionWander + QDeclarativeParticles + QDeclarativeParticlesPainter + QDeclarativeParticlesPrivate + QDeclarativePath + QDeclarativePathArc + QDeclarativePathAttribute + QDeclarativePathCatmullRomCurve + QDeclarativePathCubic + QDeclarativePathCurve + QDeclarativePathData + QDeclarativePathElement + QDeclarativePathInterpolator + QDeclarativePathLine + QDeclarativePathPercent + QDeclarativePathPrivate + QDeclarativePathQuad + QDeclarativePathSvg + QDeclarativePauseAnimation + QDeclarativePauseAnimationPrivate + QDeclarativePixmap + QDeclarativePixmapData + QDeclarativePixmapKey + QDeclarativePixmapNull + QDeclarativePixmapReader + QDeclarativePixmapReaderThreadObject + QDeclarativePixmapReply + QDeclarativePixmapStore + QDeclarativePropertyAction + QDeclarativePropertyActionPrivate + QDeclarativePropertyAnimation + QDeclarativePropertyAnimationPrivate + QDeclarativePropertyChanges + QDeclarativePropertyChangesParser + QDeclarativePropertyChangesPrivate + QDeclarativeReplaceSignalHandler + QDeclarativeRevertAction + QDeclarativeRotationAnimation + QDeclarativeRotationAnimationPrivate + QDeclarativeSequentialAnimation + QDeclarativeScriptAction + QDeclarativeScriptActionPrivate + QDeclarativeSetPropertyAnimationAction + QDeclarativeSimpleAction + QDeclarativeSmoothedAnimation + QDeclarativeSmoothedAnimationPrivate + QDeclarativeSpringAnimation + QDeclarativeSpringAnimationPrivate + QDeclarativeState + QDeclarativeStateActions + QDeclarativeStateChange + QDeclarativeStateChangeScript + QDeclarativeStateChangeScriptPrivate + QDeclarativeStateGroup + QDeclarativeStateGroupPrivate + QDeclarativeStateOperation + QDeclarativeStateOperationPrivate + QDeclarativeStatePrivate + QDeclarativeStyledText + QDeclarativeStyledTextImgTag + QDeclarativeStyledTextPrivate + QDeclarativeSystemPalette + QDeclarativeSystemPalettePrivate + QDeclarativeTextureFactory + QDeclarativeTimeLine + QDeclarativeTimeLineCallback + QDeclarativeTimeLineObject + QDeclarativeTimeLinePrivate + QDeclarativeTimeLineValue + QDeclarativeTimeLineValueProxy + QDeclarativeTimeLineValues + QDeclarativeTimer + QDeclarativeTimerPrivate + QDeclarativeTransition + QDeclarativeTransitionInstance + QDeclarativeTransitionManager + QDeclarativeTransitionManagerPrivate + QDeclarativeTransitionPrivate + QDeclarativeUtilModule + QDeclarativeVector3dAnimation + QDeclarativeView + QDeclarativeViewInspector + QDeclarativeViewInspectorPrivate + QDeclarativeViewPrivate + QDeclarativeWebView + QDeclarativeXmlListModel + QDeclarativeXmlListModelPrivate + QDeclarativeXmlListModelRole + QDeclarativeXmlListRange + QDeclarativeXmlQueryEngine + QDeclarativeXmlQueryResult + QDeclarativeXmlQueryThreadObject + QDeclarativeXmlRoleList + QDeclarativeSvgParser + QDeclarativeWorkerScript + QDeclarativeWorkerScriptEngine + QDeclarativeWorkerScriptEnginePrivate +" + +QML_INCLUDE_FILES="\ + qdeclarativeaccessible.h + qdeclarativeaccessors_p.h + qdeclarativebinding_p.h + qdeclarativebinding_p_p.h + qdeclarativeboundsignal_p.h + qdeclarativebuiltinfunctions_p.h + qdeclarativecleanup_p.h + qdeclarativecompiler_p.h + qdeclarativecomponentattached_p.h + qdeclarativecomponent.h + qdeclarativecomponent_p.h + qdeclarativecontext.h + qdeclarativecontext_p.h + qdeclarativecustomparser_p.h + qdeclarativecustomparser_p_p.h + qdeclarativedata_p.h + qdeclarativedebugclient_p.h + qdeclarativedebug.h + qdeclarativedebughelper_p.h + qdeclarativedebugserverconnection_p.h + qdeclarativedebugserver_p.h + qdeclarativedebugservice_p.h + qdeclarativedebugservice_p_p.h + qdeclarativedebugstatesdelegate_p.h + qdeclarativedebugtrace_p.h + qdeclarativedirparser_p.h + qdeclarativeenginedebug_p.h + qdeclarativeenginedebugservice_p.h + qdeclarativeengine.h + qdeclarativeengine_p.h + qdeclarativeerror.h + qdeclarativeexpression.h + qdeclarativeexpression_p.h + qdeclarativeextensioninterface.h + qdeclarativeextensionplugin.h + qdeclarativeglobal_p.h + qdeclarativeguard_p.h + qdeclarative.h + qdeclarativeimageprovider.h + qdeclarativeimport_p.h + qdeclarativeincubator.h + qdeclarativeincubator_p.h + qdeclarativeinfo.h + qdeclarativeinspectorinterface_p.h + qdeclarativeinspectorprotocol.h + qdeclarativeinspectorservice_p.h + qdeclarativeinstruction_p.h + qdeclarativeintegercache_p.h + qdeclarativejsastfwd_p.h + qdeclarativejsast_p.h + qdeclarativejsastvisitor_p.h + qdeclarativejsengine_p.h + qdeclarativejsglobal_p.h + qdeclarativejsgrammar_p.h + qdeclarativejskeywords_p.h + qdeclarativejslexer_p.h + qdeclarativejsmemorypool_p.h + qdeclarativejsparser_p.h + qdeclarativelist.h + qdeclarativelist_p.h + qdeclarativelocale_p.h + qdeclarativemetatype_p.h + qdeclarativenetworkaccessmanagerfactory.h + qdeclarativenotifier_p.h + qdeclarativenullablevalue_p_p.h + qdeclarativeopenmetaobject_p.h + qdeclarativeparserstatus.h + qdeclarativepool_p.h + qdeclarativeprivate.h + qdeclarativeprofilerservice_p.h + qdeclarativepropertycache_p.h + qdeclarativeproperty.h + qdeclarativepropertymap.h + qdeclarativeproperty_p.h + qdeclarativepropertyvalueinterceptor_p.h + qdeclarativepropertyvaluesource.h + qdeclarativeproxymetaobject_p.h + qdeclarativerefcount_p.h + qdeclarativerewrite_p.h + qdeclarativescript_p.h + qdeclarativescriptstring.h + qdeclarativescriptstring_p.h + qdeclarativesqldatabase_p.h + qdeclarativestringconverters_p.h + qdeclarativethread_p.h + qdeclarativetrace_p.h + qdeclarativetypeloader_p.h + qdeclarativetypenamecache_p.h + qdeclarativetypenotavailable_p.h + qdeclarativevaluetype_p.h + qdeclarativevmemetaobject_p.h + qdeclarativevme_p.h + qdeclarativewatcher_p.h + qdeclarativexmlhttprequest_p.h + qdeclarativexmllistmodel_p.h +" + +QUICK_INCLUDE_FILES="\ + qdeclarativeanimation_p.h + qdeclarativeanimation_p_p.h + qdeclarativeanimationcontroller_p.h + qdeclarativeapplication_p.h + qdeclarativebehavior_p.h + qdeclarativebind_p.h + qdeclarativechangeset_p.h + qdeclarativeconnections_p.h + qdeclarativefolderlistmodel.h + qdeclarativefontloader_p.h + qdeclarativelistaccessor_p.h + qdeclarativelistcompositor_p.h + qdeclarativelistmodel_p.h + qdeclarativelistmodel_p_p.h + qdeclarativelistmodelworkeragent_p.h + qdeclarativepackage_p.h + qdeclarativepathinterpolator_p.h + qdeclarativepath_p.h + qdeclarativepath_p_p.h + qdeclarativepixmapcache_p.h + qdeclarativepropertychanges_p.h + qdeclarativesmoothedanimation_p.h + qdeclarativesmoothedanimation_p_p.h + qdeclarativespringanimation_p.h + qdeclarativestategroup_p.h + qdeclarativestateoperations_p.h + qdeclarativestate_p.h + qdeclarativestate_p_p.h + qdeclarativestyledtext_p.h + qdeclarativesvgparser_p.h + qdeclarativesystempalette_p.h + qdeclarativetimeline_p_p.h + qdeclarativetimer_p.h + qdeclarativetransitionmanager_p_p.h + qdeclarativetransition_p.h + qdeclarativeutilmodule_p.h + qdeclarativeworkerscript_p.h +" + +replaceMatch() +{ + SYMBOL="$1" + REPLACEMENT="$2" + echo "Replacing $SYMBOL with $REPLACEMENT:" + + CONTAINERS=$(find "$MODIFY_DIR" ! -path ".git" -type f | xargs grep -l -I "$SYMBOL") + for CONTAINER in $CONTAINERS + do + echo " $CONTAINER" + TMP_FILE="$CONTAINER.tmp" + + sed 's|'"$SYMBOL"'|'"$REPLACEMENT"'|g' <"$CONTAINER" >"$TMP_FILE" + mv "$TMP_FILE" "$CONTAINER" + done + echo +} + +for QML_SYMBOL in $QML_SYMBOLS +do + QML_REPLACEMENT="QQml${QML_SYMBOL#QDeclarative}" + replaceMatch "\" "QtQml/$QML_REPLACEMENT" + replaceMatch "\<$QML_SYMBOL\>" "$QML_REPLACEMENT" +done + +for QUICK_SYMBOL in $QUICK_SYMBOLS +do + QUICK_REPLACEMENT="QQuick${QUICK_SYMBOL#QDeclarative}" + replaceMatch "\" "QtQuick/$QUICK_REPLACEMENT" + replaceMatch "\<$QUICK_SYMBOL\>" "$QUICK_REPLACEMENT" +done + +for QML_INCLUDE_FILE in $QML_INCLUDE_FILES +do + QML_INCLUDE_REPLACEMENT="qqml${QML_INCLUDE_FILE#qdeclarative}" + replaceMatch "\<$QML_INCLUDE_FILE\>" "$QML_INCLUDE_REPLACEMENT" +done + +for QUICK_INCLUDE_FILE in $QUICK_INCLUDE_FILES +do + QUICK_INCLUDE_REPLACEMENT="qquick${QUICK_INCLUDE_FILE#qdeclarative}" + replaceMatch "\<$QUICK_INCLUDE_FILE\>" "$QUICK_INCLUDE_REPLACEMENT" +done + +# Various one-off replacements +replaceMatch "\" "QtQml" +replaceMatch "\") +for CONTAINER in $CONTAINERS +do + echo " $CONTAINER" + TMP_FILE="$CONTAINER.tmp" + + sed 's|\|qml|g' <"$CONTAINER" >"$TMP_FILE" + mv "$TMP_FILE" "$CONTAINER" +done +echo + +echo "Replacements complete" +exit 0 diff --git a/doc/src/localstorage/localstorage.qdoc b/doc/src/localstorage/localstorage.qdoc index 7f4c2b021e..5287120e86 100644 --- a/doc/src/localstorage/localstorage.qdoc +++ b/doc/src/localstorage/localstorage.qdoc @@ -58,7 +58,7 @@ provide the ability to access local storage in an SQL database. These databases are user-specific and QML-specific, but accessible to all QML applications. They are stored in the \c Databases subdirectory -of QDeclarativeEngine::offlineStoragePath(), currently as SQLite databases. +of QQmlEngine::offlineStoragePath(), currently as SQLite databases. Database connections are automatically closed during Javascript garbage collection. diff --git a/doc/src/qml/basictypes.qdoc b/doc/src/qml/basictypes.qdoc index 150383fdc2..0f66a96731 100644 --- a/doc/src/qml/basictypes.qdoc +++ b/doc/src/qml/basictypes.qdoc @@ -180,7 +180,7 @@ \div{float-right} \inlineimage declarative-colors.png \enddiv - \snippet doc/src/snippets/declarative/colors.qml colors + \snippet doc/src/snippets/qml/colors.qml colors Or with the \l{QML:Qt::rgba()}{Qt.rgba()}, \l{QML:Qt::hsla()}{Qt.hsla()}, \l{QML:Qt::darker()}{Qt.darker()}, \l{QML:Qt::lighter()}{Qt.lighter()} or \l{QML:Qt::tint()}{Qt.tint()} functions: diff --git a/doc/src/qml/c++models.qdoc b/doc/src/qml/c++models.qdoc index e2498134fe..943c79c184 100644 --- a/doc/src/qml/c++models.qdoc +++ b/doc/src/qml/c++models.qdoc @@ -57,7 +57,7 @@ models. \bold{Note:} There is no way for the view to know that the contents of a QStringList have changed. If the QStringList changes, it will be necessary to reset - the model by calling QDeclarativeContext::setContextProperty() again. + the model by calling QQmlContext::setContextProperty() again. \section1 QObjectList-based model @@ -92,7 +92,7 @@ models. Note: There is no way for the view to know that the contents of a QList have changed. If the QList changes, it will be necessary to reset - the model by calling QDeclarativeContext::setContextProperty() again. + the model by calling QQmlContext::setContextProperty() again. \section1 QAbstractItemModel @@ -160,10 +160,10 @@ models. \section1 Exposing C++ Data Models to QML -The above examples use QDeclarativeContext::setContextProperty() to set +The above examples use QQmlContext::setContextProperty() to set model values directly in QML components. An alternative to this is to register the C++ model class as a QML type from a QML C++ plugin using -QDeclarativeExtensionPlugin. This would allow the model classes to be +QQmlExtensionPlugin. This would allow the model classes to be created directly as elements within QML: \table @@ -171,7 +171,7 @@ created directly as elements within QML: \o \code -class MyModelPlugin : public QDeclarativeExtensionPlugin +class MyModelPlugin : public QQmlExtensionPlugin { public: void registerTypes(const char *uri) diff --git a/doc/src/qml/codingconventions.qdoc b/doc/src/qml/codingconventions.qdoc index 89fdfd59f9..9e1ce34c2c 100644 --- a/doc/src/qml/codingconventions.qdoc +++ b/doc/src/qml/codingconventions.qdoc @@ -52,7 +52,7 @@ For better readability, we separate these different parts with an empty line. For example, a hypothetical \i photo QML object would look like this: -\snippet doc/src/snippets/declarative/codingconventions/photo.qml 0 +\snippet doc/src/snippets/qml/codingconventions/photo.qml 0 \section1 Grouped Properties @@ -62,11 +62,11 @@ we use the \i {group notation} rather than the \i {dot notation} to improve read For example, this: -\snippet doc/src/snippets/declarative/codingconventions/dotproperties.qml 0 +\snippet doc/src/snippets/qml/codingconventions/dotproperties.qml 0 can be written like this: -\snippet doc/src/snippets/declarative/codingconventions/dotproperties.qml 1 +\snippet doc/src/snippets/qml/codingconventions/dotproperties.qml 1 \section1 Private Properties @@ -78,7 +78,7 @@ the implementation. As a convention, private properties begin with two accessible but is not meant for public use. Note that QML and JavaScript will grant the user access to these properties. -\snippet doc/src/snippets/declarative/codingconventions/private.qml 0 +\snippet doc/src/snippets/qml/codingconventions/private.qml 0 \section1 Lists @@ -89,30 +89,30 @@ For example, it is very common for a component to only have one state. In this case, instead of: -\snippet doc/src/snippets/declarative/codingconventions/lists.qml 0 +\snippet doc/src/snippets/qml/codingconventions/lists.qml 0 we will write this: -\snippet doc/src/snippets/declarative/codingconventions/lists.qml 1 +\snippet doc/src/snippets/qml/codingconventions/lists.qml 1 \section1 JavaScript Code If the script is a single expression, we recommend writing it inline: -\snippet doc/src/snippets/declarative/codingconventions/javascript.qml 0 +\snippet doc/src/snippets/qml/codingconventions/javascript.qml 0 If the script is only a couple of lines long, we generally use a block: -\snippet doc/src/snippets/declarative/codingconventions/javascript.qml 1 +\snippet doc/src/snippets/qml/codingconventions/javascript.qml 1 If the script is more than a couple of lines long or can be used by different objects, we recommend creating a function and calling it like this: -\snippet doc/src/snippets/declarative/codingconventions/javascript.qml 2 +\snippet doc/src/snippets/qml/codingconventions/javascript.qml 2 For long scripts, we will put the functions in their own JavaScript file and import it like this: -\snippet doc/src/snippets/declarative/codingconventions/javascript-imports.qml 0 +\snippet doc/src/snippets/qml/codingconventions/javascript-imports.qml 0 */ diff --git a/doc/src/qml/debugging.qdoc b/doc/src/qml/debugging.qdoc index 520e23abb5..562464a419 100644 --- a/doc/src/qml/debugging.qdoc +++ b/doc/src/qml/debugging.qdoc @@ -148,11 +148,11 @@ If you set \c {QML_IMPORT_TRACE=1} before running the \l {QML Viewer} (or your QML C++ application), you will see output similar to this: \code -QDeclarativeImportDatabase::addImportPath "/qt-sdk/imports" -QDeclarativeImportDatabase::addImportPath "/qt-sdk/bin/QMLViewer.app/Contents/MacOS" -QDeclarativeImportDatabase::addToImport 0x106237370 "." -1.-1 File as "" -QDeclarativeImportDatabase::addToImport 0x106237370 "Qt" 4.7 Library as "" -QDeclarativeImportDatabase::resolveType "Rectangle" = "QDeclarativeRectangle" +QQmlImportDatabase::addImportPath "/qt-sdk/imports" +QQmlImportDatabase::addImportPath "/qt-sdk/bin/QMLViewer.app/Contents/MacOS" +QQmlImportDatabase::addToImport 0x106237370 "." -1.-1 File as "" +QQmlImportDatabase::addToImport 0x106237370 "Qt" 4.7 Library as "" +QQmlImportDatabase::resolveType "Rectangle" = "QDeclarativeRectangle" \endcode diff --git a/doc/src/qml/dynamicobjects.qdoc b/doc/src/qml/dynamicobjects.qdoc index e3d9adb49a..c50f9dd337 100644 --- a/doc/src/qml/dynamicobjects.qdoc +++ b/doc/src/qml/dynamicobjects.qdoc @@ -80,31 +80,31 @@ the component. This function can take one or two arguments: Here is an example. First there is \c Sprite.qml, which defines a simple QML component: -\snippet doc/src/snippets/declarative/Sprite.qml 0 +\snippet doc/src/snippets/qml/Sprite.qml 0 Our main application file, \c main.qml, imports a \c componentCreation.js JavaScript file that will create \c Sprite objects: -\snippet doc/src/snippets/declarative/createComponent.qml 0 +\snippet doc/src/snippets/qml/createComponent.qml 0 Here is \c componentCreation.js. Notice it checks whether the component \l{Component::status}{status} is \c Component.Ready before calling \l {Component::createObject()}{createObject()} in case the QML file is loaded over a network and thus is not ready immediately. -\snippet doc/src/snippets/declarative/componentCreation.js vars +\snippet doc/src/snippets/qml/componentCreation.js vars \codeline -\snippet doc/src/snippets/declarative/componentCreation.js func -\snippet doc/src/snippets/declarative/componentCreation.js remote -\snippet doc/src/snippets/declarative/componentCreation.js func-end +\snippet doc/src/snippets/qml/componentCreation.js func +\snippet doc/src/snippets/qml/componentCreation.js remote +\snippet doc/src/snippets/qml/componentCreation.js func-end \codeline -\snippet doc/src/snippets/declarative/componentCreation.js finishCreation +\snippet doc/src/snippets/qml/componentCreation.js finishCreation If you are certain the QML file to be loaded is a local file, you could omit the \c finishCreation() function and call \l {Component::createObject()}{createObject()} immediately: -\snippet doc/src/snippets/declarative/componentCreation.js func -\snippet doc/src/snippets/declarative/componentCreation.js local -\snippet doc/src/snippets/declarative/componentCreation.js func-end +\snippet doc/src/snippets/qml/componentCreation.js func +\snippet doc/src/snippets/qml/componentCreation.js local +\snippet doc/src/snippets/qml/componentCreation.js func-end Notice in both instances, \l {Component::createObject()}{createObject()} is called with \c appWindow passed as an argument so that the created object will become a child of the @@ -124,7 +124,7 @@ use the signal \c connect() method. See If the QML is not defined until runtime, you can create a QML item from a string of QML using the \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()} function, as in the following example: -\snippet doc/src/snippets/declarative/createQmlObject.qml 0 +\snippet doc/src/snippets/qml/createQmlObject.qml 0 The first argument is the string of QML to create. Just like in a new file, you will need to import any types you wish to use. The second argument is the parent item for the new item; @@ -145,7 +145,7 @@ The actual creation context depends on how an item is created: \list \o If \l {QML:Qt::createComponent()}{Qt.createComponent()} is used, the creation context - is the QDeclarativeContext in which this method is called + is the QQmlContext in which this method is called \o If \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()} if called, the creation context is the context of the parent item passed to this method \o If a \c {Component{}} item is defined and \l {Component::createObject()}{createObject()} @@ -181,8 +181,8 @@ component. Each instance runs a NumberAnimation, and when the animation has fini \o \c SelfDestroyingRect.qml \row -\o \snippet doc/src/snippets/declarative/dynamicObjects-destroy.qml 0 -\o \snippet doc/src/snippets/declarative/SelfDestroyingRect.qml 0 +\o \snippet doc/src/snippets/qml/dynamicObjects-destroy.qml 0 +\o \snippet doc/src/snippets/qml/SelfDestroyingRect.qml 0 \endtable @@ -209,6 +209,6 @@ destroyed if they were dynamically created. Objects created with \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()} can similarly be destroyed using \c destroy(): -\snippet doc/src/snippets/declarative/createQmlObject.qml 0 -\snippet doc/src/snippets/declarative/createQmlObject.qml destroy +\snippet doc/src/snippets/qml/createQmlObject.qml 0 +\snippet doc/src/snippets/qml/createQmlObject.qml destroy */ diff --git a/doc/src/qml/extending-tutorial.qdoc b/doc/src/qml/extending-tutorial.qdoc index 00f4bb5691..b995c32cca 100644 --- a/doc/src/qml/extending-tutorial.qdoc +++ b/doc/src/qml/extending-tutorial.qdoc @@ -100,14 +100,14 @@ Here is our \c PieChart class, defined in \c piechart.h: \snippet declarative/tutorials/extending/chapter1-basics/piechart.h 0 -The class inherits from QDeclarativeItem because we want to override -QDeclarativeItem::paint() in order to draw. If the class just represented some +The class inherits from QQuickItem because we want to override +QQuickItem::paint() in order to draw. If the class just represented some data type and was not an item that actually needed to be displayed, it could simply inherit from QObject. Or, if we want to extend the functionality of an existing QObject-based class, it could inherit from that class instead. The \c PieChart class defines the two properties, \c name and \c color, with the Q_PROPERTY macro, -and overrides QDeclarativeItem::paint(). The class implementation in \c piechart.cpp +and overrides QQuickItem::paint(). The class implementation in \c piechart.cpp simply sets and returns the \c m_name and \c m_color values as appropriate, and implements \c paint() to draw a simple pie chart. It also turns off the QGraphicsItem::ItemHasNoContents flag to enable painting: @@ -127,7 +127,7 @@ converted to a QColor object for the PieChart \c color property. Automatic conve provided for various other \l {QML Basic Types}{basic types}; for example, a string like "640x480" can be automatically converted to a QSize value. -We'll also create a C++ application that uses a QDeclarativeView to run and +We'll also create a C++ application that uses a QQuickView to run and display \c app.qml. The application must register the \c PieChart type using the qmlRegisterType() function, to allow it to be used from QML. If you don't register the type, \c app.qml won't be able to create a \c PieChart. @@ -265,7 +265,7 @@ int-type property to store an identifier for each chart: \code // C++ - class PieChart : public QDeclarativeItem + class PieChart : public QQuickItem { Q_PROPERTY(int chartId READ chartId WRITE setChartId NOTIFY chartIdChanged) ... @@ -306,7 +306,7 @@ we assign an \c PieSlice value which itself contains a \c color: \snippet declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml 0 -Like \c PieChart, this new \c PieSlice type inherits from QDeclarativeItem and declares +Like \c PieChart, this new \c PieSlice type inherits from QQuickItem and declares its properties with Q_PROPERTY(): \snippet declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h 0 @@ -324,7 +324,7 @@ and associated method signatures: There is one thing to be aware of when implementing \c setPieSlice(). The \c PieSlice is a visual item, so it must be set as a child of the \c PieChart using -QDeclarativeItem::setParentItem() so that the \c PieChart knows to paint this child +QQuickItem::setParentItem() so that the \c PieChart knows to paint this child item when its contents are drawn: \snippet declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp 0 @@ -359,7 +359,7 @@ have a \c slices property that accepts a list of \c PieSlice items: \image extending-tutorial-chapter5.png To do this, we replace the \c pieSlice property in \c PieChart with a \c slices property, -declared as a QDeclarativeListProperty type. The QDeclarativeListProperty class enables the +declared as a QQmlListProperty type. The QQmlListProperty class enables the creation of list properties in QML extensions. We replace the \c pieSlice() function with a \c slices() function that returns a list of slices, and add an internal \c append_slice() function (discussed below). We also use a QList to @@ -372,9 +372,9 @@ store the internal list of slices as \c m_slices: \snippet declarative/tutorials/extending/chapter5-listproperties/piechart.h 2 Although the \c slices property does not have an associated \c WRITE function, -it is still modifiable because of the way QDeclarativeListProperty works. +it is still modifiable because of the way QQmlListProperty works. In the \c PieChart implementation, we implement \c PieChart::slices() to -return a QDeclarativeListProperty value and indicate that the internal +return a QQmlListProperty value and indicate that the internal \c PieChart::append_slice() function is to be called whenever a request is made from QML to add items to the list: @@ -382,7 +382,7 @@ to add items to the list: The \c append_slice() function simply sets the parent item as before, and adds the new item to the \c m_slices list. As you can see, the append function for a -QDeclarativeListProperty is called with two arguments: the list property, and +QQmlListProperty is called with two arguments: the list property, and the item that is to be appended. The \c PieSlice class has also been modified to include \c fromAngle and \c angleSpan @@ -400,7 +400,7 @@ The complete code can be seen in the updated \c examples/tutorials/extending/cha \example declarative/tutorials/extending/chapter6-plugins Currently the \c PieChart and \c PieSlice types are used by \c app.qml, -which is displayed using a QDeclarativeView in a C++ application. An alternative +which is displayed using a QQuickView in a C++ application. An alternative way to use our QML extension is to create a plugin library to make it available to the QML engine. This allows \c app.qml to be loaded with the \l {QML Viewer} (or some other QML \l{Qt Declarative UI Runtime}{runtime} application) instead of writing a \c main.cpp file and @@ -414,8 +414,8 @@ To create a plugin library, we need: \o A \l{Writing a qmldir file}{qmldir} file that tells the QML engine to load the plugin \endlist -First, we create a plugin class named \c ChartsPlugin. It subclasses QDeclarativeExtensionPlugin -and registers our QML types in the inherited \l{QDeclarativeExtensionPlugin::}{registerTypes()} method. It also calls +First, we create a plugin class named \c ChartsPlugin. It subclasses QQmlExtensionPlugin +and registers our QML types in the inherited \l{QQmlExtensionPlugin::}{registerTypes()} method. It also calls Q_EXPORT_PLUGIN2 for Qt's \l{How to Create Qt Plugins}{plugin system}. Here is the \c ChartsPlugin definition in \c chartsplugin.h: @@ -464,7 +464,7 @@ In this tutorial, we've shown the basic steps for creating a QML extension: \o Add callable methods using Q_INVOKABLE or Qt slots, and connect to Qt signals with an \c onSignal syntax \o Add property bindings by defining \l{Qt's Property System}{NOTIFY} signals \o Define custom property types if the built-in types are not sufficient -\o Define list property types using QDeclarativeListProperty +\o Define list property types using QQmlListProperty \o Create a plugin library by defining a Qt plugin and writing a \c qmldir file \endlist diff --git a/doc/src/qml/integrating.qdoc b/doc/src/qml/integrating.qdoc index 7cd15a4fd4..2a88246006 100644 --- a/doc/src/qml/integrating.qdoc +++ b/doc/src/qml/integrating.qdoc @@ -38,13 +38,13 @@ depending on the characteristics of your existing UI code. \section1 Integrating with a \l{QWidget}-based UI If you have an existing QWidget-based UI, QML widgets can be integrated into -it using QDeclarativeView. QDeclarativeView is a subclass of QWidget so you +it using QQuickView. QQuickView is a subclass of QWidget so you can add it to your user interface like any other QWidget. Use -QDeclarativeView::setSource() to load a QML file into the view, then add the +QQuickView::setSource() to load a QML file into the view, then add the view to your UI: \code -QDeclarativeView *qmlView = new QDeclarativeView; +QQuickView *qmlView = new QQuickView; qmlView->setSource(QUrl::fromLocalFile("myqml.qml")); QWidget *widget = myExistingWidget(); @@ -52,11 +52,11 @@ QVBoxLayout *layout = new QVBoxLayout(widget); layout->addWidget(qmlView); \endcode -The one drawback to this approach is that QDeclarativeView is slower to initialize -and uses more memory than a QWidget, and creating large numbers of QDeclarativeView +The one drawback to this approach is that QQuickView is slower to initialize +and uses more memory than a QWidget, and creating large numbers of QQuickView objects may lead to performance degradation. If this is the case, it may be better to rewrite your widgets in QML, and load the widgets from a main QML widget -instead of using QDeclarativeView. +instead of using QQuickView. Keep in mind that QWidgets were designed for a different type of user interface than QML, so it is not always a good idea to port a QWidget-based application to @@ -71,7 +71,7 @@ of simple and dynamic elements. If you have an existing UI based on the \l{Graphics View Framework}, you can integrate QML widgets directly into your QGraphicsScene. Use -QDeclarativeComponent to create a QGraphicsObject from a QML file, and +QQmlComponent to create a QGraphicsObject from a QML file, and place the graphics object into your scene using \l{QGraphicsScene::addItem()}, or reparent it to an item already in the \l{QGraphicsScene}. @@ -79,8 +79,8 @@ For example: \code QGraphicsScene* scene = myExistingGraphicsScene(); -QDeclarativeEngine *engine = new QDeclarativeEngine; -QDeclarativeComponent component(engine, QUrl::fromLocalFile("myqml.qml")); +QQmlEngine *engine = new QQmlEngine; +QQmlComponent component(engine, QUrl::fromLocalFile("myqml.qml")); QGraphicsObject *object = qobject_cast(component.create()); scene->addItem(object); diff --git a/doc/src/qml/javascriptblocks.qdoc b/doc/src/qml/javascriptblocks.qdoc index 4cc98f1d7a..0c1d4c284c 100644 --- a/doc/src/qml/javascriptblocks.qdoc +++ b/doc/src/qml/javascriptblocks.qdoc @@ -200,8 +200,8 @@ in \c script.js: \table \row -\o \snippet doc/src/snippets/declarative/integrating-javascript/connectjs.qml 0 -\o \snippet doc/src/snippets/declarative/integrating-javascript/script.js 0 +\o \snippet doc/src/snippets/qml/integrating-javascript/connectjs.qml 0 +\o \snippet doc/src/snippets/qml/integrating-javascript/script.js 0 \endtable The \c jsFunction() will now be called whenever MouseArea's \c clicked signal is emitted. @@ -222,7 +222,7 @@ Both relative and absolute JavaScript URLs can be imported. In the case of a relative URL, the location is resolved relative to the location of the \l {QML Document} that contains the import. If the script file is not accessible, an error will occur. If the JavaScript needs to be fetched from a network -resource, the component's \l {QDeclarativeComponent::status()}{status} is set to +resource, the component's \l {QQmlComponent::status()}{status} is set to "Loading" until the script has been downloaded. Imported JavaScript files are always qualified using the "as" keyword. The @@ -243,10 +243,10 @@ which in turn can call \c factorial() in \c factorial.js, as it has included \table \row -\o {1,2} \snippet doc/src/snippets/declarative/integrating-javascript/includejs/app.qml 0 -\o \snippet doc/src/snippets/declarative/integrating-javascript/includejs/script.js 0 +\o {1,2} \snippet doc/src/snippets/qml/integrating-javascript/includejs/app.qml 0 +\o \snippet doc/src/snippets/qml/integrating-javascript/includejs/script.js 0 \row -\o \snippet doc/src/snippets/declarative/integrating-javascript/includejs/factorial.js 0 +\o \snippet doc/src/snippets/qml/integrating-javascript/includejs/factorial.js 0 \endtable Notice that calling \l {QML:Qt::include()}{Qt.include()} imports all functions from @@ -479,11 +479,11 @@ themselves. For the following examples, imagine that we have defined the following class: -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.h 0 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.h 0 and that we have registered it with the QML type-system as follows: -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp 0 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp 0 The AvatarExample class has a property which is a pixmap. When the property is accessed in JavaScript scope, a copy of the resource will be created and @@ -498,9 +498,9 @@ unless the client explicitly preserves it. In the following example, the scarce resource will be automatically released after the binding evaluation is complete. -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleOne.qml 0 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/exampleOne.qml 0 -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp 1 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp 1 \section2 Example Two: Automatic Release Prevented By Reference @@ -509,9 +509,9 @@ released after the binding expression evaluation is complete, because there is a property var referencing the scarce resource. -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleTwo.qml 0 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/exampleTwo.qml 0 -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp 2 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp 2 \section2 Example Three: Explicit Preservation @@ -519,11 +519,11 @@ In this example, the resource must be explicitly preserved in order to prevent the declarative engine from automatically releasing the resource after evaluation of the imported script. -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.js 0 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.js 0 -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.qml 0 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.qml 0 -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp 3 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp 3 \section2 Example Four: Explicit Destruction @@ -532,11 +532,11 @@ scarce resource variant. This example shows how a client may free system resources by releasing the scarce resource held in a JavaScript object, if required, during evaluation of a JavaScript expression. -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.js 0 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.js 0 -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.qml 0 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.qml 0 -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp 4 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp 4 \section2 Example Five: Explicit Destruction And JavaScript References @@ -546,8 +546,8 @@ to one scarce resource is held, and the client calls destroy() on one of those references (to explicitly release the scarce resource), all of the references will be affected. -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFive.qml 0 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFive.qml 0 -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp 5 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp 5 */ diff --git a/doc/src/qml/modules.qdoc b/doc/src/qml/modules.qdoc index f75c03301c..27f8ae8fb1 100644 --- a/doc/src/qml/modules.qdoc +++ b/doc/src/qml/modules.qdoc @@ -45,14 +45,14 @@ example, an \c import statement is required to use: \list \o A component defined in another QML file that is not in the same directory \o A component defined in a QML file located on a remote server -\o A \l{QDeclarativeExtensionPlugin}{QML extension plugin} library (unless the plugin is installed in the same directory) +\o A \l{QQmlExtensionPlugin}{QML extension plugin} library (unless the plugin is installed in the same directory) \o A JavaScript file (note this must be imported using \l {#namespaces}{named imports}) \endlist An \c import statement includes the module name, and possibly a version number. This can be seen in the snippet commonly found at the top of QML files: -\snippet doc/src/snippets/declarative/imports/qtquick-1.0.qml import +\snippet doc/src/snippets/qml/imports/qtquick-1.0.qml import This imports version 1.0 of the "QtQuick" module into the global namespace. (The QML library itself must be imported to use any of the \l {QML Elements}, as they @@ -111,7 +111,7 @@ Window { Similarly, if the directory resided on a network source, it could be imported like this: -\snippet doc/src/snippets/declarative/imports/network-imports.qml imports +\snippet doc/src/snippets/qml/imports/network-imports.qml imports A located module can also be imported as a network resource if it has a \l{Writing a qmldir file}{qmldir file} in the directory that specifies the QML files @@ -145,7 +145,7 @@ a later version was used, as the \c qmldir file specifies that these elements are only available in the 1.0 version. Note that modules imported as a network resource allow only access to components -defined in QML files; components defined by C++ \l{QDeclarativeExtensionPlugin}{QML extension plugins} +defined in QML files; components defined by C++ \l{QQmlExtensionPlugin}{QML extension plugins} are not available. @@ -153,7 +153,7 @@ are not available. \section1 Installed Modules Installed modules are modules that are made available through the QML import path, -as defined by QDeclarativeEngine::importPathList(), or modules defined within +as defined by QQmlEngine::importPathList(), or modules defined within C++ application code. An installed module is referred to by a URI, which allows the module to be imported from QML code without specifying a complete filesystem path or network resource URL. @@ -161,7 +161,7 @@ path or network resource URL. When importing an installed module, an un-quoted URI is used, with a mandatory version number: -\snippet doc/src/snippets/declarative/imports/installed-module.qml imports +\snippet doc/src/snippets/qml/imports/installed-module.qml imports When a module is imported, the QML engine searches the QML import path for a matching module. The root directory of the module must contain a @@ -177,7 +177,7 @@ module could be located under \c com/nokia/qml/mymodule.2/qmldir or \c com/nokia/qml/mymodule.2.1/qmldir. The engine will automatically load the module which matches best. -The import path, as returned by QDeclarativeEngine::importPathList(), defines the default +The import path, as returned by QQmlEngine::importPathList(), defines the default locations to be searched by the QML engine for a matching module. By default, this list contains: @@ -187,7 +187,7 @@ contains: \o Paths specified by the \c QML_IMPORT_PATH environment variable \endlist -Additional import paths can be added through QDeclarativeEngine::addImportPath() or the +Additional import paths can be added through QQmlEngine::addImportPath() or the \c QML_IMPORT_PATH environment variable. When running the \l {QML Viewer}, you can also use the \c -I option to add an import path. @@ -227,7 +227,7 @@ as \c http://www.some-server.com/qml and this URL was added to the QML import pa QML code would work just the same. Note that modules imported as a network resource allow only access to components -defined in QML files; components defined by C++ \l{QDeclarativeExtensionPlugin}{QML extension plugins} +defined in QML files; components defined by C++ \l{QQmlExtensionPlugin}{QML extension plugins} are not available. @@ -244,10 +244,10 @@ qmlRegisterType("Charts", 1, 0, "PieChart"); This allows the application's QML files to use the \c PieChart type by importing the declared \c Charts module: -\snippet doc/src/snippets/declarative/imports/chart.qml import +\snippet doc/src/snippets/qml/imports/chart.qml import -For \l{QDeclarativeExtensionPlugin}{QML plugins}, the -module URI is automatically passed to QDeclarativeExtensionPlugin::registerTypes(). This method +For \l{QQmlExtensionPlugin}{QML plugins}, the +module URI is automatically passed to QQmlExtensionPlugin::registerTypes(). This method can be reimplemented by the developer to register the necessary types for the module. Below is the \c registerTypes() implementation from the \l{declarative/cppextensions/plugins}{QML plugins} example: @@ -257,7 +257,7 @@ example: Once the plugin is built and installed, and includes a \l{Writing a qmldir file}{qmldir file}, the module can be imported from QML, like this: -\snippet doc/src/snippets/declarative/imports/timeexample.qml import +\snippet doc/src/snippets/qml/imports/timeexample.qml import Unlike QML types defined by QML files, a QML type defined in a C++ extension plugin cannot be loaded by a module that is imported as a network resource. @@ -271,15 +271,15 @@ By default, when a module is imported, its contents are imported into the global To import a module into a specific namespace, use the \i as keyword: -\snippet doc/src/snippets/declarative/imports/named-imports.qml imports +\snippet doc/src/snippets/qml/imports/named-imports.qml imports Types from these modules can then only be used when qualified by the namespace: -\snippet doc/src/snippets/declarative/imports/named-imports.qml imported items +\snippet doc/src/snippets/qml/imports/named-imports.qml imported items Multiple modules can be imported into the same namespace in the same way that multiple modules can be imported into the global namespace: -\snippet doc/src/snippets/declarative/imports/merged-named-imports.qml imports +\snippet doc/src/snippets/qml/imports/merged-named-imports.qml imports \section2 JavaScript Files @@ -381,14 +381,14 @@ into a Namespace exported by the module. The contents of the script file are ma available inside the namespace , which has the version number . -\bold {plugin []} lines are used to add \l{QDeclarativeExtensionPlugin}{QML C++ plugins} to the module. is the name of the library. It is usually not the same as the file name +\bold {plugin []} lines are used to add \l{QQmlExtensionPlugin}{QML C++ plugins} to the module. is the name of the library. It is usually not the same as the file name of the plugin binary, which is platform dependent; e.g. the library \c MyAppTypes would produce \c libMyAppTypes.so on Linux and \c MyAppTypes.dll on Windows. is an optional argument specifying either an absolute path to the directory containing the plugin file, or a relative path from the directory containing the \c qmldir file to the directory containing the plugin file. By default the engine searches for the plugin library in the directory that contains the \c qmldir -file. The plugin search path can be queried with QDeclarativeEngine::pluginPathList() and modified using QDeclarativeEngine::addPluginPath(). When running the \l {QML Viewer}, use the \c -P option to add paths to the plugin search path. +file. The plugin search path can be queried with QQmlEngine::pluginPathList() and modified using QQmlEngine::addPluginPath(). When running the \l {QML Viewer}, use the \c -P option to add paths to the plugin search path. \bold {typeinfo } lines add \l{Writing a qmltypes file}{type description files} to the module that can be read by QML tools such as Qt Creator to get information about the @@ -434,7 +434,7 @@ to \c /tmp/imports/My/Module/qmldir to register it. While the qmldump tool covers most cases, it does not work if: \list -\o The plugin uses a \l{QDeclarativeCustomParser}. The component that uses +\o The plugin uses a \l{QQmlCustomParser}. The component that uses the custom parser will not get its members documented. \o The plugin can not be loaded. In particular if you cross-compiled the plugin for a different architecture, qmldump will not be able to @@ -456,7 +456,7 @@ Module { // The name is a unique identifier used to refer to this type. // It is recommended you simply use the C++ type name. - name: "QDeclarativeAbstractAnimation" + name: "QQuickAbstractAnimation" // The name of the prototype Component. prototype: "QObject" @@ -492,12 +492,12 @@ Module { Property { name: "animations"; - type: "QDeclarativeAbstractAnimation" + type: "QQuickAbstractAnimation" // defaults to false, whether this property is read only isReadonly: true // defaults to false, whether the type of this property was a pointer in C++ isPointer: true - // defaults to false: whether the type actually is a QDeclarativeListProperty + // defaults to false: whether the type actually is a QQmlListProperty isList: true // defaults to 0: the meta object revision that introduced this property revision: 1 diff --git a/doc/src/qml/network.qdoc b/doc/src/qml/network.qdoc index 15a17203c3..71f42a4bfe 100644 --- a/doc/src/qml/network.qdoc +++ b/doc/src/qml/network.qdoc @@ -118,11 +118,11 @@ See the \tt examples/declarative/flickr for a real demonstration of this. \section1 Configuring the Network Access Manager -All network access from QML is managed by a QNetworkAccessManager set on the QDeclarativeEngine which executes the QML. +All network access from QML is managed by a QNetworkAccessManager set on the QQmlEngine which executes the QML. By default, this is an unmodified Qt QNetworkAccessManager. You may set a different manager by -providing a QDeclarativeNetworkAccessManagerFactory and setting it via -QDeclarativeEngine::setNetworkAccessManagerFactory(). -For example, the \l {QML Viewer} sets a QDeclarativeNetworkAccessManagerFactory which +providing a QQmlNetworkAccessManagerFactory and setting it via +QQmlEngine::setNetworkAccessManagerFactory(). +For example, the \l {QML Viewer} sets a QQmlNetworkAccessManagerFactory which creates QNetworkAccessManager that trusts HTTP Expiry headers to avoid network cache checks, allows HTTP Pipelining, adds a persistent HTTP CookieJar, a simple disk cache, and supports proxy settings. @@ -134,7 +134,7 @@ the executable using \l{The Qt Resource System}. Using this, an executable can r that is compiled into the executable: \code - QDeclarativeView *canvas = new QDeclarativeView; + QQuickView *canvas = new QQuickView; canvas->setUrl(QUrl("qrc:/dial.qml")); \endcode diff --git a/doc/src/qml/propertybinding.qdoc b/doc/src/qml/propertybinding.qdoc index b89b3d7a61..6dd862f55b 100644 --- a/doc/src/qml/propertybinding.qdoc +++ b/doc/src/qml/propertybinding.qdoc @@ -44,10 +44,10 @@ The syntax for properties is: Elements already possess useful properties but, to create custom properties, precede the property name with the keyword \c property. -\snippet doc/src/snippets/declarative/properties.qml parent begin -\snippet doc/src/snippets/declarative/properties.qml inherited properties -\snippet doc/src/snippets/declarative/properties.qml custom properties -\snippet doc/src/snippets/declarative/properties.qml parent end +\snippet doc/src/snippets/qml/properties.qml parent begin +\snippet doc/src/snippets/qml/properties.qml inherited properties +\snippet doc/src/snippets/qml/properties.qml custom properties +\snippet doc/src/snippets/qml/properties.qml parent end QML property rules coincide with many of JavaScript's property rules, for example, property names must begin with a lowercase letter. @@ -62,14 +62,14 @@ to other property values or data accessible in the application. The property val automatically kept up to date if the other properties or data values change. Property bindings are created in QML using the colon "\c {:}" before the value: -\snippet doc/src/snippets/declarative/properties.qml property binding +\snippet doc/src/snippets/qml/properties.qml property binding The property binding causes the width of the \c Rectangle to update whenever the \c {parent}'s width changes. QML extends a standards compliant JavaScript engine, so any valid JavaScript expression can be used as a property binding. Bindings can access object properties, make function calls and even use built-in JavaScript objects such as \c {Date} and \c {Math}. -\snippet doc/src/snippets/declarative/properties.qml JavaScript sample +\snippet doc/src/snippets/qml/properties.qml JavaScript sample While syntactically bindings can be of arbitrary complexity, if a binding starts to become overly complex - such as involving multiple lines, or imperative loops - it may be better @@ -82,13 +82,13 @@ function. When working with both QML and JavaScript, it is important to differentiate between QML property binding and JavaScript value assignment. In QML, a property binding is created using the colon "\c {:}". -\snippet doc/src/snippets/declarative/properties.qml property binding +\snippet doc/src/snippets/qml/properties.qml property binding The property binding causes the width of the \c Rectangle to update whenever the \c {parent}'s width changes. Assigning a property value (using the equals sign "\c {=}") does not create a property binding. -\snippet doc/src/snippets/declarative/properties.qml property assignment +\snippet doc/src/snippets/qml/properties.qml property assignment Instead of creating a property binding, the assignment simply sets the \c Rectangle \c width value to a number when the \c Component.onCompleted code is invoked. @@ -186,7 +186,7 @@ Care must be taken when referring to the parent of an object property binding. Elements and components that are bound to properties are not necessarily set as children of the properties' component. -\snippet doc/src/snippets/declarative/properties.qml object binding +\snippet doc/src/snippets/qml/properties.qml object binding The code snippet has a \l Gradient element that attempts to print its parent's \c width value. However, the \c Gradient element is bound to the \c gradient property, not the \c children property of the \c Rectangle. As a result, the @@ -205,7 +205,7 @@ Certain objects provide additional properties by \i attaching properties to othe objects. For example, the \l Keys element have properties that can \i attach to other QML objects to provide keyboard handling. -\snippet doc/src/snippets/declarative/properties.qml list attached property +\snippet doc/src/snippets/qml/properties.qml list attached property The element \l ListView provides the delegate, \c listdelegate, the property \c isCurrentItem as an attached property. The \c ListView.isCurrentItem \i{attached property} provides highlight information to the delegate. @@ -221,7 +221,7 @@ to provide additional functionality to objects. Two prominent elements, \l Component and \l Keys element provide \l{QML Signal and Handler Event System}{signal handlers} as attached signal handlers. -\snippet doc/src/snippets/declarative/properties.qml attached signal handler +\snippet doc/src/snippets/qml/properties.qml attached signal handler Read the \l{QML Signal and Handler Event System} and the \l{Keyboard Focus in QML} articles for more information. @@ -232,14 +232,14 @@ Some properties may accept a binding to a list property, where more than one component can bind to the property. List properties allow multiple \l {State}{States}, \l {Gradient}{Gradients}, and other components to bind to a single property. -\snippet doc/src/snippets/declarative/properties.qml list property +\snippet doc/src/snippets/qml/properties.qml list property The list is enclosed in square brackets, with a comma separating the list elements. In cases where you are only assigning a single item to a list, you may omit the square brackets. -\snippet doc/src/snippets/declarative/properties.qml single property +\snippet doc/src/snippets/qml/properties.qml single property To access the list, use the \c index property. -\snippet doc/src/snippets/declarative/properties.qml print list property +\snippet doc/src/snippets/qml/properties.qml print list property The snippet code simply prints the name of the first state, \c FETCH. See the \l{list}{list type} documentation @@ -252,7 +252,7 @@ In some cases properties form a logical group and use either the \i dot notation or \i group notation. Grouped properties may be written both ways: -\snippet doc/src/snippets/declarative/properties.qml grouped properties +\snippet doc/src/snippets/qml/properties.qml grouped properties In the element documentation grouped properties are shown using the dot notation. @@ -275,18 +275,18 @@ Accessing the aliasing property is similar to accessing a regular property. In addition, the optional \c default keyword indicates that the aliasing property is a \l{Default Properties}{default property}. -\snippet doc/src/snippets/declarative/Button.qml property alias +\snippet doc/src/snippets/qml/Button.qml property alias When importing the component as a \c Button, the \c buttonlabel is directly accessible through the \c label property. -\snippet doc/src/snippets/declarative/properties.qml alias usage +\snippet doc/src/snippets/qml/properties.qml alias usage In addition, the \c id property may also be aliased and referred outside the component. -\snippet doc/src/snippets/declarative/Button.qml parent begin -\snippet doc/src/snippets/declarative/Button.qml id alias -\snippet doc/src/snippets/declarative/Button.qml parent end +\snippet doc/src/snippets/qml/Button.qml parent begin +\snippet doc/src/snippets/qml/Button.qml id alias +\snippet doc/src/snippets/qml/Button.qml parent end The \c imagebutton component has the ability to modify the child \l Image object and its properties. -\snippet doc/src/snippets/declarative/properties.qml image alias +\snippet doc/src/snippets/qml/properties.qml image alias Using aliases, properties may be exposed to the \l{qml-top-level-component}{top level component}. Exposing properties to the @@ -299,7 +299,7 @@ Aliases are only activated once the component when an uninitialized alias is referenced. Likewise, aliasing an aliasing property will also result in an error. -\snippet doc/src/snippets/declarative/properties.qml alias complete +\snippet doc/src/snippets/qml/properties.qml alias complete When importing the component, however, aliasing properties appear as regular Qt properties and consequently can be used in alias references. @@ -309,7 +309,7 @@ property, effectively overwriting the existing property. For example, the following component has a \c color alias property, named the same as the built-in \l {Rectangle::color} property: -\snippet doc/src/snippets/declarative/properties.qml alias overwrite +\snippet doc/src/snippets/qml/properties.qml alias overwrite Any object that use this component and refer to its \c color property will be referring to the alias rather than the ordinary \l {Rectangle::color} property. @@ -328,13 +328,13 @@ as the \i {default property}. For example, the State element's default property is its \l{State::changes}{changes} property. \l PropertyChanges elements may simply be placed as the \c{State}'s children and they will be bound to the \c changes property. -\snippet doc/src/snippets/declarative/properties.qml state default +\snippet doc/src/snippets/qml/properties.qml state default Similarly, the \l Item element's default property is its \l{Item::data}{data} property. The \c data property manages Item's \c children and \c resources properties. This way, different data types may be placed as direct children of the \c Item. -\snippet doc/src/snippets/declarative/properties.qml default property +\snippet doc/src/snippets/qml/properties.qml default property Reassigning a default property is useful when a component is reused. For example, the \l{declarative/ui-components/tabwidget}{TabWidget} example uses @@ -350,14 +350,14 @@ For example, to bind a property exposed from the \l{The QML Engine}{declarative runtime} or \l{QmlGlobalQtObject}{Qt object}, such as the \c system.brightness property, to a value written in QML, you could use the \l Binding element as follows: -\snippet doc/src/snippets/declarative/properties.qml binding element +\snippet doc/src/snippets/qml/properties.qml binding element \section1 Changing Property Values in States The \l PropertyChanges element is for setting property bindings within a \l State element to set a property binding. -\snippet doc/src/snippets/declarative/properties.qml PropertyChanges element +\snippet doc/src/snippets/qml/properties.qml PropertyChanges element The rectangle's \c color property will bind to the \c warning component's \c color property when its \c state is set to the \c WARNING state. */ diff --git a/doc/src/qml/qmlcomponents.qdoc b/doc/src/qml/qmlcomponents.qdoc index bcc465f4b2..21b94f2ae3 100644 --- a/doc/src/qml/qmlcomponents.qdoc +++ b/doc/src/qml/qmlcomponents.qdoc @@ -50,7 +50,7 @@ is the emphasis in QML. Any snippet of QML code may become a component, by placing the code in a QML file, whose file extension is \c .qml). A complete Button component that responds to user input may be in a Button.qml file. -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml document +\snippet doc/src/snippets/qml/reusablecomponents/Button.qml document The component name, \c Button, matches the QML filename, \c Button.qml. Also, the first character is in upper case. Matching the names allow @@ -60,9 +60,9 @@ naming components with different filenames. Alternatively, a \l Component element may encapsulate a QML object to form a component. -\snippet doc/src/snippets/declarative/reusablecomponents/component.qml parent begin -\snippet doc/src/snippets/declarative/reusablecomponents/component.qml define inline component -\snippet doc/src/snippets/declarative/reusablecomponents/component.qml parent end +\snippet doc/src/snippets/qml/reusablecomponents/component.qml parent begin +\snippet doc/src/snippets/qml/reusablecomponents/component.qml define inline component +\snippet doc/src/snippets/qml/reusablecomponents/component.qml parent end Components may incorporate any \l{Qt Quick}{QML feature} such as: @@ -89,7 +89,7 @@ A component defined in a \c .qml file is directly usable by declaring the name of the component. For example, a button defined in \c Button.qml is created by declaring a \c Button. The button is defined in the \l {qml-define-components}{Defining New Components} section. -\snippet doc/src/snippets/declarative/reusablecomponents/application.qml document +\snippet doc/src/snippets/qml/reusablecomponents/application.qml document Note that the component name, \c Button, matches the QML filename, \c Button.qml. Also, the first character is in upper case. Matching the names allow @@ -100,7 +100,7 @@ For flexibility, a \c qmldir file is for dictating which additional components, plugins, or directories should be imported. By using a \c qmldir file, component names do not need to match the filenames. The \c qmldir file should, however, be in an imported path. -\snippet doc/src/snippets/declarative/reusablecomponents/qmldir document +\snippet doc/src/snippets/qml/reusablecomponents/qmldir document \section2 Loading an Inline Component @@ -109,8 +109,8 @@ delayed. A component may be created during a MouseArea event or by using a \l Loader element. The component can create an object, which is addressable in a similar way as an \l {qml-id}{identifier}. Thus, the created object may have its bindings set and read like a normal QML object. -\snippet doc/src/snippets/declarative/reusablecomponents/component.qml define inline component -\snippet doc/src/snippets/declarative/reusablecomponents/component.qml create inline component +\snippet doc/src/snippets/qml/reusablecomponents/component.qml define inline component +\snippet doc/src/snippets/qml/reusablecomponents/component.qml create inline component \keyword qml-component-properties \section1 Component Properties @@ -140,11 +140,11 @@ Consider the Button component from the object is a \l Rectangle. When imported, the Button component will possess the Rectangle's properties, methods, signals, and any custom properties. -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml parent begin -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml ellipses -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml properties -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml ellipses -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml parent end +\snippet doc/src/snippets/qml/reusablecomponents/Button.qml parent begin +\snippet doc/src/snippets/qml/reusablecomponents/Button.qml ellipses +\snippet doc/src/snippets/qml/reusablecomponents/Button.qml properties +\snippet doc/src/snippets/qml/reusablecomponents/Button.qml ellipses +\snippet doc/src/snippets/qml/reusablecomponents/Button.qml parent end The Button's \c text alias is accessible from outside the component as well as the Rectangle's visual properties and signals such as \c x, \c y, \c anchors, @@ -156,7 +156,7 @@ children which is beneficial for certain types of interfaces. However, since \c FocusScopes are not visual elements, the visual properties of its child need to be exposed. -\snippet doc/src/snippets/declarative/reusablecomponents/focusbutton.qml document +\snippet doc/src/snippets/qml/reusablecomponents/focusbutton.qml document \keyword qml-id \section2 The Object Identifier @@ -165,7 +165,7 @@ Each QML object may be given a special unique identifier called an \c id. No other object within the same QML component (see \l{QML Documents}) can have the same \c id value. QML objects may then access an object using the \c id property. -\snippet doc/src/snippets/declarative/properties.qml id property +\snippet doc/src/snippets/qml/properties.qml id property A component may readily access its parent's properties by using the \c parent property. @@ -178,15 +178,15 @@ Note that an \c id must begin with a lower-case letter or an underscore. The Objects or Items declared within a component can be made accessible by binding their id to a property alias. -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml parent begin -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml object alias -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml text -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml parent end +\snippet doc/src/snippets/qml/reusablecomponents/Button.qml parent begin +\snippet doc/src/snippets/qml/reusablecomponents/Button.qml object alias +\snippet doc/src/snippets/qml/reusablecomponents/Button.qml text +\snippet doc/src/snippets/qml/reusablecomponents/Button.qml parent end The advantage of using an alias instead a property of type of the object is that the value of the alias cannot be overridden, and members of the object can be used in property bindings when declaring an instance of the component. -\snippet doc/src/snippets/declarative/reusablecomponents/application.qml grouped property +\snippet doc/src/snippets/qml/reusablecomponents/application.qml grouped property If a property of type \c Text was used instead of an alias in this instance there would be no guarantee that \c label would be initialized before the binding was attempted which would cause the binding to fail. diff --git a/doc/src/qml/qmldocument.qdoc b/doc/src/qml/qmldocument.qdoc index fedeba35e1..426f135a45 100644 --- a/doc/src/qml/qmldocument.qdoc +++ b/doc/src/qml/qmldocument.qdoc @@ -36,7 +36,7 @@ from text data. Here is a simple QML document: -\snippet doc/src/snippets/declarative/qml-documents/non-trivial.qml document +\snippet doc/src/snippets/qml/qml-documents/non-trivial.qml document QML documents are always encoded in UTF-8 format. @@ -79,7 +79,7 @@ text property: \o application.qml \row -\o \snippet doc/src/snippets/declarative/qml-documents/qmldocuments.qml document +\o \snippet doc/src/snippets/qml/qml-documents/qmldocuments.qml document \o \qml import QtQuick 2.0 @@ -138,14 +138,14 @@ These final two examples perform identically to the original document. \table \row \o -\snippet doc/src/snippets/declarative/qml-documents/inline-component.qml document +\snippet doc/src/snippets/qml/qml-documents/inline-component.qml document \o -\snippet doc/src/snippets/declarative/qml-documents/inline-text-component.qml document +\snippet doc/src/snippets/qml/qml-documents/inline-text-component.qml document \endtable For information about components, the \l{QML Components} article details the creation of components and how to load them in other components. -\sa QDeclarativeComponent +\sa QQmlComponent */ diff --git a/doc/src/qml/qmlengine.qdoc b/doc/src/qml/qmlengine.qdoc index 3e8ef1ae3f..0865755c7b 100644 --- a/doc/src/qml/qmlengine.qdoc +++ b/doc/src/qml/qmlengine.qdoc @@ -38,16 +38,16 @@ specified in QML files, plugins, or applications. \section1 Core Module Classes - The \l{QtDeclarative}{Qt Declarative} module provides a set of C++ APIs for + The \l{QtQml}{Qt Declarative} module provides a set of C++ APIs for extending your QML applications from C++ and embedding QML into C++ applications. There are several core classes in the Qt Declarative module that provide the essential capabilities for doing this. These are: \list - \o QDeclarativeEngine: A QML engine provides the environment for executing QML code. Every + \o QQmlEngine: A QML engine provides the environment for executing QML code. Every application requires at least one engine instance. - \o QDeclarativeComponent: A component encapsulates QML information. - \o QDeclarativeContext: A context allows an application to expose data to + \o QQmlComponent: A component encapsulates QML information. + \o QQmlContext: A context allows an application to expose data to the QML components created by an engine. \endlist @@ -61,27 +61,27 @@ specified in QML files, plugins, or applications. \endlist \section2 Declarative Engine - A QDeclarativeEngine allows the configuration of global settings that + A QQmlEngine allows the configuration of global settings that apply to all of its QML component instances: for example, the QNetworkAccessManager to be used for network communications, and the file path to be used for persistent storage. - QDeclarativeComponent is used to load QML documents. Each - QDeclarativeComponent instance represents a single document. A component + QQmlComponent is used to load QML documents. Each + QQmlComponent instance represents a single document. A component can be created from the URL or file path of a QML document, or the raw QML code of the document. Component instances are instatiated through - the QDeclarativeComponent::create() method, like this: + the QQmlComponent::create() method, like this: \code - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile("MyRectangle.qml")); + QQmlEngine engine; + QQmlComponent component(&engine, QUrl::fromLocalFile("MyRectangle.qml")); QObject *rectangleInstance = component.create(); // ... delete rectangleInstance; \endcode - QML documents can also be loaded using QDeclarativeView. This class + QML documents can also be loaded using QQuickView. This class provides a convenient QWidget-based view for embedding QML components into QGraphicsView-based applications. (For other methods of integrating QML into QWidget-based applications, see \l {Integrating QML Code with @@ -91,44 +91,44 @@ specified in QML files, plugins, or applications. \section2 Loading QML Components from C++ - A QML document can be loaded with QDeclarativeComponent or QDeclarativeView. - QDeclarativeComponent loads a QML component as a C++ object; - QDeclarativeView also does this, but additionally loads the QML component + A QML document can be loaded with QQmlComponent or QQuickView. + QQmlComponent loads a QML component as a C++ object; + QQuickView also does this, but additionally loads the QML component directly into a QGraphicsView. It is convenient for loading a displayable QML component into a QWidget-based application. For example, suppose there is a \c MyItem.qml file that looks like this: - \snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml start - \snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml end + \snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml start + \snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml end - This QML document can be loaded with QDeclarativeComponent or - QDeclarativeView with the following C++ code. Using a QDeclarativeComponent - requires calling QDeclarativeComponent::create() to create a new instance of - the component, while a QDeclarativeView automatically creates an instance of - the component, which is accessible via QDeclarativeView::rootObject(): + This QML document can be loaded with QQmlComponent or + QQuickView with the following C++ code. Using a QQmlComponent + requires calling QQmlComponent::create() to create a new instance of + the component, while a QQuickView automatically creates an instance of + the component, which is accessible via QQuickView::rootObject(): \table \row \o - \snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp QDeclarativeComponent-a + \snippet doc/src/snippets/qml/qtbinding/loading/main.cpp QQmlComponent-a \dots 0 - \snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp QDeclarativeComponent-b + \snippet doc/src/snippets/qml/qtbinding/loading/main.cpp QQmlComponent-b \o - \snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp QDeclarativeView + \snippet doc/src/snippets/qml/qtbinding/loading/main.cpp QQuickView \endtable This \c object is the instance of the \c MyItem.qml component that has been created. You can now modify the item's properties using - QObject::setProperty() or QDeclarativeProperty: + QObject::setProperty() or QQmlProperty: - \snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp properties + \snippet doc/src/snippets/qml/qtbinding/loading/main.cpp properties Alternatively, you can cast the object to its actual type and call functions with compile-time safety. In this case the base object of \c MyItem.qml is - an \l Item, which is defined by the QDeclarativeItem class: + an \l Item, which is defined by the QQuickItem class: - \snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp cast + \snippet doc/src/snippets/qml/qtbinding/loading/main.cpp cast You can also connect to any signals or call functions defined in the component using QMetaObject::invokeMethod() and QObject::connect(). See \l @@ -141,14 +141,14 @@ specified in QML files, plugins, or applications. the QObject::objectName property with QObject::findChild(). For example, if the root item in \c MyItem.qml had a child \l Rectangle item: - \snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml start + \snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml start \codeline - \snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml child - \snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml end + \snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml child + \snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml end The child could be located like this: - \snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp findChild + \snippet doc/src/snippets/qml/qtbinding/loading/main.cpp findChild If \c objectName is used inside a delegate of a ListView, \l Repeater or some other element that creates multiple instances of its delegates, there @@ -172,20 +172,20 @@ specified in QML files, plugins, or applications. \section2 Embedding C++ Objects into QML Components When loading a QML scene into a C++ application, it can be useful to - directly embed C++ data into the QML object. QDeclarativeContext enables + directly embed C++ data into the QML object. QQmlContext enables this by exposing data to the context of a QML component, allowing data to be injected from C++ into QML. For example, here is a QML item that refers to a \c currentDateTime value that does not exist in the current scope: - \snippet doc/src/snippets/declarative/qtbinding/context/MyItem.qml 0 + \snippet doc/src/snippets/qml/qtbinding/context/MyItem.qml 0 This \c currentDateTime value can be set directly by the C++ application that loads the QML component, using - QDeclarativeContext::setContextProperty(): + QQmlContext::setContextProperty(): - \snippet doc/src/snippets/declarative/qtbinding/context/main.cpp 0 + \snippet doc/src/snippets/qml/qtbinding/context/main.cpp 0 Context properties can hold either QVariant or QObject* values. This means custom C++ objects can also be injected using this approach, and these @@ -196,11 +196,11 @@ specified in QML files, plugins, or applications. \table \row \o - \snippet doc/src/snippets/declarative/qtbinding/context-advanced/applicationdata.h 0 + \snippet doc/src/snippets/qml/qtbinding/context-advanced/applicationdata.h 0 \codeline - \snippet doc/src/snippets/declarative/qtbinding/context-advanced/main.cpp 0 + \snippet doc/src/snippets/qml/qtbinding/context-advanced/main.cpp 0 \o - \snippet doc/src/snippets/declarative/qtbinding/context-advanced/MyItem.qml 0 + \snippet doc/src/snippets/qml/qtbinding/context-advanced/MyItem.qml 0 \endtable (Note that date/time values returned from C++ to QML can be formatted through @@ -212,7 +212,7 @@ specified in QML files, plugins, or applications. connected to using an \c onDataChanged handler within a \l Connections object: - \snippet doc/src/snippets/declarative/qtbinding/context-advanced/connections.qml 0 + \snippet doc/src/snippets/qml/qtbinding/context-advanced/connections.qml 0 Context properties can be useful for using C++ based data models in a QML view. See the \l {declarative/modelviews/stringlistmodel}{String ListModel}, @@ -221,7 +221,7 @@ specified in QML files, plugins, or applications. respective examples on using QStringListModel, QObjectList-based models and QAbstractItemModel in QML views. - Also see the QDeclarativeContext documentation for more information. + Also see the QQmlContext documentation for more information. \section1 Invoking QML Entities through the Engine @@ -246,8 +246,8 @@ specified in QML files, plugins, or applications. \table \row - \o \snippet doc/src/snippets/declarative/qtbinding/functions-qml/MyItem.qml 0 - \o \snippet doc/src/snippets/declarative/qtbinding/functions-qml/main.cpp 0 + \o \snippet doc/src/snippets/qml/qtbinding/functions-qml/MyItem.qml 0 + \o \snippet doc/src/snippets/qml/qtbinding/functions-qml/main.cpp 0 \endtable Notice the Q_RETURN_ARG() and Q_ARG() arguments for @@ -257,16 +257,16 @@ specified in QML files, plugins, or applications. To call a C++ function from QML, the function must be either a Qt slot, or a function marked with the Q_INVOKABLE macro, to be available to QML. In the following example, the QML code invokes methods on the \c myObject object, - which has been set using QDeclarativeContext::setContextProperty(): + which has been set using QQmlContext::setContextProperty(): \table \row \o - \snippet doc/src/snippets/declarative/qtbinding/functions-cpp/MyItem.qml 0 + \snippet doc/src/snippets/qml/qtbinding/functions-cpp/MyItem.qml 0 \o - \snippet doc/src/snippets/declarative/qtbinding/functions-cpp/myclass.h 0 + \snippet doc/src/snippets/qml/qtbinding/functions-cpp/myclass.h 0 \codeline - \snippet doc/src/snippets/declarative/qtbinding/functions-cpp/main.cpp 0 + \snippet doc/src/snippets/qml/qtbinding/functions-cpp/main.cpp 0 \endtable QML supports the calling of overloaded C++ functions. If there are multiple @@ -289,11 +289,11 @@ specified in QML files, plugins, or applications. \table \row \o - \snippet doc/src/snippets/declarative/qtbinding/signals-qml/MyItem.qml 0 + \snippet doc/src/snippets/qml/qtbinding/signals-qml/MyItem.qml 0 \o - \snippet doc/src/snippets/declarative/qtbinding/signals-qml/myclass.h 0 + \snippet doc/src/snippets/qml/qtbinding/signals-qml/myclass.h 0 \codeline - \snippet doc/src/snippets/declarative/qtbinding/signals-qml/main.cpp 0 + \snippet doc/src/snippets/qml/qtbinding/signals-qml/main.cpp 0 \endtable To connect to Qt C++ signals from within QML, use a signal handler with the @@ -308,12 +308,12 @@ specified in QML files, plugins, or applications. \row \o - \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h start + \snippet doc/src/snippets/qml/qtbinding/signals-cpp/imageviewer.h start \dots 4 - \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h end + \snippet doc/src/snippets/qml/qtbinding/signals-cpp/imageviewer.h end \o - \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/standalone.qml 0 + \snippet doc/src/snippets/qml/qtbinding/signals-cpp/standalone.qml 0 \endtable (Note that if a signal has been declared as the NOTIFY signal for a @@ -326,13 +326,13 @@ specified in QML files, plugins, or applications. If, however, the object with the signal is not created from within the QML code, and the QML item only has a reference to the created object - for example, if the object was set using - QDeclarativeContext::setContextProperty() - then the \l Connections element + QQmlContext::setContextProperty() - then the \l Connections element can be used instead to create the signal handler: \table \row - \o \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/main.cpp connections - \o \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/MyItem.qml 0 + \o \snippet doc/src/snippets/qml/qtbinding/signals-cpp/main.cpp connections + \o \snippet doc/src/snippets/qml/qtbinding/signals-cpp/MyItem.qml 0 \endtable C++ signals can use enum values as parameters provided that the enum is @@ -346,14 +346,14 @@ specified in QML files, plugins, or applications. Any properties declared in a QML object are automatically accessible from C++. Given a QML item like this: - \snippet doc/src/snippets/declarative/qtbinding/properties-qml/MyItem.qml 0 + \snippet doc/src/snippets/qml/qtbinding/properties-qml/MyItem.qml 0 The value of the \c someNumber property can be set and read using - QDeclarativeProperty, or QObject::setProperty() and QObject::property(): + QQmlProperty, or QObject::setProperty() and QObject::property(): - \snippet doc/src/snippets/declarative/qtbinding/properties-qml/main.cpp 0 + \snippet doc/src/snippets/qml/qtbinding/properties-qml/main.cpp 0 - You should always use QObject::setProperty(), QDeclarativeProperty or + You should always use QObject::setProperty(), QQmlProperty or QMetaProperty::write() to change a QML property value, to ensure the QML engine is made aware of the property change. For example, say you have a custom element \c PushButton with a \c buttonText property that internally @@ -362,7 +362,7 @@ specified in QML files, plugins, or applications. \badcode // BAD! - QDeclarativeComponent component(engine, "MyButton.qml"); + QQmlComponent component(engine, "MyButton.qml"); PushButton *button = qobject_cast(component.create()); button->m_buttonText = "Click me"; \endcode @@ -381,8 +381,8 @@ specified in QML files, plugins, or applications. \table \row - \o \snippet doc/src/snippets/declarative/qtbinding/properties-cpp/applicationdata.h 0 - \o \snippet doc/src/snippets/declarative/qtbinding/properties-cpp/MyItem.qml 0 + \o \snippet doc/src/snippets/qml/qtbinding/properties-cpp/applicationdata.h 0 + \o \snippet doc/src/snippets/qml/qtbinding/properties-cpp/MyItem.qml 0 \endtable Notice the \c backgroundColorChanged signal is declared as the NOTIFY signal @@ -401,7 +401,7 @@ specified in QML files, plugins, or applications. Additional Qt code is runnable in the engine as a QML plugin. The \l{QML Plugins} article covers the creation and usage patterns of QML plugins. The - QDeclarativeExtensionPlugin class is an abstract class for writing QML + QQmlExtensionPlugin class is an abstract class for writing QML plugins. The \l {How to Create Qt Plugins} contains more information about Qt's plugin system. @@ -413,17 +413,17 @@ specified in QML files, plugins, or applications. initializing some costly data structures until after all the properties have been set. - The QML engine defines an interface class called QDeclarativeParserStatus, + The QML engine defines an interface class called QQmlParserStatus, which contains a number of virtual methods that are invoked at various stages during component instantiation. To receive these notifications, an - element implementation inherits QDeclarativeParserStatus and notifies the Qt + element implementation inherits QQmlParserStatus and notifies the Qt meta system using the Q_INTERFACES() macro. \code - class Example : public QObject, public QDeclarativeParserStatus + class Example : public QObject, public QQmlParserStatus { Q_OBJECT - Q_INTERFACES(QDeclarativeParserStatus) + Q_INTERFACES(QQmlParserStatus) public: virtual void componentComplete() { diff --git a/doc/src/qml/qmlevents.qdoc b/doc/src/qml/qmlevents.qdoc index f29b2f260b..1f2e7a9908 100644 --- a/doc/src/qml/qmlevents.qdoc +++ b/doc/src/qml/qmlevents.qdoc @@ -58,9 +58,9 @@ Attempting to declare two signals or methods with the same name in the same type block generates an error. However, a new signal may reuse the name of an existing signal on the type. (This should be done with caution, as the existing signal may be hidden and become inaccessible.) Here are various examples of signal declarations: -\snippet doc/src/snippets/declarative/events.qml parent begin -\snippet doc/src/snippets/declarative/events.qml signal declaration -\snippet doc/src/snippets/declarative/events.qml parent end +\snippet doc/src/snippets/qml/events.qml parent begin +\snippet doc/src/snippets/qml/events.qml signal declaration +\snippet doc/src/snippets/qml/events.qml parent end If the signal has no parameters, the "\c{()}" brackets are optional. If parameters are used, the parameter types must be declared, as for the \c string @@ -69,17 +69,17 @@ and \c variant arguments of the \c perform signal. Adding a signal to an item automatically adds a \i{signal handler} as well. The signal hander is named \c on, with the first letter of the signal in uppercase. The previous signals have the following signal handlers: -\snippet doc/src/snippets/declarative/events.qml signal handler declaration +\snippet doc/src/snippets/qml/events.qml signal handler declaration Further, each QML properties have a \c{Changed} signal and its corresponding \c{onChanged} signal handler. As a result, property changes may notify other components for any changes. -\snippet doc/src/snippets/declarative/events.qml automatic signals +\snippet doc/src/snippets/qml/events.qml automatic signals To emit a signal, invoke it as a method. The signal handler binding is similar to a property binding and it is invoked when the signal is emitted. Use the defined argument names to access the respective arguments. -\snippet doc/src/snippets/declarative/events.qml signal emit +\snippet doc/src/snippets/qml/events.qml signal emit Note that the \c Component.onCompleted is an \l{attached-signalhandlers}{attached signal handler}; it is invoked when the \l Component initialization is complete. @@ -93,7 +93,7 @@ automatically invoked whenever the signal is emitted. This mechanism enables a signal to be received by a method instead of a \l {Signal Handlers}{signal handler}. -\snippet doc/src/snippets/declarative/events.qml connect method +\snippet doc/src/snippets/qml/events.qml connect method The \c {connect()} method is appropriate when connecting a JavaScript method to a signal. @@ -104,7 +104,7 @@ signals. By connecting signals to other signals, the \c connect() method can form different signal chains. -\snippet doc/src/snippets/declarative/events.qml forward signal +\snippet doc/src/snippets/qml/events.qml forward signal Whenever the \l MouseArea \c clicked signal is emitted, the \c send diff --git a/doc/src/qml/qmlintro.qdoc b/doc/src/qml/qmlintro.qdoc index 03ee94d6d1..3290a27bc3 100644 --- a/doc/src/qml/qmlintro.qdoc +++ b/doc/src/qml/qmlintro.qdoc @@ -1197,7 +1197,7 @@ arrange a set of Rectangle items. The Repeater item creates a series of 24 rectangles for the Grid item to position in a 5 by 5 arrangement. \clearfloat -\snippet doc/src/snippets/declarative/repeaters/repeater-grid-index.qml document +\snippet doc/src/snippets/qml/repeaters/repeater-grid-index.qml document The number of items created by a Repeater is held by its \l{Repeater::}{count} property. It is not possible to set this property to determine the number of diff --git a/doc/src/qml/qmlplugins.qdoc b/doc/src/qml/qmlplugins.qdoc index 9b6fe29c1e..e41bba2906 100644 --- a/doc/src/qml/qmlplugins.qdoc +++ b/doc/src/qml/qmlplugins.qdoc @@ -36,16 +36,16 @@ C++ code as plugins. Plugins are imported and labeled as modules and its content are available as components. - QDeclarativeExtensionPlugin is a plugin interface that makes it possible to + QQmlExtensionPlugin is a plugin interface that makes it possible to create QML extensions that can be loaded dynamically into QML applications. These extensions allow custom QML types to be made available to the QML engine. To write a QML extension plugin: \list 1 - \o Subclass QDeclarativeExtensionPlugin - \o Implement QDeclarativeExtensionPlugin's - \l{QDeclarativeExtensionPlugin::}{registerTypes()} method + \o Subclass QQmlExtensionPlugin + \o Implement QQmlExtensionPlugin's + \l{QQmlExtensionPlugin::}{registerTypes()} method \o Register types with qmlRegisterType() \o Export the class using the Q_EXPORT_PLUGIN2() macro \o Write a project file for the plugin @@ -67,8 +67,8 @@ \dots A plugin class, \c QExampleQMLPlugin, is a subclass of - \l QDeclarativeExtensionPlugin and it implements the - \l{QDeclarativeExtensionPlugin::}{registerTypes()} method. + \l QQmlExtensionPlugin and it implements the + \l{QQmlExtensionPlugin::}{registerTypes()} method. In the registerTypes() method, the plugin class can \l{register-c++-type}{register} the \c TimeModel class to the declarative diff --git a/doc/src/qml/qmlruntime.qdoc b/doc/src/qml/qmlruntime.qdoc index 5853c14844..a803fabd7a 100644 --- a/doc/src/qml/qmlruntime.qdoc +++ b/doc/src/qml/qmlruntime.qdoc @@ -35,8 +35,8 @@ Declarative UI engine along with the built-in QML elements and plugin modules, and it also provides access to third-party QML elements and modules. Applications that use QML need to invoke the QML runtime in order to -execute QML documents. This can be done by creating a QDeclarativeView -or a QDeclarativeEngine, as described below. In addition, the Declarative UI +execute QML documents. This can be done by creating a QQuickView +or a QQmlEngine, as described below. In addition, the Declarative UI package includes the \QQV tool, which loads \c .qml files. This tool is useful for developing and testing QML code without the need to write a C++ application to load the QML runtime. @@ -47,17 +47,17 @@ a C++ application to load the QML runtime. To deploy an application that uses QML, the QML runtime must be invoked by the application. This is done by writing a Qt C++ application that loads the -QDeclarativeEngine by either: +QQmlEngine by either: \list -\o Loading the QML file through a QDeclarativeView instance, or -\o Creating a QDeclarativeEngine instance and loading QML files with QDeclarativeComponent +\o Loading the QML file through a QQuickView instance, or +\o Creating a QQmlEngine instance and loading QML files with QQmlComponent \endlist -\section2 Deploying with QDeclarativeView +\section2 Deploying with QQuickView -QDeclarativeView is a QWidget-based class that is able to load QML files. +QQuickView is a QWidget-based class that is able to load QML files. For example, if there is a QML file, \c application.qml, like this: \qml @@ -70,13 +70,13 @@ It can be loaded in a Qt application's \c main.cpp file like this: \code #include - #include + #include int main(int argc, char *argv[]) { QApplication app(argc, argv); - QDeclarativeView view; + QQuickView view; view.setSource(QUrl::fromLocalFile("application.qml")); view.show(); @@ -97,27 +97,27 @@ the \c declarative module for the \c QT variable. For example: \endcode -\section2 Creating a QDeclarativeEngine directly +\section2 Creating a QQmlEngine directly If \c application.qml does not have any graphical components, or if it is -preferred to avoid QDeclarativeView for other reasons, the QDeclarativeEngine +preferred to avoid QQuickView for other reasons, the QQmlEngine can be constructed directly instead. In this case, \c application.qml is -loaded as a QDeclarativeComponent instance rather than placed into a view: +loaded as a QQmlComponent instance rather than placed into a view: \code #include - #include - #include - #include + #include + #include + #include int main(int argc, char *argv[]) { QApplication app(argc, argv); - QDeclarativeEngine engine; - QDeclarativeContext *objectContext = new QDeclarativeContext(engine.rootContext()); + QQmlEngine engine; + QQmlContext *objectContext = new QQmlContext(engine.rootContext()); - QDeclarativeComponent component(&engine, "application.qml"); + QQmlComponent component(&engine, "application.qml"); QObject *object = component.create(objectContext); // ... delete object and objectContext when necessary @@ -127,7 +127,7 @@ loaded as a QDeclarativeComponent instance rather than placed into a view: \endcode See \l {Using QML Bindings in C++ Applications} for more information about using -QDeclarativeEngine, QDeclarativeContext and QDeclarativeComponent, as well +QQmlEngine, QQmlContext and QQmlComponent, as well as details on including QML files through \l{The Qt Resource System}{Qt's Resource system}. diff --git a/doc/src/qml/qmlsyntax.qdoc b/doc/src/qml/qmlsyntax.qdoc index b2b7fc89bd..1cd6ad7f46 100644 --- a/doc/src/qml/qmlsyntax.qdoc +++ b/doc/src/qml/qmlsyntax.qdoc @@ -133,7 +133,7 @@ Commenting in QML is similar to JavaScript. \o Multiline comments start with /* and finish with *\/ \endlist -\snippet doc/src/snippets/declarative/comments.qml 0 +\snippet doc/src/snippets/qml/comments.qml 0 Comments are ignored by the engine. They are useful for explaining what you are doing; for referring back to at a later date, or for others reading diff --git a/doc/src/qml/qmltypes.qdoc b/doc/src/qml/qmltypes.qdoc index 964ff98a15..9555e54f7e 100644 --- a/doc/src/qml/qmltypes.qdoc +++ b/doc/src/qml/qmltypes.qdoc @@ -350,7 +350,7 @@ Q_PROPERTY(int size READ size CONSTANT) Properties that are lists of objects or Qt interfaces are also declared with the Q_PROPERTY() macro. However, list properties must have the type - \l{QDeclarativeListProperty}{QDeclarativeListProperty}. + \l{QQmlListProperty}{QQmlListProperty}. \snippet examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h 2 @@ -361,7 +361,7 @@ Q_PROPERTY(int size READ size CONSTANT) \l {Extending QML - Object and List Property Types Example} shows the complete code used to create the \c BirthdayParty type. For more - information, visit \l{QDeclarativeListProperty}{QDeclarativeListProperty} + information, visit \l{QQmlListProperty}{QQmlListProperty} for creating list properties. \section2 Sequence Types @@ -756,8 +756,8 @@ itself, the QML engine sets up an association between the value source and the property. Property value sources are special types that derive from the -QDeclarativePropertyValueSource base class. This base class contains a single method, -QDeclarativePropertyValueSource::setTarget(), that the QML engine invokes when +QQmlPropertyValueSource base class. This base class contains a single method, +QQmlPropertyValueSource::setTarget(), that the QML engine invokes when associating the property value source with a property. The relevant part of the \c HappyBirthdaySong type declaration looks like this: @@ -771,7 +771,7 @@ contain properties, signals and methods just like other types. When a property value source object is assigned to a property, QML first tries to assign it normally, as though it were a regular QML type. Only if this -assignment fails does the engine call the \l {QDeclarativePropertyValueSource::}{setTarget()} method. This allows +assignment fails does the engine call the \l {QQmlPropertyValueSource::}{setTarget()} method. This allows the type to also be used in contexts other than just as a value source. \l {Extending QML - Property Value Source Example} shows the complete code used diff --git a/doc/src/qml/qmlviewer.qdoc b/doc/src/qml/qmlviewer.qdoc index 6439e95f4e..9006a053fc 100644 --- a/doc/src/qml/qmlviewer.qdoc +++ b/doc/src/qml/qmlviewer.qdoc @@ -160,7 +160,7 @@ QtObject { property int time: 54321 } \endqml To replace this with real data, you can simply bind the real data object to -the root context in C++ using QDeclarativeContext::setContextProperty(). This +the root context in C++ using QQmlContext::setContextProperty(). This is detailed in \l {Using QML Bindings in C++ Applications}. \section1 Using the \c runtime object diff --git a/doc/src/qml/qtbinding.qdoc b/doc/src/qml/qtbinding.qdoc index 10581857dc..7410836e9c 100644 --- a/doc/src/qml/qtbinding.qdoc +++ b/doc/src/qml/qtbinding.qdoc @@ -43,12 +43,12 @@ You may want to mix QML and C++ for a number of reasons. For example: \o To use functionality defined in a C++ source (for example, when using a C++ Qt-based data model, or calling functions in a third-party C++ library) \o To access functionality in the Qt Declarative module (for example, to dynamically generate -images using QDeclarativeImageProvider) +images using QQmlImageProvider) \o To write your own QML elements (whether for your applications, or for distribution to others) \endlist To use the Qt Declarative module, you must include and link to the module appropriately, as shown on -the \l {QtDeclarative}{module index page}. The \l {Qt Declarative UI Runtime} documentation +the \l {QtQml}{module index page}. The \l {Qt Declarative UI Runtime} documentation shows how to build a basic C++ application that uses this module. @@ -59,32 +59,32 @@ embedding QML into C++ applications. There are several core classes in the Qt De that provide the essential capabilities for doing this. These are: \list -\o QDeclarativeEngine: A QML engine provides the environment for executing QML code. Every +\o QQmlEngine: A QML engine provides the environment for executing QML code. Every application requires at least one engine instance. -\o QDeclarativeComponent: A component encapsulates a \l{QML Documents}{QML document}. -\o QDeclarativeContext: A context allows an application to expose data to the QML components +\o QQmlComponent: A component encapsulates a \l{QML Documents}{QML document}. +\o QQmlContext: A context allows an application to expose data to the QML components created by an engine. \endlist -A QDeclarativeEngine allows the configuration of global settings that apply to all of its QML +A QQmlEngine allows the configuration of global settings that apply to all of its QML component instances: for example, the QNetworkAccessManager to be used for network communications, and the file path to be used for persistent storage. -QDeclarativeComponent is used to load QML documents. Each QDeclarativeComponent instance represents +QQmlComponent is used to load QML documents. Each QQmlComponent instance represents a single document. A component can be created from the URL or file path of a QML document, or the raw QML code of the document. Component instances are instatiated through the -QDeclarativeComponent::create() method, like this: +QQmlComponent::create() method, like this: \code -QDeclarativeEngine engine; -QDeclarativeComponent component(&engine, QUrl::fromLocalFile("MyRectangle.qml")); +QQmlEngine engine; +QQmlComponent component(&engine, QUrl::fromLocalFile("MyRectangle.qml")); QObject *rectangleInstance = component.create(); // ... delete rectangleInstance; \endcode -QML documents can also be loaded using QDeclarativeView. This class provides a convenient +QML documents can also be loaded using QQuickView. This class provides a convenient QWidget-based view for embedding QML components into QGraphicsView-based applications. (For other methods of integrating QML into QWidget-based applications, see \l {Integrating QML Code with existing Qt UI code}.) @@ -108,41 +108,41 @@ these methods throughout your application as appropriate. \section2 Loading QML Components from C++ -A QML document can be loaded with QDeclarativeComponent or QDeclarativeView. QDeclarativeComponent -loads a QML component as a C++ object; QDeclarativeView also does this, +A QML document can be loaded with QQmlComponent or QQuickView. QQmlComponent +loads a QML component as a C++ object; QQuickView also does this, but additionally loads the QML component directly into a QGraphicsView. It is convenient for loading a displayable QML component into a QWidget-based application. For example, suppose there is a \c MyItem.qml file that looks like this: -\snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml start -\snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml end +\snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml start +\snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml end -This QML document can be loaded with QDeclarativeComponent or QDeclarativeView with the following -C++ code. Using a QDeclarativeComponent requires calling QDeclarativeComponent::create() to create -a new instance of the component, while a QDeclarativeView automatically creates an instance of the -component, which is accessible via QDeclarativeView::rootObject(): +This QML document can be loaded with QQmlComponent or QQuickView with the following +C++ code. Using a QQmlComponent requires calling QQmlComponent::create() to create +a new instance of the component, while a QQuickView automatically creates an instance of the +component, which is accessible via QQuickView::rootObject(): \table \row \o -\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp QDeclarativeComponent-a +\snippet doc/src/snippets/qml/qtbinding/loading/main.cpp QQmlComponent-a \dots 0 -\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp QDeclarativeComponent-b +\snippet doc/src/snippets/qml/qtbinding/loading/main.cpp QQmlComponent-b \o -\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp QDeclarativeView +\snippet doc/src/snippets/qml/qtbinding/loading/main.cpp QQuickView \endtable This \c object is the instance of the \c MyItem.qml component that has been created. You can now -modify the item's properties using QObject::setProperty() or QDeclarativeProperty: +modify the item's properties using QObject::setProperty() or QQmlProperty: -\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp properties +\snippet doc/src/snippets/qml/qtbinding/loading/main.cpp properties Alternatively, you can cast the object to its actual type and call functions with compile-time safety. In this case the base object of \c MyItem.qml is an \l Item, which is defined by the -QDeclarativeItem class: +QQuickItem class: -\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp cast +\snippet doc/src/snippets/qml/qtbinding/loading/main.cpp cast You can also connect to any signals or call functions defined in the component using QMetaObject::invokeMethod() and QObject::connect(). See \l {Exchanging data between QML and C++} @@ -154,14 +154,14 @@ QML components are essentially object trees with children that have siblings and Child objects of QML components can be located using the QObject::objectName property with QObject::findChild(). For example, if the root item in \c MyItem.qml had a child \l Rectangle item: -\snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml start +\snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml start \codeline -\snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml child -\snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml end +\snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml child +\snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml end The child could be located like this: -\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp findChild +\snippet doc/src/snippets/qml/qtbinding/loading/main.cpp findChild If \c objectName is used inside a delegate of a ListView, \l Repeater or some other element that creates multiple instances of its delegates, there will be multiple children with @@ -181,18 +181,18 @@ the QML user interface implementation and the composition of the QML object tree \section2 Embedding C++ Objects into QML Components When loading a QML scene into a C++ application, it can be useful to directly embed C++ data into -the QML object. QDeclarativeContext enables this by exposing data to the context of a QML +the QML object. QQmlContext enables this by exposing data to the context of a QML component, allowing data to be injected from C++ into QML. For example, here is a QML item that refers to a \c currentDateTime value that does not exist in the current scope: -\snippet doc/src/snippets/declarative/qtbinding/context/MyItem.qml 0 +\snippet doc/src/snippets/qml/qtbinding/context/MyItem.qml 0 This \c currentDateTime value can be set directly by the C++ application that loads the QML -component, using QDeclarativeContext::setContextProperty(): +component, using QQmlContext::setContextProperty(): -\snippet doc/src/snippets/declarative/qtbinding/context/main.cpp 0 +\snippet doc/src/snippets/qml/qtbinding/context/main.cpp 0 Context properties can hold either QVariant or QObject* values. This means custom C++ objects can also be injected using this approach, and these objects can be modified and read directly in QML. @@ -202,11 +202,11 @@ invokes a method on the object instance: \table \row \o -\snippet doc/src/snippets/declarative/qtbinding/context-advanced/applicationdata.h 0 +\snippet doc/src/snippets/qml/qtbinding/context-advanced/applicationdata.h 0 \codeline -\snippet doc/src/snippets/declarative/qtbinding/context-advanced/main.cpp 0 +\snippet doc/src/snippets/qml/qtbinding/context-advanced/main.cpp 0 \o -\snippet doc/src/snippets/declarative/qtbinding/context-advanced/MyItem.qml 0 +\snippet doc/src/snippets/qml/qtbinding/context-advanced/MyItem.qml 0 \endtable (Note that date/time values returned from C++ to QML can be formatted through @@ -217,7 +217,7 @@ If the QML item needs to receive signals from the context property, it can conne dataChanged(), this signal can be connected to using an \c onDataChanged handler within a \l Connections object: -\snippet doc/src/snippets/declarative/qtbinding/context-advanced/connections.qml 0 +\snippet doc/src/snippets/qml/qtbinding/context-advanced/connections.qml 0 Context properties can be useful for using C++ based data models in a QML view. See the \l {declarative/modelviews/stringlistmodel}{String ListModel}, @@ -226,7 +226,7 @@ Context properties can be useful for using C++ based data models in a QML view. respective examples on using QStringListModel, QObjectList-based models and QAbstractItemModel in QML views. -Also see the QDeclarativeContext documentation for more information. +Also see the QQmlContext documentation for more information. \section2 Defining New QML Elements @@ -236,30 +236,30 @@ defined by C++ classes; in fact, many of the core \l {QML Elements} are implemen C++ classes. When you create a QML object using one of these elements, you are simply creating an instance of a QObject-based C++ class and setting its properties. -To create a visual item that fits in with the Qt Quick elements, base your class off \l QDeclarativeItem instead of QObject directly. -You can then implement your own painting and functionality like any other QGraphicsObject. Note that QGraphicsItem::ItemHasNoContents is set by default on QDeclarativeItem because +To create a visual item that fits in with the Qt Quick elements, base your class off \l QQuickItem instead of QObject directly. +You can then implement your own painting and functionality like any other QGraphicsObject. Note that QGraphicsItem::ItemHasNoContents is set by default on QQuickItem because it does not paint anything; you will need to clear this if your item is supposed to paint anything (as opposed to being solely for input handling or logical grouping). For example, here is an \c ImageViewer class with an \c image URL property: -\snippet doc/src/snippets/declarative/qtbinding/newelements/imageviewer.h 0 +\snippet doc/src/snippets/qml/qtbinding/newelements/imageviewer.h 0 -Aside from the fact that it inherits QDeclarativeItem, this is an ordinary class that could +Aside from the fact that it inherits QQuickItem, this is an ordinary class that could exist outside of QML. However, once it is registered with the QML engine using qmlRegisterType(): -\snippet doc/src/snippets/declarative/qtbinding/newelements/main.cpp register +\snippet doc/src/snippets/qml/qtbinding/newelements/main.cpp register -Then, any QML code loaded by your C++ application or \l{QDeclarativeExtensionPlugin}{plugin} can create and manipulate +Then, any QML code loaded by your C++ application or \l{QQmlExtensionPlugin}{plugin} can create and manipulate \c ImageViewer objects: -\snippet doc/src/snippets/declarative/qtbinding/newelements/standalone.qml 0 +\snippet doc/src/snippets/qml/qtbinding/newelements/standalone.qml 0 -It is advised that you avoid using QGraphicsItem functionality beyond the properties documented in QDeclarativeItem. +It is advised that you avoid using QGraphicsItem functionality beyond the properties documented in QQuickItem. This is because the GraphicsView backend is intended to be an implementation detail for QML, so the QtQuick items can be moved to faster backends as they become available with no change from a QML perspective. -To minimize any porting requirements for custom visual items, try to stick to the documented properties in QDeclarativeItem where possible. Properties QDeclarativeItem inherits but doesn't document are classed as implementation details; they are not officially supported and may disappear between releases. +To minimize any porting requirements for custom visual items, try to stick to the documented properties in QQuickItem where possible. Properties QQuickItem inherits but doesn't document are classed as implementation details; they are not officially supported and may disappear between releases. -Note that custom C++ types do not have to inherit from QDeclarativeItem; this is only necessary if it is +Note that custom C++ types do not have to inherit from QQuickItem; this is only necessary if it is a displayable item. If the item is not displayable, it can simply inherit from QObject. For more information on defining new QML elements, see the \l {Tutorial: Writing QML extensions with C++} @@ -286,8 +286,8 @@ QMetaObject::invokeMethod(). Here is a C++ application that uses this to call a \table \row -\o \snippet doc/src/snippets/declarative/qtbinding/functions-qml/MyItem.qml 0 -\o \snippet doc/src/snippets/declarative/qtbinding/functions-qml/main.cpp 0 +\o \snippet doc/src/snippets/qml/qtbinding/functions-qml/MyItem.qml 0 +\o \snippet doc/src/snippets/qml/qtbinding/functions-qml/main.cpp 0 \endtable Notice the Q_RETURN_ARG() and Q_ARG() arguments for QMetaObject::invokeMethod() must be specified as @@ -295,16 +295,16 @@ QVariant types, as this is the generic data type used for QML functions and retu To call a C++ function from QML, the function must be either a Qt slot, or a function marked with the Q_INVOKABLE macro, to be available to QML. In the following example, the QML code invokes -methods on the \c myObject object, which has been set using QDeclarativeContext::setContextProperty(): +methods on the \c myObject object, which has been set using QQmlContext::setContextProperty(): \table \row \o -\snippet doc/src/snippets/declarative/qtbinding/functions-cpp/MyItem.qml 0 +\snippet doc/src/snippets/qml/qtbinding/functions-cpp/MyItem.qml 0 \o -\snippet doc/src/snippets/declarative/qtbinding/functions-cpp/myclass.h 0 +\snippet doc/src/snippets/qml/qtbinding/functions-cpp/myclass.h 0 \codeline -\snippet doc/src/snippets/declarative/qtbinding/functions-cpp/main.cpp 0 +\snippet doc/src/snippets/qml/qtbinding/functions-cpp/main.cpp 0 \endtable QML supports the calling of overloaded C++ functions. If there are multiple C++ functions with the @@ -325,11 +325,11 @@ is emitted: \table \row \o -\snippet doc/src/snippets/declarative/qtbinding/signals-qml/MyItem.qml 0 +\snippet doc/src/snippets/qml/qtbinding/signals-qml/MyItem.qml 0 \o -\snippet doc/src/snippets/declarative/qtbinding/signals-qml/myclass.h 0 +\snippet doc/src/snippets/qml/qtbinding/signals-qml/myclass.h 0 \codeline -\snippet doc/src/snippets/declarative/qtbinding/signals-qml/main.cpp 0 +\snippet doc/src/snippets/qml/qtbinding/signals-qml/main.cpp 0 \endtable To connect to Qt C++ signals from within QML, use a signal handler with the \c on syntax. @@ -342,12 +342,12 @@ C++ object are connected to through \c onImagedChanged and \c onLoadingError sig \row \o -\snippet doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h start +\snippet doc/src/snippets/qml/qtbinding/signals-cpp/imageviewer.h start \dots 4 -\snippet doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h end +\snippet doc/src/snippets/qml/qtbinding/signals-cpp/imageviewer.h end \o -\snippet doc/src/snippets/declarative/qtbinding/signals-cpp/standalone.qml 0 +\snippet doc/src/snippets/qml/qtbinding/signals-cpp/standalone.qml 0 \endtable (Note that if a signal has been declared as the NOTIFY signal for a property, QML allows it to be @@ -357,13 +357,13 @@ received with an \c onChanged handler even if the signal's name does n If, however, the object with the signal is not created from within the QML code, and the QML item only has a reference to the created object - for example, if the object was set using -QDeclarativeContext::setContextProperty() - then the \l Connections element can be used +QQmlContext::setContextProperty() - then the \l Connections element can be used instead to create the signal handler: \table \row -\o \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/main.cpp connections -\o \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/MyItem.qml 0 +\o \snippet doc/src/snippets/qml/qtbinding/signals-cpp/main.cpp connections +\o \snippet doc/src/snippets/qml/qtbinding/signals-cpp/MyItem.qml 0 \endtable C++ signals can use enum values as parameters provided that the enum is declared in the @@ -376,14 +376,14 @@ See \l {Using enumerations of a custom type} below for details. Any properties declared in a QML object are automatically accessible from C++. Given a QML item like this: -\snippet doc/src/snippets/declarative/qtbinding/properties-qml/MyItem.qml 0 +\snippet doc/src/snippets/qml/qtbinding/properties-qml/MyItem.qml 0 -The value of the \c someNumber property can be set and read using QDeclarativeProperty, or +The value of the \c someNumber property can be set and read using QQmlProperty, or QObject::setProperty() and QObject::property(): -\snippet doc/src/snippets/declarative/qtbinding/properties-qml/main.cpp 0 +\snippet doc/src/snippets/qml/qtbinding/properties-qml/main.cpp 0 -You should always use QObject::setProperty(), QDeclarativeProperty or QMetaProperty::write() to +You should always use QObject::setProperty(), QQmlProperty or QMetaProperty::write() to change a QML property value, to ensure the QML engine is made aware of the property change. For example, say you have a custom element \c PushButton with a \c buttonText property that internally reflects the value of a \c m_buttonText member variable. Modifying the member variable directly like this is @@ -391,7 +391,7 @@ not a good idea: \badcode // BAD! -QDeclarativeComponent component(engine, "MyButton.qml"); +QQmlComponent component(engine, "MyButton.qml"); PushButton *button = qobject_cast(component.create()); button->m_buttonText = "Click me"; \endcode @@ -410,8 +410,8 @@ property. This property can be written to and read from QML: \table \row -\o \snippet doc/src/snippets/declarative/qtbinding/properties-cpp/applicationdata.h 0 -\o \snippet doc/src/snippets/declarative/qtbinding/properties-cpp/MyItem.qml 0 +\o \snippet doc/src/snippets/qml/qtbinding/properties-cpp/applicationdata.h 0 +\o \snippet doc/src/snippets/qml/qtbinding/properties-cpp/MyItem.qml 0 \endtable Notice the \c backgroundColorChanged signal is declared as the NOTIFY signal for the @@ -468,8 +468,8 @@ converted to JavaScript array and object values, repectively: \o String format \o Example \row -\o \snippet doc/src/snippets/declarative/qtbinding/variantlistmap/MyItem.qml 0 -\o \snippet doc/src/snippets/declarative/qtbinding/variantlistmap/main.cpp 0 +\o \snippet doc/src/snippets/qml/qtbinding/variantlistmap/MyItem.qml 0 +\o \snippet doc/src/snippets/qml/qtbinding/variantlistmap/main.cpp 0 \endtable This produces output like: @@ -492,13 +492,13 @@ side, and is automatically converted to a QVariantList or QVariantMap when it is To use an enumeration from a custom C++ component, the enumeration must be declared with Q_ENUMS() to register it with Qt's meta object system. For example, the following C++ type has a \c Status enum: -\snippet doc/src/snippets/declarative/qtbinding/enums/imageviewer.h start -\snippet doc/src/snippets/declarative/qtbinding/enums/imageviewer.h end +\snippet doc/src/snippets/qml/qtbinding/enums/imageviewer.h start +\snippet doc/src/snippets/qml/qtbinding/enums/imageviewer.h end Providing the \c ImageViewer class has been registered using qmlRegisterType(), its \c Status enum can now be used from QML: -\snippet doc/src/snippets/declarative/qtbinding/enums/standalone.qml 0 +\snippet doc/src/snippets/qml/qtbinding/enums/standalone.qml 0 The C++ type must be registered with QML to use its enums. If your C++ type is not instantiable, it can be registered using qmlRegisterUncreatableType(). To be accessible from QML, the names of enum values @@ -525,7 +525,7 @@ function, the enum type must be registered using qRegisterMetaType(). For QML signals, enum values may be used as signal parameters using the \c int type: -\snippet doc/src/snippets/declarative/qtbinding/enums/standalone.qml 1 +\snippet doc/src/snippets/qml/qtbinding/enums/standalone.qml 1 \section2 Automatic Type Conversion from Strings @@ -594,11 +594,11 @@ a QColor-type property or to call a C++ function that requires a QColor paramete \section1 Writing QML plugins -The Qt Declarative module includes the QDeclarativeExtensionPlugin class, which is an abstract +The Qt Declarative module includes the QQmlExtensionPlugin class, which is an abstract class for writing QML plugins. This allows QML extension types to be dynamically loaded into QML applications. -See the QDeclarativeExtensionPlugin documentation and \l {How to Create Qt Plugins} for more +See the QQmlExtensionPlugin documentation and \l {How to Create Qt Plugins} for more details. @@ -643,22 +643,22 @@ project The \c main.qml and \c background.png files will be packaged as resource files. This is done in the \c example.qrc resource collection file: -\quotefile doc/src/snippets/declarative/qtbinding/resources/example.qrc +\quotefile doc/src/snippets/qml/qtbinding/resources/example.qrc Since \c background.png is a resource file, \c main.qml can refer to it using the relative path specified in \c example.qrc: -\snippet doc/src/snippets/declarative/qtbinding/resources/main.qml 0 +\snippet doc/src/snippets/qml/qtbinding/resources/main.qml 0 To allow QML to locate resource files correctly, the \c main.cpp loads the main QML file, \c main.qml, as a resource file using the \c qrc scheme: -\snippet doc/src/snippets/declarative/qtbinding/resources/main.cpp 0 +\snippet doc/src/snippets/qml/qtbinding/resources/main.cpp 0 Finally \c project.pro uses the RESOURCES variable to indicate that \c example.qrc should be used to build the application resources: -\quotefile doc/src/snippets/declarative/qtbinding/resources/resources.pro +\quotefile doc/src/snippets/qml/qtbinding/resources/resources.pro See \l {The Qt Resource System} for more information. diff --git a/doc/src/qml/qtdeclarative.qdoc b/doc/src/qml/qtdeclarative.qdoc index c4b59fb07b..9d14f7fc57 100644 --- a/doc/src/qml/qtdeclarative.qdoc +++ b/doc/src/qml/qtdeclarative.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! - \module QtDeclarative + \module QtQml \title Qt Declarative Module \ingroup modules @@ -37,7 +37,7 @@ following directive: \code - #include + #include \endcode To link against the module, add this line to your \l qmake \c @@ -54,16 +54,16 @@ /*! \macro QML_DECLARE_TYPE() - \relates QDeclarativeEngine + \relates QQmlEngine - Equivalent to \c Q_DECLARE_METATYPE(TYPE *) and \c Q_DECLARE_METATYPE(QDeclarativeListProperty) + Equivalent to \c Q_DECLARE_METATYPE(TYPE *) and \c Q_DECLARE_METATYPE(QQmlListProperty) - #include to use this macro. + #include to use this macro. */ /*! \macro QML_DECLARE_TYPEINFO(Type,Flags) - \relates QDeclarativeEngine + \relates QQmlEngine Declares additional properties of the given \a Type as described by the specified \a Flags. @@ -71,13 +71,13 @@ Current the only supported type info is \c QML_HAS_ATTACHED_PROPERTIES which declares that the \a Type supports \l {Attached Properties}. - #include to use this macro. + #include to use this macro. */ /*! \fn int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName) - \relates QDeclarativeEngine + \relates QQmlEngine This template function registers the C++ type in the QML system with the name \a qmlName, in the library imported from \a uri having the @@ -105,7 +105,7 @@ "com.mycompany.qmlcomponents": \code - #include + #include ... @@ -131,7 +131,7 @@ /*! \fn int qmlRegisterRevision(const char *uri, int versionMajor, int versionMinor) - \relates QDeclarativeEngine + \relates QQmlEngine This template function registers the specified revision of a C++ type in the QML system with the library imported from \a uri having the version number composed @@ -150,7 +150,7 @@ /*! \fn int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message) - \relates QDeclarativeEngine + \relates QQmlEngine This template function registers the C++ type in the QML system with the name \a qmlName, in the library imported from \a uri having the @@ -163,14 +163,14 @@ Returns the QML type id. - #include to use this function. + #include to use this function. \sa qmlRegisterTypeNotAvailable() */ /*! \fn int qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message) - \relates QDeclarativeEngine + \relates QQmlEngine This function registers a type in the QML system with the name \a qmlName, in the library imported from \a uri having the version number composed from \a versionMajor and \a versionMinor, but any attempt to instantiate the type @@ -200,40 +200,40 @@ Without this, a generic "Game is not a type" message would be given. - #include to use this function. + #include to use this function. \sa qmlRegisterUncreatableType() */ /*! \fn int qmlRegisterType() - \relates QDeclarativeEngine + \relates QQmlEngine \overload This template function registers the C++ type in the QML system. Instances of this type cannot be created from the QML system. - #include to use this function. + #include to use this function. Returns the QML type id. */ /*! \fn int qmlRegisterInterface(const char *typeName) - \relates QDeclarativeEngine + \relates QQmlEngine This template function registers the C++ type in the QML system under the name \a typeName. - #include to use this function. + #include to use this function. Returns the QML type id. */ /*! - \fn int qmlRegisterModuleApi(const char *uri, int versionMajor, int versionMinor, QJSValue (*callback)(QDeclarativeEngine *, QJSEngine *)) - \relates QDeclarativeEngine + \fn int qmlRegisterModuleApi(const char *uri, int versionMajor, int versionMinor, QJSValue (*callback)(QQmlEngine *, QJSEngine *)) + \relates QQmlEngine This function may be used to register a module API provider \a callback in a particular \a uri with a version specified in \a versionMajor and \a versionMinor. @@ -250,7 +250,7 @@ Usage: \code // first, define the module API provider function (callback). - static QJSValue *example_qjsvalue_module_api_provider(QDeclarativeEngine *engine, QJSEngine *scriptEngine) + static QJSValue *example_qjsvalue_module_api_provider(QQmlEngine *engine, QJSEngine *scriptEngine) { Q_UNUSED(engine) @@ -278,8 +278,8 @@ */ /*! - \fn int qmlRegisterModuleApi(const char *uri, int versionMajor, int versionMinor, QObject *(*callback)(QDeclarativeEngine *, QJSEngine *)) - \relates QDeclarativeEngine + \fn int qmlRegisterModuleApi(const char *uri, int versionMajor, int versionMinor, QObject *(*callback)(QQmlEngine *, QJSEngine *)) + \relates QQmlEngine This function may be used to register a module API provider \a callback in a particular \a uri with a version specified in \a versionMajor and \a versionMinor. @@ -325,7 +325,7 @@ }; // second, define the module API provider function (callback). - static QObject *example_qobject_module_api_provider(QDeclarativeEngine *engine, QJSEngine *scriptEngine) + static QObject *example_qobject_module_api_provider(QQmlEngine *engine, QJSEngine *scriptEngine) { Q_UNUSED(engine) Q_UNUSED(scriptEngine) diff --git a/doc/src/qml/qtprogrammers.qdoc b/doc/src/qml/qtprogrammers.qdoc index 215f71859c..9338a2c29f 100644 --- a/doc/src/qml/qtprogrammers.qdoc +++ b/doc/src/qml/qtprogrammers.qdoc @@ -44,7 +44,7 @@ QML provides direct access to the following concepts from Qt: \o QAction - the \l {QML Basic Types}{action} type \o QObject signals and slots - available as functions to call in JavaScript \o QObject properties - available as variables in JavaScript - \o QWidget - QDeclarativeView is a QML-displaying widget + \o QWidget - QQuickView is a QML-displaying widget \o Qt models - used directly in data binding (QAbstractItemModel) \endlist @@ -71,12 +71,12 @@ QML Items also serve these purposes. Each is considered separately below. \section2 Simple Widgets -The most important rule to remember while implementing a new QDeclarativeItem in C++ +The most important rule to remember while implementing a new QQuickItem in C++ is that it should not contain any look and feel policies; leave that to the QML usage of the item. As an example, imagine you wanted a reusable Button item. If you therefore decided -to write a QDeclarativeItem subclass to implement a button, just as QToolButton +to write a QQuickItem subclass to implement a button, just as QToolButton subclasses QWidget for this purpose, following the rule above, your \c QDeclarativeButton would not have any appearance; just the notions of enabled, triggering, etc. @@ -92,7 +92,7 @@ between states, and exactly how it responds to mouse, key, or touch input, shoul all be left for definition in QML. It is illustrative to note that QDeclarativeTextEdit is built upon QTextControl, -QDeclarativeWebView is built upon QWebPage, and ListView uses QAbstractItemModel, +QQuickWebView is built upon QWebPage, and ListView uses QAbstractItemModel, just as QTextEdit, QWebView, and QListView are built upon those same UI-agnostic components. @@ -167,7 +167,7 @@ QGraphicsWidgets are usually designed to be laid out with QGraphicsLayouts. QML not use QGraphicsLayouts, as the Qt layouts do not mix well with animated and fluid UIs, so the geometry interface is one of the main differences. When writing QML elements, you allow the designers to place their bounding rectangle using absolute -geometry, bindings or anchors (all set up for you when you inherit QDeclarativeItem) +geometry, bindings or anchors (all set up for you when you inherit QQuickItem) and you do not use layouts or size hints. If size hints are appropriate, then place them in the QML documentation so that the designers know how to use the item best, but still have complete control over the look and feel. @@ -182,14 +182,14 @@ look and feel (which involves the UI logic) can be written in QML. Both differences are caused by the different method of interaction. QGraphicsWidget is a QGraphicsObject subclass which makes fluid UI development from C++ easier, and -QDeclarativeItem is a QGraphicsObject subclass which makes fluid UI development +QQuickItem is a QGraphicsObject subclass which makes fluid UI development from QML easier. The difference, therefore, is primarily one of the interface exposed, and the design of the items that come with it; the declarative primitives for QML and nothing for QGraphicsWidget, because you need to write your own UI logic into the subclass. If you wish to use both QML and C++ to write the UI, for example to ease the -transition period, it is recommended to use QDeclarativeItem subclasses, although +transition period, it is recommended to use QQuickItem subclasses, although you can use QGraphicsWidgets as well. To allow for easier use from C++, make the root item of each C++ component a \l LayoutItem, and load individual "widgets" of QML (possibly comprised of multiple files, and containing a self-contained bundle diff --git a/doc/src/qtquick2/animation.qdoc b/doc/src/qtquick2/animation.qdoc index 626571f50e..cf656fb209 100644 --- a/doc/src/qtquick2/animation.qdoc +++ b/doc/src/qtquick2/animation.qdoc @@ -76,14 +76,14 @@ There are several ways of setting animation to an object. To create an immediate movement or animated movement, set the property value directly. This may be done in signal handlers or attached properties. -\snippet doc/src/snippets/declarative/animation.qml direct property change +\snippet doc/src/snippets/qml/animation.qml direct property change However, to create more control, \i {property animations} apply smooth movements by interpolating values between property value changes. Property animations provide timing controls and allows different interpolations through \l{qml-easing-animation}{easing curves}. -\snippet doc/src/snippets/declarative/animation.qml property animation +\snippet doc/src/snippets/qml/animation.qml property animation Specialized \l{qml-property-animation-elements}{property animation elements} have more efficient implementations than the \l{PropertyAnimation} element. They @@ -112,14 +112,14 @@ change from the \c pressed state to the \c released state. Likewise, there would be an animation during the change from the \c released state to the \c pressed state. -\snippet doc/src/snippets/declarative/animation.qml transition animation +\snippet doc/src/snippets/qml/animation.qml transition animation Binding the \c to and \c from properties to the state's name will assign that particular transition to the state change. For simple or symmetric transitions, setting the to \c to property to the wild card symbol, "\c{*}", denotes that the transition applies to any state change. -\snippet doc/src/snippets/declarative/animation.qml wildcard animation +\snippet doc/src/snippets/qml/animation.qml wildcard animation \section2 Default Animation as Behaviors @@ -133,7 +133,7 @@ A ball component might have a behavior animation assigned to its \c x, \c y, and elastic effect. In effect, this behavior animation would apply the elastic effect to the properties whenever the ball moves. -\snippet doc/src/snippets/declarative/animation.qml behavior animation +\snippet doc/src/snippets/qml/animation.qml behavior animation There are several methods of assigning behavior animations to properties. The \c{Behavior on } declaration is a convenient way of assigning a @@ -156,7 +156,7 @@ object. Using the \l{SequentialAnimation} element, the opacity animations will play after the preceding animation finishes. The \l{ParallelAnimation} element will play the animations at the same time. -\snippet doc/src/snippets/declarative/animation.qml sequential animation +\snippet doc/src/snippets/qml/animation.qml sequential animation Once individual animations are placed into a SequentialAnimation or ParallelAnimation, they can no longer be started and stopped independently. The @@ -257,15 +257,15 @@ Rectangle { -\snippet doc/src/snippets/declarative/animation-elements.qml color -\snippet doc/src/snippets/declarative/animation-propertyvaluesource.qml 0 -\snippet doc/src/snippets/declarative/animation-signalhandler.qml 0 -\snippet doc/src/snippets/declarative/animation-standalone.qml 0 +\snippet doc/src/snippets/qml/animation-elements.qml color +\snippet doc/src/snippets/qml/animation-propertyvaluesource.qml 0 +\snippet doc/src/snippets/qml/animation-signalhandler.qml 0 +\snippet doc/src/snippets/qml/animation-standalone.qml 0 -\snippet doc/src/snippets/declarative/animation-transitions.qml 0 -\snippet doc/src/snippets/declarative/animation-groups.qml 0 +\snippet doc/src/snippets/qml/animation-transitions.qml 0 +\snippet doc/src/snippets/qml/animation-groups.qml 0 -\snippet doc/src/snippets/declarative/animation-groups.qml 1 -\snippet doc/src/snippets/declarative/animation-groups.qml 0 +\snippet doc/src/snippets/qml/animation-groups.qml 1 +\snippet doc/src/snippets/qml/animation-groups.qml 0 \image propanim.gif diff --git a/doc/src/qtquick2/focus.qdoc b/doc/src/qtquick2/focus.qdoc index 05d797e7be..e2c4c79d3c 100644 --- a/doc/src/qtquick2/focus.qdoc +++ b/doc/src/qtquick2/focus.qdoc @@ -43,7 +43,7 @@ and to address some of the cases unique to fluid user interfaces, the QML items When the user presses or releases a key, the following occurs: \list 1 \o Qt receives the key action and generates a key event. -\o If the Qt widget containing the \l QDeclarativeView has focus, the key event +\o If the Qt widget containing the \l QQuickView has focus, the key event is delivered to it. Otherwise, regular Qt key handling continues. \o The key event is delivered by the scene to the QML \l Item with \i {active focus}. If no Item has active focus, the key event is @@ -56,8 +56,8 @@ If the \c {Rectangle} element in the following example has active focus and the it will bubble up to its parent. However, pressing the \c B key will bubble up to the root item and thus subsequently be ignored. -\snippet doc/src/snippets/declarative/focus/rectangle.qml simple key event -\snippet doc/src/snippets/declarative/focus/rectangle.qml simple key event end +\snippet doc/src/snippets/qml/focus/rectangle.qml simple key event +\snippet doc/src/snippets/qml/focus/rectangle.qml simple key event end \o If the root \l Item is reached, the key event is \l {QEvent::ignore()}{ignored} and regular Qt key handling continues. @@ -71,7 +71,7 @@ Whether or not an \l Item has active focus can be queried through the property \c {Item::activeFocus} property. For example, here we have a \l Text element whose text is determined by whether or not it has active focus. -\snippet doc/src/snippets/declarative/focus/rectangle.qml active focus +\snippet doc/src/snippets/qml/focus/rectangle.qml active focus \section1 Acquiring Focus and Focus Scopes @@ -82,7 +82,7 @@ sufficient. If we run the following example with the \l {QML Viewer}, we see tha the \c {keyHandler} element has active focus and pressing the \c A, \c B, or \c C keys modifies the text appropriately. -\snippet doc/src/snippets/declarative/focus/basicwidget.qml focus true +\snippet doc/src/snippets/qml/focus/basicwidget.qml focus true \image declarative-qmlfocus1.png @@ -95,10 +95,10 @@ set the first one to have focus. The intention is that when the \c A, \c B, or responds accordingly. The code that imports and creates two MyWidget instances: -\snippet doc/src/snippets/declarative/focus/widget.qml window +\snippet doc/src/snippets/qml/focus/widget.qml window The MyWidget code: -\snippet doc/src/snippets/declarative/focus/MyWidget.qml mywidget +\snippet doc/src/snippets/qml/focus/MyWidget.qml mywidget We would like to have the first MyWidget object to have the focus by setting its \c focus property to \c true. However, by running the code, we can confirm that @@ -126,7 +126,7 @@ A focus scope is created by declaring the \l FocusScope element. In the next example, a \l FocusScope element is added to the component, and the visual result shown. -\snippet doc/src/snippets/declarative/focus/myfocusscopewidget.qml widget in focusscope +\snippet doc/src/snippets/qml/focus/myfocusscopewidget.qml widget in focusscope \image declarative-qmlfocus3.png @@ -158,10 +158,10 @@ Now, clicking either MyClickableWidget gives it focus and the other widget loses the focus. The code that imports and creates two MyClickableWidget instances: -\snippet doc/src/snippets/declarative/focus/clickablewidget.qml clickable window +\snippet doc/src/snippets/qml/focus/clickablewidget.qml clickable window The MyClickableWidget code: -\snippet doc/src/snippets/declarative/focus/MyClickableWidget.qml clickable in focusscope +\snippet doc/src/snippets/qml/focus/MyClickableWidget.qml clickable in focusscope \image declarative-qmlfocus4.png @@ -188,7 +188,7 @@ current item delegate to react to key presses. This contrived example shows how this works. Pressing the \c Return key will print the name of the current list item. -\snippet doc/src/snippets/declarative/focus/advancedFocus.qml FocusScope delegate +\snippet doc/src/snippets/qml/focus/advancedFocus.qml FocusScope delegate \image declarative-qmlfocus5.png diff --git a/doc/src/qtquick2/modelview.qdoc b/doc/src/qtquick2/modelview.qdoc index 56c726eab8..5d799027ad 100644 --- a/doc/src/qtquick2/modelview.qdoc +++ b/doc/src/qtquick2/modelview.qdoc @@ -80,13 +80,13 @@ To visualize data, bind the view's \c model property to a model and the Suppose that a specific club wants to decorate its members list with its brand colors. A member list is in a \c model and the \c delegate will display the model's content. - \snippet doc/src/snippets/declarative/listview-decorations.qml model - \snippet doc/src/snippets/declarative/listview-decorations.qml delegate + \snippet doc/src/snippets/qml/listview-decorations.qml model + \snippet doc/src/snippets/qml/listview-decorations.qml delegate The club may decorate the members list by binding visual objects to the \c header and \c footer properties. The visual object may be defined inline, in another file, or in a \l {Component} element. - \snippet doc/src/snippets/declarative/listview-decorations.qml decorations + \snippet doc/src/snippets/qml/listview-decorations.qml decorations \image listview-decorations.png \section2 Mouse and Touch Handling @@ -110,8 +110,8 @@ To visualize data, bind the view's \c model property to a model and the A list may contain a list indicating people's names and the team on which team the person belongs. - \snippet doc/src/snippets/declarative/listview-sections.qml model - \snippet doc/src/snippets/declarative/listview-sections.qml delegate + \snippet doc/src/snippets/qml/listview-sections.qml model + \snippet doc/src/snippets/qml/listview-sections.qml delegate The ListView element has the \c section \l{Property Binding in QML#Attached Properties}{attached property} that can combine adjacent and related @@ -119,7 +119,7 @@ To visualize data, bind the view's \c model property to a model and the which list element property to use as sections. The \c criteria can dictate how the section names are displayed and the \c delegate is similar to the views' \l {qml-view-delegate}{delegate} property. - \snippet doc/src/snippets/declarative/listview-sections.qml section + \snippet doc/src/snippets/qml/listview-sections.qml section \image listview-section.png \keyword qml-view-delegate @@ -129,7 +129,7 @@ To visualize data, bind the view's \c model property to a model and the visualize each item list according to the template defined by the delegate. Items in a model are accessible through the \c index property as well as the item's properties. - \snippet doc/src/snippets/declarative/listview.qml delegate + \snippet doc/src/snippets/qml/listview.qml delegate \image listview-setup.png \section2 Accessing Views and Models from Delegates @@ -150,7 +150,7 @@ To visualize data, bind the view's \c model property to a model and the the model, and the color of one of the fields depends on the property \i{fruit_color} of the view. - \snippet doc/src/snippets/declarative/models/views-models-delegates.qml rectangle + \snippet doc/src/snippets/qml/models/views-models-delegates.qml rectangle \keyword qml-data-models \section1 Models @@ -159,7 +159,7 @@ To visualize data, bind the view's \c model property to a model and the bind to. Here is a ListModel with two roles, \i type and \i age, and a ListView with a delegate that binds to these roles to display their values: - \snippet doc/src/snippets/declarative/qml-data-models/listmodel-listview.qml document + \snippet doc/src/snippets/qml/qml-data-models/listmodel-listview.qml document If there is a naming clash between the model's properties and the delegate's properties, the roles can be accessed with the qualified \i model name @@ -197,12 +197,12 @@ To visualize data, bind the view's \c model property to a model and the ListModel is a simple hierarchy of elements specified in QML. The available roles are specified by the \l ListElement properties. - \snippet doc/src/snippets/declarative/qml-data-models/listelements.qml model + \snippet doc/src/snippets/qml/qml-data-models/listelements.qml model The above model has two roles, \i name and \i cost. These can be bound to by a ListView delegate, for example: - \snippet doc/src/snippets/declarative/qml-data-models/listelements.qml view + \snippet doc/src/snippets/qml/qml-data-models/listelements.qml view ListModel provides methods to manipulate the ListModel directly via JavaScript. In this case, the first item inserted determines the roles available @@ -210,9 +210,9 @@ To visualize data, bind the view's \c model property to a model and the created and populated via JavaScript, the roles provided by the first insertion are the only roles that will be shown in the view: - \snippet doc/src/snippets/declarative/qml-data-models/dynamic-listmodel.qml model + \snippet doc/src/snippets/qml/qml-data-models/dynamic-listmodel.qml model \dots - \snippet doc/src/snippets/declarative/qml-data-models/dynamic-listmodel.qml mouse area + \snippet doc/src/snippets/qml/qml-data-models/dynamic-listmodel.qml mouse area When the MouseArea is clicked, \c fruitModel will have two roles, \i cost and \i name. Even if subsequent roles are added, only the first two will be handled by views @@ -253,7 +253,7 @@ To visualize data, bind the view's \c model property to a model and the VisualItemModel provide the contents of the delegate. The model does not provide any roles. - \snippet doc/src/snippets/declarative/models/visual-model-and-view.qml visual model and view + \snippet doc/src/snippets/qml/models/visual-model-and-view.qml visual model and view Note that in the above example there is no delegate required. The items of the model itself provide the visual elements that @@ -347,7 +347,7 @@ The following example shows a repeater used with a \l{#Grid}{Grid} item to arrange a set of Rectangle items. The Repeater item creates a series of 24 rectangles for the Grid item to position in a 5 by 5 arrangement. -\snippet doc/src/snippets/declarative/repeaters/repeater-grid-index.qml document +\snippet doc/src/snippets/qml/repeaters/repeater-grid-index.qml document The number of items created by a Repeater is held by its \l{Repeater::}{count} property. It is not possible to set this property to determine the number of diff --git a/doc/src/qtquick2/mouseevents.qdoc b/doc/src/qtquick2/mouseevents.qdoc index d981c7c1dd..e452611416 100644 --- a/doc/src/qtquick2/mouseevents.qdoc +++ b/doc/src/qtquick2/mouseevents.qdoc @@ -55,7 +55,7 @@ to define this area is to anchor the \c MouseArea to its parent's area using the component), then the MouseArea will fill the area defined by the parent's dimensions. Alternatively, an area smaller or larger than the parent is definable. -\snippet doc/src/snippets/declarative/mousearea/mousearea-snippet.qml anchor fill +\snippet doc/src/snippets/qml/mousearea/mousearea-snippet.qml anchor fill \section1 Receiving Events @@ -77,7 +77,7 @@ gestures in greater detail: \endlist These signals have signal handlers that are invoked when the signals are emitted. -\snippet doc/src/snippets/declarative/mousearea/mousearea-snippet.qml mouse handlers +\snippet doc/src/snippets/qml/mousearea/mousearea-snippet.qml mouse handlers \section1 Enabling Gestures Some mouse gestures and button clicks need to be enabled before they send or @@ -95,7 +95,7 @@ positioning even when there are no mouse button presses. Setting the \c hoverEnabled property to \c true, in turn will enable the \c entered, \c exited, and \c positionChanged signal and their respective signal handlers. -\snippet doc/src/snippets/declarative/mousearea/mousearea-snippet.qml enable handlers +\snippet doc/src/snippets/qml/mousearea/mousearea-snippet.qml enable handlers Additionally, to disable the whole mouse area, set the \c MouseArea element's \c enabled property to \c false. diff --git a/doc/src/qtquick2/positioners.qdoc b/doc/src/qtquick2/positioners.qdoc index c7110f7cf9..55be7087fd 100644 --- a/doc/src/qtquick2/positioners.qdoc +++ b/doc/src/qtquick2/positioners.qdoc @@ -61,7 +61,7 @@ uses a Column item to arrange three \l Rectangle items in an area defined by an outer \l Item. The \l{Column::spacing}{spacing} property is set to include a small amount of space between the rectangles. -\snippet doc/src/snippets/declarative/column/column.qml document +\snippet doc/src/snippets/qml/column/column.qml document Note that, since Column inherits directly from Item, any background color must be added to a parent Rectangle, if desired. @@ -80,7 +80,7 @@ include a small amount of space between the rectangles. We ensure that the parent Rectangle is large enough so that there is some space left around the edges of the horizontally centered Row item. -\snippet doc/src/snippets/declarative/row.qml document +\snippet doc/src/snippets/qml/row.qml document \section2 Grid @@ -93,7 +93,7 @@ The following example uses a Grid item to place four \l Rectangle items in a 2-by-2 grid. As with the other positioners, the spacing between items can be specified using the \l{Grid::spacing}{spacing} property. -\snippet doc/src/snippets/declarative/grid-spacing.qml document +\snippet doc/src/snippets/qml/grid-spacing.qml document There is no difference between horizontal and vertical spacing inserted between items, so any additional space must be added within the items @@ -122,7 +122,7 @@ The following example shows a Flow item containing a number of \l Text child items. These are arranged in a similar way to those shown in the screenshots. -\snippet doc/src/snippets/declarative/flow.qml document +\snippet doc/src/snippets/qml/flow.qml document The main differences between the Grid and Flow positioners are that items inside a Flow will wrap when they run out of space on the minor axis, and diff --git a/doc/src/qtquick2/qmltexthandling.qdoc b/doc/src/qtquick2/qmltexthandling.qdoc index 876ab3c42f..6e6b2a4c6b 100644 --- a/doc/src/qtquick2/qmltexthandling.qdoc +++ b/doc/src/qtquick2/qmltexthandling.qdoc @@ -62,10 +62,10 @@ respective element documentation. The \l {Validators}{validator} elements enforce the type and format of \l TextInput objects. -\snippet doc/src/snippets/declarative/texthandling.qml int validator +\snippet doc/src/snippets/qml/texthandling.qml int validator The validator elements bind to \c {TextInput}'s \c validator property. -\snippet doc/src/snippets/declarative/texthandling.qml regexp validator +\snippet doc/src/snippets/qml/texthandling.qml regexp validator The regular expression in the snippet will only allow the inputted text to be \c {fruit basket}. diff --git a/doc/src/qtquick2/qtquick-intro.qdoc b/doc/src/qtquick2/qtquick-intro.qdoc index 8aeab7e199..9eebb0bddc 100644 --- a/doc/src/qtquick2/qtquick-intro.qdoc +++ b/doc/src/qtquick2/qtquick-intro.qdoc @@ -34,7 +34,7 @@ create the kind of intuitive, modern, and fluid user interfaces that are increasingly used on mobile phones, media players, set-top boxes, and other portable devices. Qt Quick consists of a rich set of user interface \l{QML Elements}{elements}, a \l{QML Syntax}{declarative} language for -describing user interfaces, and a language \l{QtDeclarative Module}{runtime}. A +describing user interfaces, and a language \l{QtQml Module}{runtime}. A collection of C++ APIs is used to integrate these high level features with classic Qt applications. Version 2.1 of the Qt Creator integrated development environment (IDE) introduces tools for developing Qt Quick applications. @@ -74,16 +74,16 @@ used to implement high level user interface logic. \l{How to Learn QML} introduces the reader to the language and declarative concepts. -\section1 QtDeclarative Module +\section1 QtQml Module -To make Qt Quick possible, Qt introduces the \l{QtDeclarative} module. The +To make Qt Quick possible, Qt introduces the \l{QtQml} module. The module creates a JavaScript runtime that QML runs under with a Qt based backend. -Because QtDeclarative and QML are built upon Qt, they inherit many of Qt's +Because QtQml and QML are built upon Qt, they inherit many of Qt's technology, namely the \l{Signals and Slots}{signals and slots} mechanism and the \l{The Meta-Object System}{meta-object} system. Data created using C++ are directly accessible from QML, and QML objects are also accessible from C++ code. -The QtDeclarative module separates the interface logic in QML from the +The QtQml module separates the interface logic in QML from the application logic in C++. It also allows the range of standard QML elements to be \l{Extending QML with C++}{extended with new ones written in C++}. diff --git a/doc/src/qtquick2/qtquick2.qdoc b/doc/src/qtquick2/qtquick2.qdoc index 6a1b7999c9..20361adb16 100644 --- a/doc/src/qtquick2/qtquick2.qdoc +++ b/doc/src/qtquick2/qtquick2.qdoc @@ -32,7 +32,7 @@ \brief The QML Elements This QML module contains all the QML elements that are - instantiated as objects of C++ classes in the QtDeclarative + instantiated as objects of C++ classes in the QtQml module. These elements work with the Scenegraph renderer and their own canvas. */ diff --git a/doc/src/qtquick2/righttoleft.qdoc b/doc/src/qtquick2/righttoleft.qdoc index b2cff57ee0..1781e3582a 100644 --- a/doc/src/qtquick2/righttoleft.qdoc +++ b/doc/src/qtquick2/righttoleft.qdoc @@ -68,7 +68,7 @@ Note that when \l LayoutMirroring is set, the \c horizontalAlignment property va the effective alignment of the text element that takes the mirroring into account can be read from the \c effectiveHorizontalAlignment property. -\snippet doc/src/snippets/declarative/righttoleft.qml 0 +\snippet doc/src/snippets/qml/righttoleft.qml 0 \section1 Layout direction of positioners and views @@ -84,7 +84,7 @@ This causes the effective \c layoutDirection of positioners and views to be mirr of the \c layoutDirection property will remain unchanged; the effective layout direction of positioners and views that takes the mirroring into account can be read from the \c effectiveLayoutDirection property. -\snippet doc/src/snippets/declarative/righttoleft.qml 1 +\snippet doc/src/snippets/qml/righttoleft.qml 1 \section1 Layout mirroring @@ -95,11 +95,11 @@ support for existing left-to-right Qt Quick applications. It mirrors the behavio You can enable layout mirroring for a particular \l Item: -\snippet doc/src/snippets/declarative/righttoleft.qml 2 +\snippet doc/src/snippets/qml/righttoleft.qml 2 Or set all child elements to also inherit the layout direction: -\snippet doc/src/snippets/declarative/righttoleft.qml 3 +\snippet doc/src/snippets/qml/righttoleft.qml 3 Applying mirroring in this manner does not change the actual value of the relevant anchor, \c layoutDirection or \c horizontalAlignment properties. The separate read-only property @@ -116,7 +116,7 @@ especially in views that rely on both the anchors and x coordinate-based positio the \l LayoutMirroring attached property to apply mirroring to an item that is positioned using \l {Item::}{x} coordinates: -\snippet doc/src/snippets/declarative/righttoleft.qml 4 +\snippet doc/src/snippets/qml/righttoleft.qml 4 Not all layouts should necessarily be mirrored. There are cases where a visual element is positioned to the right side of the screen for improved one-handed use, because most people are right-handed, and not @@ -135,7 +135,7 @@ aligned and just make sure that text is translated and aligned properly. Most images do not need to be mirrored, but some directional icons, such as arrows, may need to be mirrored. The painting of these icons can be mirrored with a dedicated \c mirror property introduced in Qt Quick 1.1: -\snippet doc/src/snippets/declarative/righttoleft.qml 5 +\snippet doc/src/snippets/qml/righttoleft.qml 5 \section1 Default layout direction diff --git a/doc/src/qtquick2/states.qdoc b/doc/src/qtquick2/states.qdoc index 559b4facac..622a1619b0 100644 --- a/doc/src/qtquick2/states.qdoc +++ b/doc/src/qtquick2/states.qdoc @@ -80,7 +80,7 @@ signal should be \c green and the warning \c flag is down. Meanwhile, in the \c CRITICAL state, the \c color should be \c red and the flag is \c up. We may model the states using the \c State element and the color and flag configurations with the \c PropertyChanges element. -\snippet doc/src/snippets/declarative/states.qml signal states +\snippet doc/src/snippets/qml/states.qml signal states The \l PropertyChanges element will change the values of object properties. Objects are referenced through their \l {qml-id}{id}. Objects outside the component are also referenced using the \c id property, exemplified by the @@ -89,7 +89,7 @@ property change to the external \c flag object. Further, the state may change by assigning the \c state property with the appropriate signal state. A state switch could be in a \l MouseArea element, assigning a different state whenever the signal receives a mouse click. -\snippet doc/src/snippets/declarative/states.qml switch states +\snippet doc/src/snippets/qml/states.qml switch states The State element is not limited to performing modifications on property values. It can also: @@ -115,7 +115,7 @@ expressions to change the state whenever the bound expression evaluates to \c true. The \c when property will revert the state back to the \l {The Default State}{default state} when the expression evaluates to false. -\snippet doc/src/snippets/declarative/states.qml when property +\snippet doc/src/snippets/qml/states.qml when property The \c bell component will change to the \c RINGING state whenever the \c signal.state is \c CRITICAL. diff --git a/doc/src/qtquick2/writingcomponents.qdoc b/doc/src/qtquick2/writingcomponents.qdoc index 64d28eff0b..31267cf20c 100644 --- a/doc/src/qtquick2/writingcomponents.qdoc +++ b/doc/src/qtquick2/writingcomponents.qdoc @@ -55,14 +55,14 @@ For example, one of the simplest and most common components you can build in QML button-type component. Below, we implement this component as a \l Rectangle with a clickable \l MouseArea, in a file named \c Button.qml: -\snippet doc/src/snippets/declarative/qml-extending-types/components/Button.qml 0 +\snippet doc/src/snippets/qml/qml-extending-types/components/Button.qml 0 Now this component can be reused by another file within the same directory. Since the file is named \c Button.qml, the component is referred to as \c Button: \table \row -\o \snippet doc/src/snippets/declarative/qml-extending-types/components/application.qml 0 +\o \snippet doc/src/snippets/qml/qml-extending-types/components/application.qml 0 \o \image qml-extending-types.png \endtable @@ -73,7 +73,7 @@ customize the \c width, \c height, \c radius and \c color properties of \c Butto If \c Button.qml was not in the same directory, \c application.qml would need to load it as a -\l {Modules}{module} from a specific filesystem path or \l{QDeclarativeExtensionPlugin}{plugin}. +\l {Modules}{module} from a specific filesystem path or \l{QQmlExtensionPlugin}{plugin}. Also, note the letter case of the component file name is significant on some (notably UNIX) filesystems. It is recommended the file name case matches the case of the QML component name exactly - for example, \c Box.qml and not \c BoX.qml - regardless of the platform to which the @@ -119,8 +119,8 @@ an \c ImageViewer object and read or modify the \c currentImage value: \table \row -\o \snippet doc/src/snippets/declarative/qml-extending-types/properties/ImageViewer.qml 0 -\o \snippet doc/src/snippets/declarative/qml-extending-types/properties/application.qml 0 +\o \snippet doc/src/snippets/qml/qml-extending-types/properties/ImageViewer.qml 0 +\o \snippet doc/src/snippets/qml/qml-extending-types/properties/application.qml 0 \endtable It is optional for a property to have a default value. The default value is a convenient shortcut, and is @@ -195,7 +195,7 @@ property name. For example, the following \c onMyNumberChanged signal handler is automatically called whenever the \c myNumber property changes: -\snippet doc/src/snippets/declarative/qml-extending-types/properties/property-signals.qml 0 +\snippet doc/src/snippets/qml/qml-extending-types/properties/property-signals.qml 0 \section2 Default properties @@ -266,7 +266,7 @@ declaring the alias, and, optionally, refers to a property on that ob For example, below is a \c Button.qml component with a \c buttonText aliased property which is connected to the child Text object's \c text property: -\snippet doc/src/snippets/declarative/qml-extending-types/properties/alias.qml 0 +\snippet doc/src/snippets/qml/qml-extending-types/properties/alias.qml 0 The following code would create a \c Button with a defined text string for the child \l Text object: @@ -290,8 +290,8 @@ been changed to an alias to the child \l Image object: \table \row -\o \snippet doc/src/snippets/declarative/qml-extending-types/properties/alias/ImageViewer.qml 0 -\o \snippet doc/src/snippets/declarative/qml-extending-types/properties/alias/application.qml 0 +\o \snippet doc/src/snippets/qml/qml-extending-types/properties/alias/ImageViewer.qml 0 +\o \snippet doc/src/snippets/qml/qml-extending-types/properties/alias/application.qml 0 \endtable Instead of being limited to setting the \l Image source, \c application.qml can now directly @@ -335,7 +335,7 @@ It is possible for an aliased property to have the same name as an existing prop the following component has a \c color alias property, named the same as the built-in \l {Rectangle::color} property: -\snippet doc/src/snippets/declarative/qml-extending-types/properties/alias-override.qml 0 +\snippet doc/src/snippets/qml/qml-extending-types/properties/alias-override.qml 0 Any objects that use this component and refer to its \c color property will be referring to the alias rather than the ordinary \l {Rectangle::color} property. Internally, @@ -366,7 +366,7 @@ the parameters by name. Here is an example of a component with a \c say() method that accepts a single \c text argument: -\snippet doc/src/snippets/declarative/qml-extending-types/methods/app.qml 0 +\snippet doc/src/snippets/qml/qml-extending-types/methods/app.qml 0 A method can be connected to a signal so that it is automatically invoked whenever the signal is emitted. See \l {Connecting signals to methods and other signals} below. @@ -422,8 +422,8 @@ signal is received by \c application.qml through an \c onButtonClicked signal ha \table \row -\o \snippet doc/src/snippets/declarative/qml-extending-types/signals/basic.qml 0 -\o \snippet doc/src/snippets/declarative/qml-extending-types/signals/no-parameters.qml 0 +\o \snippet doc/src/snippets/qml/qml-extending-types/signals/basic.qml 0 +\o \snippet doc/src/snippets/qml/qml-extending-types/signals/no-parameters.qml 0 \endtable If the signal has parameters, they are accessible by parameter name in the signal handler. @@ -431,8 +431,8 @@ In the example below, \c buttonClicked is emitted with \c xPos and \c yPos param \table \row -\o \snippet doc/src/snippets/declarative/qml-extending-types/signals/Button.qml 0 -\o \snippet doc/src/snippets/declarative/qml-extending-types/signals/parameters.qml 0 +\o \snippet doc/src/snippets/qml/qml-extending-types/signals/Button.qml 0 +\o \snippet doc/src/snippets/qml/qml-extending-types/signals/parameters.qml 0 \endtable @@ -446,7 +446,7 @@ to be received by a method instead of a \l {Signal Handlers}{signal handler}. For example, the \c application.qml above could be rewritten as: -\snippet doc/src/snippets/declarative/qml-extending-types/signals/connectslots.qml 0 +\snippet doc/src/snippets/qml/qml-extending-types/signals/connectslots.qml 0 The \c myMethod() method will be called whenever the \c buttonClicked signal is received. @@ -458,7 +458,7 @@ or \l {Integrating JavaScript}{integrating JavaScript code}, then you will find objects dynamically, and connects the \c buttonClicked signal of each object to the \c myMethod() function: -\snippet doc/src/snippets/declarative/qml-extending-types/signals/connectdynamic.qml 0 +\snippet doc/src/snippets/qml/qml-extending-types/signals/connectdynamic.qml 0 In the same way, you could connect a signal to methods defined in a dynamically created object, or \l {Receiving QML Signals in JavaScript}{connect a signal to a JavaScript method}. diff --git a/doc/src/snippets/declarative/qtbinding/context-advanced/main.cpp b/doc/src/snippets/declarative/qtbinding/context-advanced/main.cpp deleted file mode 100644 index d7cfe6f3ef..0000000000 --- a/doc/src/snippets/declarative/qtbinding/context-advanced/main.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -#include "applicationdata.h" - -//![0] -int main(int argc, char *argv[]) { - QApplication app(argc, argv); - - QDeclarativeView view; - - ApplicationData data; - view.rootContext()->setContextProperty("applicationData", &data); - - view.setSource(QUrl::fromLocalFile("MyItem.qml")); - view.show(); - - return app.exec(); -} -//![0] - diff --git a/doc/src/snippets/declarative/qtbinding/context/main.cpp b/doc/src/snippets/declarative/qtbinding/context/main.cpp deleted file mode 100644 index e0d9a83e64..0000000000 --- a/doc/src/snippets/declarative/qtbinding/context/main.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - -//![0] -QDeclarativeView view; -view.rootContext()->setContextProperty("currentDateTime", QDateTime::currentDateTime()); -view.setSource(QUrl::fromLocalFile("MyItem.qml")); -view.show(); -//![0] - - return app.exec(); -} - diff --git a/doc/src/snippets/declarative/qtbinding/enums/imageviewer.h b/doc/src/snippets/declarative/qtbinding/enums/imageviewer.h deleted file mode 100644 index de9f2ecaab..0000000000 --- a/doc/src/snippets/declarative/qtbinding/enums/imageviewer.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -//![start] -class ImageViewer : public QDeclarativeItem -{ - Q_OBJECT - Q_ENUMS(Status) - Q_PROPERTY(Status status READ status NOTIFY statusChanged) -public: - enum Status { - Ready, - Loading, - Error - }; - - Status status() const; -//![start] - - ImageViewer(QDeclarativeItem *parent = 0); - -public slots: - void emitSignals(); - -//![end] -signals: - void statusChanged(); -}; -//![end] diff --git a/doc/src/snippets/declarative/qtbinding/functions-cpp/main.cpp b/doc/src/snippets/declarative/qtbinding/functions-cpp/main.cpp deleted file mode 100644 index 5e6c474a8f..0000000000 --- a/doc/src/snippets/declarative/qtbinding/functions-cpp/main.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -#include "myclass.h" - -//![0] -int main(int argc, char *argv[]) { - QApplication app(argc, argv); - - QDeclarativeView view; - MyClass myClass; - view.rootContext()->setContextProperty("myObject", &myClass); - - view.setSource(QUrl::fromLocalFile("MyItem.qml")); - view.show(); - - return app.exec(); -} -//![0] - diff --git a/doc/src/snippets/declarative/qtbinding/functions-qml/main.cpp b/doc/src/snippets/declarative/qtbinding/functions-qml/main.cpp deleted file mode 100644 index ba72e9459a..0000000000 --- a/doc/src/snippets/declarative/qtbinding/functions-qml/main.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - -//![0] -// main.cpp -QDeclarativeEngine engine; -QDeclarativeComponent component(&engine, "MyItem.qml"); -QObject *object = component.create(); - -QVariant returnedValue; -QVariant msg = "Hello from C++"; -QMetaObject::invokeMethod(object, "myQmlFunction", - Q_RETURN_ARG(QVariant, returnedValue), - Q_ARG(QVariant, msg)); - -qDebug() << "QML function returned:" << returnedValue.toString(); -delete object; -//![0] -} - diff --git a/doc/src/snippets/declarative/qtbinding/loading/main.cpp b/doc/src/snippets/declarative/qtbinding/loading/main.cpp deleted file mode 100644 index 839b7352a5..0000000000 --- a/doc/src/snippets/declarative/qtbinding/loading/main.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -static void withComponent() -{ -//![QDeclarativeComponent-a] -// Using QDeclarativeComponent -QDeclarativeEngine engine; -QDeclarativeComponent component(&engine, - QUrl::fromLocalFile("MyItem.qml")); -QObject *object = component.create(); -//![QDeclarativeComponent-a] -} - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - -//![QDeclarativeView] -// Using QDeclarativeView -QDeclarativeView view; -view.setSource(QUrl::fromLocalFile("MyItem.qml")); -view.show(); -QObject *object = view.rootObject(); -//![QDeclarativeView] - -//![properties] -object->setProperty("width", 500); -QDeclarativeProperty(object, "width").write(500); -//![properties] - -//![cast] -QDeclarativeItem *item = qobject_cast(object); -item->setWidth(500); -//![cast] - -//![findChild] -QObject *rect = object->findChild("rect"); -if (rect) - rect->setProperty("color", "red"); -//![findChild] - -//![QDeclarativeComponent-b] -delete object; -//![QDeclarativeComponent-b] - -withComponent(); - - return app.exec(); -} - diff --git a/doc/src/snippets/declarative/qtbinding/newelements/imageviewer.h b/doc/src/snippets/declarative/qtbinding/newelements/imageviewer.h deleted file mode 100644 index 7bbc243d83..0000000000 --- a/doc/src/snippets/declarative/qtbinding/newelements/imageviewer.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -#include -#include - -class ImageViewer : public QDeclarativeItem -{ - Q_OBJECT - Q_PROPERTY(QUrl image READ image WRITE setImage NOTIFY imageChanged) - -public: - void setImage(const QUrl &url); - QUrl image() const; - -signals: - void imageChanged(); -}; -//![0] diff --git a/doc/src/snippets/declarative/qtbinding/newelements/main.cpp b/doc/src/snippets/declarative/qtbinding/newelements/main.cpp deleted file mode 100644 index ead2fd1722..0000000000 --- a/doc/src/snippets/declarative/qtbinding/newelements/main.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -#include "imageviewer.h" - -void ImageViewer::setImage(const QUrl &url) {} -QUrl ImageViewer::image() const { return QUrl(); } - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - //![register] - qmlRegisterType("MyLibrary", 1, 0, "ImageViewer"); - //![register] - - QDeclarativeView view; - view.setSource(QUrl::fromLocalFile("standalone.qml")); - view.show(); - - return app.exec(); -} - diff --git a/doc/src/snippets/declarative/qtbinding/properties-qml/main.cpp b/doc/src/snippets/declarative/qtbinding/properties-qml/main.cpp deleted file mode 100644 index 91347ee70f..0000000000 --- a/doc/src/snippets/declarative/qtbinding/properties-qml/main.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - -//![0] -QDeclarativeEngine engine; -QDeclarativeComponent component(&engine, "MyItem.qml"); -QObject *object = component.create(); - -qDebug() << "Property value:" << QDeclarativeProperty::read(object, "someNumber").toInt(); -QDeclarativeProperty::write(object, "someNumber", 5000); - -qDebug() << "Property value:" << object->property("someNumber").toInt(); -object->setProperty("someNumber", 100); -//![0] - - return app.exec(); -} - diff --git a/doc/src/snippets/declarative/qtbinding/resources/main.cpp b/doc/src/snippets/declarative/qtbinding/resources/main.cpp deleted file mode 100644 index 0ec1189eeb..0000000000 --- a/doc/src/snippets/declarative/qtbinding/resources/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include - -//![0] -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - QDeclarativeView view; - view.setSource(QUrl("qrc:/main.qml")); - view.show(); - - return app.exec(); -} -//![0] - diff --git a/doc/src/snippets/declarative/qtbinding/resources/resources.pro b/doc/src/snippets/declarative/qtbinding/resources/resources.pro deleted file mode 100644 index cc01ee126f..0000000000 --- a/doc/src/snippets/declarative/qtbinding/resources/resources.pro +++ /dev/null @@ -1,4 +0,0 @@ -QT += declarative - -SOURCES += main.cpp -RESOURCES += example.qrc diff --git a/doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h b/doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h deleted file mode 100644 index a066447cfb..0000000000 --- a/doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -//![start] -class ImageViewer : public QDeclarativeItem -{ - Q_OBJECT - Q_PROPERTY(QUrl image READ image WRITE setImage NOTIFY imageChanged) -public: -//![start] - ImageViewer(QDeclarativeItem *item = 0); - - void setImage(const QUrl &url) {} - QUrl image() const { return QUrl(); } - -public slots: - void emitSignals(); - -//![end] -signals: - void imageChanged(); - void loadingError(const QString &errorMsg); -}; -//![end] - diff --git a/doc/src/snippets/declarative/qtbinding/signals-cpp/main.cpp b/doc/src/snippets/declarative/qtbinding/signals-cpp/main.cpp deleted file mode 100644 index f3ea3f26df..0000000000 --- a/doc/src/snippets/declarative/qtbinding/signals-cpp/main.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -#include "imageviewer.h" - - -ImageViewer::ImageViewer(QDeclarativeItem *item) - : QDeclarativeItem(item) -{ - QTimer::singleShot(0, this, SLOT(emitSignals())); -} - -void ImageViewer::emitSignals() -{ - emit imageChanged(); - emit loadingError("some error message"); -} - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - qmlRegisterType("MyLibrary", 1, 0, "ImageViewer"); - - QDeclarativeView standalone; - standalone.setSource(QUrl::fromLocalFile("standalone.qml")); - standalone.show(); - -//![connections] -ImageViewer viewer; - -QDeclarativeView view; -view.rootContext()->setContextProperty("imageViewer", &viewer); - -view.setSource(QUrl::fromLocalFile("MyItem.qml")); -view.show(); -//![connections] - - return app.exec(); -} - - diff --git a/doc/src/snippets/declarative/qtbinding/signals-qml/main.cpp b/doc/src/snippets/declarative/qtbinding/signals-qml/main.cpp deleted file mode 100644 index 084d5f0e4b..0000000000 --- a/doc/src/snippets/declarative/qtbinding/signals-qml/main.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -//![0] -int main(int argc, char *argv[]) { - QApplication app(argc, argv); - - QDeclarativeView view(QUrl::fromLocalFile("MyItem.qml")); - QObject *item = view.rootObject(); - - MyClass myClass; - QObject::connect(item, SIGNAL(qmlSignal(QString)), - &myClass, SLOT(cppSlot(QString))); - - view.show(); - return app.exec(); -} -//![0] - -#include "moc_main.cpp" diff --git a/doc/src/snippets/declarative/qtbinding/variantlistmap/main.cpp b/doc/src/snippets/declarative/qtbinding/variantlistmap/main.cpp deleted file mode 100644 index 1cebecdff4..0000000000 --- a/doc/src/snippets/declarative/qtbinding/variantlistmap/main.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -int main(int argc, char *argv[]) { - QApplication app(argc, argv); - -//![0] -// C++ -QDeclarativeView view(QUrl::fromLocalFile("MyItem.qml")); - -QVariantList list; -list << 10 << Qt::green << "bottles"; - -QVariantMap map; -map.insert("language", "QML"); -map.insert("released", QDate(2010, 9, 21)); - -QMetaObject::invokeMethod(view.rootObject(), "readValues", - Q_ARG(QVariant, QVariant::fromValue(list)), - Q_ARG(QVariant, QVariant::fromValue(map))); -//![0] - - view.setSource(QUrl::fromLocalFile("MyItem.qml")); - view.show(); - - return app.exec(); -} - diff --git a/doc/src/snippets/declarative/visualdatamodel_rootindex/main.cpp b/doc/src/snippets/declarative/visualdatamodel_rootindex/main.cpp deleted file mode 100644 index 206828e883..0000000000 --- a/doc/src/snippets/declarative/visualdatamodel_rootindex/main.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -#include -#include - -//![0] -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - - QDeclarativeView view; - - QDirModel model; - view.rootContext()->setContextProperty("dirModel", &model); - - view.setSource(QUrl::fromLocalFile("view.qml")); - view.show(); - - return app.exec(); -} -//![0] - diff --git a/doc/src/snippets/declarative/Button.qml b/doc/src/snippets/qml/Button.qml similarity index 100% rename from doc/src/snippets/declarative/Button.qml rename to doc/src/snippets/qml/Button.qml diff --git a/doc/src/snippets/declarative/SelfDestroyingRect.qml b/doc/src/snippets/qml/SelfDestroyingRect.qml similarity index 100% rename from doc/src/snippets/declarative/SelfDestroyingRect.qml rename to doc/src/snippets/qml/SelfDestroyingRect.qml diff --git a/doc/src/snippets/declarative/Sprite.qml b/doc/src/snippets/qml/Sprite.qml similarity index 100% rename from doc/src/snippets/declarative/Sprite.qml rename to doc/src/snippets/qml/Sprite.qml diff --git a/doc/src/snippets/declarative/anchoranimation.qml b/doc/src/snippets/qml/anchoranimation.qml similarity index 100% rename from doc/src/snippets/declarative/anchoranimation.qml rename to doc/src/snippets/qml/anchoranimation.qml diff --git a/doc/src/snippets/declarative/anchorchanges.qml b/doc/src/snippets/qml/anchorchanges.qml similarity index 100% rename from doc/src/snippets/declarative/anchorchanges.qml rename to doc/src/snippets/qml/anchorchanges.qml diff --git a/doc/src/snippets/declarative/animatedimage.qml b/doc/src/snippets/qml/animatedimage.qml similarity index 100% rename from doc/src/snippets/declarative/animatedimage.qml rename to doc/src/snippets/qml/animatedimage.qml diff --git a/doc/src/snippets/declarative/animation.qml b/doc/src/snippets/qml/animation.qml similarity index 100% rename from doc/src/snippets/declarative/animation.qml rename to doc/src/snippets/qml/animation.qml diff --git a/doc/src/snippets/declarative/application.qml b/doc/src/snippets/qml/application.qml similarity index 100% rename from doc/src/snippets/declarative/application.qml rename to doc/src/snippets/qml/application.qml diff --git a/doc/src/snippets/declarative/behavior.qml b/doc/src/snippets/qml/behavior.qml similarity index 100% rename from doc/src/snippets/declarative/behavior.qml rename to doc/src/snippets/qml/behavior.qml diff --git a/doc/src/snippets/declarative/borderimage/borderimage-scaled.qml b/doc/src/snippets/qml/borderimage/borderimage-scaled.qml similarity index 100% rename from doc/src/snippets/declarative/borderimage/borderimage-scaled.qml rename to doc/src/snippets/qml/borderimage/borderimage-scaled.qml diff --git a/doc/src/snippets/declarative/borderimage/borderimage-tiled.qml b/doc/src/snippets/qml/borderimage/borderimage-tiled.qml similarity index 100% rename from doc/src/snippets/declarative/borderimage/borderimage-tiled.qml rename to doc/src/snippets/qml/borderimage/borderimage-tiled.qml diff --git a/doc/src/snippets/declarative/borderimage/normal-image.qml b/doc/src/snippets/qml/borderimage/normal-image.qml similarity index 100% rename from doc/src/snippets/declarative/borderimage/normal-image.qml rename to doc/src/snippets/qml/borderimage/normal-image.qml diff --git a/doc/src/snippets/declarative/codingconventions/dotproperties.qml b/doc/src/snippets/qml/codingconventions/dotproperties.qml similarity index 100% rename from doc/src/snippets/declarative/codingconventions/dotproperties.qml rename to doc/src/snippets/qml/codingconventions/dotproperties.qml diff --git a/doc/src/snippets/declarative/codingconventions/javascript-imports.qml b/doc/src/snippets/qml/codingconventions/javascript-imports.qml similarity index 100% rename from doc/src/snippets/declarative/codingconventions/javascript-imports.qml rename to doc/src/snippets/qml/codingconventions/javascript-imports.qml diff --git a/doc/src/snippets/declarative/codingconventions/javascript.qml b/doc/src/snippets/qml/codingconventions/javascript.qml similarity index 100% rename from doc/src/snippets/declarative/codingconventions/javascript.qml rename to doc/src/snippets/qml/codingconventions/javascript.qml diff --git a/doc/src/snippets/declarative/codingconventions/lists.qml b/doc/src/snippets/qml/codingconventions/lists.qml similarity index 100% rename from doc/src/snippets/declarative/codingconventions/lists.qml rename to doc/src/snippets/qml/codingconventions/lists.qml diff --git a/doc/src/snippets/declarative/codingconventions/myscript.js b/doc/src/snippets/qml/codingconventions/myscript.js similarity index 100% rename from doc/src/snippets/declarative/codingconventions/myscript.js rename to doc/src/snippets/qml/codingconventions/myscript.js diff --git a/doc/src/snippets/declarative/codingconventions/photo.qml b/doc/src/snippets/qml/codingconventions/photo.qml similarity index 100% rename from doc/src/snippets/declarative/codingconventions/photo.qml rename to doc/src/snippets/qml/codingconventions/photo.qml diff --git a/doc/src/snippets/declarative/codingconventions/private.qml b/doc/src/snippets/qml/codingconventions/private.qml similarity index 100% rename from doc/src/snippets/declarative/codingconventions/private.qml rename to doc/src/snippets/qml/codingconventions/private.qml diff --git a/doc/src/snippets/declarative/coloranimation.qml b/doc/src/snippets/qml/coloranimation.qml similarity index 100% rename from doc/src/snippets/declarative/coloranimation.qml rename to doc/src/snippets/qml/coloranimation.qml diff --git a/doc/src/snippets/declarative/colors.qml b/doc/src/snippets/qml/colors.qml similarity index 100% rename from doc/src/snippets/declarative/colors.qml rename to doc/src/snippets/qml/colors.qml diff --git a/doc/src/snippets/declarative/column/column-transitions.qml b/doc/src/snippets/qml/column/column-transitions.qml similarity index 100% rename from doc/src/snippets/declarative/column/column-transitions.qml rename to doc/src/snippets/qml/column/column-transitions.qml diff --git a/doc/src/snippets/declarative/column/column.qml b/doc/src/snippets/qml/column/column.qml similarity index 100% rename from doc/src/snippets/declarative/column/column.qml rename to doc/src/snippets/qml/column/column.qml diff --git a/doc/src/snippets/declarative/column/vertical-positioner.qml b/doc/src/snippets/qml/column/vertical-positioner.qml similarity index 100% rename from doc/src/snippets/declarative/column/vertical-positioner.qml rename to doc/src/snippets/qml/column/vertical-positioner.qml diff --git a/doc/src/snippets/declarative/comments.qml b/doc/src/snippets/qml/comments.qml similarity index 100% rename from doc/src/snippets/declarative/comments.qml rename to doc/src/snippets/qml/comments.qml diff --git a/doc/src/snippets/declarative/component.qml b/doc/src/snippets/qml/component.qml similarity index 100% rename from doc/src/snippets/declarative/component.qml rename to doc/src/snippets/qml/component.qml diff --git a/doc/src/snippets/declarative/componentCreation.js b/doc/src/snippets/qml/componentCreation.js similarity index 100% rename from doc/src/snippets/declarative/componentCreation.js rename to doc/src/snippets/qml/componentCreation.js diff --git a/doc/src/snippets/declarative/createComponent-simple.qml b/doc/src/snippets/qml/createComponent-simple.qml similarity index 100% rename from doc/src/snippets/declarative/createComponent-simple.qml rename to doc/src/snippets/qml/createComponent-simple.qml diff --git a/doc/src/snippets/declarative/createComponent.qml b/doc/src/snippets/qml/createComponent.qml similarity index 100% rename from doc/src/snippets/declarative/createComponent.qml rename to doc/src/snippets/qml/createComponent.qml diff --git a/doc/src/snippets/declarative/createQmlObject.qml b/doc/src/snippets/qml/createQmlObject.qml similarity index 100% rename from doc/src/snippets/declarative/createQmlObject.qml rename to doc/src/snippets/qml/createQmlObject.qml diff --git a/doc/src/snippets/declarative/drag.qml b/doc/src/snippets/qml/drag.qml similarity index 100% rename from doc/src/snippets/declarative/drag.qml rename to doc/src/snippets/qml/drag.qml diff --git a/doc/src/snippets/declarative/dynamicObjects-destroy.qml b/doc/src/snippets/qml/dynamicObjects-destroy.qml similarity index 100% rename from doc/src/snippets/declarative/dynamicObjects-destroy.qml rename to doc/src/snippets/qml/dynamicObjects-destroy.qml diff --git a/doc/src/snippets/declarative/events.qml b/doc/src/snippets/qml/events.qml similarity index 100% rename from doc/src/snippets/declarative/events.qml rename to doc/src/snippets/qml/events.qml diff --git a/doc/src/snippets/declarative/flickable.qml b/doc/src/snippets/qml/flickable.qml similarity index 100% rename from doc/src/snippets/declarative/flickable.qml rename to doc/src/snippets/qml/flickable.qml diff --git a/doc/src/snippets/declarative/flickableScrollbar.qml b/doc/src/snippets/qml/flickableScrollbar.qml similarity index 100% rename from doc/src/snippets/declarative/flickableScrollbar.qml rename to doc/src/snippets/qml/flickableScrollbar.qml diff --git a/doc/src/snippets/declarative/flipable/flipable.qml b/doc/src/snippets/qml/flipable/flipable.qml similarity index 100% rename from doc/src/snippets/declarative/flipable/flipable.qml rename to doc/src/snippets/qml/flipable/flipable.qml diff --git a/doc/src/snippets/declarative/flow.qml b/doc/src/snippets/qml/flow.qml similarity index 100% rename from doc/src/snippets/declarative/flow.qml rename to doc/src/snippets/qml/flow.qml diff --git a/doc/src/snippets/declarative/focus/MyClickableWidget.qml b/doc/src/snippets/qml/focus/MyClickableWidget.qml similarity index 100% rename from doc/src/snippets/declarative/focus/MyClickableWidget.qml rename to doc/src/snippets/qml/focus/MyClickableWidget.qml diff --git a/doc/src/snippets/declarative/focus/MyWidget.qml b/doc/src/snippets/qml/focus/MyWidget.qml similarity index 100% rename from doc/src/snippets/declarative/focus/MyWidget.qml rename to doc/src/snippets/qml/focus/MyWidget.qml diff --git a/doc/src/snippets/declarative/focus/advancedFocus.qml b/doc/src/snippets/qml/focus/advancedFocus.qml similarity index 100% rename from doc/src/snippets/declarative/focus/advancedFocus.qml rename to doc/src/snippets/qml/focus/advancedFocus.qml diff --git a/doc/src/snippets/declarative/focus/basicwidget.qml b/doc/src/snippets/qml/focus/basicwidget.qml similarity index 100% rename from doc/src/snippets/declarative/focus/basicwidget.qml rename to doc/src/snippets/qml/focus/basicwidget.qml diff --git a/doc/src/snippets/declarative/focus/clickablewidget.qml b/doc/src/snippets/qml/focus/clickablewidget.qml similarity index 100% rename from doc/src/snippets/declarative/focus/clickablewidget.qml rename to doc/src/snippets/qml/focus/clickablewidget.qml diff --git a/doc/src/snippets/declarative/focus/myfocusscopewidget.qml b/doc/src/snippets/qml/focus/myfocusscopewidget.qml similarity index 100% rename from doc/src/snippets/declarative/focus/myfocusscopewidget.qml rename to doc/src/snippets/qml/focus/myfocusscopewidget.qml diff --git a/doc/src/snippets/declarative/focus/rectangle.qml b/doc/src/snippets/qml/focus/rectangle.qml similarity index 100% rename from doc/src/snippets/declarative/focus/rectangle.qml rename to doc/src/snippets/qml/focus/rectangle.qml diff --git a/doc/src/snippets/declarative/focus/widget.qml b/doc/src/snippets/qml/focus/widget.qml similarity index 100% rename from doc/src/snippets/declarative/focus/widget.qml rename to doc/src/snippets/qml/focus/widget.qml diff --git a/doc/src/snippets/declarative/folderlistmodel.qml b/doc/src/snippets/qml/folderlistmodel.qml similarity index 100% rename from doc/src/snippets/declarative/folderlistmodel.qml rename to doc/src/snippets/qml/folderlistmodel.qml diff --git a/doc/src/snippets/declarative/gradient.qml b/doc/src/snippets/qml/gradient.qml similarity index 100% rename from doc/src/snippets/declarative/gradient.qml rename to doc/src/snippets/qml/gradient.qml diff --git a/doc/src/snippets/declarative/grid-spacing.qml b/doc/src/snippets/qml/grid-spacing.qml similarity index 100% rename from doc/src/snippets/declarative/grid-spacing.qml rename to doc/src/snippets/qml/grid-spacing.qml diff --git a/doc/src/snippets/declarative/grid/grid-items.qml b/doc/src/snippets/qml/grid/grid-items.qml similarity index 100% rename from doc/src/snippets/declarative/grid/grid-items.qml rename to doc/src/snippets/qml/grid/grid-items.qml diff --git a/doc/src/snippets/declarative/grid/grid-no-spacing.qml b/doc/src/snippets/qml/grid/grid-no-spacing.qml similarity index 100% rename from doc/src/snippets/declarative/grid/grid-no-spacing.qml rename to doc/src/snippets/qml/grid/grid-no-spacing.qml diff --git a/doc/src/snippets/declarative/grid/grid-spacing.qml b/doc/src/snippets/qml/grid/grid-spacing.qml similarity index 100% rename from doc/src/snippets/declarative/grid/grid-spacing.qml rename to doc/src/snippets/qml/grid/grid-spacing.qml diff --git a/doc/src/snippets/declarative/grid/grid.qml b/doc/src/snippets/qml/grid/grid.qml similarity index 100% rename from doc/src/snippets/declarative/grid/grid.qml rename to doc/src/snippets/qml/grid/grid.qml diff --git a/doc/src/snippets/declarative/gridview/ContactModel.qml b/doc/src/snippets/qml/gridview/ContactModel.qml similarity index 100% rename from doc/src/snippets/declarative/gridview/ContactModel.qml rename to doc/src/snippets/qml/gridview/ContactModel.qml diff --git a/doc/src/snippets/declarative/gridview/gridview.qml b/doc/src/snippets/qml/gridview/gridview.qml similarity index 100% rename from doc/src/snippets/declarative/gridview/gridview.qml rename to doc/src/snippets/qml/gridview/gridview.qml diff --git a/doc/src/snippets/declarative/image.qml b/doc/src/snippets/qml/image.qml similarity index 100% rename from doc/src/snippets/declarative/image.qml rename to doc/src/snippets/qml/image.qml diff --git a/doc/src/snippets/declarative/imports/chart.qml b/doc/src/snippets/qml/imports/chart.qml similarity index 100% rename from doc/src/snippets/declarative/imports/chart.qml rename to doc/src/snippets/qml/imports/chart.qml diff --git a/doc/src/snippets/declarative/imports/installed-module.qml b/doc/src/snippets/qml/imports/installed-module.qml similarity index 100% rename from doc/src/snippets/declarative/imports/installed-module.qml rename to doc/src/snippets/qml/imports/installed-module.qml diff --git a/doc/src/snippets/declarative/imports/merged-named-imports.qml b/doc/src/snippets/qml/imports/merged-named-imports.qml similarity index 100% rename from doc/src/snippets/declarative/imports/merged-named-imports.qml rename to doc/src/snippets/qml/imports/merged-named-imports.qml diff --git a/doc/src/snippets/declarative/imports/named-imports.qml b/doc/src/snippets/qml/imports/named-imports.qml similarity index 100% rename from doc/src/snippets/declarative/imports/named-imports.qml rename to doc/src/snippets/qml/imports/named-imports.qml diff --git a/doc/src/snippets/declarative/imports/network-imports.qml b/doc/src/snippets/qml/imports/network-imports.qml similarity index 100% rename from doc/src/snippets/declarative/imports/network-imports.qml rename to doc/src/snippets/qml/imports/network-imports.qml diff --git a/doc/src/snippets/declarative/imports/qtquick-1.0.qml b/doc/src/snippets/qml/imports/qtquick-1.0.qml similarity index 100% rename from doc/src/snippets/declarative/imports/qtquick-1.0.qml rename to doc/src/snippets/qml/imports/qtquick-1.0.qml diff --git a/doc/src/snippets/declarative/imports/timeexample.qml b/doc/src/snippets/qml/imports/timeexample.qml similarity index 100% rename from doc/src/snippets/declarative/imports/timeexample.qml rename to doc/src/snippets/qml/imports/timeexample.qml diff --git a/doc/src/snippets/declarative/integrating-javascript/connectjs.qml b/doc/src/snippets/qml/integrating-javascript/connectjs.qml similarity index 100% rename from doc/src/snippets/declarative/integrating-javascript/connectjs.qml rename to doc/src/snippets/qml/integrating-javascript/connectjs.qml diff --git a/doc/src/snippets/declarative/integrating-javascript/includejs/app.qml b/doc/src/snippets/qml/integrating-javascript/includejs/app.qml similarity index 100% rename from doc/src/snippets/declarative/integrating-javascript/includejs/app.qml rename to doc/src/snippets/qml/integrating-javascript/includejs/app.qml diff --git a/doc/src/snippets/declarative/integrating-javascript/includejs/factorial.js b/doc/src/snippets/qml/integrating-javascript/includejs/factorial.js similarity index 100% rename from doc/src/snippets/declarative/integrating-javascript/includejs/factorial.js rename to doc/src/snippets/qml/integrating-javascript/includejs/factorial.js diff --git a/doc/src/snippets/declarative/integrating-javascript/includejs/script.js b/doc/src/snippets/qml/integrating-javascript/includejs/script.js similarity index 100% rename from doc/src/snippets/declarative/integrating-javascript/includejs/script.js rename to doc/src/snippets/qml/integrating-javascript/includejs/script.js diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp b/doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp similarity index 92% rename from doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp rename to doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp index 8825cca4bb..e018a68292 100644 --- a/doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp +++ b/doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp @@ -39,8 +39,8 @@ ****************************************************************************/ #include "avatarExample.h" -#include -#include +#include +#include void registerTypes() { @@ -52,7 +52,7 @@ void registerTypes() void expectOne() { //![1] -QDeclarativeComponent component(&engine, "exampleOne.qml"); +QQmlComponent component(&engine, "exampleOne.qml"); QObject *object = component.create(); // The scarce resource will have been released automatically // by this point, after the binding expression was evaluated. @@ -63,7 +63,7 @@ delete object; void expectTwo() { //![2] -QDeclarativeComponent component(&engine, "exampleTwo.qml"); +QQmlComponent component(&engine, "exampleTwo.qml"); QObject *object = component.create(); // The scarce resource will not have been released automatically // after the binding expression was evaluated. @@ -77,7 +77,7 @@ delete object; void expectThree() { //![3] -QDeclarativeComponent component(&engine, "exampleThree.qml"); +QQmlComponent component(&engine, "exampleThree.qml"); QObject *object = component.create(); // The resource was preserved explicitly during evaluation of the // JavaScript expression. Thus, during property assignment, the @@ -92,7 +92,7 @@ delete object; void expectFour() { //![4] -QDeclarativeComponent component(&engine, "exampleFour.qml"); +QQmlComponent component(&engine, "exampleFour.qml"); QObject *object = component.create(); // The scarce resource was explicitly preserved by the client during // the importAvatar() function, and so the scarce resource @@ -111,7 +111,7 @@ delete object; void expectFive() { //![5] -QDeclarativeComponent component(&engine, "exampleFive.qml"); +QQmlComponent component(&engine, "exampleFive.qml"); QObject *object = component.create(); // We have the expected results: bool expectedResultOne = (object->property("avatarOne").isValid() == false); diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.h b/doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.h similarity index 100% rename from doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.h rename to doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.h diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFive.qml b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFive.qml similarity index 100% rename from doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFive.qml rename to doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFive.qml diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.js b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.js similarity index 100% rename from doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.js rename to doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.js diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.qml b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.qml similarity index 100% rename from doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.qml rename to doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.qml diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleOne.qml b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleOne.qml similarity index 100% rename from doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleOne.qml rename to doc/src/snippets/qml/integrating-javascript/scarceresources/exampleOne.qml diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.js b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.js similarity index 100% rename from doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.js rename to doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.js diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.qml b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.qml similarity index 100% rename from doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.qml rename to doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.qml diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleTwo.qml b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleTwo.qml similarity index 100% rename from doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleTwo.qml rename to doc/src/snippets/qml/integrating-javascript/scarceresources/exampleTwo.qml diff --git a/doc/src/snippets/declarative/integrating-javascript/script.js b/doc/src/snippets/qml/integrating-javascript/script.js similarity index 100% rename from doc/src/snippets/declarative/integrating-javascript/script.js rename to doc/src/snippets/qml/integrating-javascript/script.js diff --git a/doc/src/snippets/declarative/keynavigation.qml b/doc/src/snippets/qml/keynavigation.qml similarity index 100% rename from doc/src/snippets/declarative/keynavigation.qml rename to doc/src/snippets/qml/keynavigation.qml diff --git a/doc/src/snippets/declarative/keys/keys-handler.qml b/doc/src/snippets/qml/keys/keys-handler.qml similarity index 100% rename from doc/src/snippets/declarative/keys/keys-handler.qml rename to doc/src/snippets/qml/keys/keys-handler.qml diff --git a/doc/src/snippets/declarative/keys/keys-pressed.qml b/doc/src/snippets/qml/keys/keys-pressed.qml similarity index 100% rename from doc/src/snippets/declarative/keys/keys-pressed.qml rename to doc/src/snippets/qml/keys/keys-pressed.qml diff --git a/doc/src/snippets/declarative/layoutmirroring.qml b/doc/src/snippets/qml/layoutmirroring.qml similarity index 100% rename from doc/src/snippets/declarative/layoutmirroring.qml rename to doc/src/snippets/qml/layoutmirroring.qml diff --git a/doc/src/snippets/declarative/listmodel-modify.qml b/doc/src/snippets/qml/listmodel-modify.qml similarity index 100% rename from doc/src/snippets/declarative/listmodel-modify.qml rename to doc/src/snippets/qml/listmodel-modify.qml diff --git a/doc/src/snippets/declarative/listmodel-nested.qml b/doc/src/snippets/qml/listmodel-nested.qml similarity index 100% rename from doc/src/snippets/declarative/listmodel-nested.qml rename to doc/src/snippets/qml/listmodel-nested.qml diff --git a/doc/src/snippets/declarative/listmodel-simple.qml b/doc/src/snippets/qml/listmodel-simple.qml similarity index 100% rename from doc/src/snippets/declarative/listmodel-simple.qml rename to doc/src/snippets/qml/listmodel-simple.qml diff --git a/doc/src/snippets/declarative/listmodel.qml b/doc/src/snippets/qml/listmodel.qml similarity index 100% rename from doc/src/snippets/declarative/listmodel.qml rename to doc/src/snippets/qml/listmodel.qml diff --git a/doc/src/snippets/declarative/listview-decorations.qml b/doc/src/snippets/qml/listview-decorations.qml similarity index 100% rename from doc/src/snippets/declarative/listview-decorations.qml rename to doc/src/snippets/qml/listview-decorations.qml diff --git a/doc/src/snippets/declarative/listview-sections.qml b/doc/src/snippets/qml/listview-sections.qml similarity index 100% rename from doc/src/snippets/declarative/listview-sections.qml rename to doc/src/snippets/qml/listview-sections.qml diff --git a/doc/src/snippets/declarative/listview.qml b/doc/src/snippets/qml/listview.qml similarity index 100% rename from doc/src/snippets/declarative/listview.qml rename to doc/src/snippets/qml/listview.qml diff --git a/doc/src/snippets/declarative/listview/ContactModel.qml b/doc/src/snippets/qml/listview/ContactModel.qml similarity index 100% rename from doc/src/snippets/declarative/listview/ContactModel.qml rename to doc/src/snippets/qml/listview/ContactModel.qml diff --git a/doc/src/snippets/declarative/listview/listview-snippet.qml b/doc/src/snippets/qml/listview/listview-snippet.qml similarity index 100% rename from doc/src/snippets/declarative/listview/listview-snippet.qml rename to doc/src/snippets/qml/listview/listview-snippet.qml diff --git a/doc/src/snippets/declarative/listview/listview.qml b/doc/src/snippets/qml/listview/listview.qml similarity index 100% rename from doc/src/snippets/declarative/listview/listview.qml rename to doc/src/snippets/qml/listview/listview.qml diff --git a/doc/src/snippets/declarative/loader/KeyReader.qml b/doc/src/snippets/qml/loader/KeyReader.qml similarity index 100% rename from doc/src/snippets/declarative/loader/KeyReader.qml rename to doc/src/snippets/qml/loader/KeyReader.qml diff --git a/doc/src/snippets/declarative/loader/MyItem.qml b/doc/src/snippets/qml/loader/MyItem.qml similarity index 100% rename from doc/src/snippets/declarative/loader/MyItem.qml rename to doc/src/snippets/qml/loader/MyItem.qml diff --git a/doc/src/snippets/declarative/loader/connections.qml b/doc/src/snippets/qml/loader/connections.qml similarity index 100% rename from doc/src/snippets/declarative/loader/connections.qml rename to doc/src/snippets/qml/loader/connections.qml diff --git a/doc/src/snippets/declarative/loader/focus.qml b/doc/src/snippets/qml/loader/focus.qml similarity index 100% rename from doc/src/snippets/declarative/loader/focus.qml rename to doc/src/snippets/qml/loader/focus.qml diff --git a/doc/src/snippets/declarative/loader/simple.qml b/doc/src/snippets/qml/loader/simple.qml similarity index 100% rename from doc/src/snippets/declarative/loader/simple.qml rename to doc/src/snippets/qml/loader/simple.qml diff --git a/doc/src/snippets/declarative/loader/sizeitem.qml b/doc/src/snippets/qml/loader/sizeitem.qml similarity index 100% rename from doc/src/snippets/declarative/loader/sizeitem.qml rename to doc/src/snippets/qml/loader/sizeitem.qml diff --git a/doc/src/snippets/declarative/loader/sizeloader.qml b/doc/src/snippets/qml/loader/sizeloader.qml similarity index 100% rename from doc/src/snippets/declarative/loader/sizeloader.qml rename to doc/src/snippets/qml/loader/sizeloader.qml diff --git a/doc/src/snippets/declarative/models/views-models-delegates.qml b/doc/src/snippets/qml/models/views-models-delegates.qml similarity index 100% rename from doc/src/snippets/declarative/models/views-models-delegates.qml rename to doc/src/snippets/qml/models/views-models-delegates.qml diff --git a/doc/src/snippets/declarative/models/visual-model-and-view.qml b/doc/src/snippets/qml/models/visual-model-and-view.qml similarity index 100% rename from doc/src/snippets/declarative/models/visual-model-and-view.qml rename to doc/src/snippets/qml/models/visual-model-and-view.qml diff --git a/doc/src/snippets/declarative/mousearea/mousearea-snippet.qml b/doc/src/snippets/qml/mousearea/mousearea-snippet.qml similarity index 100% rename from doc/src/snippets/declarative/mousearea/mousearea-snippet.qml rename to doc/src/snippets/qml/mousearea/mousearea-snippet.qml diff --git a/doc/src/snippets/declarative/mousearea/mousearea.qml b/doc/src/snippets/qml/mousearea/mousearea.qml similarity index 100% rename from doc/src/snippets/declarative/mousearea/mousearea.qml rename to doc/src/snippets/qml/mousearea/mousearea.qml diff --git a/doc/src/snippets/declarative/mousearea/mouseareadragfilter.qml b/doc/src/snippets/qml/mousearea/mouseareadragfilter.qml similarity index 100% rename from doc/src/snippets/declarative/mousearea/mouseareadragfilter.qml rename to doc/src/snippets/qml/mousearea/mouseareadragfilter.qml diff --git a/doc/src/snippets/declarative/multipointtoucharea/multipointtoucharea.qml b/doc/src/snippets/qml/multipointtoucharea/multipointtoucharea.qml similarity index 100% rename from doc/src/snippets/declarative/multipointtoucharea/multipointtoucharea.qml rename to doc/src/snippets/qml/multipointtoucharea/multipointtoucharea.qml diff --git a/doc/src/snippets/declarative/numberanimation.qml b/doc/src/snippets/qml/numberanimation.qml similarity index 100% rename from doc/src/snippets/declarative/numberanimation.qml rename to doc/src/snippets/qml/numberanimation.qml diff --git a/doc/src/snippets/declarative/parallelanimation.qml b/doc/src/snippets/qml/parallelanimation.qml similarity index 100% rename from doc/src/snippets/declarative/parallelanimation.qml rename to doc/src/snippets/qml/parallelanimation.qml diff --git a/doc/src/snippets/declarative/parentanimation.qml b/doc/src/snippets/qml/parentanimation.qml similarity index 100% rename from doc/src/snippets/declarative/parentanimation.qml rename to doc/src/snippets/qml/parentanimation.qml diff --git a/doc/src/snippets/declarative/parentchange.qml b/doc/src/snippets/qml/parentchange.qml similarity index 100% rename from doc/src/snippets/declarative/parentchange.qml rename to doc/src/snippets/qml/parentchange.qml diff --git a/doc/src/snippets/declarative/path/arcdirection.qml b/doc/src/snippets/qml/path/arcdirection.qml similarity index 100% rename from doc/src/snippets/declarative/path/arcdirection.qml rename to doc/src/snippets/qml/path/arcdirection.qml diff --git a/doc/src/snippets/declarative/path/arcradius.qml b/doc/src/snippets/qml/path/arcradius.qml similarity index 100% rename from doc/src/snippets/declarative/path/arcradius.qml rename to doc/src/snippets/qml/path/arcradius.qml diff --git a/doc/src/snippets/declarative/path/basicarc.qml b/doc/src/snippets/qml/path/basicarc.qml similarity index 100% rename from doc/src/snippets/declarative/path/basicarc.qml rename to doc/src/snippets/qml/path/basicarc.qml diff --git a/doc/src/snippets/declarative/path/basiccurve.qml b/doc/src/snippets/qml/path/basiccurve.qml similarity index 100% rename from doc/src/snippets/declarative/path/basiccurve.qml rename to doc/src/snippets/qml/path/basiccurve.qml diff --git a/doc/src/snippets/declarative/path/largearc.qml b/doc/src/snippets/qml/path/largearc.qml similarity index 100% rename from doc/src/snippets/declarative/path/largearc.qml rename to doc/src/snippets/qml/path/largearc.qml diff --git a/doc/src/snippets/declarative/pathinterpolator.qml b/doc/src/snippets/qml/pathinterpolator.qml similarity index 100% rename from doc/src/snippets/declarative/pathinterpolator.qml rename to doc/src/snippets/qml/pathinterpolator.qml diff --git a/doc/src/snippets/declarative/pathview/ContactModel.qml b/doc/src/snippets/qml/pathview/ContactModel.qml similarity index 100% rename from doc/src/snippets/declarative/pathview/ContactModel.qml rename to doc/src/snippets/qml/pathview/ContactModel.qml diff --git a/doc/src/snippets/declarative/pathview/pathattributes.qml b/doc/src/snippets/qml/pathview/pathattributes.qml similarity index 100% rename from doc/src/snippets/declarative/pathview/pathattributes.qml rename to doc/src/snippets/qml/pathview/pathattributes.qml diff --git a/doc/src/snippets/declarative/pathview/pathview.qml b/doc/src/snippets/qml/pathview/pathview.qml similarity index 100% rename from doc/src/snippets/declarative/pathview/pathview.qml rename to doc/src/snippets/qml/pathview/pathview.qml diff --git a/doc/src/snippets/declarative/properties.qml b/doc/src/snippets/qml/properties.qml similarity index 100% rename from doc/src/snippets/declarative/properties.qml rename to doc/src/snippets/qml/properties.qml diff --git a/doc/src/snippets/declarative/propertyaction-sequential.qml b/doc/src/snippets/qml/propertyaction-sequential.qml similarity index 100% rename from doc/src/snippets/declarative/propertyaction-sequential.qml rename to doc/src/snippets/qml/propertyaction-sequential.qml diff --git a/doc/src/snippets/declarative/propertyaction.qml b/doc/src/snippets/qml/propertyaction.qml similarity index 100% rename from doc/src/snippets/declarative/propertyaction.qml rename to doc/src/snippets/qml/propertyaction.qml diff --git a/doc/src/snippets/declarative/propertyanimation.qml b/doc/src/snippets/qml/propertyanimation.qml similarity index 100% rename from doc/src/snippets/declarative/propertyanimation.qml rename to doc/src/snippets/qml/propertyanimation.qml diff --git a/doc/src/snippets/declarative/propertychanges.qml b/doc/src/snippets/qml/propertychanges.qml similarity index 100% rename from doc/src/snippets/declarative/propertychanges.qml rename to doc/src/snippets/qml/propertychanges.qml diff --git a/doc/src/snippets/declarative/qml-data-models/dynamic-listmodel.qml b/doc/src/snippets/qml/qml-data-models/dynamic-listmodel.qml similarity index 100% rename from doc/src/snippets/declarative/qml-data-models/dynamic-listmodel.qml rename to doc/src/snippets/qml/qml-data-models/dynamic-listmodel.qml diff --git a/doc/src/snippets/declarative/qml-data-models/listelements.qml b/doc/src/snippets/qml/qml-data-models/listelements.qml similarity index 100% rename from doc/src/snippets/declarative/qml-data-models/listelements.qml rename to doc/src/snippets/qml/qml-data-models/listelements.qml diff --git a/doc/src/snippets/declarative/qml-data-models/listmodel-listview.qml b/doc/src/snippets/qml/qml-data-models/listmodel-listview.qml similarity index 100% rename from doc/src/snippets/declarative/qml-data-models/listmodel-listview.qml rename to doc/src/snippets/qml/qml-data-models/listmodel-listview.qml diff --git a/doc/src/snippets/declarative/qml-documents/inline-component.qml b/doc/src/snippets/qml/qml-documents/inline-component.qml similarity index 100% rename from doc/src/snippets/declarative/qml-documents/inline-component.qml rename to doc/src/snippets/qml/qml-documents/inline-component.qml diff --git a/doc/src/snippets/declarative/qml-documents/inline-text-component.qml b/doc/src/snippets/qml/qml-documents/inline-text-component.qml similarity index 100% rename from doc/src/snippets/declarative/qml-documents/inline-text-component.qml rename to doc/src/snippets/qml/qml-documents/inline-text-component.qml diff --git a/doc/src/snippets/declarative/qml-documents/non-trivial.qml b/doc/src/snippets/qml/qml-documents/non-trivial.qml similarity index 100% rename from doc/src/snippets/declarative/qml-documents/non-trivial.qml rename to doc/src/snippets/qml/qml-documents/non-trivial.qml diff --git a/doc/src/snippets/declarative/qml-documents/qmldocuments.qml b/doc/src/snippets/qml/qml-documents/qmldocuments.qml similarity index 100% rename from doc/src/snippets/declarative/qml-documents/qmldocuments.qml rename to doc/src/snippets/qml/qml-documents/qmldocuments.qml diff --git a/doc/src/snippets/declarative/qml-intro/images/qt-logo.svg b/doc/src/snippets/qml/qml-intro/images/qt-logo.svg similarity index 100% rename from doc/src/snippets/declarative/qml-intro/images/qt-logo.svg rename to doc/src/snippets/qml/qml-intro/images/qt-logo.svg diff --git a/doc/src/snippets/declarative/qtbinding/context-advanced/MyItem.qml b/doc/src/snippets/qml/qtbinding/context-advanced/MyItem.qml similarity index 100% rename from doc/src/snippets/declarative/qtbinding/context-advanced/MyItem.qml rename to doc/src/snippets/qml/qtbinding/context-advanced/MyItem.qml diff --git a/doc/src/snippets/declarative/qtbinding/context-advanced/applicationdata.h b/doc/src/snippets/qml/qtbinding/context-advanced/applicationdata.h similarity index 100% rename from doc/src/snippets/declarative/qtbinding/context-advanced/applicationdata.h rename to doc/src/snippets/qml/qtbinding/context-advanced/applicationdata.h diff --git a/doc/src/snippets/declarative/qtbinding/context-advanced/connections.qml b/doc/src/snippets/qml/qtbinding/context-advanced/connections.qml similarity index 100% rename from doc/src/snippets/declarative/qtbinding/context-advanced/connections.qml rename to doc/src/snippets/qml/qtbinding/context-advanced/connections.qml diff --git a/doc/src/snippets/qml/qtbinding/context-advanced/main.cpp b/doc/src/snippets/qml/qtbinding/context-advanced/main.cpp new file mode 100644 index 0000000000..b9676e4b66 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/context-advanced/main.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +#include "applicationdata.h" + +//![0] +int main(int argc, char *argv[]) { + QApplication app(argc, argv); + + QQuickView view; + + ApplicationData data; + view.rootContext()->setContextProperty("applicationData", &data); + + view.setSource(QUrl::fromLocalFile("MyItem.qml")); + view.show(); + + return app.exec(); +} +//![0] + diff --git a/doc/src/snippets/declarative/qtbinding/context/MyItem.qml b/doc/src/snippets/qml/qtbinding/context/MyItem.qml similarity index 100% rename from doc/src/snippets/declarative/qtbinding/context/MyItem.qml rename to doc/src/snippets/qml/qtbinding/context/MyItem.qml diff --git a/doc/src/snippets/qml/qtbinding/context/main.cpp b/doc/src/snippets/qml/qtbinding/context/main.cpp new file mode 100644 index 0000000000..0849a845a6 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/context/main.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + +//![0] +QQuickView view; +view.rootContext()->setContextProperty("currentDateTime", QDateTime::currentDateTime()); +view.setSource(QUrl::fromLocalFile("MyItem.qml")); +view.show(); +//![0] + + return app.exec(); +} + diff --git a/doc/src/snippets/qml/qtbinding/enums/imageviewer.h b/doc/src/snippets/qml/qtbinding/enums/imageviewer.h new file mode 100644 index 0000000000..df9709953f --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/enums/imageviewer.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +//![start] +class ImageViewer : public QQuickItem +{ + Q_OBJECT + Q_ENUMS(Status) + Q_PROPERTY(Status status READ status NOTIFY statusChanged) +public: + enum Status { + Ready, + Loading, + Error + }; + + Status status() const; +//![start] + + ImageViewer(QQuickItem *parent = 0); + +public slots: + void emitSignals(); + +//![end] +signals: + void statusChanged(); +}; +//![end] diff --git a/doc/src/snippets/declarative/qtbinding/enums/standalone.qml b/doc/src/snippets/qml/qtbinding/enums/standalone.qml similarity index 100% rename from doc/src/snippets/declarative/qtbinding/enums/standalone.qml rename to doc/src/snippets/qml/qtbinding/enums/standalone.qml diff --git a/doc/src/snippets/declarative/qtbinding/functions-cpp/MyItem.qml b/doc/src/snippets/qml/qtbinding/functions-cpp/MyItem.qml similarity index 100% rename from doc/src/snippets/declarative/qtbinding/functions-cpp/MyItem.qml rename to doc/src/snippets/qml/qtbinding/functions-cpp/MyItem.qml diff --git a/doc/src/snippets/qml/qtbinding/functions-cpp/main.cpp b/doc/src/snippets/qml/qtbinding/functions-cpp/main.cpp new file mode 100644 index 0000000000..3d63e055a3 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/functions-cpp/main.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +#include "myclass.h" + +//![0] +int main(int argc, char *argv[]) { + QApplication app(argc, argv); + + QQuickView view; + MyClass myClass; + view.rootContext()->setContextProperty("myObject", &myClass); + + view.setSource(QUrl::fromLocalFile("MyItem.qml")); + view.show(); + + return app.exec(); +} +//![0] + diff --git a/doc/src/snippets/declarative/qtbinding/functions-cpp/myclass.h b/doc/src/snippets/qml/qtbinding/functions-cpp/myclass.h similarity index 100% rename from doc/src/snippets/declarative/qtbinding/functions-cpp/myclass.h rename to doc/src/snippets/qml/qtbinding/functions-cpp/myclass.h diff --git a/doc/src/snippets/declarative/qtbinding/functions-qml/MyItem.qml b/doc/src/snippets/qml/qtbinding/functions-qml/MyItem.qml similarity index 100% rename from doc/src/snippets/declarative/qtbinding/functions-qml/MyItem.qml rename to doc/src/snippets/qml/qtbinding/functions-qml/MyItem.qml diff --git a/doc/src/snippets/qml/qtbinding/functions-qml/main.cpp b/doc/src/snippets/qml/qtbinding/functions-qml/main.cpp new file mode 100644 index 0000000000..5c6a0c507d --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/functions-qml/main.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + +//![0] +// main.cpp +QQmlEngine engine; +QQmlComponent component(&engine, "MyItem.qml"); +QObject *object = component.create(); + +QVariant returnedValue; +QVariant msg = "Hello from C++"; +QMetaObject::invokeMethod(object, "myQmlFunction", + Q_RETURN_ARG(QVariant, returnedValue), + Q_ARG(QVariant, msg)); + +qDebug() << "QML function returned:" << returnedValue.toString(); +delete object; +//![0] +} + diff --git a/doc/src/snippets/declarative/qtbinding/loading/MyItem.qml b/doc/src/snippets/qml/qtbinding/loading/MyItem.qml similarity index 100% rename from doc/src/snippets/declarative/qtbinding/loading/MyItem.qml rename to doc/src/snippets/qml/qtbinding/loading/MyItem.qml diff --git a/doc/src/snippets/qml/qtbinding/loading/main.cpp b/doc/src/snippets/qml/qtbinding/loading/main.cpp new file mode 100644 index 0000000000..98ed4173f9 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/loading/main.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +static void withComponent() +{ +//![QQmlComponent-a] +// Using QQmlComponent +QQmlEngine engine; +QQmlComponent component(&engine, + QUrl::fromLocalFile("MyItem.qml")); +QObject *object = component.create(); +//![QQmlComponent-a] +} + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + +//![QQuickView] +// Using QQuickView +QQuickView view; +view.setSource(QUrl::fromLocalFile("MyItem.qml")); +view.show(); +QObject *object = view.rootObject(); +//![QQuickView] + +//![properties] +object->setProperty("width", 500); +QQmlProperty(object, "width").write(500); +//![properties] + +//![cast] +QQuickItem *item = qobject_cast(object); +item->setWidth(500); +//![cast] + +//![findChild] +QObject *rect = object->findChild("rect"); +if (rect) + rect->setProperty("color", "red"); +//![findChild] + +//![QQmlComponent-b] +delete object; +//![QQmlComponent-b] + +withComponent(); + + return app.exec(); +} + diff --git a/doc/src/snippets/qml/qtbinding/newelements/imageviewer.h b/doc/src/snippets/qml/qtbinding/newelements/imageviewer.h new file mode 100644 index 0000000000..3559951693 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/newelements/imageviewer.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +#include +#include + +class ImageViewer : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(QUrl image READ image WRITE setImage NOTIFY imageChanged) + +public: + void setImage(const QUrl &url); + QUrl image() const; + +signals: + void imageChanged(); +}; +//![0] diff --git a/doc/src/snippets/qml/qtbinding/newelements/main.cpp b/doc/src/snippets/qml/qtbinding/newelements/main.cpp new file mode 100644 index 0000000000..8ab7eb63f4 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/newelements/main.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +#include "imageviewer.h" + +void ImageViewer::setImage(const QUrl &url) {} +QUrl ImageViewer::image() const { return QUrl(); } + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + //![register] + qmlRegisterType("MyLibrary", 1, 0, "ImageViewer"); + //![register] + + QQuickView view; + view.setSource(QUrl::fromLocalFile("standalone.qml")); + view.show(); + + return app.exec(); +} + diff --git a/doc/src/snippets/declarative/qtbinding/newelements/standalone.qml b/doc/src/snippets/qml/qtbinding/newelements/standalone.qml similarity index 100% rename from doc/src/snippets/declarative/qtbinding/newelements/standalone.qml rename to doc/src/snippets/qml/qtbinding/newelements/standalone.qml diff --git a/doc/src/snippets/declarative/qtbinding/properties-cpp/MyItem.qml b/doc/src/snippets/qml/qtbinding/properties-cpp/MyItem.qml similarity index 100% rename from doc/src/snippets/declarative/qtbinding/properties-cpp/MyItem.qml rename to doc/src/snippets/qml/qtbinding/properties-cpp/MyItem.qml diff --git a/doc/src/snippets/declarative/qtbinding/properties-cpp/applicationdata.h b/doc/src/snippets/qml/qtbinding/properties-cpp/applicationdata.h similarity index 100% rename from doc/src/snippets/declarative/qtbinding/properties-cpp/applicationdata.h rename to doc/src/snippets/qml/qtbinding/properties-cpp/applicationdata.h diff --git a/doc/src/snippets/declarative/qtbinding/properties-qml/MyItem.qml b/doc/src/snippets/qml/qtbinding/properties-qml/MyItem.qml similarity index 100% rename from doc/src/snippets/declarative/qtbinding/properties-qml/MyItem.qml rename to doc/src/snippets/qml/qtbinding/properties-qml/MyItem.qml diff --git a/doc/src/snippets/qml/qtbinding/properties-qml/main.cpp b/doc/src/snippets/qml/qtbinding/properties-qml/main.cpp new file mode 100644 index 0000000000..15cb517c7b --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/properties-qml/main.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + +//![0] +QQmlEngine engine; +QQmlComponent component(&engine, "MyItem.qml"); +QObject *object = component.create(); + +qDebug() << "Property value:" << QQmlProperty::read(object, "someNumber").toInt(); +QQmlProperty::write(object, "someNumber", 5000); + +qDebug() << "Property value:" << object->property("someNumber").toInt(); +object->setProperty("someNumber", 100); +//![0] + + return app.exec(); +} + diff --git a/doc/src/snippets/declarative/qtbinding/resources/example.qrc b/doc/src/snippets/qml/qtbinding/resources/example.qrc similarity index 100% rename from doc/src/snippets/declarative/qtbinding/resources/example.qrc rename to doc/src/snippets/qml/qtbinding/resources/example.qrc diff --git a/doc/src/snippets/qml/qtbinding/resources/main.cpp b/doc/src/snippets/qml/qtbinding/resources/main.cpp new file mode 100644 index 0000000000..2902064fc9 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/resources/main.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +//![0] +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QQuickView view; + view.setSource(QUrl("qrc:/main.qml")); + view.show(); + + return app.exec(); +} +//![0] + diff --git a/doc/src/snippets/declarative/qtbinding/resources/main.qml b/doc/src/snippets/qml/qtbinding/resources/main.qml similarity index 100% rename from doc/src/snippets/declarative/qtbinding/resources/main.qml rename to doc/src/snippets/qml/qtbinding/resources/main.qml diff --git a/doc/src/snippets/qml/qtbinding/resources/resources.pro b/doc/src/snippets/qml/qtbinding/resources/resources.pro new file mode 100644 index 0000000000..5aee288a6e --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/resources/resources.pro @@ -0,0 +1,4 @@ +QT += qml + +SOURCES += main.cpp +RESOURCES += example.qrc diff --git a/doc/src/snippets/declarative/qtbinding/signals-cpp/MyItem.qml b/doc/src/snippets/qml/qtbinding/signals-cpp/MyItem.qml similarity index 100% rename from doc/src/snippets/declarative/qtbinding/signals-cpp/MyItem.qml rename to doc/src/snippets/qml/qtbinding/signals-cpp/MyItem.qml diff --git a/doc/src/snippets/qml/qtbinding/signals-cpp/imageviewer.h b/doc/src/snippets/qml/qtbinding/signals-cpp/imageviewer.h new file mode 100644 index 0000000000..3423295234 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/signals-cpp/imageviewer.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +//![start] +class ImageViewer : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(QUrl image READ image WRITE setImage NOTIFY imageChanged) +public: +//![start] + ImageViewer(QQuickItem *item = 0); + + void setImage(const QUrl &url) {} + QUrl image() const { return QUrl(); } + +public slots: + void emitSignals(); + +//![end] +signals: + void imageChanged(); + void loadingError(const QString &errorMsg); +}; +//![end] + diff --git a/doc/src/snippets/qml/qtbinding/signals-cpp/main.cpp b/doc/src/snippets/qml/qtbinding/signals-cpp/main.cpp new file mode 100644 index 0000000000..402e811913 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/signals-cpp/main.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +#include "imageviewer.h" + + +ImageViewer::ImageViewer(QQuickItem *item) + : QQuickItem(item) +{ + QTimer::singleShot(0, this, SLOT(emitSignals())); +} + +void ImageViewer::emitSignals() +{ + emit imageChanged(); + emit loadingError("some error message"); +} + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + qmlRegisterType("MyLibrary", 1, 0, "ImageViewer"); + + QQuickView standalone; + standalone.setSource(QUrl::fromLocalFile("standalone.qml")); + standalone.show(); + +//![connections] +ImageViewer viewer; + +QQuickView view; +view.rootContext()->setContextProperty("imageViewer", &viewer); + +view.setSource(QUrl::fromLocalFile("MyItem.qml")); +view.show(); +//![connections] + + return app.exec(); +} + + diff --git a/doc/src/snippets/declarative/qtbinding/signals-cpp/standalone.qml b/doc/src/snippets/qml/qtbinding/signals-cpp/standalone.qml similarity index 100% rename from doc/src/snippets/declarative/qtbinding/signals-cpp/standalone.qml rename to doc/src/snippets/qml/qtbinding/signals-cpp/standalone.qml diff --git a/doc/src/snippets/declarative/qtbinding/signals-qml/MyItem.qml b/doc/src/snippets/qml/qtbinding/signals-qml/MyItem.qml similarity index 100% rename from doc/src/snippets/declarative/qtbinding/signals-qml/MyItem.qml rename to doc/src/snippets/qml/qtbinding/signals-qml/MyItem.qml diff --git a/doc/src/snippets/qml/qtbinding/signals-qml/main.cpp b/doc/src/snippets/qml/qtbinding/signals-qml/main.cpp new file mode 100644 index 0000000000..8528d9ce5e --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/signals-qml/main.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +//![0] +int main(int argc, char *argv[]) { + QApplication app(argc, argv); + + QQuickView view(QUrl::fromLocalFile("MyItem.qml")); + QObject *item = view.rootObject(); + + MyClass myClass; + QObject::connect(item, SIGNAL(qmlSignal(QString)), + &myClass, SLOT(cppSlot(QString))); + + view.show(); + return app.exec(); +} +//![0] + +#include "moc_main.cpp" diff --git a/doc/src/snippets/declarative/qtbinding/signals-qml/myclass.h b/doc/src/snippets/qml/qtbinding/signals-qml/myclass.h similarity index 100% rename from doc/src/snippets/declarative/qtbinding/signals-qml/myclass.h rename to doc/src/snippets/qml/qtbinding/signals-qml/myclass.h diff --git a/doc/src/snippets/declarative/qtbinding/variantlistmap/MyItem.qml b/doc/src/snippets/qml/qtbinding/variantlistmap/MyItem.qml similarity index 100% rename from doc/src/snippets/declarative/qtbinding/variantlistmap/MyItem.qml rename to doc/src/snippets/qml/qtbinding/variantlistmap/MyItem.qml diff --git a/doc/src/snippets/qml/qtbinding/variantlistmap/main.cpp b/doc/src/snippets/qml/qtbinding/variantlistmap/main.cpp new file mode 100644 index 0000000000..a10b9a8c12 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/variantlistmap/main.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +int main(int argc, char *argv[]) { + QApplication app(argc, argv); + +//![0] +// C++ +QQuickView view(QUrl::fromLocalFile("MyItem.qml")); + +QVariantList list; +list << 10 << Qt::green << "bottles"; + +QVariantMap map; +map.insert("language", "QML"); +map.insert("released", QDate(2010, 9, 21)); + +QMetaObject::invokeMethod(view.rootObject(), "readValues", + Q_ARG(QVariant, QVariant::fromValue(list)), + Q_ARG(QVariant, QVariant::fromValue(map))); +//![0] + + view.setSource(QUrl::fromLocalFile("MyItem.qml")); + view.show(); + + return app.exec(); +} + diff --git a/doc/src/snippets/declarative/qtobject.qml b/doc/src/snippets/qml/qtobject.qml similarity index 100% rename from doc/src/snippets/declarative/qtobject.qml rename to doc/src/snippets/qml/qtobject.qml diff --git a/doc/src/snippets/declarative/rectangle/rect-border-width.qml b/doc/src/snippets/qml/rectangle/rect-border-width.qml similarity index 100% rename from doc/src/snippets/declarative/rectangle/rect-border-width.qml rename to doc/src/snippets/qml/rectangle/rect-border-width.qml diff --git a/doc/src/snippets/declarative/rectangle/rectangle-colors.qml b/doc/src/snippets/qml/rectangle/rectangle-colors.qml similarity index 100% rename from doc/src/snippets/declarative/rectangle/rectangle-colors.qml rename to doc/src/snippets/qml/rectangle/rectangle-colors.qml diff --git a/doc/src/snippets/declarative/rectangle/rectangle-gradient.qml b/doc/src/snippets/qml/rectangle/rectangle-gradient.qml similarity index 100% rename from doc/src/snippets/declarative/rectangle/rectangle-gradient.qml rename to doc/src/snippets/qml/rectangle/rectangle-gradient.qml diff --git a/doc/src/snippets/declarative/rectangle/rectangle.qml b/doc/src/snippets/qml/rectangle/rectangle.qml similarity index 100% rename from doc/src/snippets/declarative/rectangle/rectangle.qml rename to doc/src/snippets/qml/rectangle/rectangle.qml diff --git a/doc/src/snippets/declarative/repeaters/repeater-grid-index.qml b/doc/src/snippets/qml/repeaters/repeater-grid-index.qml similarity index 100% rename from doc/src/snippets/declarative/repeaters/repeater-grid-index.qml rename to doc/src/snippets/qml/repeaters/repeater-grid-index.qml diff --git a/doc/src/snippets/declarative/repeaters/repeater.qml b/doc/src/snippets/qml/repeaters/repeater.qml similarity index 100% rename from doc/src/snippets/declarative/repeaters/repeater.qml rename to doc/src/snippets/qml/repeaters/repeater.qml diff --git a/doc/src/snippets/declarative/reusablecomponents/Button.qml b/doc/src/snippets/qml/reusablecomponents/Button.qml similarity index 100% rename from doc/src/snippets/declarative/reusablecomponents/Button.qml rename to doc/src/snippets/qml/reusablecomponents/Button.qml diff --git a/doc/src/snippets/declarative/reusablecomponents/application.qml b/doc/src/snippets/qml/reusablecomponents/application.qml similarity index 100% rename from doc/src/snippets/declarative/reusablecomponents/application.qml rename to doc/src/snippets/qml/reusablecomponents/application.qml diff --git a/doc/src/snippets/declarative/reusablecomponents/component.qml b/doc/src/snippets/qml/reusablecomponents/component.qml similarity index 100% rename from doc/src/snippets/declarative/reusablecomponents/component.qml rename to doc/src/snippets/qml/reusablecomponents/component.qml diff --git a/doc/src/snippets/declarative/reusablecomponents/focusbutton.qml b/doc/src/snippets/qml/reusablecomponents/focusbutton.qml similarity index 100% rename from doc/src/snippets/declarative/reusablecomponents/focusbutton.qml rename to doc/src/snippets/qml/reusablecomponents/focusbutton.qml diff --git a/doc/src/snippets/declarative/reusablecomponents/qmldir b/doc/src/snippets/qml/reusablecomponents/qmldir similarity index 100% rename from doc/src/snippets/declarative/reusablecomponents/qmldir rename to doc/src/snippets/qml/reusablecomponents/qmldir diff --git a/doc/src/snippets/declarative/righttoleft.qml b/doc/src/snippets/qml/righttoleft.qml similarity index 100% rename from doc/src/snippets/declarative/righttoleft.qml rename to doc/src/snippets/qml/righttoleft.qml diff --git a/doc/src/snippets/declarative/righttoleft/Child.qml b/doc/src/snippets/qml/righttoleft/Child.qml similarity index 100% rename from doc/src/snippets/declarative/righttoleft/Child.qml rename to doc/src/snippets/qml/righttoleft/Child.qml diff --git a/doc/src/snippets/declarative/rotation.qml b/doc/src/snippets/qml/rotation.qml similarity index 100% rename from doc/src/snippets/declarative/rotation.qml rename to doc/src/snippets/qml/rotation.qml diff --git a/doc/src/snippets/declarative/rotationanimation.qml b/doc/src/snippets/qml/rotationanimation.qml similarity index 100% rename from doc/src/snippets/declarative/rotationanimation.qml rename to doc/src/snippets/qml/rotationanimation.qml diff --git a/doc/src/snippets/declarative/row.qml b/doc/src/snippets/qml/row.qml similarity index 100% rename from doc/src/snippets/declarative/row.qml rename to doc/src/snippets/qml/row.qml diff --git a/doc/src/snippets/declarative/row/row.qml b/doc/src/snippets/qml/row/row.qml similarity index 100% rename from doc/src/snippets/declarative/row/row.qml rename to doc/src/snippets/qml/row/row.qml diff --git a/doc/src/snippets/declarative/script.js b/doc/src/snippets/qml/script.js similarity index 100% rename from doc/src/snippets/declarative/script.js rename to doc/src/snippets/qml/script.js diff --git a/doc/src/snippets/declarative/sequentialanimation.qml b/doc/src/snippets/qml/sequentialanimation.qml similarity index 100% rename from doc/src/snippets/declarative/sequentialanimation.qml rename to doc/src/snippets/qml/sequentialanimation.qml diff --git a/doc/src/snippets/declarative/smoothedanimation.qml b/doc/src/snippets/qml/smoothedanimation.qml similarity index 100% rename from doc/src/snippets/declarative/smoothedanimation.qml rename to doc/src/snippets/qml/smoothedanimation.qml diff --git a/doc/src/snippets/declarative/springanimation.qml b/doc/src/snippets/qml/springanimation.qml similarity index 100% rename from doc/src/snippets/declarative/springanimation.qml rename to doc/src/snippets/qml/springanimation.qml diff --git a/doc/src/snippets/declarative/state-when.qml b/doc/src/snippets/qml/state-when.qml similarity index 100% rename from doc/src/snippets/declarative/state-when.qml rename to doc/src/snippets/qml/state-when.qml diff --git a/doc/src/snippets/declarative/state.qml b/doc/src/snippets/qml/state.qml similarity index 100% rename from doc/src/snippets/declarative/state.qml rename to doc/src/snippets/qml/state.qml diff --git a/doc/src/snippets/declarative/states.qml b/doc/src/snippets/qml/states.qml similarity index 100% rename from doc/src/snippets/declarative/states.qml rename to doc/src/snippets/qml/states.qml diff --git a/doc/src/snippets/declarative/states/statechangescript.qml b/doc/src/snippets/qml/states/statechangescript.qml similarity index 100% rename from doc/src/snippets/declarative/states/statechangescript.qml rename to doc/src/snippets/qml/states/statechangescript.qml diff --git a/doc/src/snippets/declarative/systempalette.qml b/doc/src/snippets/qml/systempalette.qml similarity index 100% rename from doc/src/snippets/declarative/systempalette.qml rename to doc/src/snippets/qml/systempalette.qml diff --git a/doc/src/snippets/declarative/text/onLinkActivated.qml b/doc/src/snippets/qml/text/onLinkActivated.qml similarity index 97% rename from doc/src/snippets/declarative/text/onLinkActivated.qml rename to doc/src/snippets/qml/text/onLinkActivated.qml index 71545ad3e2..03641d989e 100644 --- a/doc/src/snippets/declarative/text/onLinkActivated.qml +++ b/doc/src/snippets/qml/text/onLinkActivated.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/doc/src/snippets/declarative/texthandling.qml b/doc/src/snippets/qml/texthandling.qml similarity index 100% rename from doc/src/snippets/declarative/texthandling.qml rename to doc/src/snippets/qml/texthandling.qml diff --git a/doc/src/snippets/declarative/transition-from-to-modified.qml b/doc/src/snippets/qml/transition-from-to-modified.qml similarity index 100% rename from doc/src/snippets/declarative/transition-from-to-modified.qml rename to doc/src/snippets/qml/transition-from-to-modified.qml diff --git a/doc/src/snippets/declarative/transition-from-to.qml b/doc/src/snippets/qml/transition-from-to.qml similarity index 100% rename from doc/src/snippets/declarative/transition-from-to.qml rename to doc/src/snippets/qml/transition-from-to.qml diff --git a/doc/src/snippets/declarative/transition-reversible.qml b/doc/src/snippets/qml/transition-reversible.qml similarity index 100% rename from doc/src/snippets/declarative/transition-reversible.qml rename to doc/src/snippets/qml/transition-reversible.qml diff --git a/doc/src/snippets/declarative/transition.qml b/doc/src/snippets/qml/transition.qml similarity index 100% rename from doc/src/snippets/declarative/transition.qml rename to doc/src/snippets/qml/transition.qml diff --git a/doc/src/snippets/declarative/transitions-list.qml b/doc/src/snippets/qml/transitions-list.qml similarity index 100% rename from doc/src/snippets/declarative/transitions-list.qml rename to doc/src/snippets/qml/transitions-list.qml diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-basic.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-basic.qml similarity index 100% rename from doc/src/snippets/declarative/viewtransitions/viewtransitions-basic.qml rename to doc/src/snippets/qml/viewtransitions/viewtransitions-basic.qml diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-delayedbyindex.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-delayedbyindex.qml similarity index 100% rename from doc/src/snippets/declarative/viewtransitions/viewtransitions-delayedbyindex.qml rename to doc/src/snippets/qml/viewtransitions/viewtransitions-delayedbyindex.qml diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-intermediatemove.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-intermediatemove.qml similarity index 100% rename from doc/src/snippets/declarative/viewtransitions/viewtransitions-intermediatemove.qml rename to doc/src/snippets/qml/viewtransitions/viewtransitions-intermediatemove.qml diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-interruptedgood.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-interruptedgood.qml similarity index 100% rename from doc/src/snippets/declarative/viewtransitions/viewtransitions-interruptedgood.qml rename to doc/src/snippets/qml/viewtransitions/viewtransitions-interruptedgood.qml diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-pathanim.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-pathanim.qml similarity index 100% rename from doc/src/snippets/declarative/viewtransitions/viewtransitions-pathanim.qml rename to doc/src/snippets/qml/viewtransitions/viewtransitions-pathanim.qml diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactionbad.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactionbad.qml similarity index 100% rename from doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactionbad.qml rename to doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactionbad.qml diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactiongood.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactiongood.qml similarity index 100% rename from doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactiongood.qml rename to doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactiongood.qml diff --git a/doc/src/snippets/declarative/visualdatagroup.qml b/doc/src/snippets/qml/visualdatagroup.qml similarity index 100% rename from doc/src/snippets/declarative/visualdatagroup.qml rename to doc/src/snippets/qml/visualdatagroup.qml diff --git a/doc/src/snippets/declarative/visualdatamodel.qml b/doc/src/snippets/qml/visualdatamodel.qml similarity index 100% rename from doc/src/snippets/declarative/visualdatamodel.qml rename to doc/src/snippets/qml/visualdatamodel.qml diff --git a/doc/src/snippets/qml/visualdatamodel_rootindex/main.cpp b/doc/src/snippets/qml/visualdatamodel_rootindex/main.cpp new file mode 100644 index 0000000000..4468d06db4 --- /dev/null +++ b/doc/src/snippets/qml/visualdatamodel_rootindex/main.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +#include +#include + +//![0] +int main(int argc, char ** argv) +{ + QApplication app(argc, argv); + + QQuickView view; + + QDirModel model; + view.rootContext()->setContextProperty("dirModel", &model); + + view.setSource(QUrl::fromLocalFile("view.qml")); + view.show(); + + return app.exec(); +} +//![0] + diff --git a/doc/src/snippets/declarative/visualdatamodel_rootindex/view.qml b/doc/src/snippets/qml/visualdatamodel_rootindex/view.qml similarity index 100% rename from doc/src/snippets/declarative/visualdatamodel_rootindex/view.qml rename to doc/src/snippets/qml/visualdatamodel_rootindex/view.qml diff --git a/doc/src/snippets/declarative/workerscript.qml b/doc/src/snippets/qml/workerscript.qml similarity index 100% rename from doc/src/snippets/declarative/workerscript.qml rename to doc/src/snippets/qml/workerscript.qml diff --git a/doc/src/snippets/declarative/xmlrole.qml b/doc/src/snippets/qml/xmlrole.qml similarity index 100% rename from doc/src/snippets/declarative/xmlrole.qml rename to doc/src/snippets/qml/xmlrole.qml diff --git a/doc/src/snippets/declarative/xmlrole.xml b/doc/src/snippets/qml/xmlrole.xml similarity index 100% rename from doc/src/snippets/declarative/xmlrole.xml rename to doc/src/snippets/qml/xmlrole.xml diff --git a/doc/src/snippets/qtjavascript/evaluation/main.cpp b/doc/src/snippets/qtjavascript/evaluation/main.cpp index 8d1cbf0484..3d3e3bfda2 100644 --- a/doc/src/snippets/qtjavascript/evaluation/main.cpp +++ b/doc/src/snippets/qtjavascript/evaluation/main.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ -#include +#include int main(int argc, char *argv[]) { diff --git a/doc/src/snippets/qtjavascript/registeringobjects/main.cpp b/doc/src/snippets/qtjavascript/registeringobjects/main.cpp index 27d696da63..f34c1061fe 100644 --- a/doc/src/snippets/qtjavascript/registeringobjects/main.cpp +++ b/doc/src/snippets/qtjavascript/registeringobjects/main.cpp @@ -39,7 +39,7 @@ ****************************************************************************/ #include -#include +#include #include "myobject.h" int main(int argc, char *argv[]) diff --git a/doc/src/snippets/qtjavascript/registeringvalues/main.cpp b/doc/src/snippets/qtjavascript/registeringvalues/main.cpp index be2d293cf7..f168f4f554 100644 --- a/doc/src/snippets/qtjavascript/registeringvalues/main.cpp +++ b/doc/src/snippets/qtjavascript/registeringvalues/main.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ -#include +#include int main(int argc, char *argv[]) { diff --git a/doc/src/whatsnew.qdoc b/doc/src/whatsnew.qdoc index 1c92cdb16b..c791e72c25 100644 --- a/doc/src/whatsnew.qdoc +++ b/doc/src/whatsnew.qdoc @@ -67,8 +67,8 @@ Properties of the "var" type may hold JavaScript references. See \l{QML Basic T QML properties of type \c var and \c variant can now hold pixmaps. See \l{Scarce Resources in JavaScript} for more information -QDeclarativeExpression can now be directly (and more efficiently) constructed from a -QDeclarativeScriptString. +QQmlExpression can now be directly (and more efficiently) constructed from a +QQmlScriptString. Support for certain sequence types (QList, QList, QList, QList, QList and QStringList) has been improved. QObjects can define Q_PROPERTYs of these types which can be accessed transparently from JavaScript. See the section on diff --git a/examples/HACKING b/examples/HACKING index 7eea4975ac..9539d2d129 100644 --- a/examples/HACKING +++ b/examples/HACKING @@ -1,4 +1,4 @@ -Some guidelines for QtDeclarative examples +Some guidelines for QtQml examples Snippets --- diff --git a/examples/demos/calculator/CalculatorCore/Button.qml b/examples/demos/calculator/CalculatorCore/Button.qml index 872fc81174..e7b3637b4c 100644 --- a/examples/demos/calculator/CalculatorCore/Button.qml +++ b/examples/demos/calculator/CalculatorCore/Button.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/calculator/CalculatorCore/Display.qml b/examples/demos/calculator/CalculatorCore/Display.qml index 3333484971..3dceeab169 100644 --- a/examples/demos/calculator/CalculatorCore/Display.qml +++ b/examples/demos/calculator/CalculatorCore/Display.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/calculator/calculator-desktop.qml b/examples/demos/calculator/calculator-desktop.qml index 7e72f50beb..be65c77170 100644 --- a/examples/demos/calculator/calculator-desktop.qml +++ b/examples/demos/calculator/calculator-desktop.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/calculator/calculator-mobile.qml b/examples/demos/calculator/calculator-mobile.qml index b4fc372b39..7ee622f698 100644 --- a/examples/demos/calculator/calculator-mobile.qml +++ b/examples/demos/calculator/calculator-mobile.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/calculator/calculator.pro b/examples/demos/calculator/calculator.pro index 3bf3b8ca2f..297d5cfdbb 100644 --- a/examples/demos/calculator/calculator.pro +++ b/examples/demos/calculator/calculator.pro @@ -1,6 +1,6 @@ TEMPLATE = app -QT += quick declarative +QT += quick qml SOURCES += main.cpp target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/demos/calculator diff --git a/examples/demos/calculator/main.cpp b/examples/demos/calculator/main.cpp index c7f9b29952..fafe14fe46 100644 --- a/examples/demos/calculator/main.cpp +++ b/examples/demos/calculator/main.cpp @@ -41,7 +41,7 @@ #include #include #include -#include +#include void usage() { diff --git a/examples/demos/flickr/content/Button.qml b/examples/demos/flickr/content/Button.qml index d6a8d3e001..57f846aec3 100644 --- a/examples/demos/flickr/content/Button.qml +++ b/examples/demos/flickr/content/Button.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/flickr/content/GridDelegate.qml b/examples/demos/flickr/content/GridDelegate.qml index 794d768c74..f8838bd609 100644 --- a/examples/demos/flickr/content/GridDelegate.qml +++ b/examples/demos/flickr/content/GridDelegate.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/flickr/content/ImageDetails.qml b/examples/demos/flickr/content/ImageDetails.qml index 83f2537d65..42b5e845ea 100644 --- a/examples/demos/flickr/content/ImageDetails.qml +++ b/examples/demos/flickr/content/ImageDetails.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/flickr/content/ListDelegate.qml b/examples/demos/flickr/content/ListDelegate.qml index 9c239151f1..00f837f862 100644 --- a/examples/demos/flickr/content/ListDelegate.qml +++ b/examples/demos/flickr/content/ListDelegate.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/flickr/content/Progress.qml b/examples/demos/flickr/content/Progress.qml index 81f1e79ed6..ed2629b48a 100644 --- a/examples/demos/flickr/content/Progress.qml +++ b/examples/demos/flickr/content/Progress.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/flickr/content/RssModel.qml b/examples/demos/flickr/content/RssModel.qml index f28a23d502..51cea498e6 100644 --- a/examples/demos/flickr/content/RssModel.qml +++ b/examples/demos/flickr/content/RssModel.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/flickr/content/ScrollBar.qml b/examples/demos/flickr/content/ScrollBar.qml index 388e43dc2d..7c62ad088f 100644 --- a/examples/demos/flickr/content/ScrollBar.qml +++ b/examples/demos/flickr/content/ScrollBar.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/flickr/content/Slider.qml b/examples/demos/flickr/content/Slider.qml index 0f9e8b20f2..c4e743641f 100644 --- a/examples/demos/flickr/content/Slider.qml +++ b/examples/demos/flickr/content/Slider.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/flickr/content/TitleBar.qml b/examples/demos/flickr/content/TitleBar.qml index 3dab005a11..223939f81a 100644 --- a/examples/demos/flickr/content/TitleBar.qml +++ b/examples/demos/flickr/content/TitleBar.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/flickr/content/ToolBar.qml b/examples/demos/flickr/content/ToolBar.qml index e82be63e7e..356993b41a 100644 --- a/examples/demos/flickr/content/ToolBar.qml +++ b/examples/demos/flickr/content/ToolBar.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/flickr/content/UnifiedDelegate.qml b/examples/demos/flickr/content/UnifiedDelegate.qml index 00a777b0a1..0b068c0abe 100644 --- a/examples/demos/flickr/content/UnifiedDelegate.qml +++ b/examples/demos/flickr/content/UnifiedDelegate.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/flickr/flickr-90.qml b/examples/demos/flickr/flickr-90.qml index ae06957649..b95b1c9872 100644 --- a/examples/demos/flickr/flickr-90.qml +++ b/examples/demos/flickr/flickr-90.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/flickr/flickr.qml b/examples/demos/flickr/flickr.qml index 74c41f185b..98ca5197ab 100644 --- a/examples/demos/flickr/flickr.qml +++ b/examples/demos/flickr/flickr.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/minehunt/MinehuntCore/Explosion.qml b/examples/demos/minehunt/MinehuntCore/Explosion.qml index 0983b68db4..a1b4292bcf 100644 --- a/examples/demos/minehunt/MinehuntCore/Explosion.qml +++ b/examples/demos/minehunt/MinehuntCore/Explosion.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/minehunt/MinehuntCore/Tile.qml b/examples/demos/minehunt/MinehuntCore/Tile.qml index 14c1f51f9e..1180b6f584 100644 --- a/examples/demos/minehunt/MinehuntCore/Tile.qml +++ b/examples/demos/minehunt/MinehuntCore/Tile.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/minehunt/main.cpp b/examples/demos/minehunt/main.cpp index 47c0436969..0aa11a1d7a 100644 --- a/examples/demos/minehunt/main.cpp +++ b/examples/demos/minehunt/main.cpp @@ -41,8 +41,8 @@ #include #include -#include -#include +#include +#include #include "minehunt.h" diff --git a/examples/demos/minehunt/minehunt.cpp b/examples/demos/minehunt/minehunt.cpp index facbec375a..cde30278b3 100644 --- a/examples/demos/minehunt/minehunt.cpp +++ b/examples/demos/minehunt/minehunt.cpp @@ -45,25 +45,25 @@ #include "minehunt.h" -void tilesPropAppend(QDeclarativeListProperty* prop, TileData* value) +void tilesPropAppend(QQmlListProperty* prop, TileData* value) { Q_UNUSED(prop); Q_UNUSED(value); return; //Append not supported } -int tilesPropCount(QDeclarativeListProperty* prop) +int tilesPropCount(QQmlListProperty* prop) { return static_cast*>(prop->data)->count(); } -TileData* tilesPropAt(QDeclarativeListProperty* prop, int index) +TileData* tilesPropAt(QQmlListProperty* prop, int index) { return static_cast*>(prop->data)->at(index); } -QDeclarativeListProperty MinehuntGame::tiles(){ - return QDeclarativeListProperty(this, &_tiles, &tilesPropAppend, +QQmlListProperty MinehuntGame::tiles(){ + return QQmlListProperty(this, &_tiles, &tilesPropAppend, &tilesPropCount, &tilesPropAt, 0); } diff --git a/examples/demos/minehunt/minehunt.h b/examples/demos/minehunt/minehunt.h index a0ae23fa8a..34bab71218 100644 --- a/examples/demos/minehunt/minehunt.h +++ b/examples/demos/minehunt/minehunt.h @@ -40,7 +40,7 @@ ****************************************************************************/ -#include +#include class TileData : public QObject { @@ -85,8 +85,8 @@ class MinehuntGame : public QObject public: MinehuntGame(); - Q_PROPERTY(QDeclarativeListProperty tiles READ tiles CONSTANT) - QDeclarativeListProperty tiles(); + Q_PROPERTY(QQmlListProperty tiles READ tiles CONSTANT) + QQmlListProperty tiles(); Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged) bool isPlaying() {return playing;} diff --git a/examples/demos/minehunt/minehunt.pro b/examples/demos/minehunt/minehunt.pro index 81b6b80486..78e874d805 100644 --- a/examples/demos/minehunt/minehunt.pro +++ b/examples/demos/minehunt/minehunt.pro @@ -1,4 +1,4 @@ -QT += declarative quick +QT += qml quick HEADERS += minehunt.h SOURCES += main.cpp minehunt.cpp diff --git a/examples/demos/minehunt/minehunt.qml b/examples/demos/minehunt/minehunt.qml index 7c4948a3bb..42dc408fff 100644 --- a/examples/demos/minehunt/minehunt.qml +++ b/examples/demos/minehunt/minehunt.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml b/examples/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml index f183c4b2a0..164f47faa9 100644 --- a/examples/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml +++ b/examples/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml b/examples/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml index 2b1a75f369..867c268399 100644 --- a/examples/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml +++ b/examples/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/photoviewer/PhotoViewerCore/Button.qml b/examples/demos/photoviewer/PhotoViewerCore/Button.qml index fcce969fbd..8f4177c097 100644 --- a/examples/demos/photoviewer/PhotoViewerCore/Button.qml +++ b/examples/demos/photoviewer/PhotoViewerCore/Button.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/photoviewer/PhotoViewerCore/EditableButton.qml b/examples/demos/photoviewer/PhotoViewerCore/EditableButton.qml index 5d845938c7..435ad2644f 100644 --- a/examples/demos/photoviewer/PhotoViewerCore/EditableButton.qml +++ b/examples/demos/photoviewer/PhotoViewerCore/EditableButton.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml b/examples/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml index b972c938eb..5d4e5aee5d 100644 --- a/examples/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml +++ b/examples/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/photoviewer/PhotoViewerCore/ProgressBar.qml b/examples/demos/photoviewer/PhotoViewerCore/ProgressBar.qml index 43c936e342..58beef57f3 100644 --- a/examples/demos/photoviewer/PhotoViewerCore/ProgressBar.qml +++ b/examples/demos/photoviewer/PhotoViewerCore/ProgressBar.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/photoviewer/PhotoViewerCore/RssModel.qml b/examples/demos/photoviewer/PhotoViewerCore/RssModel.qml index ab818924ac..1598977bb1 100644 --- a/examples/demos/photoviewer/PhotoViewerCore/RssModel.qml +++ b/examples/demos/photoviewer/PhotoViewerCore/RssModel.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/photoviewer/PhotoViewerCore/Tag.qml b/examples/demos/photoviewer/PhotoViewerCore/Tag.qml index 2b546a3ac6..ed4a248a7b 100644 --- a/examples/demos/photoviewer/PhotoViewerCore/Tag.qml +++ b/examples/demos/photoviewer/PhotoViewerCore/Tag.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/photoviewer/photoviewer.qml b/examples/demos/photoviewer/photoviewer.qml index 918438832b..208720b9e6 100644 --- a/examples/demos/photoviewer/photoviewer.qml +++ b/examples/demos/photoviewer/photoviewer.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/plasmapatrol/content/BlasterHardpoint.qml b/examples/demos/plasmapatrol/content/BlasterHardpoint.qml index 4ac30d0202..10c50d43c8 100644 --- a/examples/demos/plasmapatrol/content/BlasterHardpoint.qml +++ b/examples/demos/plasmapatrol/content/BlasterHardpoint.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/plasmapatrol/content/Button.qml b/examples/demos/plasmapatrol/content/Button.qml index 405b99304f..992be295fc 100644 --- a/examples/demos/plasmapatrol/content/Button.qml +++ b/examples/demos/plasmapatrol/content/Button.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/plasmapatrol/content/CannonHardpoint.qml b/examples/demos/plasmapatrol/content/CannonHardpoint.qml index c4aa412760..48eb9d171a 100644 --- a/examples/demos/plasmapatrol/content/CannonHardpoint.qml +++ b/examples/demos/plasmapatrol/content/CannonHardpoint.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/plasmapatrol/content/ChoiceBox.qml b/examples/demos/plasmapatrol/content/ChoiceBox.qml index a678bc9dd4..6e21101f2e 100644 --- a/examples/demos/plasmapatrol/content/ChoiceBox.qml +++ b/examples/demos/plasmapatrol/content/ChoiceBox.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/plasmapatrol/content/Cruiser.qml b/examples/demos/plasmapatrol/content/Cruiser.qml index c689879dce..c469eb46d2 100644 --- a/examples/demos/plasmapatrol/content/Cruiser.qml +++ b/examples/demos/plasmapatrol/content/Cruiser.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/plasmapatrol/content/Frigate.qml b/examples/demos/plasmapatrol/content/Frigate.qml index de099bed72..92c63b87d1 100644 --- a/examples/demos/plasmapatrol/content/Frigate.qml +++ b/examples/demos/plasmapatrol/content/Frigate.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/plasmapatrol/content/Hardpoint.qml b/examples/demos/plasmapatrol/content/Hardpoint.qml index 5c7fb5521b..9e6057057d 100644 --- a/examples/demos/plasmapatrol/content/Hardpoint.qml +++ b/examples/demos/plasmapatrol/content/Hardpoint.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/plasmapatrol/content/HelpScreens.qml b/examples/demos/plasmapatrol/content/HelpScreens.qml index 9297f86f31..db70c6ee90 100644 --- a/examples/demos/plasmapatrol/content/HelpScreens.qml +++ b/examples/demos/plasmapatrol/content/HelpScreens.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/plasmapatrol/content/LaserHardpoint.qml b/examples/demos/plasmapatrol/content/LaserHardpoint.qml index 87ac3e9e62..a7baed604b 100644 --- a/examples/demos/plasmapatrol/content/LaserHardpoint.qml +++ b/examples/demos/plasmapatrol/content/LaserHardpoint.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/plasmapatrol/content/PlasmaPatrolParticles.qml b/examples/demos/plasmapatrol/content/PlasmaPatrolParticles.qml index 1d856b5805..e1924c3467 100644 --- a/examples/demos/plasmapatrol/content/PlasmaPatrolParticles.qml +++ b/examples/demos/plasmapatrol/content/PlasmaPatrolParticles.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/plasmapatrol/content/SequentialLoader.qml b/examples/demos/plasmapatrol/content/SequentialLoader.qml index eaef87fe57..3707759ce3 100644 --- a/examples/demos/plasmapatrol/content/SequentialLoader.qml +++ b/examples/demos/plasmapatrol/content/SequentialLoader.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/plasmapatrol/content/Ship.qml b/examples/demos/plasmapatrol/content/Ship.qml index a928cd2a2e..bd023b1dc2 100644 --- a/examples/demos/plasmapatrol/content/Ship.qml +++ b/examples/demos/plasmapatrol/content/Ship.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/plasmapatrol/content/Sloop.qml b/examples/demos/plasmapatrol/content/Sloop.qml index c6b1183162..3bc58a28b0 100644 --- a/examples/demos/plasmapatrol/content/Sloop.qml +++ b/examples/demos/plasmapatrol/content/Sloop.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/plasmapatrol/plasmapatrol.qml b/examples/demos/plasmapatrol/plasmapatrol.qml index 45f81c7222..b14ac6385b 100644 --- a/examples/demos/plasmapatrol/plasmapatrol.qml +++ b/examples/demos/plasmapatrol/plasmapatrol.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/rssnews/content/BusyIndicator.qml b/examples/demos/rssnews/content/BusyIndicator.qml index b6264ead92..f1abd1119c 100644 --- a/examples/demos/rssnews/content/BusyIndicator.qml +++ b/examples/demos/rssnews/content/BusyIndicator.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/rssnews/content/CategoryDelegate.qml b/examples/demos/rssnews/content/CategoryDelegate.qml index 1a56184489..fe64238adb 100644 --- a/examples/demos/rssnews/content/CategoryDelegate.qml +++ b/examples/demos/rssnews/content/CategoryDelegate.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/rssnews/content/NewsDelegate.qml b/examples/demos/rssnews/content/NewsDelegate.qml index 84019a9179..59ab269d3b 100644 --- a/examples/demos/rssnews/content/NewsDelegate.qml +++ b/examples/demos/rssnews/content/NewsDelegate.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/rssnews/content/RssFeeds.qml b/examples/demos/rssnews/content/RssFeeds.qml index 278f05752c..ed58ef3852 100644 --- a/examples/demos/rssnews/content/RssFeeds.qml +++ b/examples/demos/rssnews/content/RssFeeds.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/rssnews/content/ScrollBar.qml b/examples/demos/rssnews/content/ScrollBar.qml index 4ca4132c6b..7b1a2ac3e5 100644 --- a/examples/demos/rssnews/content/ScrollBar.qml +++ b/examples/demos/rssnews/content/ScrollBar.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/rssnews/rssnews.qml b/examples/demos/rssnews/rssnews.qml index 491cefda07..d26b94b6d3 100644 --- a/examples/demos/rssnews/rssnews.qml +++ b/examples/demos/rssnews/rssnews.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/samegame/content/BoomBlock.qml b/examples/demos/samegame/content/BoomBlock.qml index 47f86bd81b..a348368ae1 100644 --- a/examples/demos/samegame/content/BoomBlock.qml +++ b/examples/demos/samegame/content/BoomBlock.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/samegame/content/Button.qml b/examples/demos/samegame/content/Button.qml index b305455c92..2d1a993226 100644 --- a/examples/demos/samegame/content/Button.qml +++ b/examples/demos/samegame/content/Button.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/samegame/content/Dialog.qml b/examples/demos/samegame/content/Dialog.qml index 80e5984bfe..c81580e6a5 100644 --- a/examples/demos/samegame/content/Dialog.qml +++ b/examples/demos/samegame/content/Dialog.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/samegame/content/GameArea.qml b/examples/demos/samegame/content/GameArea.qml index a43d55117a..3422582b21 100644 --- a/examples/demos/samegame/content/GameArea.qml +++ b/examples/demos/samegame/content/GameArea.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/samegame/content/NameInputDialog.qml b/examples/demos/samegame/content/NameInputDialog.qml index 602e69789a..7c3bfa274a 100644 --- a/examples/demos/samegame/content/NameInputDialog.qml +++ b/examples/demos/samegame/content/NameInputDialog.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/samegame/samegame.qml b/examples/demos/samegame/samegame.qml index 201f826a29..b98b6a0074 100644 --- a/examples/demos/samegame/samegame.qml +++ b/examples/demos/samegame/samegame.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/snake/content/Button.qml b/examples/demos/snake/content/Button.qml index dfac45049a..4f294556b3 100644 --- a/examples/demos/snake/content/Button.qml +++ b/examples/demos/snake/content/Button.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/snake/content/Cookie.qml b/examples/demos/snake/content/Cookie.qml index cae53af525..35ffe400b8 100644 --- a/examples/demos/snake/content/Cookie.qml +++ b/examples/demos/snake/content/Cookie.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/snake/content/HighScoreModel.qml b/examples/demos/snake/content/HighScoreModel.qml index af66b99ede..734a661f5b 100644 --- a/examples/demos/snake/content/HighScoreModel.qml +++ b/examples/demos/snake/content/HighScoreModel.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/snake/content/Link.qml b/examples/demos/snake/content/Link.qml index 891adafe5e..aab005afd5 100644 --- a/examples/demos/snake/content/Link.qml +++ b/examples/demos/snake/content/Link.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/snake/content/Skull.qml b/examples/demos/snake/content/Skull.qml index 9026790a5d..0c173be7da 100644 --- a/examples/demos/snake/content/Skull.qml +++ b/examples/demos/snake/content/Skull.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/snake/snake.qml b/examples/demos/snake/snake.qml index fca3273def..efd5747173 100644 --- a/examples/demos/snake/snake.qml +++ b/examples/demos/snake/snake.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/twitter/TwitterCore/Button.qml b/examples/demos/twitter/TwitterCore/Button.qml index 064fd4b277..353b993742 100644 --- a/examples/demos/twitter/TwitterCore/Button.qml +++ b/examples/demos/twitter/TwitterCore/Button.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/twitter/TwitterCore/FatDelegate.qml b/examples/demos/twitter/TwitterCore/FatDelegate.qml index 5fd0d1622b..4cb0dfc713 100644 --- a/examples/demos/twitter/TwitterCore/FatDelegate.qml +++ b/examples/demos/twitter/TwitterCore/FatDelegate.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/twitter/TwitterCore/Input.qml b/examples/demos/twitter/TwitterCore/Input.qml index 2987b9e5d8..68b1c6186a 100644 --- a/examples/demos/twitter/TwitterCore/Input.qml +++ b/examples/demos/twitter/TwitterCore/Input.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/twitter/TwitterCore/Loading.qml b/examples/demos/twitter/TwitterCore/Loading.qml index 8f7c868bee..566857b8b2 100644 --- a/examples/demos/twitter/TwitterCore/Loading.qml +++ b/examples/demos/twitter/TwitterCore/Loading.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/twitter/TwitterCore/MultiTitleBar.qml b/examples/demos/twitter/TwitterCore/MultiTitleBar.qml index f52ce5be26..3920520b7a 100644 --- a/examples/demos/twitter/TwitterCore/MultiTitleBar.qml +++ b/examples/demos/twitter/TwitterCore/MultiTitleBar.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/twitter/TwitterCore/RssModel.qml b/examples/demos/twitter/TwitterCore/RssModel.qml index c4050994e6..27f7495be2 100644 --- a/examples/demos/twitter/TwitterCore/RssModel.qml +++ b/examples/demos/twitter/TwitterCore/RssModel.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/twitter/TwitterCore/SearchView.qml b/examples/demos/twitter/TwitterCore/SearchView.qml index 82a8559889..7732e6f68d 100644 --- a/examples/demos/twitter/TwitterCore/SearchView.qml +++ b/examples/demos/twitter/TwitterCore/SearchView.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/twitter/TwitterCore/TitleBar.qml b/examples/demos/twitter/TwitterCore/TitleBar.qml index 3624048c4d..3e0818b0dd 100644 --- a/examples/demos/twitter/TwitterCore/TitleBar.qml +++ b/examples/demos/twitter/TwitterCore/TitleBar.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/twitter/TwitterCore/ToolBar.qml b/examples/demos/twitter/TwitterCore/ToolBar.qml index 06d3324ee3..d4265f3e98 100644 --- a/examples/demos/twitter/TwitterCore/ToolBar.qml +++ b/examples/demos/twitter/TwitterCore/ToolBar.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/twitter/TwitterCore/UserModel.qml b/examples/demos/twitter/TwitterCore/UserModel.qml index f88837c344..428089b539 100644 --- a/examples/demos/twitter/TwitterCore/UserModel.qml +++ b/examples/demos/twitter/TwitterCore/UserModel.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/demos/twitter/twitter.qml b/examples/demos/twitter/twitter.qml index 26e4a7079b..aca0968cfb 100644 --- a/examples/demos/twitter/twitter.qml +++ b/examples/demos/twitter/twitter.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/examples/embedded/embedded.pro b/examples/embedded/embedded.pro new file mode 100644 index 0000000000..81334fa552 --- /dev/null +++ b/examples/embedded/embedded.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS += qmleasing qmlflickr qmldialcontrol qmlcalculator qmlphotoviewer qmlclocks qmltwitter diff --git a/examples/embedded/qmlcalculator/deployment.pri b/examples/embedded/qmlcalculator/deployment.pri new file mode 100644 index 0000000000..4286bb6e24 --- /dev/null +++ b/examples/embedded/qmlcalculator/deployment.pri @@ -0,0 +1,4 @@ +qmlcalculator_src = $$PWD/../../qml/calculator + +qmlcalculator_files.files = $$qmlcalculator_src/calculator.qml $$qmlcalculator_src/Core +DEPLOYMENT += qmlcalculator_files diff --git a/examples/embedded/qmlcalculator/qmlcalculator.cpp b/examples/embedded/qmlcalculator/qmlcalculator.cpp new file mode 100644 index 0000000000..17bf0f14f2 --- /dev/null +++ b/examples/embedded/qmlcalculator/qmlcalculator.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication application(argc, argv); + + const QString mainQmlApp = QLatin1String("calculator.qml"); + QQuickView view; + view.setSource(QUrl(mainQmlApp)); + view.setResizeMode(QQuickView::SizeRootObjectToView); + QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); + +#if defined(QT_KEYPAD_NAVIGATION) + QApplication::setNavigationMode(Qt::NavigationModeCursorAuto); +#endif // QT_KEYPAD_NAVIGATION + + view.show(); + return application.exec(); +} diff --git a/examples/embedded/qmlcalculator/qmlcalculator.pro b/examples/embedded/qmlcalculator/qmlcalculator.pro new file mode 100644 index 0000000000..4ebf2d5972 --- /dev/null +++ b/examples/embedded/qmlcalculator/qmlcalculator.pro @@ -0,0 +1,5 @@ +!wince*:warning("DEPLOYMENT support required. This project only works on WinCE.") + +QT += qml +SOURCES += $$PWD/qmlcalculator.cpp +include($$PWD/deployment.pri) diff --git a/examples/embedded/qmlclocks/deployment.pri b/examples/embedded/qmlclocks/deployment.pri new file mode 100644 index 0000000000..75b39ac48f --- /dev/null +++ b/examples/embedded/qmlclocks/deployment.pri @@ -0,0 +1,4 @@ +qmlclocks_src = $$PWD/../../../examples/qml/toys/clocks + +qmlclocks_files.files = $$qmlclocks_src/clocks.qml $$qmlclocks_src/content +DEPLOYMENT += qmlclocks_files diff --git a/examples/embedded/qmlclocks/qmlclocks.cpp b/examples/embedded/qmlclocks/qmlclocks.cpp new file mode 100644 index 0000000000..1f9a553944 --- /dev/null +++ b/examples/embedded/qmlclocks/qmlclocks.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication application(argc, argv); + + const QString mainQmlApp = QLatin1String("clocks.qml"); + QQuickView view; + view.setSource(QUrl(mainQmlApp)); + view.setResizeMode(QQuickView::SizeRootObjectToView); + QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); + +#if defined(QT_KEYPAD_NAVIGATION) + QApplication::setNavigationMode(Qt::NavigationModeCursorAuto); +#endif // QT_KEYPAD_NAVIGATION + + view.show(); + return application.exec(); +} diff --git a/examples/embedded/qmlclocks/qmlclocks.pro b/examples/embedded/qmlclocks/qmlclocks.pro new file mode 100644 index 0000000000..43a9e31972 --- /dev/null +++ b/examples/embedded/qmlclocks/qmlclocks.pro @@ -0,0 +1,5 @@ +!wince*:warning("DEPLOYMENT support required. This project only works on WinCE.") + +QT += qml +SOURCES += $$PWD/qmlclocks.cpp +include($$PWD/deployment.pri) diff --git a/examples/embedded/qmldialcontrol/deployment.pri b/examples/embedded/qmldialcontrol/deployment.pri new file mode 100644 index 0000000000..58c815e1e5 --- /dev/null +++ b/examples/embedded/qmldialcontrol/deployment.pri @@ -0,0 +1,4 @@ +qmldialcontrol_src = $$PWD/../../../examples/qml/ui-components/dialcontrol + +qmldialcontrol_files.files = $$qmldialcontrol_src/dialcontrol.qml $$qmldialcontrol_src/content +DEPLOYMENT += qmldialcontrol_files diff --git a/examples/embedded/qmldialcontrol/qmldialcontrol.cpp b/examples/embedded/qmldialcontrol/qmldialcontrol.cpp new file mode 100644 index 0000000000..6f81e5f8a0 --- /dev/null +++ b/examples/embedded/qmldialcontrol/qmldialcontrol.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication application(argc, argv); + + const QString mainQmlApp = QLatin1String("dialcontrol.qml"); + QQuickView view; + view.setSource(QUrl(mainQmlApp)); + view.setResizeMode(QQuickView::SizeRootObjectToView); + QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); + +#if defined(QT_KEYPAD_NAVIGATION) + QApplication::setNavigationMode(Qt::NavigationModeCursorAuto); +#endif // QT_KEYPAD_NAVIGATION + + view.show(); + return application.exec(); +} diff --git a/examples/embedded/qmldialcontrol/qmldialcontrol.pro b/examples/embedded/qmldialcontrol/qmldialcontrol.pro new file mode 100644 index 0000000000..58ed7cabb8 --- /dev/null +++ b/examples/embedded/qmldialcontrol/qmldialcontrol.pro @@ -0,0 +1,5 @@ +!wince*:warning("DEPLOYMENT support required. This project only works on WinCE.") + +QT += qml +SOURCES += $$PWD/qmldialcontrol.cpp +include($$PWD/deployment.pri) diff --git a/examples/embedded/qmleasing/deployment.pri b/examples/embedded/qmleasing/deployment.pri new file mode 100644 index 0000000000..427259b816 --- /dev/null +++ b/examples/embedded/qmleasing/deployment.pri @@ -0,0 +1,4 @@ +qmleasing_src = $$PWD/../../../examples/qml/animation/easing + +qmleasing_files.files = $$qmleasing_src/easing.qml $$qmleasing_src/content +DEPLOYMENT += qmleasing_files diff --git a/examples/embedded/qmleasing/qmleasing.cpp b/examples/embedded/qmleasing/qmleasing.cpp new file mode 100644 index 0000000000..d516825d9a --- /dev/null +++ b/examples/embedded/qmleasing/qmleasing.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication application(argc, argv); + + const QString mainQmlApp = QLatin1String("easing.qml"); + QQuickView view; + view.setSource(QUrl(mainQmlApp)); + view.setResizeMode(QQuickView::SizeRootObjectToView); + QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); + +#if defined(QT_KEYPAD_NAVIGATION) + QApplication::setNavigationMode(Qt::NavigationModeCursorAuto); +#endif // QT_KEYPAD_NAVIGATION + + view.show(); + return application.exec(); +} diff --git a/examples/embedded/qmleasing/qmleasing.pro b/examples/embedded/qmleasing/qmleasing.pro new file mode 100644 index 0000000000..6e0383502b --- /dev/null +++ b/examples/embedded/qmleasing/qmleasing.pro @@ -0,0 +1,5 @@ +!wince*:warning("DEPLOYMENT support required. This project only works on WinCE.") + +QT += qml +SOURCES += $$PWD/qmleasing.cpp +include($$PWD/deployment.pri) diff --git a/examples/embedded/qmlflickr/deployment.pri b/examples/embedded/qmlflickr/deployment.pri new file mode 100644 index 0000000000..7b9b62b459 --- /dev/null +++ b/examples/embedded/qmlflickr/deployment.pri @@ -0,0 +1,4 @@ +qmlflickr_src = $$PWD/../../qml/flickr + +qmlflickr_files.files = $$qmlflickr_src/flickr.qml $$qmlflickr_src/common $$qmlflickr_src/mobile +DEPLOYMENT += qmlflickr_files diff --git a/examples/embedded/qmlflickr/qmlflickr.cpp b/examples/embedded/qmlflickr/qmlflickr.cpp new file mode 100644 index 0000000000..268542e61b --- /dev/null +++ b/examples/embedded/qmlflickr/qmlflickr.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Factory to create QNetworkAccessManagers that use the saved network configuration; otherwise +// the system default. +class NetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory +{ +public: + ~NetworkAccessManagerFactory() { } + + QNetworkAccessManager *create(QObject *parent); +}; + +QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent) +{ + QNetworkAccessManager *accessManager = new QNetworkAccessManager(parent); + + QNetworkConfigurationManager manager; + if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { + // Get saved network configuration + QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + settings.beginGroup(QLatin1String("QtNetwork")); + const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); + settings.endGroup(); + + // If the saved network configuration is not currently discovered use the system default + QNetworkConfiguration config = manager.configurationFromIdentifier(id); + if ((config.state() & QNetworkConfiguration::Discovered) != + QNetworkConfiguration::Discovered) { + config = manager.defaultConfiguration(); + } + + accessManager->setConfiguration(config); + } + + return accessManager; +} + +int main(int argc, char *argv[]) +{ + QApplication application(argc, argv); + + NetworkAccessManagerFactory networkAccessManagerFactory; + + const QString mainQmlApp = QLatin1String("flickr.qml"); + QQuickView view; + view.engine()->setNetworkAccessManagerFactory(&networkAccessManagerFactory); + view.setSource(QUrl(mainQmlApp)); + view.setResizeMode(QQuickView::SizeRootObjectToView); + QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); + view.setGeometry(QRect(100, 100, 360, 640)); + view.show(); + return application.exec(); +} + diff --git a/examples/embedded/qmlflickr/qmlflickr.pro b/examples/embedded/qmlflickr/qmlflickr.pro new file mode 100644 index 0000000000..141c02d3fe --- /dev/null +++ b/examples/embedded/qmlflickr/qmlflickr.pro @@ -0,0 +1,5 @@ +!wince*:warning("DEPLOYMENT support required. This project only works on WinCE.") + +QT += qml network +SOURCES += $$PWD/qmlflickr.cpp +include($$PWD/deployment.pri) diff --git a/examples/embedded/qmlphotoviewer/deployment.pri b/examples/embedded/qmlphotoviewer/deployment.pri new file mode 100644 index 0000000000..ea9a052b4b --- /dev/null +++ b/examples/embedded/qmlphotoviewer/deployment.pri @@ -0,0 +1,4 @@ +qmlphotoviewer_src = $$PWD/../../qml/photoviewer + +qmlphotoviewer_files.files = $$qmlphotoviewer_src/photoviewer.qml $$qmlphotoviewer_src/PhotoViewerCore +DEPLOYMENT += qmlphotoviewer_files diff --git a/examples/embedded/qmlphotoviewer/qmlphotoviewer.cpp b/examples/embedded/qmlphotoviewer/qmlphotoviewer.cpp new file mode 100644 index 0000000000..18bf1ae094 --- /dev/null +++ b/examples/embedded/qmlphotoviewer/qmlphotoviewer.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Factory to create QNetworkAccessManagers that use the saved network configuration; otherwise +// the system default. +class NetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory +{ +public: + ~NetworkAccessManagerFactory() { } + + QNetworkAccessManager *create(QObject *parent); +}; + +QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent) +{ + QNetworkAccessManager *accessManager = new QNetworkAccessManager(parent); + + QNetworkConfigurationManager manager; + if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { + // Get saved network configuration + QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + settings.beginGroup(QLatin1String("QtNetwork")); + const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); + settings.endGroup(); + + // If the saved network configuration is not currently discovered use the system default + QNetworkConfiguration config = manager.configurationFromIdentifier(id); + if ((config.state() & QNetworkConfiguration::Discovered) != + QNetworkConfiguration::Discovered) { + config = manager.defaultConfiguration(); + } + + accessManager->setConfiguration(config); + } + + return accessManager; +} + +int main(int argc, char *argv[]) +{ + QApplication application(argc, argv); + + NetworkAccessManagerFactory networkAccessManagerFactory; + + const QString mainQmlApp = QLatin1String("photoviewer.qml"); + QQuickView view; + view.engine()->setNetworkAccessManagerFactory(&networkAccessManagerFactory); + view.setSource(QUrl(mainQmlApp)); + view.setResizeMode(QQuickView::SizeRootObjectToView); + + QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); + view.setGeometry(QRect(100, 100, 360, 640)); + view.show(); + return application.exec(); +} + diff --git a/examples/embedded/qmlphotoviewer/qmlphotoviewer.pro b/examples/embedded/qmlphotoviewer/qmlphotoviewer.pro new file mode 100644 index 0000000000..1c0301118e --- /dev/null +++ b/examples/embedded/qmlphotoviewer/qmlphotoviewer.pro @@ -0,0 +1,5 @@ +!wince*:warning("DEPLOYMENT support required. This project only works on WinCE.") + +QT += qml network +SOURCES += $$PWD/qmlphotoviewer.cpp +include($$PWD/deployment.pri) diff --git a/examples/embedded/qmltwitter/deployment.pri b/examples/embedded/qmltwitter/deployment.pri new file mode 100644 index 0000000000..2f3066bc72 --- /dev/null +++ b/examples/embedded/qmltwitter/deployment.pri @@ -0,0 +1,4 @@ +qmltwitter_src = $$PWD/../../qml/twitter + +qmltwitter_files.files = $$qmltwitter_src/twitter.qml $$qmltwitter_src/TwitterCore +DEPLOYMENT += qmltwitter_files diff --git a/examples/embedded/qmltwitter/qmltwitter.cpp b/examples/embedded/qmltwitter/qmltwitter.cpp new file mode 100644 index 0000000000..a3a5c40f34 --- /dev/null +++ b/examples/embedded/qmltwitter/qmltwitter.cpp @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Factory to create QNetworkAccessManagers that use the saved network configuration; otherwise +// the system default. +class NetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory +{ +public: + ~NetworkAccessManagerFactory() { } + + QNetworkAccessManager *create(QObject *parent); +}; + +QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent) +{ + QNetworkAccessManager *accessManager = new QNetworkAccessManager(parent); + + QNetworkConfigurationManager manager; + if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { + // Get saved network configuration + QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + settings.beginGroup(QLatin1String("QtNetwork")); + const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); + settings.endGroup(); + + // If the saved network configuration is not currently discovered use the system default + QNetworkConfiguration config = manager.configurationFromIdentifier(id); + if ((config.state() & QNetworkConfiguration::Discovered) != + QNetworkConfiguration::Discovered) { + config = manager.defaultConfiguration(); + } + + accessManager->setConfiguration(config); + } + + return accessManager; +} + +int main(int argc, char *argv[]) +{ + QApplication application(argc, argv); + + NetworkAccessManagerFactory networkAccessManagerFactory; + + const QString mainQmlApp = QLatin1String("twitter.qml"); + QQuickView view; + view.engine()->setNetworkAccessManagerFactory(&networkAccessManagerFactory); + view.setSource(QUrl(mainQmlApp)); + view.setResizeMode(QQuickView::SizeRootObjectToView); + QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); + view.setGeometry(QRect(100, 100, 360, 640)); + view.show(); + return application.exec(); +} + diff --git a/examples/embedded/qmltwitter/qmltwitter.pro b/examples/embedded/qmltwitter/qmltwitter.pro new file mode 100644 index 0000000000..eca46f9f97 --- /dev/null +++ b/examples/embedded/qmltwitter/qmltwitter.pro @@ -0,0 +1,5 @@ +!wince*:warning("DEPLOYMENT support required. This project only works on WinCE.") + +QT += qml network +SOURCES += $$PWD/qmltwitter.cpp +include($$PWD/deployment.pri) diff --git a/examples/examples.pro b/examples/examples.pro index 2b78ed7e12..d3d2f5520f 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,3 +1,3 @@ TEMPLATE = subdirs -SUBDIRS += demos shared localstorage particles qml qtquick tutorials window +SUBDIRS += demos shared localstorage particles qml quick tutorials window contains(QT_CONFIG, qmltest): SUBDIRS += qmltest diff --git a/examples/qml/README b/examples/qml/README new file mode 100644 index 0000000000..56c48d71fb --- /dev/null +++ b/examples/qml/README @@ -0,0 +1,13 @@ +The Qt Declarative module provides the ability to specify and implement +your user interface declaratively, using the Qt Meta-Object Language (QML). This +language is very expressive and human readable, and can be used by +designers to actually implement their UI vision. QML UIs can integrate +with C++ code in many ways, including being loaded as a part of a C++ UI +and loading data models from C++ and interacting with them. + +Mostof these examples can be viewed directly with the +QML viewer utility, without requiring compilation. + + +Documentation for these examples can be found via the Examples +link in the main Qt documentation. diff --git a/examples/qml/accessibility/accessibility.qml b/examples/qml/accessibility/accessibility.qml new file mode 100644 index 0000000000..e0152f065b --- /dev/null +++ b/examples/qml/accessibility/accessibility.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Window 2.0 +import "widgets" + +Rectangle { + id: window + + width: 360; height: 300 + color: "white" + + Column { + id: column + spacing: 6 + anchors.fill: parent + width: parent.width + Row { + spacing: 6 + width: column.width + Button { width: 100; height: column.h + 20; text: "Send" } + Button { width: 100; height: column.h + 20; text: "Discard" } + } + + Row { + spacing: 6 + width: column.width + height: column.h + Text { + id: subjectLabel + Accessible.role: Accessible.StaticText + Accessible.name: text + text: "Subject:" + width: 50 + } + Rectangle { + id: subjectBorder + Accessible.role: Accessible.EditableText + Accessible.name: subjectEdit.text + border.width: 1 + border.color: "black" + height: subjectEdit.height + width: 304 + TextInput { + id: subjectEdit + text: "Vacation plans" + } + } + } + Rectangle { + id: textBorder + Accessible.role: Accessible.EditableText + property alias text : textEdit.text + border.width: 1 + border.color: "black" + width: parent.width + height: textEdit.height + TextEdit { + id: textEdit + text: "Hi, we're going to the Dolomites this summer. Weren't you also going to northern Italy? \n\nbest wishes, your friend Luke" + width: parent.width + wrapMode: TextEdit.WordWrap + } + } + } +} diff --git a/examples/qml/accessibility/widgets/Button.qml b/examples/qml/accessibility/widgets/Button.qml new file mode 100644 index 0000000000..793f895c57 --- /dev/null +++ b/examples/qml/accessibility/widgets/Button.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: button + + property alias text : buttonText.text + Accessible.name: text + Accessible.description: "This button does " + text + Accessible.role: Accessible.Button + + signal clicked + + width: buttonText.width + 20 + height: 30 + gradient: Gradient { + GradientStop { position: 0.0; color: "lightsteelblue" } + GradientStop { position: 1.0; color: "blue" } + } + border.width: 2 + border.color: "black"; + radius: 10 + + Text { + id: buttonText + text: parent.description + anchors.centerIn: parent + font.pixelSize: parent.height * .5 + style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { + checked = !checked; + } + } +} diff --git a/examples/qml/animation/animation.qml b/examples/qml/animation/animation.qml new file mode 100644 index 0000000000..7c5829e790 --- /dev/null +++ b/examples/qml/animation/animation.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../shared" + +Item { + height: 480 + width: 320 + LauncherList { + id: ll + anchors.fill: parent + Component.onCompleted: { + addExample("ColorAnimation", "Interpolates between colors", Qt.resolvedUrl("basics/color-animation.qml")); + addExample("PropertyAnimation", "Interpolates between numbers", Qt.resolvedUrl("basics/property-animation.qml")); + addExample("Behaviors", "Animates procedural movement", Qt.resolvedUrl("behaviors/behavior-example.qml")); + addExample("WigglyText", "Text that wiggles as you drag it", Qt.resolvedUrl("behaviors/wigglytext.qml")); + addExample("Easing Curves", "Compare available easing curves", Qt.resolvedUrl("easing/easing.qml")); + addExample("States", "Simple states", Qt.resolvedUrl("states/states.qml")); + addExample("Transitions", "Simple states with animated transitions", Qt.resolvedUrl("states/transitions.qml")); + addExample("PathAnimation", "Animate along a path", Qt.resolvedUrl("pathanimation/pathanimation.qml")); + addExample("PathInterpolator", "Interpolates along a path", Qt.resolvedUrl("pathinterpolator/pathinterpolator.qml")); + } + } +} diff --git a/examples/qtquick/animation/animation.qmlproject b/examples/qml/animation/animation.qmlproject similarity index 100% rename from examples/qtquick/animation/animation.qmlproject rename to examples/qml/animation/animation.qmlproject diff --git a/examples/qml/animation/basics/color-animation.qml b/examples/qml/animation/basics/color-animation.qml new file mode 100644 index 0000000000..a54091d7dd --- /dev/null +++ b/examples/qml/animation/basics/color-animation.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: window + width: 640; height: 480 + + // Let's draw the sky... + Rectangle { + anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter } + gradient: Gradient { + GradientStop { + position: 0.0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { from: "DeepSkyBlue"; to: "#0E1533"; duration: 5000 } + ColorAnimation { from: "#0E1533"; to: "DeepSkyBlue"; duration: 5000 } + } + } + GradientStop { + position: 1.0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { from: "SkyBlue"; to: "#437284"; duration: 5000 } + ColorAnimation { from: "#437284"; to: "SkyBlue"; duration: 5000 } + } + } + } + } + + // the sun, moon, and stars + Item { + width: parent.width; height: 2 * parent.height + NumberAnimation on rotation { from: 0; to: 360; duration: 10000; loops: Animation.Infinite } + Image { + source: "images/sun.png"; y: 10; anchors.horizontalCenter: parent.horizontalCenter + rotation: -3 * parent.rotation + } + Image { + source: "images/moon.png"; y: parent.height - 74; anchors.horizontalCenter: parent.horizontalCenter + rotation: -parent.rotation + } + ParticleSystem { + id: particlesystem + x: 0; y: parent.height/2 + width: parent.width; height: parent.height/2 + ImageParticle { + source: "images/star.png" + groups: ["star"] + color: "#00333333" + SequentialAnimation on opacity { + loops: Animation.Infinite + NumberAnimation { from: 0; to: 1; duration: 5000 } + NumberAnimation { from: 1; to: 0; duration: 5000 } + } + } + Emitter { + group: "star" + anchors.fill: parent + emitRate: parent.width / 50 + lifeSpan: 5000 + } + } + } + + // ...and the ground. + Rectangle { + anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom } + gradient: Gradient { + GradientStop { + position: 0.0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { from: "ForestGreen"; to: "#001600"; duration: 5000 } + ColorAnimation { from: "#001600"; to: "ForestGreen"; duration: 5000 } + } + } + GradientStop { position: 1.0; color: "DarkGreen" } + } + } +} diff --git a/examples/qtquick/animation/basics/images/face-smile.png b/examples/qml/animation/basics/images/face-smile.png similarity index 100% rename from examples/qtquick/animation/basics/images/face-smile.png rename to examples/qml/animation/basics/images/face-smile.png diff --git a/examples/qtquick/animation/basics/images/moon.png b/examples/qml/animation/basics/images/moon.png similarity index 100% rename from examples/qtquick/animation/basics/images/moon.png rename to examples/qml/animation/basics/images/moon.png diff --git a/examples/qtquick/animation/basics/images/shadow.png b/examples/qml/animation/basics/images/shadow.png similarity index 100% rename from examples/qtquick/animation/basics/images/shadow.png rename to examples/qml/animation/basics/images/shadow.png diff --git a/examples/qtquick/animation/basics/images/star.png b/examples/qml/animation/basics/images/star.png similarity index 100% rename from examples/qtquick/animation/basics/images/star.png rename to examples/qml/animation/basics/images/star.png diff --git a/examples/qtquick/animation/basics/images/sun.png b/examples/qml/animation/basics/images/sun.png similarity index 100% rename from examples/qtquick/animation/basics/images/sun.png rename to examples/qml/animation/basics/images/sun.png diff --git a/examples/qtquick/animation/basics/property-animation.qml b/examples/qml/animation/basics/property-animation.qml similarity index 100% rename from examples/qtquick/animation/basics/property-animation.qml rename to examples/qml/animation/basics/property-animation.qml diff --git a/examples/qtquick/animation/behaviors/SideRect.qml b/examples/qml/animation/behaviors/SideRect.qml similarity index 100% rename from examples/qtquick/animation/behaviors/SideRect.qml rename to examples/qml/animation/behaviors/SideRect.qml diff --git a/examples/qml/animation/behaviors/behavior-example.qml b/examples/qml/animation/behaviors/behavior-example.qml new file mode 100644 index 0000000000..89fc9992b6 --- /dev/null +++ b/examples/qml/animation/behaviors/behavior-example.qml @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 600; height: 400 + color: "#343434" + + Rectangle { + anchors.centerIn: parent + width: 200; height: 200 + radius: 30 + color: "transparent" + border.width: 4; border.color: "white" + + + SideRect { + id: leftRect + anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.left } + text: "Left" + } + + SideRect { + id: rightRect + anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.right } + text: "Right" + } + + SideRect { + id: topRect + anchors { verticalCenter: parent.top; horizontalCenter: parent.horizontalCenter } + text: "Top" + } + + SideRect { + id: bottomRect + anchors { verticalCenter: parent.bottom; horizontalCenter: parent.horizontalCenter } + text: "Bottom" + } + + + Rectangle { + id: focusRect + + property string text + + x: 62; y: 75; width: 75; height: 50 + radius: 6 + border.width: 4; border.color: "white" + color: "firebrick" + + // Set an 'elastic' behavior on the focusRect's x property. + Behavior on x { + NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 } + } + + // Set an 'elastic' behavior on the focusRect's y property. + Behavior on y { + NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 } + } + + Text { + id: focusText + text: focusRect.text + anchors.centerIn: parent + color: "white" + font.pixelSize: 16; font.bold: true + + // Set a behavior on the focusText's x property: + // Set the opacity to 0, set the new text value, then set the opacity back to 1. + Behavior on text { + SequentialAnimation { + NumberAnimation { target: focusText; property: "opacity"; to: 0; duration: 150 } + NumberAnimation { target: focusText; property: "opacity"; to: 1; duration: 150 } + } + } + } + } + } +} diff --git a/examples/qml/animation/behaviors/wigglytext.qml b/examples/qml/animation/behaviors/wigglytext.qml new file mode 100644 index 0000000000..e2ed472088 --- /dev/null +++ b/examples/qml/animation/behaviors/wigglytext.qml @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property string text: "Drag this text..." + property bool animated: true + + width: 640; height: 480; color: "#474747"; focus: true + + Keys.onPressed: { + if (event.key == Qt.Key_Delete || event.key == Qt.Key_Backspace) + container.remove() + else if (event.text != "") { + container.append(event.text) + } + } + + function append(text) { + container.animated = false + var lastLetter = container.children[container.children.length - 1] + var newLetter = letterComponent.createObject(container) + newLetter.text = text + newLetter.follow = lastLetter + container.animated = true + } + + function remove() { + if (container.children.length) + container.children[container.children.length - 1].destroy() + } + + function doLayout() { + var follow = null + for (var i = 0; i < container.text.length; ++i) { + var newLetter = letterComponent.createObject(container) + newLetter.text = container.text[i] + newLetter.follow = follow + follow = newLetter + } + } + + Component { + id: letterComponent + Text { + id: letter + property variant follow + + x: follow ? follow.x + follow.width : container.width / 3 + y: follow ? follow.y : container.height / 2 + + font.pixelSize: 40; font.bold: true + color: "#999999"; styleColor: "#222222"; style: Text.Raised + + MouseArea { + anchors.fill: parent + drag.target: letter; drag.axis: Drag.XandYAxis + onPressed: letter.color = "#dddddd" + onReleased: letter.color = "#999999" + } + + Behavior on x { enabled: container.animated; SpringAnimation { spring: 3; damping: 0.3; mass: 1.0 } } + Behavior on y { enabled: container.animated; SpringAnimation { spring: 3; damping: 0.3; mass: 1.0 } } + } + } + + Component.onCompleted: doLayout() +} diff --git a/examples/qtquick/animation/easing/content/QuitButton.qml b/examples/qml/animation/easing/content/QuitButton.qml similarity index 100% rename from examples/qtquick/animation/easing/content/QuitButton.qml rename to examples/qml/animation/easing/content/QuitButton.qml diff --git a/examples/qtquick/animation/easing/content/quit.png b/examples/qml/animation/easing/content/quit.png similarity index 100% rename from examples/qtquick/animation/easing/content/quit.png rename to examples/qml/animation/easing/content/quit.png diff --git a/examples/qml/animation/easing/easing.qml b/examples/qml/animation/easing/easing.qml new file mode 100644 index 0000000000..207b653d6e --- /dev/null +++ b/examples/qml/animation/easing/easing.qml @@ -0,0 +1,170 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + id: window + width: 600; height: 460; color: "#232323" + + property var easingCurve: [ 0.2, 0.2, 0.13, 0.65, 0.2, 0.8, + 0.624, 0.98, 0.93, 0.95, 1, 1 ] + + ListModel { + id: easingTypes + ListElement { name: "Easing.Linear"; type: Easing.Linear; ballColor: "DarkRed" } + ListElement { name: "Easing.InQuad"; type: Easing.InQuad; ballColor: "IndianRed" } + ListElement { name: "Easing.OutQuad"; type: Easing.OutQuad; ballColor: "Salmon" } + ListElement { name: "Easing.InOutQuad"; type: Easing.InOutQuad; ballColor: "Tomato" } + ListElement { name: "Easing.OutInQuad"; type: Easing.OutInQuad; ballColor: "DarkOrange" } + ListElement { name: "Easing.InCubic"; type: Easing.InCubic; ballColor: "Gold" } + ListElement { name: "Easing.OutCubic"; type: Easing.OutCubic; ballColor: "Yellow" } + ListElement { name: "Easing.InOutCubic"; type: Easing.InOutCubic; ballColor: "PeachPuff" } + ListElement { name: "Easing.OutInCubic"; type: Easing.OutInCubic; ballColor: "Thistle" } + ListElement { name: "Easing.InQuart"; type: Easing.InQuart; ballColor: "Orchid" } + ListElement { name: "Easing.OutQuart"; type: Easing.OutQuart; ballColor: "Purple" } + ListElement { name: "Easing.InOutQuart"; type: Easing.InOutQuart; ballColor: "SlateBlue" } + ListElement { name: "Easing.OutInQuart"; type: Easing.OutInQuart; ballColor: "Chartreuse" } + ListElement { name: "Easing.InQuint"; type: Easing.InQuint; ballColor: "LimeGreen" } + ListElement { name: "Easing.OutQuint"; type: Easing.OutQuint; ballColor: "SeaGreen" } + ListElement { name: "Easing.InOutQuint"; type: Easing.InOutQuint; ballColor: "DarkGreen" } + ListElement { name: "Easing.OutInQuint"; type: Easing.OutInQuint; ballColor: "Olive" } + ListElement { name: "Easing.InSine"; type: Easing.InSine; ballColor: "DarkSeaGreen" } + ListElement { name: "Easing.OutSine"; type: Easing.OutSine; ballColor: "Teal" } + ListElement { name: "Easing.InOutSine"; type: Easing.InOutSine; ballColor: "Turquoise" } + ListElement { name: "Easing.OutInSine"; type: Easing.OutInSine; ballColor: "SteelBlue" } + ListElement { name: "Easing.InExpo"; type: Easing.InExpo; ballColor: "SkyBlue" } + ListElement { name: "Easing.OutExpo"; type: Easing.OutExpo; ballColor: "RoyalBlue" } + ListElement { name: "Easing.InOutExpo"; type: Easing.InOutExpo; ballColor: "MediumBlue" } + ListElement { name: "Easing.OutInExpo"; type: Easing.OutInExpo; ballColor: "MidnightBlue" } + ListElement { name: "Easing.InCirc"; type: Easing.InCirc; ballColor: "CornSilk" } + ListElement { name: "Easing.OutCirc"; type: Easing.OutCirc; ballColor: "Bisque" } + ListElement { name: "Easing.InOutCirc"; type: Easing.InOutCirc; ballColor: "RosyBrown" } + ListElement { name: "Easing.OutInCirc"; type: Easing.OutInCirc; ballColor: "SandyBrown" } + ListElement { name: "Easing.InElastic"; type: Easing.InElastic; ballColor: "DarkGoldenRod" } + ListElement { name: "Easing.OutElastic"; type: Easing.OutElastic; ballColor: "Chocolate" } + ListElement { name: "Easing.InOutElastic"; type: Easing.InOutElastic; ballColor: "SaddleBrown" } + ListElement { name: "Easing.OutInElastic"; type: Easing.OutInElastic; ballColor: "Brown" } + ListElement { name: "Easing.InBack"; type: Easing.InBack; ballColor: "Maroon" } + ListElement { name: "Easing.OutBack"; type: Easing.OutBack; ballColor: "LavenderBlush" } + ListElement { name: "Easing.InOutBack"; type: Easing.InOutBack; ballColor: "MistyRose" } + ListElement { name: "Easing.OutInBack"; type: Easing.OutInBack; ballColor: "Gainsboro" } + ListElement { name: "Easing.OutBounce"; type: Easing.OutBounce; ballColor: "Silver" } + ListElement { name: "Easing.InBounce"; type: Easing.InBounce; ballColor: "DimGray" } + ListElement { name: "Easing.InOutBounce"; type: Easing.InOutBounce; ballColor: "SlateGray" } + ListElement { name: "Easing.OutInBounce"; type: Easing.OutInBounce; ballColor: "DarkSlateGray" } + ListElement { name: "Easing.Bezier"; type: Easing.Bezier; ballColor: "Chartreuse"; } + } + + Component { + id: delegate + + Item { + height: 56; width: window.width + + Text { text: name; anchors.centerIn: parent; color: "White" } + + Rectangle { + id: slot1; color: "#121212"; x: 30; height: 46; width: 46 + border.color: "#343434"; border.width: 1; radius: 12 + anchors.verticalCenter: parent.verticalCenter + } + + Rectangle { + id: slot2; color: "#121212"; x: window.width - 76; height: 46; width: 46 + border.color: "#343434"; border.width: 1; radius: 12 + anchors.verticalCenter: parent.verticalCenter + } + + Rectangle { + id: rect; x: 30; color: "#454545" + border.color: "White"; border.width: 2 + height: 46; width: 46; radius: 12 + anchors.verticalCenter: parent.verticalCenter + + MouseArea { + onClicked: if (rect.state == '') rect.state = "right"; else rect.state = '' + anchors.fill: parent + anchors.margins: -5 // Make MouseArea bigger than the rectangle, itself + } + + states : State { + name: "right" + PropertyChanges { target: rect; x: window.width - 76; color: ballColor } + } + + transitions: Transition { + NumberAnimation { properties: "x"; easing.type: type; easing.bezierCurve: getBezierCurve(name); duration: 1000 } + ColorAnimation { properties: "color"; easing.type: type; easing.bezierCurve: getBezierCurve(name); duration: 1000 } + } + } + } + } + + Flickable { + anchors.fill: parent + contentHeight: layout.height+50 + Rectangle { + id: titlePane + color: "#444444" + height: 35 + anchors { top: parent.top; left: parent.left; right: parent.right } + QuitButton { + id: quitButton + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: 10 + } + } + Column { + id: layout + anchors { top: titlePane.bottom; topMargin: 10; left: parent.left; right: parent.right } + Repeater { model: easingTypes; delegate: delegate } + } + } + + function getBezierCurve(name) + { + if (name === "Easing.Bezier") + return easingCurve; + return []; + } +} diff --git a/examples/qml/animation/pathanimation/pathanimation.qml b/examples/qml/animation/pathanimation/pathanimation.qml new file mode 100644 index 0000000000..4d0a31bdf8 --- /dev/null +++ b/examples/qml/animation/pathanimation/pathanimation.qml @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: window + width: 400 + height: 400 + + Canvas { + id: canvas + anchors.fill: parent + smooth: true + + onPaint: { + context.clearRect(0, 0, width, height) + context.strokeStyle = "black" + context.path = pathAnim.path + context.stroke() + } + } + + PathAnimation { + id: pathAnim + + duration: 2000 + easing.type: Easing.InQuad + + target: box + orientation: PathAnimation.RightFirst + anchorPoint: Qt.point(box.width/2, box.height/2) + path: Path { + startX: 50; startY: 50 + + PathCubic { + x: window.width - 50 + y: window.height - 50 + + control1X: x; control1Y: 50 + control2X: 50; control2Y: y + } + + onChanged: canvas.requestPaint() + } + } + + Rectangle { + id: box + + x: 25; y: 25 + width: 50; height: 50 + border.width: 1 + smooth: true + + Text { + anchors.centerIn: parent + text: "Box" + } + } + + MouseArea { + anchors.fill: parent + onClicked: pathAnim.restart() + } + + Text { + text: "Click anywhere to animate along the path" + anchors.horizontalCenter: parent.horizontalCenter + } +} diff --git a/examples/qml/animation/pathinterpolator/pathinterpolator.qml b/examples/qml/animation/pathinterpolator/pathinterpolator.qml new file mode 100644 index 0000000000..67a34ce582 --- /dev/null +++ b/examples/qml/animation/pathinterpolator/pathinterpolator.qml @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: window + width: 400 + height: 400 + + Canvas { + id: canvas + anchors.fill: parent + smooth: true + + onPaint: { + context.clearRect(0, 0, width, height) + context.strokeStyle = "black" + context.path = motionPath.path + context.stroke() + } + } + + PathInterpolator { + id: motionPath + + path: Path { + startX: 50; startY: 50 + + PathCubic { + x: window.width - 50 + y: window.height - 50 + + control1X: x; control1Y: 50 + control2X: 50; control2Y: y + } + + onChanged: canvas.requestPaint() + } + + NumberAnimation on progress { + id: progressAnim + running: false + from: 0; to: 1 + duration: 2000 + easing.type: Easing.InQuad + } + } + + Rectangle { + id: box + + width: 50; height: 50 + border.width: 1 + smooth: true + + //bind our attributes to follow the path as progress changes + x: motionPath.x + y: motionPath.y + rotation: motionPath.angle + transform: Translate { x: -box.width/2; y: -box.height/2 } + + Text { + anchors.centerIn: parent + text: "Box" + } + } + + MouseArea { + anchors.fill: parent + onClicked: progressAnim.restart() + } + + Text { + text: "Click anywhere to animate along the path" + anchors.horizontalCenter: parent.horizontalCenter + } +} diff --git a/examples/qtquick/animation/states/qt-logo.png b/examples/qml/animation/states/qt-logo.png similarity index 100% rename from examples/qtquick/animation/states/qt-logo.png rename to examples/qml/animation/states/qt-logo.png diff --git a/examples/qtquick/animation/states/states.qml b/examples/qml/animation/states/states.qml similarity index 100% rename from examples/qtquick/animation/states/states.qml rename to examples/qml/animation/states/states.qml diff --git a/examples/qtquick/animation/states/transitions.qml b/examples/qml/animation/states/transitions.qml similarity index 100% rename from examples/qtquick/animation/states/transitions.qml rename to examples/qml/animation/states/transitions.qml diff --git a/examples/qml/calculator/calculator.qml b/examples/qml/calculator/calculator.qml new file mode 100644 index 0000000000..913643a93b --- /dev/null +++ b/examples/qml/calculator/calculator.qml @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Window 2.0 +import "content" +import "content/calculator.js" as CalcEngine + +Rectangle { + id: window + + width: 360; height: 480 + color: "#282828" + + property string rotateLeft: "\u2939" + property string rotateRight: "\u2935" + property string leftArrow: "\u2190" + property string division : "\u00f7" + property string multiplication : "\u00d7" + property string squareRoot : "\u221a" + property string plusminus : "\u00b1" + + function doOp(operation) { CalcEngine.doOperation(operation) } + + Item { + id: main + state: "orientation " + Screen.orientation + + property bool landscapeWindow: window.width > window.height + property real baseWidth: landscapeWindow ? window.height : window.width + property real baseHeight: landscapeWindow ? window.width : window.height + property real rotationDelta: landscapeWindow ? -90 : 0 + + rotation: rotationDelta + width: main.baseWidth + height: main.baseHeight + anchors.centerIn: parent + + Column { + id: box; spacing: 8 + + anchors { fill: parent; topMargin: 6; bottomMargin: 6; leftMargin: 6; rightMargin: 6 } + + Display { + id: display + width: box.width-3 + height: 64 + } + + Column { + id: column; spacing: 6 + + property real h: ((box.height - 72) / 6) - ((spacing * (6 - 1)) / 6) + property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) + + Row { + spacing: 6 + Button { width: column.w; height: column.h; color: 'purple'; operation: "Off" } + Button { width: column.w; height: column.h; color: 'purple'; operation: leftArrow } + Button { width: column.w; height: column.h; color: 'purple'; operation: "C" } + Button { width: column.w; height: column.h; color: 'purple'; operation: "AC" } + } + + Row { + spacing: 6 + property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) + + Button { width: column.w; height: column.h; color: 'green'; operation: "mc" } + Button { width: column.w; height: column.h; color: 'green'; operation: "m+" } + Button { width: column.w; height: column.h; color: 'green'; operation: "m-" } + Button { width: column.w; height: column.h; color: 'green'; operation: "mr" } + } + + Grid { + id: grid; rows: 5; columns: 5; spacing: 6 + + property real w: (box.width / columns) - ((spacing * (columns - 1)) / columns) + + Button { width: grid.w; height: column.h; operation: "7"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "8"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "9"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: division } + Button { width: grid.w; height: column.h; operation: squareRoot } + Button { width: grid.w; height: column.h; operation: "4"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "5"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "6"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: multiplication } + Button { width: grid.w; height: column.h; operation: "x^2" } + Button { width: grid.w; height: column.h; operation: "1"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "2"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "3"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "-" } + Button { width: grid.w; height: column.h; operation: "1/x" } + Button { width: grid.w; height: column.h; operation: "0"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "." } + Button { width: grid.w; height: column.h; operation: plusminus } + Button { width: grid.w; height: column.h; operation: "+" } + Button { width: grid.w; height: column.h; operation: "="; color: 'red' } + } + } + } + + states: [ + State { + name: "orientation " + Qt.LandscapeOrientation + PropertyChanges { target: main; rotation: 90 + rotationDelta; width: main.baseHeight; height: main.baseWidth } + }, + State { + name: "orientation " + Qt.InvertedPortraitOrientation + PropertyChanges { target: main; rotation: 180 + rotationDelta; } + }, + State { + name: "orientation " + Qt.InvertedLandscapeOrientation + PropertyChanges { target: main; rotation: 270 + rotationDelta; width: main.baseHeight; height: main.baseWidth } + } + ] + + transitions: Transition { + SequentialAnimation { + RotationAnimation { direction: RotationAnimation.Shortest; duration: 300; easing.type: Easing.InOutQuint } + NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint } + } + } + } +} diff --git a/examples/qml/calculator/content/Button.qml b/examples/qml/calculator/content/Button.qml new file mode 100644 index 0000000000..feaa5e7df3 --- /dev/null +++ b/examples/qml/calculator/content/Button.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +BorderImage { + id: button + + property alias operation: buttonText.text + property string color: "" + + Accessible.name: operation + Accessible.description: "This button does " + operation + Accessible.role: Accessible.Button + + signal clicked + + source: "images/button-" + color + ".png"; clip: true + border { left: 10; top: 10; right: 10; bottom: 10 } + + Rectangle { + id: shade + anchors.fill: button; radius: 10; color: "black"; opacity: 0 + } + + Text { + id: buttonText + anchors.centerIn: parent; anchors.verticalCenterOffset: -1 + font.pixelSize: parent.width > parent.height ? parent.height * .5 : parent.width * .5 + style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { + doOp(operation) + button.clicked() + } + } + + states: State { + name: "pressed"; when: mouseArea.pressed == true + PropertyChanges { target: shade; opacity: .4 } + } +} diff --git a/examples/qml/calculator/content/Display.qml b/examples/qml/calculator/content/Display.qml new file mode 100644 index 0000000000..3dceeab169 --- /dev/null +++ b/examples/qml/calculator/content/Display.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +BorderImage { + id: image + + property alias text : displayText.text + property alias currentOperation : operationText + + source: "images/display.png" + border { left: 10; top: 10; right: 10; bottom: 10 } + + Text { + id: displayText + anchors { + right: parent.right; verticalCenter: parent.verticalCenter; verticalCenterOffset: -1 + rightMargin: 6; left: operationText.right + } + font.pixelSize: parent.height * .6; text: "0"; horizontalAlignment: Text.AlignRight; elide: Text.ElideRight + color: "#343434"; smooth: true; font.bold: true + } + Text { + id: operationText + font.bold: true; font.pixelSize: parent.height * .7 + color: "#343434"; smooth: true + anchors { left: parent.left; leftMargin: 6; verticalCenterOffset: -3; verticalCenter: parent.verticalCenter } + } +} diff --git a/examples/qml/calculator/content/calculator.js b/examples/qml/calculator/content/calculator.js new file mode 100644 index 0000000000..7c363c7f30 --- /dev/null +++ b/examples/qml/calculator/content/calculator.js @@ -0,0 +1,91 @@ + +var curVal = 0 +var memory = 0 +var lastOp = "" +var timer = 0 + +function disabled(op) { + if (op == "." && display.text.toString().search(/\./) != -1) { + return true + } else if (op == squareRoot && display.text.toString().search(/-/) != -1) { + return true + } else { + return false + } +} + +function doOperation(op) { + if (disabled(op)) { + return + } + + if (op.toString().length==1 && ((op >= "0" && op <= "9") || op==".") ) { + if (display.text.toString().length >= 14) + return; // No arbitrary length numbers + if (lastOp.toString().length == 1 && ((lastOp >= "0" && lastOp <= "9") || lastOp == ".") ) { + display.text = display.text + op.toString() + } else { + display.text = op + } + lastOp = op + return + } + lastOp = op + + if (display.currentOperation.text == "+") { + display.text = Number(display.text.valueOf()) + Number(curVal.valueOf()) + } else if (display.currentOperation.text == "-") { + display.text = Number(curVal) - Number(display.text.valueOf()) + } else if (display.currentOperation.text == multiplication) { + display.text = Number(curVal) * Number(display.text.valueOf()) + } else if (display.currentOperation.text == division) { + display.text = Number(Number(curVal) / Number(display.text.valueOf())).toString() + } else if (display.currentOperation.text == "=") { + } + + if (op == "+" || op == "-" || op == multiplication || op == division) { + display.currentOperation.text = op + curVal = display.text.valueOf() + return + } + + curVal = 0 + display.currentOperation.text = "" + + if (op == "1/x") { + display.text = (1 / display.text.valueOf()).toString() + } else if (op == "x^2") { + display.text = (display.text.valueOf() * display.text.valueOf()).toString() + } else if (op == "Abs") { + display.text = (Math.abs(display.text.valueOf())).toString() + } else if (op == "Int") { + display.text = (Math.floor(display.text.valueOf())).toString() + } else if (op == plusminus) { + display.text = (display.text.valueOf() * -1).toString() + } else if (op == squareRoot) { + display.text = (Math.sqrt(display.text.valueOf())).toString() + } else if (op == "mc") { + memory = 0; + } else if (op == "m+") { + memory += display.text.valueOf() + } else if (op == "mr") { + display.text = memory.toString() + } else if (op == "m-") { + memory = display.text.valueOf() + } else if (op == leftArrow) { + display.text = display.text.toString().slice(0, -1) + if (display.text.length == 0) { + display.text = "0" + } + } else if (op == "Off") { + Qt.quit(); + } else if (op == "C") { + display.text = "0" + } else if (op == "AC") { + curVal = 0 + memory = 0 + lastOp = "" + display.text ="0" + } +} + diff --git a/examples/qml/calculator/content/images/button-.png b/examples/qml/calculator/content/images/button-.png new file mode 100644 index 0000000000..544e514536 Binary files /dev/null and b/examples/qml/calculator/content/images/button-.png differ diff --git a/examples/qml/calculator/content/images/button-blue.png b/examples/qml/calculator/content/images/button-blue.png new file mode 100644 index 0000000000..5f92de32d0 Binary files /dev/null and b/examples/qml/calculator/content/images/button-blue.png differ diff --git a/examples/qml/calculator/content/images/button-green.png b/examples/qml/calculator/content/images/button-green.png new file mode 100644 index 0000000000..36c93914c7 Binary files /dev/null and b/examples/qml/calculator/content/images/button-green.png differ diff --git a/examples/qml/calculator/content/images/button-purple.png b/examples/qml/calculator/content/images/button-purple.png new file mode 100644 index 0000000000..347cbbea9d Binary files /dev/null and b/examples/qml/calculator/content/images/button-purple.png differ diff --git a/examples/qml/calculator/content/images/button-red.png b/examples/qml/calculator/content/images/button-red.png new file mode 100644 index 0000000000..3b335891ae Binary files /dev/null and b/examples/qml/calculator/content/images/button-red.png differ diff --git a/examples/qml/calculator/content/images/display.png b/examples/qml/calculator/content/images/display.png new file mode 100644 index 0000000000..9507f4382e Binary files /dev/null and b/examples/qml/calculator/content/images/display.png differ diff --git a/examples/qml/calculator/content/qmldir b/examples/qml/calculator/content/qmldir new file mode 100644 index 0000000000..a926b93fac --- /dev/null +++ b/examples/qml/calculator/content/qmldir @@ -0,0 +1,2 @@ +Button Button.qml +Display Display.qml diff --git a/examples/qtquick/canvas/bezierCurve/bezierCurve.qml b/examples/qml/canvas/bezierCurve/bezierCurve.qml similarity index 100% rename from examples/qtquick/canvas/bezierCurve/bezierCurve.qml rename to examples/qml/canvas/bezierCurve/bezierCurve.qml diff --git a/examples/qtquick/canvas/clip/clip.qml b/examples/qml/canvas/clip/clip.qml similarity index 100% rename from examples/qtquick/canvas/clip/clip.qml rename to examples/qml/canvas/clip/clip.qml diff --git a/examples/qtquick/canvas/contents/Button.qml b/examples/qml/canvas/contents/Button.qml similarity index 100% rename from examples/qtquick/canvas/contents/Button.qml rename to examples/qml/canvas/contents/Button.qml diff --git a/examples/qtquick/canvas/contents/ScrollBar.qml b/examples/qml/canvas/contents/ScrollBar.qml similarity index 100% rename from examples/qtquick/canvas/contents/ScrollBar.qml rename to examples/qml/canvas/contents/ScrollBar.qml diff --git a/examples/qtquick/canvas/contents/Slider.qml b/examples/qml/canvas/contents/Slider.qml similarity index 100% rename from examples/qtquick/canvas/contents/Slider.qml rename to examples/qml/canvas/contents/Slider.qml diff --git a/examples/qtquick/canvas/contents/Stocks.qml b/examples/qml/canvas/contents/Stocks.qml similarity index 100% rename from examples/qtquick/canvas/contents/Stocks.qml rename to examples/qml/canvas/contents/Stocks.qml diff --git a/examples/qtquick/canvas/contents/TitleBar.qml b/examples/qml/canvas/contents/TitleBar.qml similarity index 100% rename from examples/qtquick/canvas/contents/TitleBar.qml rename to examples/qml/canvas/contents/TitleBar.qml diff --git a/examples/qtquick/canvas/contents/ToolBar.qml b/examples/qml/canvas/contents/ToolBar.qml similarity index 100% rename from examples/qtquick/canvas/contents/ToolBar.qml rename to examples/qml/canvas/contents/ToolBar.qml diff --git a/examples/qtquick/canvas/contents/images/button-pressed.png b/examples/qml/canvas/contents/images/button-pressed.png similarity index 100% rename from examples/qtquick/canvas/contents/images/button-pressed.png rename to examples/qml/canvas/contents/images/button-pressed.png diff --git a/examples/qtquick/canvas/contents/images/button.png b/examples/qml/canvas/contents/images/button.png similarity index 100% rename from examples/qtquick/canvas/contents/images/button.png rename to examples/qml/canvas/contents/images/button.png diff --git a/examples/qtquick/canvas/contents/images/default.svg b/examples/qml/canvas/contents/images/default.svg similarity index 100% rename from examples/qtquick/canvas/contents/images/default.svg rename to examples/qml/canvas/contents/images/default.svg diff --git a/examples/qtquick/canvas/contents/images/gloss.png b/examples/qml/canvas/contents/images/gloss.png similarity index 100% rename from examples/qtquick/canvas/contents/images/gloss.png rename to examples/qml/canvas/contents/images/gloss.png diff --git a/examples/qtquick/canvas/contents/images/lineedit.png b/examples/qml/canvas/contents/images/lineedit.png similarity index 100% rename from examples/qtquick/canvas/contents/images/lineedit.png rename to examples/qml/canvas/contents/images/lineedit.png diff --git a/examples/qtquick/canvas/contents/images/lineedit.sci b/examples/qml/canvas/contents/images/lineedit.sci similarity index 100% rename from examples/qtquick/canvas/contents/images/lineedit.sci rename to examples/qml/canvas/contents/images/lineedit.sci diff --git a/examples/qtquick/canvas/contents/images/quit.png b/examples/qml/canvas/contents/images/quit.png similarity index 100% rename from examples/qtquick/canvas/contents/images/quit.png rename to examples/qml/canvas/contents/images/quit.png diff --git a/examples/qtquick/canvas/contents/images/stripes.png b/examples/qml/canvas/contents/images/stripes.png similarity index 100% rename from examples/qtquick/canvas/contents/images/stripes.png rename to examples/qml/canvas/contents/images/stripes.png diff --git a/examples/qtquick/canvas/contents/images/titlebar.png b/examples/qml/canvas/contents/images/titlebar.png similarity index 100% rename from examples/qtquick/canvas/contents/images/titlebar.png rename to examples/qml/canvas/contents/images/titlebar.png diff --git a/examples/qtquick/canvas/contents/images/titlebar.sci b/examples/qml/canvas/contents/images/titlebar.sci similarity index 100% rename from examples/qtquick/canvas/contents/images/titlebar.sci rename to examples/qml/canvas/contents/images/titlebar.sci diff --git a/examples/qtquick/canvas/contents/images/toolbutton.png b/examples/qml/canvas/contents/images/toolbutton.png similarity index 100% rename from examples/qtquick/canvas/contents/images/toolbutton.png rename to examples/qml/canvas/contents/images/toolbutton.png diff --git a/examples/qtquick/canvas/contents/images/toolbutton.sci b/examples/qml/canvas/contents/images/toolbutton.sci similarity index 100% rename from examples/qtquick/canvas/contents/images/toolbutton.sci rename to examples/qml/canvas/contents/images/toolbutton.sci diff --git a/examples/qtquick/canvas/contents/qt-logo.png b/examples/qml/canvas/contents/qt-logo.png similarity index 100% rename from examples/qtquick/canvas/contents/qt-logo.png rename to examples/qml/canvas/contents/qt-logo.png diff --git a/examples/qtquick/canvas/quadraticCurveTo/quadraticCurveTo.qml b/examples/qml/canvas/quadraticCurveTo/quadraticCurveTo.qml similarity index 100% rename from examples/qtquick/canvas/quadraticCurveTo/quadraticCurveTo.qml rename to examples/qml/canvas/quadraticCurveTo/quadraticCurveTo.qml diff --git a/examples/qtquick/canvas/roundedrect/roundedrect.qml b/examples/qml/canvas/roundedrect/roundedrect.qml similarity index 100% rename from examples/qtquick/canvas/roundedrect/roundedrect.qml rename to examples/qml/canvas/roundedrect/roundedrect.qml diff --git a/examples/qtquick/canvas/smile/smile.qml b/examples/qml/canvas/smile/smile.qml similarity index 100% rename from examples/qtquick/canvas/smile/smile.qml rename to examples/qml/canvas/smile/smile.qml diff --git a/examples/qtquick/canvas/squircle/squircle.png b/examples/qml/canvas/squircle/squircle.png similarity index 100% rename from examples/qtquick/canvas/squircle/squircle.png rename to examples/qml/canvas/squircle/squircle.png diff --git a/examples/qtquick/canvas/squircle/squircle.qml b/examples/qml/canvas/squircle/squircle.qml similarity index 100% rename from examples/qtquick/canvas/squircle/squircle.qml rename to examples/qml/canvas/squircle/squircle.qml diff --git a/examples/qtquick/canvas/stockchart/README b/examples/qml/canvas/stockchart/README similarity index 100% rename from examples/qtquick/canvas/stockchart/README rename to examples/qml/canvas/stockchart/README diff --git a/examples/qtquick/canvas/stockchart/com/nokia/StockChartExample/qmldir b/examples/qml/canvas/stockchart/com/nokia/StockChartExample/qmldir similarity index 100% rename from examples/qtquick/canvas/stockchart/com/nokia/StockChartExample/qmldir rename to examples/qml/canvas/stockchart/com/nokia/StockChartExample/qmldir diff --git a/examples/qtquick/canvas/stockchart/model.cpp b/examples/qml/canvas/stockchart/model.cpp similarity index 100% rename from examples/qtquick/canvas/stockchart/model.cpp rename to examples/qml/canvas/stockchart/model.cpp diff --git a/examples/qtquick/canvas/stockchart/model.h b/examples/qml/canvas/stockchart/model.h similarity index 100% rename from examples/qtquick/canvas/stockchart/model.h rename to examples/qml/canvas/stockchart/model.h diff --git a/examples/qml/canvas/stockchart/plugin.cpp b/examples/qml/canvas/stockchart/plugin.cpp new file mode 100644 index 0000000000..3b354e2b31 --- /dev/null +++ b/examples/qml/canvas/stockchart/plugin.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include "model.h" + +class QStockChartExampleQmlPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT +public: + void registerTypes(const char *uri) + { + Q_ASSERT(uri == QLatin1String("com.nokia.StockChartExample")); + qmlRegisterType(uri, 1, 0, "StockModel"); + qmlRegisterType(uri, 1, 0, "StockPrice"); + } +}; + +#include "plugin.moc" + +Q_EXPORT_PLUGIN2(qmlstockchartexampleplugin, QStockChartExampleQmlPlugin); diff --git a/examples/qtquick/canvas/stockchart/stock.qml b/examples/qml/canvas/stockchart/stock.qml similarity index 100% rename from examples/qtquick/canvas/stockchart/stock.qml rename to examples/qml/canvas/stockchart/stock.qml diff --git a/examples/qml/canvas/stockchart/stockchart.pro b/examples/qml/canvas/stockchart/stockchart.pro new file mode 100644 index 0000000000..0e3ca82c44 --- /dev/null +++ b/examples/qml/canvas/stockchart/stockchart.pro @@ -0,0 +1,20 @@ +TEMPLATE = lib +CONFIG += qt plugin +QT += qml network + +DESTDIR = com/nokia/StockChartExample +TARGET = qmlstockchartexampleplugin + +SOURCES += model.cpp plugin.cpp +HEADERS += model.h +qqmlsources.files += \ + com/nokia/StockChartExample/qmldir \ + stock.qml + +qqmlsources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins/com/nokia/StockChartExample + +sources.files += stockchart.pro model.h model.cpp plugin.cpp README +sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins +target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins/com/nokia/StockChartExample + +INSTALLS += qqmlsources sources target diff --git a/examples/qtquick/canvas/tiger/tiger.js b/examples/qml/canvas/tiger/tiger.js similarity index 100% rename from examples/qtquick/canvas/tiger/tiger.js rename to examples/qml/canvas/tiger/tiger.js diff --git a/examples/qtquick/canvas/tiger/tiger.qml b/examples/qml/canvas/tiger/tiger.qml similarity index 100% rename from examples/qtquick/canvas/tiger/tiger.qml rename to examples/qml/canvas/tiger/tiger.qml diff --git a/examples/qtquick/canvas/twitterfriends/TwitterUser.qml b/examples/qml/canvas/twitterfriends/TwitterUser.qml similarity index 100% rename from examples/qtquick/canvas/twitterfriends/TwitterUser.qml rename to examples/qml/canvas/twitterfriends/TwitterUser.qml diff --git a/examples/qtquick/canvas/twitterfriends/cache.js b/examples/qml/canvas/twitterfriends/cache.js similarity index 100% rename from examples/qtquick/canvas/twitterfriends/cache.js rename to examples/qml/canvas/twitterfriends/cache.js diff --git a/examples/qtquick/canvas/twitterfriends/twitter.qml b/examples/qml/canvas/twitterfriends/twitter.qml similarity index 100% rename from examples/qtquick/canvas/twitterfriends/twitter.qml rename to examples/qml/canvas/twitterfriends/twitter.qml diff --git a/examples/qml/cppextensions/imageprovider/imageprovider.cpp b/examples/qml/cppextensions/imageprovider/imageprovider.cpp index 7fe4b72c08..f6632a89e8 100644 --- a/examples/qml/cppextensions/imageprovider/imageprovider.cpp +++ b/examples/qml/cppextensions/imageprovider/imageprovider.cpp @@ -39,19 +39,19 @@ ****************************************************************************/ -#include +#include -#include -#include +#include +#include #include #include //![0] -class ColorImageProvider : public QDeclarativeImageProvider +class ColorImageProvider : public QQmlImageProvider { public: ColorImageProvider() - : QDeclarativeImageProvider(QDeclarativeImageProvider::Pixmap) + : QQmlImageProvider(QQmlImageProvider::Pixmap) { } @@ -84,17 +84,17 @@ class ColorImageProvider : public QDeclarativeImageProvider //![1] -class ImageProviderExtensionPlugin : public QDeclarativeExtensionPlugin +class ImageProviderExtensionPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "imageprovider.json") + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "imageprovider.json") public: void registerTypes(const char *uri) { Q_UNUSED(uri); } - void initializeEngine(QDeclarativeEngine *engine, const char *uri) + void initializeEngine(QQmlEngine *engine, const char *uri) { Q_UNUSED(uri); engine->addImageProvider("colors", new ColorImageProvider); @@ -103,7 +103,7 @@ class ImageProviderExtensionPlugin : public QDeclarativeExtensionPlugin }; -#define QDeclarativeExtensionInterface_iid "org.qt-project.Qt.QDeclarativeExtensionInterface" +#define QQmlExtensionInterface_iid "org.qt-project.Qt.QQmlExtensionInterface" #include "imageprovider.moc" diff --git a/examples/qml/cppextensions/imageprovider/imageprovider.pro b/examples/qml/cppextensions/imageprovider/imageprovider.pro index dd128d56a8..b4a832b720 100644 --- a/examples/qml/cppextensions/imageprovider/imageprovider.pro +++ b/examples/qml/cppextensions/imageprovider/imageprovider.pro @@ -1,6 +1,6 @@ TEMPLATE = lib CONFIG += qt plugin -QT += declarative +QT += qml DESTDIR = ImageProviderCore TARGET = qmlimageproviderplugin @@ -10,13 +10,13 @@ SOURCES += imageprovider.cpp OTHER_FILES += imageprovider.json sources.files = $$SOURCES imageprovider.qml imageprovider.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/imageprovider +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/imageprovider -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/imageprovider/ImageProviderCore +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/imageprovider/ImageProviderCore ImageProviderCore_sources.files = \ ImageProviderCore/qmldir -ImageProviderCore_sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/imageprovider/ImageProviderCore +ImageProviderCore_sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/imageprovider/ImageProviderCore INSTALLS = sources ImageProviderCore_sources target diff --git a/examples/qml/cppextensions/networkaccessmanagerfactory/main.cpp b/examples/qml/cppextensions/networkaccessmanagerfactory/main.cpp index 2bad2aa285..6ebded0512 100644 --- a/examples/qml/cppextensions/networkaccessmanagerfactory/main.cpp +++ b/examples/qml/cppextensions/networkaccessmanagerfactory/main.cpp @@ -42,13 +42,13 @@ #include #include -#include -#include +#include +#include #include /* - This example illustrates using a QDeclarativeNetworkAccessManagerFactory to + This example illustrates using a QQmlNetworkAccessManagerFactory to create a QNetworkAccessManager with a proxy. Usage: @@ -58,7 +58,7 @@ static QString proxyHost; static int proxyPort = 0; -class MyNetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory +class MyNetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory { public: virtual QNetworkAccessManager *create(QObject *parent); diff --git a/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro b/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro index 479af364d0..6cbc24a7b8 100644 --- a/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro +++ b/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro @@ -1,4 +1,4 @@ -QT += declarative quick network +QT += qml quick network SOURCES += main.cpp RESOURCES += networkaccessmanagerfactory.qrc diff --git a/examples/qml/cppextensions/plugins/plugin.cpp b/examples/qml/cppextensions/plugins/plugin.cpp index 4ba0a928eb..5e9900cb4f 100644 --- a/examples/qml/cppextensions/plugins/plugin.cpp +++ b/examples/qml/cppextensions/plugins/plugin.cpp @@ -38,8 +38,8 @@ ** ****************************************************************************/ -#include -#include +#include +#include #include #include #include @@ -138,10 +138,10 @@ int TimeModel::instances=0; MinuteTimer *TimeModel::timer=0; //![plugin] -class QExampleQmlPlugin : public QDeclarativeExtensionPlugin +class QExampleQmlPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "plugin.json") + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "plugin.json") public: void registerTypes(const char *uri) diff --git a/examples/qml/cppextensions/plugins/plugins.pro b/examples/qml/cppextensions/plugins/plugins.pro index a28582a07a..08a4d1a61c 100644 --- a/examples/qml/cppextensions/plugins/plugins.pro +++ b/examples/qml/cppextensions/plugins/plugins.pro @@ -1,6 +1,6 @@ TEMPLATE = lib CONFIG += qt plugin -QT += declarative +QT += qml DESTDIR = com/nokia/TimeExample TARGET = qmlqtimeexampleplugin @@ -17,11 +17,11 @@ qdeclarativesources.files += \ com/nokia/TimeExample/hour.png \ com/nokia/TimeExample/minute.png -qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins/com/nokia/TimeExample +qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins/com/nokia/TimeExample sources.files += plugins.pro plugin.cpp plugins.qml README -sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins -target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins/com/nokia/TimeExample +sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins +target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins/com/nokia/TimeExample INSTALLS += qdeclarativesources sources target diff --git a/examples/qml/cppextensions/referenceexamples/adding/adding.pro b/examples/qml/cppextensions/referenceexamples/adding/adding.pro index 1a972926b7..706322e9ff 100644 --- a/examples/qml/cppextensions/referenceexamples/adding/adding.pro +++ b/examples/qml/cppextensions/referenceexamples/adding/adding.pro @@ -1,11 +1,11 @@ -QT += declarative +QT += qml SOURCES += main.cpp \ person.cpp HEADERS += person.h RESOURCES += adding.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/adding +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/adding sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS adding.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/adding +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/adding INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/adding/main.cpp b/examples/qml/cppextensions/referenceexamples/adding/main.cpp index 4c1918b6de..c3a0ab6812 100644 --- a/examples/qml/cppextensions/referenceexamples/adding/main.cpp +++ b/examples/qml/cppextensions/referenceexamples/adding/main.cpp @@ -38,8 +38,8 @@ ** ****************************************************************************/ #include -#include -#include +#include +#include #include #include "person.h" @@ -50,8 +50,8 @@ int main(int argc, char ** argv) qmlRegisterType("People", 1,0, "Person"); //![0] - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:example.qml")); Person *person = qobject_cast(component.create()); if (person) { qWarning() << "The person's name is" << person->name(); diff --git a/examples/qml/cppextensions/referenceexamples/attached/attached.pro b/examples/qml/cppextensions/referenceexamples/attached/attached.pro index 4cfd4e0aed..f4385e1a30 100644 --- a/examples/qml/cppextensions/referenceexamples/attached/attached.pro +++ b/examples/qml/cppextensions/referenceexamples/attached/attached.pro @@ -1,4 +1,4 @@ -QT += declarative +QT += qml SOURCES += main.cpp \ person.cpp \ @@ -7,7 +7,7 @@ HEADERS += person.h \ birthdayparty.h RESOURCES += attached.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/attached +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/attached sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS attached.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/attached +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/attached INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp index feefef4fe1..c4f906119a 100644 --- a/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp +++ b/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp @@ -69,9 +69,9 @@ void BirthdayParty::setHost(Person *c) m_host = c; } -QDeclarativeListProperty BirthdayParty::guests() +QQmlListProperty BirthdayParty::guests() { - return QDeclarativeListProperty(this, m_guests); + return QQmlListProperty(this, m_guests); } int BirthdayParty::guestCount() const diff --git a/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.h index c789c0bd51..1da6c34026 100644 --- a/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.h +++ b/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.h @@ -42,7 +42,7 @@ #include #include -#include +#include #include "person.h" class BirthdayPartyAttached : public QObject @@ -63,7 +63,7 @@ class BirthdayParty : public QObject { Q_OBJECT Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_PROPERTY(QQmlListProperty guests READ guests) Q_CLASSINFO("DefaultProperty", "guests") public: BirthdayParty(QObject *parent = 0); @@ -71,7 +71,7 @@ class BirthdayParty : public QObject Person *host() const; void setHost(Person *); - QDeclarativeListProperty guests(); + QQmlListProperty guests(); int guestCount() const; Person *guest(int) const; diff --git a/examples/qml/cppextensions/referenceexamples/attached/main.cpp b/examples/qml/cppextensions/referenceexamples/attached/main.cpp index 4c2c3003fe..ce067bbbf7 100644 --- a/examples/qml/cppextensions/referenceexamples/attached/main.cpp +++ b/examples/qml/cppextensions/referenceexamples/attached/main.cpp @@ -38,8 +38,8 @@ ** ****************************************************************************/ #include -#include -#include +#include +#include #include #include "birthdayparty.h" #include "person.h" @@ -55,8 +55,8 @@ int main(int argc, char ** argv) qmlRegisterType("People", 1,0, "Boy"); qmlRegisterType("People", 1,0, "Girl"); - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:example.qml")); BirthdayParty *party = qobject_cast(component.create()); if (party && party->host()) { diff --git a/examples/qml/cppextensions/referenceexamples/binding/binding.pro b/examples/qml/cppextensions/referenceexamples/binding/binding.pro index 2add33fa47..0379f93ea7 100644 --- a/examples/qml/cppextensions/referenceexamples/binding/binding.pro +++ b/examples/qml/cppextensions/referenceexamples/binding/binding.pro @@ -1,4 +1,4 @@ -QT += declarative +QT += qml SOURCES += main.cpp \ person.cpp \ @@ -9,7 +9,7 @@ HEADERS += person.h \ happybirthdaysong.h RESOURCES += binding.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/binding +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/binding sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS binding.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/binding +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/binding INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp index 4f5acdfb75..62499862f0 100644 --- a/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp +++ b/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp @@ -75,9 +75,9 @@ void BirthdayParty::setHost(Person *c) emit hostChanged(); } -QDeclarativeListProperty BirthdayParty::guests() +QQmlListProperty BirthdayParty::guests() { - return QDeclarativeListProperty(this, m_guests); + return QQmlListProperty(this, m_guests); } int BirthdayParty::guestCount() const diff --git a/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.h index 376d107f26..195e9cd9cf 100644 --- a/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.h +++ b/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.h @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include "person.h" class BirthdayPartyAttached : public QObject @@ -69,7 +69,7 @@ class BirthdayParty : public QObject // ![0] Q_PROPERTY(Person *host READ host WRITE setHost NOTIFY hostChanged) // ![0] - Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_PROPERTY(QQmlListProperty guests READ guests) Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement) Q_CLASSINFO("DefaultProperty", "guests") public: @@ -78,7 +78,7 @@ class BirthdayParty : public QObject Person *host() const; void setHost(Person *); - QDeclarativeListProperty guests(); + QQmlListProperty guests(); int guestCount() const; Person *guest(int) const; diff --git a/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.cpp b/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.cpp index df4dbec9c4..90220e15ae 100644 --- a/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.cpp +++ b/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.cpp @@ -49,7 +49,7 @@ HappyBirthdaySong::HappyBirthdaySong(QObject *parent) timer->start(1000); } -void HappyBirthdaySong::setTarget(const QDeclarativeProperty &p) +void HappyBirthdaySong::setTarget(const QQmlProperty &p) { m_target = p; } diff --git a/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.h b/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.h index a9f3a94544..ace48b2af0 100644 --- a/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.h +++ b/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.h @@ -40,20 +40,20 @@ #ifndef HAPPYBIRTHDAYSONG_H #define HAPPYBIRTHDAYSONG_H -#include -#include +#include +#include #include -class HappyBirthdaySong : public QObject, public QDeclarativePropertyValueSource +class HappyBirthdaySong : public QObject, public QQmlPropertyValueSource { Q_OBJECT Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_INTERFACES(QDeclarativePropertyValueSource) + Q_INTERFACES(QQmlPropertyValueSource) public: HappyBirthdaySong(QObject *parent = 0); - virtual void setTarget(const QDeclarativeProperty &); + virtual void setTarget(const QQmlProperty &); QString name() const; void setName(const QString &); @@ -66,7 +66,7 @@ private slots: private: int m_line; QStringList m_lyrics; - QDeclarativeProperty m_target; + QQmlProperty m_target; QString m_name; }; diff --git a/examples/qml/cppextensions/referenceexamples/binding/main.cpp b/examples/qml/cppextensions/referenceexamples/binding/main.cpp index 551d24b702..389cb7609b 100644 --- a/examples/qml/cppextensions/referenceexamples/binding/main.cpp +++ b/examples/qml/cppextensions/referenceexamples/binding/main.cpp @@ -38,8 +38,8 @@ ** ****************************************************************************/ #include -#include -#include +#include +#include #include #include "birthdayparty.h" #include "happybirthdaysong.h" @@ -56,8 +56,8 @@ int main(int argc, char ** argv) qmlRegisterType("People", 1,0, "Boy"); qmlRegisterType("People", 1,0, "Girl"); - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:example.qml")); BirthdayParty *party = qobject_cast(component.create()); if (party && party->host()) { diff --git a/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp index 1859ca9461..e15ffe1604 100644 --- a/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp +++ b/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp @@ -54,9 +54,9 @@ void BirthdayParty::setHost(Person *c) m_host = c; } -QDeclarativeListProperty BirthdayParty::guests() +QQmlListProperty BirthdayParty::guests() { - return QDeclarativeListProperty(this, m_guests); + return QQmlListProperty(this, m_guests); } int BirthdayParty::guestCount() const diff --git a/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.h index 4315d3727e..43611693d9 100644 --- a/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.h +++ b/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.h @@ -41,7 +41,7 @@ #define BIRTHDAYPARTY_H #include -#include +#include #include "person.h" class BirthdayParty : public QObject @@ -49,7 +49,7 @@ class BirthdayParty : public QObject Q_OBJECT // ![0] Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_PROPERTY(QQmlListProperty guests READ guests) // ![0] public: BirthdayParty(QObject *parent = 0); @@ -57,7 +57,7 @@ class BirthdayParty : public QObject Person *host() const; void setHost(Person *); - QDeclarativeListProperty guests(); + QQmlListProperty guests(); int guestCount() const; Person *guest(int) const; diff --git a/examples/qml/cppextensions/referenceexamples/coercion/coercion.pro b/examples/qml/cppextensions/referenceexamples/coercion/coercion.pro index 742b85b683..60e8532bab 100644 --- a/examples/qml/cppextensions/referenceexamples/coercion/coercion.pro +++ b/examples/qml/cppextensions/referenceexamples/coercion/coercion.pro @@ -1,4 +1,4 @@ -QT += declarative +QT += qml SOURCES += main.cpp \ person.cpp \ @@ -7,7 +7,7 @@ HEADERS += person.h \ birthdayparty.h RESOURCES += coercion.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/coercion +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/coercion sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS coercion.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/coercion +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/coercion INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/coercion/main.cpp b/examples/qml/cppextensions/referenceexamples/coercion/main.cpp index 95b309de4c..15e41ca597 100644 --- a/examples/qml/cppextensions/referenceexamples/coercion/main.cpp +++ b/examples/qml/cppextensions/referenceexamples/coercion/main.cpp @@ -38,8 +38,8 @@ ** ****************************************************************************/ #include -#include -#include +#include +#include #include #include "birthdayparty.h" #include "person.h" @@ -58,8 +58,8 @@ int main(int argc, char ** argv) qmlRegisterType("People", 1,0, "Girl"); //![register boy girl] - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:example.qml")); BirthdayParty *party = qobject_cast(component.create()); if (party && party->host()) { diff --git a/examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp index 1859ca9461..e15ffe1604 100644 --- a/examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp +++ b/examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp @@ -54,9 +54,9 @@ void BirthdayParty::setHost(Person *c) m_host = c; } -QDeclarativeListProperty BirthdayParty::guests() +QQmlListProperty BirthdayParty::guests() { - return QDeclarativeListProperty(this, m_guests); + return QQmlListProperty(this, m_guests); } int BirthdayParty::guestCount() const diff --git a/examples/qml/cppextensions/referenceexamples/default/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/default/birthdayparty.h index cfca6689db..3ee635039d 100644 --- a/examples/qml/cppextensions/referenceexamples/default/birthdayparty.h +++ b/examples/qml/cppextensions/referenceexamples/default/birthdayparty.h @@ -41,7 +41,7 @@ #define BIRTHDAYPARTY_H #include -#include +#include #include "person.h" // ![0] @@ -49,7 +49,7 @@ class BirthdayParty : public QObject { Q_OBJECT Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_PROPERTY(QQmlListProperty guests READ guests) Q_CLASSINFO("DefaultProperty", "guests") public: BirthdayParty(QObject *parent = 0); @@ -57,7 +57,7 @@ class BirthdayParty : public QObject Person *host() const; void setHost(Person *); - QDeclarativeListProperty guests(); + QQmlListProperty guests(); int guestCount() const; Person *guest(int) const; diff --git a/examples/qml/cppextensions/referenceexamples/default/default.pro b/examples/qml/cppextensions/referenceexamples/default/default.pro index 6533cdd7d3..36ef39fc55 100644 --- a/examples/qml/cppextensions/referenceexamples/default/default.pro +++ b/examples/qml/cppextensions/referenceexamples/default/default.pro @@ -1,4 +1,4 @@ -QT += declarative +QT += qml SOURCES += main.cpp \ person.cpp \ @@ -7,7 +7,7 @@ HEADERS += person.h \ birthdayparty.h RESOURCES += default.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/default +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/default sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS default.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/default +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/default INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/default/main.cpp b/examples/qml/cppextensions/referenceexamples/default/main.cpp index 3a03279129..175945fc5d 100644 --- a/examples/qml/cppextensions/referenceexamples/default/main.cpp +++ b/examples/qml/cppextensions/referenceexamples/default/main.cpp @@ -38,8 +38,8 @@ ** ****************************************************************************/ #include -#include -#include +#include +#include #include #include "birthdayparty.h" #include "person.h" @@ -53,8 +53,8 @@ int main(int argc, char ** argv) qmlRegisterType("People", 1,0, "Boy"); qmlRegisterType("People", 1,0, "Girl"); - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:example.qml")); BirthdayParty *party = qobject_cast(component.create()); if (party && party->host()) { diff --git a/examples/qml/cppextensions/referenceexamples/extended/extended.pro b/examples/qml/cppextensions/referenceexamples/extended/extended.pro index 3d9f59c470..206ea19c61 100644 --- a/examples/qml/cppextensions/referenceexamples/extended/extended.pro +++ b/examples/qml/cppextensions/referenceexamples/extended/extended.pro @@ -1,11 +1,11 @@ -QT += declarative widgets +QT += qml widgets SOURCES += main.cpp \ lineedit.cpp HEADERS += lineedit.h RESOURCES += extended.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/extended +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/extended sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS extended.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/extended +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/extended INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/extended/lineedit.cpp b/examples/qml/cppextensions/referenceexamples/extended/lineedit.cpp index 8f7fd8aa93..a3b1d0d54e 100644 --- a/examples/qml/cppextensions/referenceexamples/extended/lineedit.cpp +++ b/examples/qml/cppextensions/referenceexamples/extended/lineedit.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ #include "lineedit.h" -#include +#include LineEditExtension::LineEditExtension(QObject *object) : QObject(object), m_lineedit(static_cast(object)) diff --git a/examples/qml/cppextensions/referenceexamples/extended/main.cpp b/examples/qml/cppextensions/referenceexamples/extended/main.cpp index 3c580396f2..de7c450169 100644 --- a/examples/qml/cppextensions/referenceexamples/extended/main.cpp +++ b/examples/qml/cppextensions/referenceexamples/extended/main.cpp @@ -38,8 +38,8 @@ ** ****************************************************************************/ #include -#include -#include +#include +#include #include #include #include "lineedit.h" @@ -50,8 +50,8 @@ int main(int argc, char ** argv) qmlRegisterExtendedType("People", 1,0, "QLineEdit"); - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:example.qml")); QLineEdit *edit = qobject_cast(component.create()); if (edit) { diff --git a/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp index 1859ca9461..e15ffe1604 100644 --- a/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp +++ b/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp @@ -54,9 +54,9 @@ void BirthdayParty::setHost(Person *c) m_host = c; } -QDeclarativeListProperty BirthdayParty::guests() +QQmlListProperty BirthdayParty::guests() { - return QDeclarativeListProperty(this, m_guests); + return QQmlListProperty(this, m_guests); } int BirthdayParty::guestCount() const diff --git a/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.h index 491903adc5..5ca0e9b982 100644 --- a/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.h +++ b/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.h @@ -41,14 +41,14 @@ #define BIRTHDAYPARTY_H #include -#include +#include #include "person.h" class BirthdayParty : public QObject { Q_OBJECT Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_PROPERTY(QQmlListProperty guests READ guests) Q_CLASSINFO("DefaultProperty", "guests") public: BirthdayParty(QObject *parent = 0); @@ -56,7 +56,7 @@ class BirthdayParty : public QObject Person *host() const; void setHost(Person *); - QDeclarativeListProperty guests(); + QQmlListProperty guests(); int guestCount() const; Person *guest(int) const; diff --git a/examples/qml/cppextensions/referenceexamples/grouped/grouped.pro b/examples/qml/cppextensions/referenceexamples/grouped/grouped.pro index aab0c8469a..d32a98f79b 100644 --- a/examples/qml/cppextensions/referenceexamples/grouped/grouped.pro +++ b/examples/qml/cppextensions/referenceexamples/grouped/grouped.pro @@ -1,4 +1,4 @@ -QT += declarative +QT += qml SOURCES += main.cpp \ person.cpp \ @@ -7,7 +7,7 @@ HEADERS += person.h \ birthdayparty.h RESOURCES += grouped.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/grouped +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/grouped sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS grouped.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/grouped +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/grouped INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/grouped/main.cpp b/examples/qml/cppextensions/referenceexamples/grouped/main.cpp index de7d714c52..55be3b715b 100644 --- a/examples/qml/cppextensions/referenceexamples/grouped/main.cpp +++ b/examples/qml/cppextensions/referenceexamples/grouped/main.cpp @@ -38,8 +38,8 @@ ** ****************************************************************************/ #include -#include -#include +#include +#include #include #include "birthdayparty.h" #include "person.h" @@ -54,8 +54,8 @@ int main(int argc, char ** argv) qmlRegisterType("People", 1,0, "Boy"); qmlRegisterType("People", 1,0, "Girl"); - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:example.qml")); BirthdayParty *party = qobject_cast(component.create()); if (party && party->host()) { diff --git a/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp index 35444f505a..c96f41d944 100644 --- a/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp +++ b/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp @@ -55,9 +55,9 @@ void BirthdayParty::setHost(Person *c) m_host = c; } -QDeclarativeListProperty BirthdayParty::guests() +QQmlListProperty BirthdayParty::guests() { - return QDeclarativeListProperty(this, m_guests); + return QQmlListProperty(this, m_guests); } int BirthdayParty::guestCount() const diff --git a/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.h index e49afdb78d..df8a859972 100644 --- a/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.h +++ b/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.h @@ -41,21 +41,21 @@ #define BIRTHDAYPARTY_H #include -#include +#include #include "person.h" class BirthdayParty : public QObject { Q_OBJECT Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_PROPERTY(QQmlListProperty guests READ guests) public: BirthdayParty(QObject *parent = 0); Person *host() const; void setHost(Person *); - QDeclarativeListProperty guests(); + QQmlListProperty guests(); int guestCount() const; Person *guest(int) const; diff --git a/examples/qml/cppextensions/referenceexamples/methods/main.cpp b/examples/qml/cppextensions/referenceexamples/methods/main.cpp index d037d88f20..1e502c3943 100644 --- a/examples/qml/cppextensions/referenceexamples/methods/main.cpp +++ b/examples/qml/cppextensions/referenceexamples/methods/main.cpp @@ -38,8 +38,8 @@ ** ****************************************************************************/ #include -#include -#include +#include +#include #include #include "birthdayparty.h" #include "person.h" @@ -51,8 +51,8 @@ int main(int argc, char ** argv) qmlRegisterType("People", 1,0, "BirthdayParty"); qmlRegisterType("People", 1,0, "Person"); - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:example.qml")); BirthdayParty *party = qobject_cast(component.create()); if (party && party->host()) { diff --git a/examples/qml/cppextensions/referenceexamples/methods/methods.pro b/examples/qml/cppextensions/referenceexamples/methods/methods.pro index ee28355188..f4c63bfa29 100644 --- a/examples/qml/cppextensions/referenceexamples/methods/methods.pro +++ b/examples/qml/cppextensions/referenceexamples/methods/methods.pro @@ -1,4 +1,4 @@ -QT += declarative +QT += qml SOURCES += main.cpp \ person.cpp \ @@ -7,7 +7,7 @@ HEADERS += person.h \ birthdayparty.h RESOURCES += methods.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/methods +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/methods sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS methods.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/methods +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/methods INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp index 0038cd0a41..8e79d07748 100644 --- a/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp +++ b/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp @@ -55,9 +55,9 @@ void BirthdayParty::setHost(Person *c) m_host = c; } -QDeclarativeListProperty BirthdayParty::guests() +QQmlListProperty BirthdayParty::guests() { - return QDeclarativeListProperty(this, m_guests); + return QQmlListProperty(this, m_guests); } int BirthdayParty::guestCount() const diff --git a/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.h index 2c3d128b6d..84eefa52ae 100644 --- a/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.h +++ b/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.h @@ -41,7 +41,7 @@ #define BIRTHDAYPARTY_H #include -#include +#include #include "person.h" // ![0] @@ -53,7 +53,7 @@ class BirthdayParty : public QObject Q_PROPERTY(Person *host READ host WRITE setHost) // ![1] // ![2] - Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_PROPERTY(QQmlListProperty guests READ guests) // ![2] // ![3] public: @@ -62,7 +62,7 @@ class BirthdayParty : public QObject Person *host() const; void setHost(Person *); - QDeclarativeListProperty guests(); + QQmlListProperty guests(); int guestCount() const; Person *guest(int) const; diff --git a/examples/qml/cppextensions/referenceexamples/properties/main.cpp b/examples/qml/cppextensions/referenceexamples/properties/main.cpp index 421ce9fbaa..cc0de89221 100644 --- a/examples/qml/cppextensions/referenceexamples/properties/main.cpp +++ b/examples/qml/cppextensions/referenceexamples/properties/main.cpp @@ -38,8 +38,8 @@ ** ****************************************************************************/ #include -#include -#include +#include +#include #include #include "birthdayparty.h" #include "person.h" @@ -53,8 +53,8 @@ int main(int argc, char ** argv) qmlRegisterType("People", 1,0, "Person"); //![register list] - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:example.qml")); BirthdayParty *party = qobject_cast(component.create()); if (party && party->host()) { diff --git a/examples/qml/cppextensions/referenceexamples/properties/properties.pro b/examples/qml/cppextensions/referenceexamples/properties/properties.pro index 936d0ea429..e079b1f79e 100644 --- a/examples/qml/cppextensions/referenceexamples/properties/properties.pro +++ b/examples/qml/cppextensions/referenceexamples/properties/properties.pro @@ -1,4 +1,4 @@ -QT += declarative +QT += qml SOURCES += main.cpp \ person.cpp \ @@ -7,7 +7,7 @@ HEADERS += person.h \ birthdayparty.h RESOURCES += properties.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/properties +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/properties sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS properties.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/properties +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/properties INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp index d576c2a278..b9f7e15907 100644 --- a/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp +++ b/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp @@ -70,9 +70,9 @@ void BirthdayParty::setHost(Person *c) m_host = c; } -QDeclarativeListProperty BirthdayParty::guests() +QQmlListProperty BirthdayParty::guests() { - return QDeclarativeListProperty(this, m_guests); + return QQmlListProperty(this, m_guests); } int BirthdayParty::guestCount() const diff --git a/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.h index 45ad4f0acf..3f1b020b5a 100644 --- a/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.h +++ b/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.h @@ -42,7 +42,7 @@ #include #include -#include +#include #include "person.h" class BirthdayPartyAttached : public QObject @@ -63,7 +63,7 @@ class BirthdayParty : public QObject { Q_OBJECT Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_PROPERTY(QQmlListProperty guests READ guests) Q_CLASSINFO("DefaultProperty", "guests") public: BirthdayParty(QObject *parent = 0); @@ -71,7 +71,7 @@ class BirthdayParty : public QObject Person *host() const; void setHost(Person *); - QDeclarativeListProperty guests(); + QQmlListProperty guests(); int guestCount() const; Person *guest(int) const; diff --git a/examples/qml/cppextensions/referenceexamples/signal/main.cpp b/examples/qml/cppextensions/referenceexamples/signal/main.cpp index 5800cf450f..21a26d9b67 100644 --- a/examples/qml/cppextensions/referenceexamples/signal/main.cpp +++ b/examples/qml/cppextensions/referenceexamples/signal/main.cpp @@ -38,8 +38,8 @@ ** ****************************************************************************/ #include -#include -#include +#include +#include #include #include "birthdayparty.h" #include "person.h" @@ -55,8 +55,8 @@ int main(int argc, char ** argv) qmlRegisterType("People", 1,0, "Boy"); qmlRegisterType("People", 1,0, "Girl"); - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:example.qml")); BirthdayParty *party = qobject_cast(component.create()); if (party && party->host()) { diff --git a/examples/qml/cppextensions/referenceexamples/signal/signal.pro b/examples/qml/cppextensions/referenceexamples/signal/signal.pro index 8ffdb50f90..d426e398a5 100644 --- a/examples/qml/cppextensions/referenceexamples/signal/signal.pro +++ b/examples/qml/cppextensions/referenceexamples/signal/signal.pro @@ -1,4 +1,4 @@ -QT += declarative +QT += qml SOURCES += main.cpp \ person.cpp \ @@ -7,7 +7,7 @@ HEADERS += person.h \ birthdayparty.h RESOURCES += signal.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/signal +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/signal sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS signal.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/signal +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/signal INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp index 09137c41a8..aa8bc77116 100644 --- a/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp +++ b/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp @@ -70,9 +70,9 @@ void BirthdayParty::setHost(Person *c) m_host = c; } -QDeclarativeListProperty BirthdayParty::guests() +QQmlListProperty BirthdayParty::guests() { - return QDeclarativeListProperty(this, m_guests); + return QQmlListProperty(this, m_guests); } int BirthdayParty::guestCount() const diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.h index 5d561da807..f3635e899b 100644 --- a/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.h +++ b/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.h @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include "person.h" class BirthdayPartyAttached : public QObject @@ -64,7 +64,7 @@ class BirthdayParty : public QObject { Q_OBJECT Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_PROPERTY(QQmlListProperty guests READ guests) // ![0] Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement) // ![0] @@ -75,7 +75,7 @@ class BirthdayParty : public QObject Person *host() const; void setHost(Person *); - QDeclarativeListProperty guests(); + QQmlListProperty guests(); int guestCount() const; Person *guest(int) const; diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp b/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp index 629c354543..d69154b57a 100644 --- a/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp +++ b/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp @@ -49,7 +49,7 @@ HappyBirthdaySong::HappyBirthdaySong(QObject *parent) timer->start(1000); } -void HappyBirthdaySong::setTarget(const QDeclarativeProperty &p) +void HappyBirthdaySong::setTarget(const QQmlProperty &p) { m_target = p; } diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.h b/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.h index 9721350435..19e47c28ac 100644 --- a/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.h +++ b/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.h @@ -40,24 +40,24 @@ #ifndef HAPPYBIRTHDAYSONG_H #define HAPPYBIRTHDAYSONG_H -#include -#include -#include +#include +#include +#include #include // ![0] -class HappyBirthdaySong : public QObject, public QDeclarativePropertyValueSource +class HappyBirthdaySong : public QObject, public QQmlPropertyValueSource { Q_OBJECT - Q_INTERFACES(QDeclarativePropertyValueSource) + Q_INTERFACES(QQmlPropertyValueSource) // ![0] Q_PROPERTY(QString name READ name WRITE setName) // ![1] public: HappyBirthdaySong(QObject *parent = 0); - virtual void setTarget(const QDeclarativeProperty &); + virtual void setTarget(const QQmlProperty &); // ![1] QString name() const; @@ -69,7 +69,7 @@ private slots: private: int m_line; QStringList m_lyrics; - QDeclarativeProperty m_target; + QQmlProperty m_target; QString m_name; // ![2] }; diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/main.cpp b/examples/qml/cppextensions/referenceexamples/valuesource/main.cpp index 53d676dfbe..e119e719af 100644 --- a/examples/qml/cppextensions/referenceexamples/valuesource/main.cpp +++ b/examples/qml/cppextensions/referenceexamples/valuesource/main.cpp @@ -38,8 +38,8 @@ ** ****************************************************************************/ #include -#include -#include +#include +#include #include #include "birthdayparty.h" #include "happybirthdaysong.h" @@ -57,8 +57,8 @@ int main(int argc, char ** argv) qmlRegisterType("People", 1,0, "Boy"); qmlRegisterType("People", 1,0, "Girl"); - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:example.qml")); BirthdayParty *party = qobject_cast(component.create()); if (party && party->host()) { diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.pro b/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.pro index a978d8452a..afc1784d71 100644 --- a/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.pro +++ b/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.pro @@ -1,4 +1,4 @@ -QT += declarative +QT += qml SOURCES += main.cpp \ person.cpp \ @@ -9,7 +9,7 @@ HEADERS += person.h \ happybirthdaysong.h RESOURCES += valuesource.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/valuesource +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/valuesource sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS valuesource.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/valuesource +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/valuesource INSTALLS += target sources diff --git a/examples/qtquick/modelviews/objectlistmodel/objectlistmodel.qmlproject b/examples/qml/draganddrop/dragtarget.qmlproject similarity index 100% rename from examples/qtquick/modelviews/objectlistmodel/objectlistmodel.qmlproject rename to examples/qml/draganddrop/dragtarget.qmlproject diff --git a/examples/qml/draganddrop/tiles/DragTile.qml b/examples/qml/draganddrop/tiles/DragTile.qml new file mode 100644 index 0000000000..2813fa8caf --- /dev/null +++ b/examples/qml/draganddrop/tiles/DragTile.qml @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root + property string colorKey + + width: 100; height: 100 + + MouseArea { + id: mouseArea + + width: 100; height: 100 + anchors.centerIn: parent + + drag.target: tile + + onReleased: parent = tile.Drag.target !== null ? tile.Drag.target : root + + Rectangle { + id: tile + + width: 100; height: 100 + + anchors.horizontalCenter: parent.horizontalCenter; anchors.verticalCenter: parent.verticalCenter + color: colorKey + + Drag.keys: [ colorKey ] + Drag.active: mouseArea.drag.active + Drag.hotSpot.x: 50 + Drag.hotSpot.y: 50 + + Text { + anchors.fill: parent + color: "white" + font.pixelSize: 90 + text: modelData + 1 + horizontalAlignment:Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + + states: State { + when: mouseArea.drag.active + ParentChange { target: tile; parent: root } + AnchorChanges { target: tile; anchors.verticalCenter: undefined; anchors.horizontalCenter: undefined } + } + } + } +} + diff --git a/examples/qml/draganddrop/tiles/DropTile.qml b/examples/qml/draganddrop/tiles/DropTile.qml new file mode 100644 index 0000000000..e8566f04cc --- /dev/null +++ b/examples/qml/draganddrop/tiles/DropTile.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +DropArea { + id: dragTarget + + property string colorKey + property alias dropProxy: dragTarget + + width: 100; height: 100 + keys: [ colorKey ] + + Rectangle { + id: dropRectangle + + anchors.fill: parent + color: colorKey + + states: [ + State { + when: dragTarget.containsDrag + PropertyChanges { + target: dropRectangle + color: "grey" + } + } + ] + } +} diff --git a/examples/qml/draganddrop/tiles/tiles.qml b/examples/qml/draganddrop/tiles/tiles.qml new file mode 100644 index 0000000000..31c87f8244 --- /dev/null +++ b/examples/qml/draganddrop/tiles/tiles.qml @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: root + + width: 620 + height: 410 + + color: "black" + + Grid { + id: redDestination + + anchors.left: redSource.right; anchors.top: parent.top; + anchors.margins: 5 + width: 300 + height: 300 + opacity: 0.5 + columns: 3 + + Repeater { + model: 9; + delegate: DropTile { colorKey: "red" } + } + } + + Grid { + anchors.right: blueSource.left; anchors.bottom: parent.bottom; + anchors.margins: 5 + width: 300 + height: 300 + + opacity: 0.5 + + columns: 3 + + Repeater { + model: 9 + delegate: DropTile { colorKey: "blue" } + } + } + + Column { + id: redSource + + anchors.left: parent.left; anchors.top: parent.top; anchors.bottom: parent.bottom + anchors.margins: 5 + width: 100 + spacing: -60 + + Repeater { + model: 9 + delegate: DragTile { colorKey: "red" } + } + } + Column { + id: blueSource + + anchors.right: parent.right; anchors.top: parent.top; anchors.bottom: parent.bottom + anchors.margins: 5 + width: 100 + spacing: -60 + + Repeater { + model: 9 + delegate: DragTile { colorKey: "blue" } + } + } +} diff --git a/examples/qml/draganddrop/views/gridview.qml b/examples/qml/draganddrop/views/gridview.qml new file mode 100644 index 0000000000..375f3d2824 --- /dev/null +++ b/examples/qml/draganddrop/views/gridview.qml @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +GridView { + id: root + width: 360; height: 360 + cellWidth: 90; cellHeight: 90 + + model: VisualDataModel { + id: visualModel + model: ListModel { + id: colorModel + ListElement { color: "blue" } + ListElement { color: "green" } + ListElement { color: "red" } + ListElement { color: "yellow" } + ListElement { color: "orange" } + ListElement { color: "purple" } + ListElement { color: "cyan" } + ListElement { color: "magenta" } + ListElement { color: "chartreuse" } + ListElement { color: "aquamarine" } + ListElement { color: "indigo" } + ListElement { color: "black" } + ListElement { color: "chartreuse" } + ListElement { color: "violet" } + ListElement { color: "grey" } + ListElement { color: "springgreen" } + } + + delegate: MouseArea { + id: delegateRoot + + property int visualIndex: VisualDataModel.itemsIndex + + width: 90; height: 90 + drag.target: icon + + Rectangle { + id: icon + width: 80; height: 80 + anchors { + horizontalCenter: parent.horizontalCenter; + verticalCenter: parent.verticalCenter + } + color: model.color + radius: 3 + + Drag.active: delegateRoot.pressed + Drag.source: delegateRoot + Drag.hotSpot.x: 40 + Drag.hotSpot.y: 40 + + states: [ + State { + when: icon.Drag.active + ParentChange { + target: icon + parent: root + } + + AnchorChanges { + target: icon; + anchors.horizontalCenter: undefined; + anchors.verticalCenter: undefined + } + } + ] + } + + DropArea { + anchors { fill: parent; margins: 15 } + + onEntered: visualModel.items.move(drag.source.visualIndex, delegateRoot.visualIndex) + } + } + } +} diff --git a/examples/qml/flickr/content/Button.qml b/examples/qml/flickr/content/Button.qml new file mode 100644 index 0000000000..57f846aec3 --- /dev/null +++ b/examples/qml/flickr/content/Button.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + signal clicked + + property string text + + BorderImage { + id: buttonImage + source: "images/toolbutton.sci" + width: container.width; height: container.height + } + BorderImage { + id: pressed + opacity: 0 + source: "images/toolbutton.sci" + width: container.width; height: container.height + } + MouseArea { + id: mouseRegion + anchors.fill: buttonImage + onClicked: { container.clicked(); } + } + Text { + color: "white" + anchors.centerIn: buttonImage; font.bold: true; font.pixelSize: 15 + text: container.text; style: Text.Raised; styleColor: "black" + } + states: [ + State { + name: "Pressed" + when: mouseRegion.pressed == true + PropertyChanges { target: pressed; opacity: 1 } + } + ] +} diff --git a/examples/qml/flickr/content/GridDelegate.qml b/examples/qml/flickr/content/GridDelegate.qml new file mode 100644 index 0000000000..f8838bd609 --- /dev/null +++ b/examples/qml/flickr/content/GridDelegate.qml @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: wrapper; width: GridView.view.cellWidth; height: GridView.view.cellHeight + + function photoClicked() { + imageDetails.photoTitle = title; + imageDetails.photoTags = tags; + imageDetails.photoWidth = photoWidth; + imageDetails.photoHeight = photoHeight; + imageDetails.photoType = photoType; + imageDetails.photoAuthor = photoAuthor; + imageDetails.photoDate = photoDate; + imageDetails.photoUrl = url; + imageDetails.rating = 0; + scaleMe.state = "Details"; + } + + Item { + anchors.centerIn: parent + scale: 0.0 + Behavior on scale { NumberAnimation { easing.type: Easing.InOutQuad} } + id: scaleMe + + Item { + width: 77; height: 77; anchors.centerIn: parent + Rectangle { + id: whiteRect; width: 77; height: 77; color: "#dddddd"; smooth: true + Image { id: thumb; source: imagePath; x: 1; y: 1; smooth: true } + Image { source: "images/gloss.png" } + } + } + + Connections { + target: toolBar + onButton2Clicked: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show' + } + + states: [ + State { + name: "Show"; when: thumb.status == Image.Ready + PropertyChanges { target: scaleMe; scale: 1 } + }, + State { + name: "Details" + PropertyChanges { target: scaleMe; scale: 1 } + ParentChange { target: whiteRect; x: 10; y: 20; parent: imageDetails.frontContainer } + PropertyChanges { target: background; state: "DetailedView" } + } + ] + transitions: [ + Transition { + from: "Show"; to: "Details" + ParentAnimation { + via: foreground + NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } + } + }, + Transition { + from: "Details"; to: "Show" + ParentAnimation { + via: foreground + NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } + } + } + ] + } + MouseArea { anchors.fill: wrapper; onClicked: photoClicked() } +} + diff --git a/examples/qml/flickr/content/ImageDetails.qml b/examples/qml/flickr/content/ImageDetails.qml new file mode 100644 index 0000000000..42b5e845ea --- /dev/null +++ b/examples/qml/flickr/content/ImageDetails.qml @@ -0,0 +1,323 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Flipable { + id: container + + property alias frontContainer: containerFront + property string photoTitle: "" + property string photoTags: "" + property int photoWidth + property int photoHeight + property string photoType + property string photoAuthor + property string photoDate + property string photoUrl + property int rating: 2 + property variant prevScale: 1.0 + + property int flipDuration: 1600 + + signal closed + + transform: Rotation { + id: itemRotation + origin.x: container.width / 2; + axis.y: 1; axis.z: 0 + } + + front: Item { + id: containerFront; anchors.fill: container + + Rectangle { + anchors.fill: parent + color: "black"; opacity: 0.4 + } + + Column { + spacing: 10 + anchors { + left: parent.left; leftMargin: 10 + right: parent.right; rightMargin: 10 + top: parent.top; topMargin: 120 + } + Text { font.bold: true; color: "white"; elide: Text.ElideRight; text: container.photoTitle; width: parent.width } + Text { color: "white"; elide: Text.ElideRight; text: "Size: " + container.photoWidth + 'x' + container.photoHeight; width: parent.width } + Text { color: "white"; elide: Text.ElideRight; text: "Type: " + container.photoType; width: parent.width } + Text { color: "white"; elide: Text.ElideRight; text: "Author: " + container.photoAuthor; width: parent.width } + Text { color: "white"; elide: Text.ElideRight; text: "Published: " + container.photoDate; width: parent.width } + Text { color: "white"; elide: Text.ElideRight; text: container.photoTags == "" ? "" : "Tags: "; width: parent.width } + Text { color: "white"; elide: Text.ElideRight; text: container.photoTags; width: parent.width } + } + } + + back: Item { + anchors.fill: container + + Rectangle { anchors.fill: parent; color: "black"; opacity: 0.4 } + + Progress { + anchors.centerIn: parent; width: 200; height: 22 + progress: bigImage.progress; visible: bigImage.status != Image.Ready + } + + Flickable { + id: flickable; anchors.fill: parent; clip: true + contentWidth: imageContainer.width; contentHeight: imageContainer.height + + function updateMinimumScale() { + if (bigImage.status == Image.Ready && bigImage.width != 0) { + slider.minimum = Math.min(flickable.width / bigImage.width, flickable.height / bigImage.height); + if (bigImage.width * slider.value > flickable.width) { + var xoff = (flickable.width/2 + flickable.contentX) * slider.value / prevScale; + flickable.contentX = xoff - flickable.width/2; + } + if (bigImage.height * slider.value > flickable.height) { + var yoff = (flickable.height/2 + flickable.contentY) * slider.value / prevScale; + flickable.contentY = yoff - flickable.height/2; + } + prevScale = slider.value; + } + } + + onWidthChanged: updateMinimumScale() + onHeightChanged: updateMinimumScale() + + Item { + id: imageContainer + width: Math.max(bigImage.width * bigImage.scale, flickable.width); + height: Math.max(bigImage.height * bigImage.scale, flickable.height); + Image { + id: bigImage; source: container.photoUrl; scale: slider.value + anchors.centerIn: parent; smooth: !flickable.movingVertically + onStatusChanged : { + // Default scale shows the entire image. + if (bigImage.status == Image.Ready && bigImage.width != 0) { + slider.minimum = Math.min(flickable.width / bigImage.width, flickable.height / bigImage.height); + prevScale = Math.min(slider.minimum, 1); + slider.value = prevScale; + } + if (inBackState && bigImage.status == Image.Ready) + effectBox.imageInAnim(); + } + property bool inBackState: false + onInBackStateChanged:{ + if(inBackState && bigImage.status == Image.Ready) + effectBox.imageInAnim(); + else if (!inBackState && bigImage.status == Image.Ready) + effectBox.imageOutAnim(); + } + } + ShaderEffectSource{ + id: pictureSource + sourceItem: bigImage + smooth: true + //Workaround: Doesn't work below lines + width: bigImage.width + height: bigImage.width + visible: false + } + Turbulence{//only fill visible rect + id: turbulence + system: imageSystem + anchors.fill: parent + strength: 240 + enabled: false + } + + Item{ + id: effectBox + width: bigImage.width * bigImage.scale + height: bigImage.height * bigImage.scale + anchors.centerIn: parent + function imageInAnim(){ + bigImage.visible = false; + noiseIn.visible = true; + endEffectTimer.start(); + } + function imageOutAnim(){ + bigImage.visible = false; + noiseIn.visible = false; + turbulence.enabled = true; + endEffectTimer.start(); + pixelEmitter.burst(2048); + } + Timer{ + id: endEffectTimer + interval: flipDuration + repeat: false + running: false + onTriggered:{ + turbulence.enabled = false; + noiseIn.visible = false; + bigImage.visible = true; + } + } + ShaderEffect{ + id: noiseIn + anchors.fill: parent + property real t: 0 + visible: false + onVisibleChanged: tAnim.start() + NumberAnimation{ + id: tAnim + target: noiseIn + property: "t" + from: 0.0 + to: 1.0 + duration: flipDuration + } + property variant source: pictureSource + property variant noise: ShaderEffectSource{ + sourceItem:Image{ + source: "images/noise.png" + } + hideSource: true + smooth: false + } + fragmentShader:" + uniform sampler2D noise; + uniform sampler2D source; + uniform highp float t; + uniform lowp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + void main(){ + //Want to use noise2, but it always returns (0,0)? + if(texture2D(noise, qt_TexCoord0).w <= t) + gl_FragColor = texture2D(source, qt_TexCoord0) * qt_Opacity; + else + gl_FragColor = vec4(0.,0.,0.,0.); + } + " + } + ParticleSystem{ + id: imageSystem + } + Emitter{ + id: pixelEmitter + system: imageSystem + //anchors.fill: parent + width: Math.min(bigImage.width * bigImage.scale, flickable.width); + height: Math.min(bigImage.height * bigImage.scale, flickable.height); + anchors.centerIn: parent + size: 4 + lifeSpan: flipDuration + emitRate: 2048 + enabled: false + } + CustomParticle{ + id: blowOut + system: imageSystem + property real maxWidth: effectBox.width + property real maxHeight: effectBox.height + vertexShader:" + uniform highp float maxWidth; + uniform highp float maxHeight; + + varying highp vec2 fTex2; + + void main() { + defaultMain(); + fTex2 = vec2(qt_ParticlePos.x / maxWidth, qt_ParticlePos.y / maxHeight); + } + " + property variant pictureTexture: pictureSource + fragmentShader: " + uniform lowp float qt_Opacity; + uniform sampler2D pictureTexture; + varying highp vec2 fTex2; + void main() { + gl_FragColor = texture2D(pictureTexture, fTex2) * qt_Opacity; + }" + } + + + + } + } + } + + Text { + text: "Image Unavailable" + visible: bigImage.status == Image.Error + anchors.centerIn: parent; color: "white"; font.bold: true + } + + Slider { + id: slider; visible: { bigImage.status == Image.Ready && maximum > minimum } + anchors { + bottom: parent.bottom; bottomMargin: 65 + left: parent.left; leftMargin: 25 + right: parent.right; rightMargin: 25 + } + onValueChanged: { + if (bigImage.width * value > flickable.width) { + var xoff = (flickable.width/2 + flickable.contentX) * value / prevScale; + flickable.contentX = xoff - flickable.width/2; + } + if (bigImage.height * value > flickable.height) { + var yoff = (flickable.height/2 + flickable.contentY) * value / prevScale; + flickable.contentY = yoff - flickable.height/2; + } + prevScale = value; + } + } + } + + states: State { + name: "Back" + PropertyChanges { target: itemRotation; angle: 180 } + PropertyChanges { target: toolBar; button2Visible: false } + PropertyChanges { target: toolBar; button1Label: "Back" } + PropertyChanges { target: bigImage; inBackState: true } + } + + transitions: Transition { + SequentialAnimation { + PropertyAction { target: bigImage; property: "smooth"; value: false } + NumberAnimation { easing.type: Easing.InOutQuad; properties: "angle"; duration: flipDuration } + PropertyAction { target: bigImage; property: "smooth"; value: !flickable.movingVertically } + } + } +} diff --git a/examples/qml/flickr/content/ListDelegate.qml b/examples/qml/flickr/content/ListDelegate.qml new file mode 100644 index 0000000000..00f837f862 --- /dev/null +++ b/examples/qml/flickr/content/ListDelegate.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Component { + Item { + id: wrapper; width: wrapper.ListView.view.width; height: 86 + Item { + id: moveMe + Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: 84; width: wrapper.width; y: 1 } + Rectangle { + x: 6; y: 4; width: 77; height: 77; color: "white"; smooth: true + + Image { source: imagePath; x: 1; y: 1 } + Image { source: "images/gloss.png" } + } + Column { + x: 92; width: wrapper.ListView.view.width - 95; y: 15; spacing: 2 + Text { text: title; color: "white"; width: parent.width; font.pixelSize: 14; font.bold: true; elide: Text.ElideRight; style: Text.Raised; styleColor: "black" } + Text { text: photoAuthor; width: parent.width; font.pixelSize: 14; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" } + Text { text: photoDate; width: parent.width; font.pixelSize: 14; elide: Text.ElideRight; color: "#cccccc"; style: Text.Raised; styleColor: "black" } + } + } + } +} diff --git a/examples/qml/flickr/content/Progress.qml b/examples/qml/flickr/content/Progress.qml new file mode 100644 index 0000000000..ed2629b48a --- /dev/null +++ b/examples/qml/flickr/content/Progress.qml @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item{ + id: container + property variant progress: 0 + + Rectangle { + anchors.fill: parent; smooth: true + border.color: "white"; border.width: 0; radius: height/2 - 2 + gradient: Gradient { + GradientStop { position: 0; color: "#66343434" } + GradientStop { position: 1.0; color: "#66000000" } + } + } + + ParticleSystem{ + running: container.visible + id: barSys + } + ImageParticle{ + color: "lightsteelblue" + alpha: 0.1 + colorVariation: 0.05 + source: "images/particle.png" + system: barSys + } + Emitter{ + y: 2; height: parent.height-4; + x: 2; width: Math.max(parent.width * progress - 4, 0); + speed: AngleDirection{ angleVariation: 180; magnitudeVariation: 12 } + system: barSys + emitRate: width; + lifeSpan: 1000 + size: 20 + sizeVariation: 4 + endSize: 12 + maximumEmitted: parent.width; + } + + Text { + text: Math.round(progress * 100) + "%" + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + color: Qt.rgba(1.0, 1.0 - progress, 1.0 - progress,0.9); font.bold: true; font.pixelSize: 15 + } +} diff --git a/examples/qml/flickr/content/RssModel.qml b/examples/qml/flickr/content/RssModel.qml new file mode 100644 index 0000000000..51cea498e6 --- /dev/null +++ b/examples/qml/flickr/content/RssModel.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + property string tags : "" + + function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); } + + source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "")+"format=rss2" + query: "/rss/channel/item" + namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" + + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" } + XmlRole { name: "url"; query: "media:content/@url/string()" } + XmlRole { name: "description"; query: "description/string()" } + XmlRole { name: "tags"; query: "media:category/string()" } + XmlRole { name: "photoWidth"; query: "media:content/@width/string()" } + XmlRole { name: "photoHeight"; query: "media:content/@height/string()" } + XmlRole { name: "photoType"; query: "media:content/@type/string()" } + XmlRole { name: "photoAuthor"; query: "author/string()" } + XmlRole { name: "photoDate"; query: "pubDate/string()" } +} diff --git a/examples/qml/flickr/content/ScrollBar.qml b/examples/qml/flickr/content/ScrollBar.qml new file mode 100644 index 0000000000..7c62ad088f --- /dev/null +++ b/examples/qml/flickr/content/ScrollBar.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + property variant flickableArea + + Rectangle { + radius: 5 + color: "black" + opacity: 0.3 + border.color: "white" + border.width: 2 + x: 0 + y: flickableArea.visibleArea.yPosition * container.height + width: parent.width + height: flickableArea.visibleArea.heightRatio * container.height + } + states: [ + State { + name: "show" + when: flickableArea.movingVertically + PropertyChanges { + target: container + opacity: 1 + } + } + ] + transitions: [ + Transition { + from: "*" + to: "*" + NumberAnimation { + target: container + properties: "opacity" + duration: 400 + } + } + ] +} diff --git a/examples/qml/flickr/content/Slider.qml b/examples/qml/flickr/content/Slider.qml new file mode 100644 index 0000000000..c4e743641f --- /dev/null +++ b/examples/qml/flickr/content/Slider.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: slider; width: 400; height: 16 + + // value is read/write. + property real value: 1 + onValueChanged: updatePos(); + property real maximum: 1 + property real minimum: 1 + property int xMax: width - handle.width - 4 + onXMaxChanged: updatePos(); + onMinimumChanged: updatePos(); + + function updatePos() { + if (maximum > minimum) { + var pos = 2 + (value - minimum) * slider.xMax / (maximum - minimum); + pos = Math.min(pos, width - handle.width - 2); + pos = Math.max(pos, 2); + handle.x = pos; + } else { + handle.x = 2; + } + } + + Rectangle { + anchors.fill: parent + border.color: "white"; border.width: 0; radius: 8 + gradient: Gradient { + GradientStop { position: 0.0; color: "#66343434" } + GradientStop { position: 1.0; color: "#66000000" } + } + } + + Rectangle { + id: handle; smooth: true + y: 2; width: 30; height: slider.height-4; radius: 6 + gradient: Gradient { + GradientStop { position: 0.0; color: "lightgray" } + GradientStop { position: 1.0; color: "gray" } + } + + MouseArea { + id: mouse + anchors.fill: parent; drag.target: parent + drag.axis: Drag.XAxis; drag.minimumX: 2; drag.maximumX: slider.xMax+2 + onPositionChanged: { value = (maximum - minimum) * (handle.x-2) / slider.xMax + minimum; } + } + } +} diff --git a/examples/qml/flickr/content/TitleBar.qml b/examples/qml/flickr/content/TitleBar.qml new file mode 100644 index 0000000000..223939f81a --- /dev/null +++ b/examples/qml/flickr/content/TitleBar.qml @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: titleBar + property string untaggedString: "Uploads from everyone" + property string taggedString: "Recent uploads tagged " + + BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } + + Item { + id: container + width: (parent.width * 2) - 55 ; height: parent.height + + function accept() { + imageDetails.closed() + titleBar.state = "" + background.state = "" + rssModel.tags = editor.text + } + + Image { + id: quitButton + anchors.left: parent.left//; anchors.leftMargin: 0 + anchors.verticalCenter: parent.verticalCenter + source: "images/quit.png" + MouseArea { + anchors.fill: parent + onClicked: Qt.quit() + } + } + + Text { + id: categoryText + anchors { + left: quitButton.right; right: tagButton.left; leftMargin: 10; rightMargin: 10 + verticalCenter: parent.verticalCenter + } + elide: Text.ElideLeft + text: (rssModel.tags=="" ? untaggedString : taggedString + rssModel.tags) + font.bold: true; font.pixelSize: 15; color: "White"; style: Text.Raised; styleColor: "Black" + } + + Button { + id: tagButton; x: titleBar.width - 50; width: 45; height: 32; text: "..." + onClicked: if (titleBar.state == "Tags") container.accept(); else titleBar.state = "Tags" + anchors.verticalCenter: parent.verticalCenter + } + + Item { + id: lineEdit + y: 4; height: parent.height - 9 + anchors { left: tagButton.right; leftMargin: 5; right: parent.right; rightMargin: 5 } + + BorderImage { source: "images/lineedit.sci"; anchors.fill: parent } + + TextInput { + id: editor + anchors { + left: parent.left; right: parent.right; leftMargin: 10; rightMargin: 10 + verticalCenter: parent.verticalCenter + } + cursorVisible: true; font.bold: true + color: "#151515"; selectionColor: "Green" + } + + Keys.forwardTo: [ (returnKey), (editor)] + + Item { + id: returnKey + Keys.onReturnPressed: container.accept() + Keys.onEnterPressed: container.accept() + Keys.onEscapePressed: titleBar.state = "" + } + } + } + + states: State { + name: "Tags" + PropertyChanges { target: container; x: -tagButton.x + 5 } + PropertyChanges { target: tagButton; text: "OK" } + PropertyChanges { target: editor; focus: true } + } + + transitions: Transition { + NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad } + } +} diff --git a/examples/qml/flickr/content/ToolBar.qml b/examples/qml/flickr/content/ToolBar.qml new file mode 100644 index 0000000000..356993b41a --- /dev/null +++ b/examples/qml/flickr/content/ToolBar.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: toolbar + + property alias button1Label: button1.text + property alias button2Label: button2.text + property alias button2Visible: button2.visible + + signal button1Clicked + signal button2Clicked + + BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } + + Row { + anchors.right: parent.right; anchors.rightMargin: 5; y: 3; height: 32; spacing: 30 + Button { + id: button1 + width: 140; height: 32 + onClicked: toolbar.button1Clicked() + } + + Button { + id: button2; width: 140; height: 32 + onClicked: toolbar.button2Clicked() + } + } +} diff --git a/examples/qml/flickr/content/UnifiedDelegate.qml b/examples/qml/flickr/content/UnifiedDelegate.qml new file mode 100644 index 0000000000..0b068c0abe --- /dev/null +++ b/examples/qml/flickr/content/UnifiedDelegate.qml @@ -0,0 +1,154 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Package { + function photoClicked() { + imageDetails.photoTitle = title; + imageDetails.photoTags = tags; + imageDetails.photoWidth = photoWidth; + imageDetails.photoHeight = photoHeight; + imageDetails.photoType = photoType; + imageDetails.photoAuthor = photoAuthor; + imageDetails.photoDate = photoDate; + imageDetails.photoUrl = url; + imageDetails.rating = 0; + scaleMe.state = "Details"; + } + + Item { + id: gridwrapper; + width: GridView.view.cellWidth; height: GridView.view.cellHeight + Package.name: "grid" + } + Item { + id: streamwrapper; + width: 80; height: 80 + Package.name: "stream" + } + Item { + //anchors.centerIn: parent//Doesn't animate :( + width: 80; height: 80 + scale: 0.0 + Behavior on scale { NumberAnimation { easing.type: Easing.InOutQuad} } + id: scaleMe + + Item { + id: whiteRectContainer + width: 77; height: 77; anchors.centerIn: parent + Rectangle { + id: whiteRect; width: 77; height: 77; color: "#dddddd"; smooth: true + x:0; y:0 + Image { id: thumb; source: imagePath; x: 1; y: 1; smooth: true } + Image { source: "images/gloss.png" } + MouseArea { anchors.fill: parent; onClicked: photoClicked() } + } + } + + Connections { + target: toolBar + onButton2Clicked: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show' + } + + state: 'inStream' + states: [ + State { + name: "Show"; when: thumb.status == Image.Ready + PropertyChanges { target: scaleMe; scale: 1; } + }, + State { + name: "Details" + PropertyChanges { target: scaleMe; scale: 1 } + ParentChange { target: whiteRect; x: 10; y: 20; parent: imageDetails.frontContainer } + PropertyChanges { target: background; state: "DetailedView" } + } + ] + transitions: [ + Transition { + from: "Show"; to: "Details" + ParentAnimation { + via: foreground + NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } + } + }, + Transition { + from: "Details"; to: "Show" + SequentialAnimation{ + ParentAnimation { + via: foreground + NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } + } + } + } + ] + Item{ + id: stateContainer + states: [ + State { + name: 'inStream' + when: screen.inGridView == false + ParentChange { + target: scaleMe; parent: streamwrapper + x: 0; y: 0; + } + }, + State { + name: 'inGrid' + when: screen.inGridView == true + ParentChange { + target: scaleMe; parent: gridwrapper + x: 0; y: 0; + } + } + ] + + transitions: [ + Transition { + ParentAnimation { + NumberAnimation { target: scaleMe; properties: 'x,y,width,height'; duration: 300 } + } + } + ] + } + } +} diff --git a/examples/qml/flickr/content/images/gloss.png b/examples/qml/flickr/content/images/gloss.png new file mode 100644 index 0000000000..5d370cd93d Binary files /dev/null and b/examples/qml/flickr/content/images/gloss.png differ diff --git a/examples/qml/flickr/content/images/lineedit.png b/examples/qml/flickr/content/images/lineedit.png new file mode 100644 index 0000000000..2cc38dc35b Binary files /dev/null and b/examples/qml/flickr/content/images/lineedit.png differ diff --git a/examples/qml/flickr/content/images/lineedit.sci b/examples/qml/flickr/content/images/lineedit.sci new file mode 100644 index 0000000000..054bff78be --- /dev/null +++ b/examples/qml/flickr/content/images/lineedit.sci @@ -0,0 +1,5 @@ +border.left: 10 +border.top: 10 +border.bottom: 10 +border.right: 10 +source: lineedit.png diff --git a/examples/qml/flickr/content/images/noise.png b/examples/qml/flickr/content/images/noise.png new file mode 100644 index 0000000000..c5a5ba0053 Binary files /dev/null and b/examples/qml/flickr/content/images/noise.png differ diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/blur-circle3.png b/examples/qml/flickr/content/images/particle.png similarity index 100% rename from examples/qtquick/touchinteraction/multipointtouch/content/blur-circle3.png rename to examples/qml/flickr/content/images/particle.png diff --git a/examples/qml/flickr/content/images/quit.png b/examples/qml/flickr/content/images/quit.png new file mode 100644 index 0000000000..5bda1b6e0d Binary files /dev/null and b/examples/qml/flickr/content/images/quit.png differ diff --git a/examples/qml/flickr/content/images/squareParticle.png b/examples/qml/flickr/content/images/squareParticle.png new file mode 100644 index 0000000000..faf85c24e0 Binary files /dev/null and b/examples/qml/flickr/content/images/squareParticle.png differ diff --git a/examples/qml/flickr/content/images/stripes.png b/examples/qml/flickr/content/images/stripes.png new file mode 100644 index 0000000000..9f36727ea4 Binary files /dev/null and b/examples/qml/flickr/content/images/stripes.png differ diff --git a/examples/qml/flickr/content/images/titlebar.png b/examples/qml/flickr/content/images/titlebar.png new file mode 100644 index 0000000000..51c90082d0 Binary files /dev/null and b/examples/qml/flickr/content/images/titlebar.png differ diff --git a/examples/qml/flickr/content/images/titlebar.sci b/examples/qml/flickr/content/images/titlebar.sci new file mode 100644 index 0000000000..0418d94cd6 --- /dev/null +++ b/examples/qml/flickr/content/images/titlebar.sci @@ -0,0 +1,5 @@ +border.left: 10 +border.top: 12 +border.bottom: 12 +border.right: 10 +source: titlebar.png diff --git a/examples/qml/flickr/content/images/toolbutton.png b/examples/qml/flickr/content/images/toolbutton.png new file mode 100644 index 0000000000..11310013ee Binary files /dev/null and b/examples/qml/flickr/content/images/toolbutton.png differ diff --git a/examples/qml/flickr/content/images/toolbutton.sci b/examples/qml/flickr/content/images/toolbutton.sci new file mode 100644 index 0000000000..9e4f965307 --- /dev/null +++ b/examples/qml/flickr/content/images/toolbutton.sci @@ -0,0 +1,5 @@ +border.left: 15 +border.top: 4 +border.bottom: 4 +border.right: 15 +source: toolbutton.png diff --git a/examples/qml/flickr/content/qmldir b/examples/qml/flickr/content/qmldir new file mode 100644 index 0000000000..adc2479b9f --- /dev/null +++ b/examples/qml/flickr/content/qmldir @@ -0,0 +1,10 @@ +ImageDetails ImageDetails.qml +LikeOMeter LikeOMeter.qml +Loading Loading.qml +MediaButton MediaButton.qml +MediaLineEdit MediaLineEdit.qml +Progress Progress.qml +RssModel RssModel.qml +ScrollBar ScrollBar.qml +Slider Slider.qml +Star Star.qml diff --git a/examples/qml/flickr/flickr-90.qml b/examples/qml/flickr/flickr-90.qml new file mode 100644 index 0000000000..b95b1c9872 --- /dev/null +++ b/examples/qml/flickr/flickr-90.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + width: 480; height: 320 + + Loader { + y: 320; rotation: -90 + transformOrigin: Item.TopLeft + source: "flickr.qml" + } +} diff --git a/examples/qml/flickr/flickr.qml b/examples/qml/flickr/flickr.qml new file mode 100644 index 0000000000..98ca5197ab --- /dev/null +++ b/examples/qml/flickr/flickr.qml @@ -0,0 +1,158 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "content" + +Item { + id: screen; width: 320; height: 480 + property bool inGridView : true + + Rectangle { + id: background + anchors.fill: parent; color: "#343434"; + + Image { source: "content/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 } + ParticleSystem { + id: bgParticles + anchors.fill: parent + ImageParticle { + groups: ["trail"] + source: "content/images/particle.png" + color: "#1A1A6F" + alpha: 0.1 + colorVariation: 0.01 + blueVariation: 0.8 + } + Emitter { + group: "drops" + width: parent.width + emitRate: 0.5 + lifeSpan: 20000 + startTime: 16000 + speed: PointDirection{ + y: {screen.height/18} + } + } + TrailEmitter { + follow: "drops" + group: "trail" + emitRatePerParticle: 18 + size: 32 + endSize: 0 + sizeVariation: 4 + lifeSpan: 1200 + anchors.fill: parent + emitWidth: 16 + emitHeight: 16 + emitShape: EllipseShape{} + } + } + + VisualDataModel{ + id: vdm + delegate: UnifiedDelegate{} + model: RssModel { id: rssModel } + } + + Item { + id: views + width: parent.width + anchors.top: titleBar.bottom; anchors.bottom: toolBar.top + + GridView { + id: photoGridView; model: vdm.parts.grid + cacheBuffer: 1000 + cellWidth: (parent.width-2)/4; cellHeight: cellWidth; width: parent.width; height: parent.height + } + + states: State { + name: "GridView"; when: state.inGridView == true + } + + transitions: Transition { + NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad } + } + + ImageDetails { id: imageDetails; width: parent.width; anchors.left: views.right; height: parent.height } + + Item { id: foreground; anchors.fill: parent } + } + + TitleBar { id: titleBar; width: parent.width; height: 40; opacity: 0.9 } + + ToolBar { + id: toolBar + height: 40; anchors.bottom: parent.bottom; width: parent.width; opacity: 0.9 + button1Label: "Update"; button2Label: "View mode" + onButton1Clicked: rssModel.reload() + onButton2Clicked: if (screen.inGridView == true) screen.inGridView = false; else screen.inGridView = true + } + + Connections { + target: imageDetails + onClosed: { + if (background.state == "DetailedView") { + background.state = ''; + imageDetails.photoUrl = ""; + } + } + } + + states: State { + name: "DetailedView" + PropertyChanges { target: views; x: -parent.width } + PropertyChanges { target: toolBar; button1Label: "View..." } + PropertyChanges { + target: toolBar + onButton1Clicked: if (imageDetails.state=='') imageDetails.state='Back'; else imageDetails.state='' + } + PropertyChanges { target: toolBar; button2Label: "Back" } + PropertyChanges { target: toolBar; onButton2Clicked: imageDetails.closed() } + } + + transitions: Transition { + NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad } + } + + } +} diff --git a/examples/qml/flickr/flickr.qmlproject b/examples/qml/flickr/flickr.qmlproject new file mode 100644 index 0000000000..af5179d84b --- /dev/null +++ b/examples/qml/flickr/flickr.qmlproject @@ -0,0 +1,17 @@ +import QmlProject 1.1 + +Project { + mainFile: "flickr.qml" + //mainFile: "flickr-90.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/imageelements/borderimage.qml b/examples/qml/imageelements/borderimage.qml new file mode 100644 index 0000000000..3dd5d1d9bb --- /dev/null +++ b/examples/qml/imageelements/borderimage.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + id: page + width: 1030; height: 540 + + Grid { + anchors.centerIn: parent; spacing: 20 + + MyBorderImage { + minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 + source: "content/colors.png"; margin: 30 + } + + MyBorderImage { + minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 + source: "content/colors.png"; margin: 30 + horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat + } + + MyBorderImage { + minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 + source: "content/colors.png"; margin: 30 + horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat + } + + MyBorderImage { + minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 + source: "content/colors.png"; margin: 30 + horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round + } + + MyBorderImage { + minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 + source: "content/bw.png"; margin: 10 + } + + MyBorderImage { + minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 + source: "content/bw.png"; margin: 10 + horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat + } + + MyBorderImage { + minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 + source: "content/bw.png"; margin: 10 + horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat + } + + MyBorderImage { + minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 + source: "content/bw.png"; margin: 10 + horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round + } + } +} diff --git a/examples/qtquick/imageelements/content/BearSheet.png b/examples/qml/imageelements/content/BearSheet.png similarity index 100% rename from examples/qtquick/imageelements/content/BearSheet.png rename to examples/qml/imageelements/content/BearSheet.png diff --git a/examples/qtquick/imageelements/content/ImageCell.qml b/examples/qml/imageelements/content/ImageCell.qml similarity index 100% rename from examples/qtquick/imageelements/content/ImageCell.qml rename to examples/qml/imageelements/content/ImageCell.qml diff --git a/examples/qml/imageelements/content/MyBorderImage.qml b/examples/qml/imageelements/content/MyBorderImage.qml new file mode 100644 index 0000000000..178e3706db --- /dev/null +++ b/examples/qml/imageelements/content/MyBorderImage.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + property alias horizontalMode: image.horizontalTileMode + property alias verticalMode: image.verticalTileMode + property alias source: image.source + + property int minWidth + property int minHeight + property int maxWidth + property int maxHeight + property int margin + + width: 240; height: 240 + + BorderImage { + id: image; anchors.centerIn: parent + + SequentialAnimation on width { + loops: Animation.Infinite + NumberAnimation { + from: container.minWidth; to: container.maxWidth + duration: 2000; easing.type: Easing.InOutQuad + } + NumberAnimation { + from: container.maxWidth; to: container.minWidth + duration: 2000; easing.type: Easing.InOutQuad + } + } + + SequentialAnimation on height { + loops: Animation.Infinite + NumberAnimation { + from: container.minHeight; to: container.maxHeight + duration: 2000; easing.type: Easing.InOutQuad + } + NumberAnimation { + from: container.maxHeight; to: container.minHeight + duration: 2000; easing.type: Easing.InOutQuad + } + } + + border.top: container.margin + border.left: container.margin + border.bottom: container.margin + border.right: container.margin + } +} diff --git a/examples/qtquick/imageelements/content/ShadowRectangle.qml b/examples/qml/imageelements/content/ShadowRectangle.qml similarity index 100% rename from examples/qtquick/imageelements/content/ShadowRectangle.qml rename to examples/qml/imageelements/content/ShadowRectangle.qml diff --git a/examples/qtquick/imageelements/content/bw.png b/examples/qml/imageelements/content/bw.png similarity index 100% rename from examples/qtquick/imageelements/content/bw.png rename to examples/qml/imageelements/content/bw.png diff --git a/examples/qtquick/imageelements/content/colors-round.sci b/examples/qml/imageelements/content/colors-round.sci similarity index 100% rename from examples/qtquick/imageelements/content/colors-round.sci rename to examples/qml/imageelements/content/colors-round.sci diff --git a/examples/qtquick/imageelements/content/colors-stretch.sci b/examples/qml/imageelements/content/colors-stretch.sci similarity index 100% rename from examples/qtquick/imageelements/content/colors-stretch.sci rename to examples/qml/imageelements/content/colors-stretch.sci diff --git a/examples/qtquick/imageelements/content/colors.png b/examples/qml/imageelements/content/colors.png similarity index 100% rename from examples/qtquick/imageelements/content/colors.png rename to examples/qml/imageelements/content/colors.png diff --git a/examples/qtquick/imageelements/content/qt-logo.png b/examples/qml/imageelements/content/qt-logo.png similarity index 100% rename from examples/qtquick/imageelements/content/qt-logo.png rename to examples/qml/imageelements/content/qt-logo.png diff --git a/examples/qtquick/imageelements/content/shadow.png b/examples/qml/imageelements/content/shadow.png similarity index 100% rename from examples/qtquick/imageelements/content/shadow.png rename to examples/qml/imageelements/content/shadow.png diff --git a/examples/qtquick/imageelements/content/speaker.png b/examples/qml/imageelements/content/speaker.png similarity index 100% rename from examples/qtquick/imageelements/content/speaker.png rename to examples/qml/imageelements/content/speaker.png diff --git a/examples/qml/imageelements/image.qml b/examples/qml/imageelements/image.qml new file mode 100644 index 0000000000..4ca26c1630 --- /dev/null +++ b/examples/qml/imageelements/image.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + width: 490 + height: 285 + + Grid { + property int cellWidth: (width - (spacing * (columns - 1))) / columns + property int cellHeight: (height - (spacing * (rows - 1))) / rows + + anchors.fill: parent + anchors.margins: 30 + + columns: 3 + rows: 2 + spacing: 30 + + ImageCell { mode: Image.Stretch; caption: "Stretch" } + ImageCell { mode: Image.PreserveAspectFit; caption: "PreserveAspectFit" } + ImageCell { mode: Image.PreserveAspectCrop; caption: "PreserveAspectCrop" } + + ImageCell { mode: Image.Tile; caption: "Tile" } + ImageCell { mode: Image.TileHorizontally; caption: "TileHorizontally" } + ImageCell { mode: Image.TileVertically; caption: "TileVertically" } + } +} diff --git a/examples/qml/imageelements/imageelements.qml b/examples/qml/imageelements/imageelements.qml new file mode 100644 index 0000000000..2ef5154968 --- /dev/null +++ b/examples/qml/imageelements/imageelements.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../shared" + +Item { + height: 480 + width: 640 + LauncherList { + id: ll + anchors.fill: parent + Component.onCompleted: { + addExample("BorderImage", "An image with scaled borders", Qt.resolvedUrl("borderimage.qml")); + addExample("Image", "A showcase of the options available to Image", Qt.resolvedUrl("image.qml")); + addExample("Shadows", "Rectangles with a drop-shadow effect", Qt.resolvedUrl("shadows.qml")); + addExample("Simple Sprite", "A simple sprite-based animation", Qt.resolvedUrl("simplesprite.qml")); + addExample("Sprite Image", "A sprite-based animation with complex transitions", Qt.resolvedUrl("spriteimage.qml")); + } + } +} diff --git a/examples/qtquick/imageelements/imageelements.qmlproject b/examples/qml/imageelements/imageelements.qmlproject similarity index 100% rename from examples/qtquick/imageelements/imageelements.qmlproject rename to examples/qml/imageelements/imageelements.qmlproject diff --git a/examples/qtquick/imageelements/shadows.qml b/examples/qml/imageelements/shadows.qml similarity index 100% rename from examples/qtquick/imageelements/shadows.qml rename to examples/qml/imageelements/shadows.qml diff --git a/examples/qml/imageelements/simplesprite.qml b/examples/qml/imageelements/simplesprite.qml new file mode 100644 index 0000000000..f619913bfc --- /dev/null +++ b/examples/qml/imageelements/simplesprite.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Item { + width: 400 + height: 400 + Rectangle { + anchors.fill: parent + color: "white" + } + SpriteImage { + anchors.fill: parent + Sprite{ + source: "content/speaker.png" + frames: 60 + frameSync: true + frameWidth: 170 + frameHeight: 170 + } + } +} diff --git a/examples/qml/imageelements/spriteimage.qml b/examples/qml/imageelements/spriteimage.qml new file mode 100644 index 0000000000..559bb10a50 --- /dev/null +++ b/examples/qml/imageelements/spriteimage.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Item { + width: 480 + height: 1280 + MouseArea { + onClicked: anim.start(); + anchors.fill: parent + } + SequentialAnimation { + id: anim + ScriptAction { script: image.goalSprite = "falling"; } + NumberAnimation { target: image; property: "y"; to: 1480; duration: 12000; } + ScriptAction { script: {image.goalSprite = ""; image.jumpTo("still");} } + PropertyAction { target: image; property: "y"; value: 0 } + } + SpriteImage { + id: image + width: 256 + height: 256 + anchors.horizontalCenter: parent.horizontalCenter + interpolate: false + goalSprite: "" + Sprite{ + name: "still" + source: "content/BearSheet.png" + frames: 1 + frameWidth: 256 + frameHeight: 256 + frameDuration: 100 + to: {"still":1, "blink":0.1, "floating":0} + } + Sprite{ + name: "blink" + source: "content/BearSheet.png" + frames: 3 + frameX: 256 + frameY: 1536 + frameWidth: 256 + frameHeight: 256 + frameDuration: 100 + to: {"still":1} + } + Sprite{ + name: "floating" + source: "content/BearSheet.png" + frames: 9 + frameX: 0 + frameY: 0 + frameWidth: 256 + frameHeight: 256 + frameDuration: 160 + to: {"still":0, "flailing":1} + } + Sprite{ + name: "flailing" + source: "content/BearSheet.png" + frames: 8 + frameX: 0 + frameY: 768 + frameWidth: 256 + frameHeight: 256 + frameDuration: 160 + to: {"falling":1} + } + Sprite{ + name: "falling" + source: "content/BearSheet.png" + frames: 5 + frameY: 1280 + frameWidth: 256 + frameHeight: 256 + frameDuration: 160 + to: {"falling":1} + } + } +} diff --git a/examples/qtquick/keyinteraction/focus/Core/ContextMenu.qml b/examples/qml/keyinteraction/focus/Core/ContextMenu.qml similarity index 100% rename from examples/qtquick/keyinteraction/focus/Core/ContextMenu.qml rename to examples/qml/keyinteraction/focus/Core/ContextMenu.qml diff --git a/examples/qtquick/keyinteraction/focus/Core/GridMenu.qml b/examples/qml/keyinteraction/focus/Core/GridMenu.qml similarity index 100% rename from examples/qtquick/keyinteraction/focus/Core/GridMenu.qml rename to examples/qml/keyinteraction/focus/Core/GridMenu.qml diff --git a/examples/qtquick/keyinteraction/focus/Core/ListMenu.qml b/examples/qml/keyinteraction/focus/Core/ListMenu.qml similarity index 100% rename from examples/qtquick/keyinteraction/focus/Core/ListMenu.qml rename to examples/qml/keyinteraction/focus/Core/ListMenu.qml diff --git a/examples/qtquick/keyinteraction/focus/Core/ListViewDelegate.qml b/examples/qml/keyinteraction/focus/Core/ListViewDelegate.qml similarity index 100% rename from examples/qtquick/keyinteraction/focus/Core/ListViewDelegate.qml rename to examples/qml/keyinteraction/focus/Core/ListViewDelegate.qml diff --git a/examples/qtquick/keyinteraction/focus/Core/images/arrow.png b/examples/qml/keyinteraction/focus/Core/images/arrow.png similarity index 100% rename from examples/qtquick/keyinteraction/focus/Core/images/arrow.png rename to examples/qml/keyinteraction/focus/Core/images/arrow.png diff --git a/examples/qtquick/keyinteraction/focus/Core/images/qt-logo.png b/examples/qml/keyinteraction/focus/Core/images/qt-logo.png similarity index 100% rename from examples/qtquick/keyinteraction/focus/Core/images/qt-logo.png rename to examples/qml/keyinteraction/focus/Core/images/qt-logo.png diff --git a/examples/qtquick/keyinteraction/focus/focus.qml b/examples/qml/keyinteraction/focus/focus.qml similarity index 100% rename from examples/qtquick/keyinteraction/focus/focus.qml rename to examples/qml/keyinteraction/focus/focus.qml diff --git a/examples/qml/minehunt/MinehuntCore/Explosion.qml b/examples/qml/minehunt/MinehuntCore/Explosion.qml new file mode 100644 index 0000000000..a1b4292bcf --- /dev/null +++ b/examples/qml/minehunt/MinehuntCore/Explosion.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + property bool explode : false + ParticleSystem { + width: 40 + height: 40 + ImageParticle { + groups: ["star"] + source: "file:MinehuntCore/pics/star.png" // TODO: Use qrc path once QTBUG-21129 is fixed + } + Emitter { + id: particles + enabled: false + anchors.centerIn: parent + group: "star" + speed: AngleDirection { angleVariation: 360; magnitude: 150; magnitudeVariation: 50 } + emitRate: 200 + z: 100 + lifeSpan: 1000 + } + } + states: State { name: "exploding"; when: explode + StateChangeScript { script: particles.burst(200); } + } + +} diff --git a/examples/qml/minehunt/MinehuntCore/Tile.qml b/examples/qml/minehunt/MinehuntCore/Tile.qml new file mode 100644 index 0000000000..1180b6f584 --- /dev/null +++ b/examples/qml/minehunt/MinehuntCore/Tile.qml @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Flipable { + id: flipable + property int angle: 0 + + width: 40; height: 40 + transform: Rotation { origin.x: 20; origin.y: 20; axis.x: 1; axis.z: 0; angle: flipable.angle } + + front: Image { + source: "pics/front.png"; width: 40; height: 40 + + Image { + anchors.centerIn: parent + source: "pics/flag.png"; opacity: modelData.hasFlag + + Behavior on opacity { NumberAnimation {} } + } + } + + back: Image { + source: "pics/back.png" + width: 40; height: 40 + + Text { + anchors.centerIn: parent + text: modelData.hint; color: "white"; font.bold: true + opacity: !modelData.hasMine && modelData.hint > 0 + } + + Image { + anchors.centerIn: parent + source: "pics/bomb.png"; opacity: modelData.hasMine + } + + Explosion { id: expl } + } + + states: State { + name: "back"; when: modelData.flipped + PropertyChanges { target: flipable; angle: 180 } + } + + property real pauseDur: 250 + transitions: Transition { + SequentialAnimation { + ScriptAction { + script: { + var ret = Math.abs(flipable.x - field.clickx) + + Math.abs(flipable.y - field.clicky); + if (modelData.hasMine && modelData.flipped) + pauseDur = ret * 3 + else + pauseDur = ret + } + } + PauseAnimation { + duration: pauseDur + } + RotationAnimation { easing.type: Easing.InOutQuad } + ScriptAction { script: if (modelData.hasMine && modelData.flipped) { expl.explode = true } } + } + } + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: { + field.clickx = flipable.x + field.clicky = flipable.y + var row = Math.floor(index / 9) + var col = index - (Math.floor(index / 9) * 9) + if (mouse.button == undefined || mouse.button == Qt.RightButton) { + flag(row, col) + } else { + flip(row, col) + } + } + onPressAndHold: { + field.clickx = flipable.x + field.clicky = flipable.y + var row = Math.floor(index / 9) + var col = index - (Math.floor(index / 9) * 9) + flag(row, col) + } + } +} diff --git a/examples/qml/minehunt/MinehuntCore/pics/back.png b/examples/qml/minehunt/MinehuntCore/pics/back.png new file mode 100644 index 0000000000..f6b3f0b4d7 Binary files /dev/null and b/examples/qml/minehunt/MinehuntCore/pics/back.png differ diff --git a/examples/qml/minehunt/MinehuntCore/pics/background.png b/examples/qml/minehunt/MinehuntCore/pics/background.png new file mode 100644 index 0000000000..3734a27744 Binary files /dev/null and b/examples/qml/minehunt/MinehuntCore/pics/background.png differ diff --git a/examples/qml/minehunt/MinehuntCore/pics/bomb-color.png b/examples/qml/minehunt/MinehuntCore/pics/bomb-color.png new file mode 100644 index 0000000000..61ad0a928f Binary files /dev/null and b/examples/qml/minehunt/MinehuntCore/pics/bomb-color.png differ diff --git a/examples/qml/minehunt/MinehuntCore/pics/bomb.png b/examples/qml/minehunt/MinehuntCore/pics/bomb.png new file mode 100644 index 0000000000..a992575518 Binary files /dev/null and b/examples/qml/minehunt/MinehuntCore/pics/bomb.png differ diff --git a/examples/qml/minehunt/MinehuntCore/pics/face-sad.png b/examples/qml/minehunt/MinehuntCore/pics/face-sad.png new file mode 100644 index 0000000000..cf00aafe1f Binary files /dev/null and b/examples/qml/minehunt/MinehuntCore/pics/face-sad.png differ diff --git a/examples/qml/minehunt/MinehuntCore/pics/face-smile-big.png b/examples/qml/minehunt/MinehuntCore/pics/face-smile-big.png new file mode 100644 index 0000000000..f9c2335df5 Binary files /dev/null and b/examples/qml/minehunt/MinehuntCore/pics/face-smile-big.png differ diff --git a/examples/qtquick/modelviews/parallax/content/pics/face-smile.png b/examples/qml/minehunt/MinehuntCore/pics/face-smile.png similarity index 100% rename from examples/qtquick/modelviews/parallax/content/pics/face-smile.png rename to examples/qml/minehunt/MinehuntCore/pics/face-smile.png diff --git a/examples/qml/minehunt/MinehuntCore/pics/flag-color.png b/examples/qml/minehunt/MinehuntCore/pics/flag-color.png new file mode 100644 index 0000000000..aadad0f11a Binary files /dev/null and b/examples/qml/minehunt/MinehuntCore/pics/flag-color.png differ diff --git a/examples/qml/minehunt/MinehuntCore/pics/flag.png b/examples/qml/minehunt/MinehuntCore/pics/flag.png new file mode 100644 index 0000000000..39cde4df82 Binary files /dev/null and b/examples/qml/minehunt/MinehuntCore/pics/flag.png differ diff --git a/examples/qml/minehunt/MinehuntCore/pics/front.png b/examples/qml/minehunt/MinehuntCore/pics/front.png new file mode 100644 index 0000000000..834331bd49 Binary files /dev/null and b/examples/qml/minehunt/MinehuntCore/pics/front.png differ diff --git a/examples/qtquick/modelviews/parallax/content/quit.png b/examples/qml/minehunt/MinehuntCore/pics/quit.png similarity index 100% rename from examples/qtquick/modelviews/parallax/content/quit.png rename to examples/qml/minehunt/MinehuntCore/pics/quit.png diff --git a/examples/qml/minehunt/MinehuntCore/pics/star.png b/examples/qml/minehunt/MinehuntCore/pics/star.png new file mode 100644 index 0000000000..3772359188 Binary files /dev/null and b/examples/qml/minehunt/MinehuntCore/pics/star.png differ diff --git a/examples/qml/minehunt/MinehuntCore/qmldir b/examples/qml/minehunt/MinehuntCore/qmldir new file mode 100644 index 0000000000..a0213a19c4 --- /dev/null +++ b/examples/qml/minehunt/MinehuntCore/qmldir @@ -0,0 +1,2 @@ +Explosion 2.0 Explosion.qml +Tile 2.0 Tile.qml diff --git a/examples/qml/minehunt/README b/examples/qml/minehunt/README new file mode 100644 index 0000000000..3849ca5fbf --- /dev/null +++ b/examples/qml/minehunt/README @@ -0,0 +1,6 @@ +Minehunt has to be compiled to run. + +To compile the C++ part, do 'qmake && make'. +To run, simply run the executable. +To deploy on a device, do 'make sis'. + diff --git a/examples/qml/minehunt/main.cpp b/examples/qml/minehunt/main.cpp new file mode 100644 index 0000000000..0aa11a1d7a --- /dev/null +++ b/examples/qml/minehunt/main.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +#include "minehunt.h" + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + QQuickView canvas; + + qmlRegisterType(); + MinehuntGame* game = new MinehuntGame(); + + canvas.setResizeMode(QQuickView::SizeRootObjectToView); + canvas.engine()->rootContext()->setContextObject(game); + canvas.setSource(QString("qrc:///minehunt.qml")); + QObject::connect(canvas.engine(), SIGNAL(quit()), &app, SLOT(quit())); + + canvas.show(); + return app.exec(); +} diff --git a/examples/qml/minehunt/minehunt.cpp b/examples/qml/minehunt/minehunt.cpp new file mode 100644 index 0000000000..cde30278b3 --- /dev/null +++ b/examples/qml/minehunt/minehunt.cpp @@ -0,0 +1,221 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +#include "minehunt.h" + +void tilesPropAppend(QQmlListProperty* prop, TileData* value) +{ + Q_UNUSED(prop); + Q_UNUSED(value); + return; //Append not supported +} + +int tilesPropCount(QQmlListProperty* prop) +{ + return static_cast*>(prop->data)->count(); +} + +TileData* tilesPropAt(QQmlListProperty* prop, int index) +{ + return static_cast*>(prop->data)->at(index); +} + +QQmlListProperty MinehuntGame::tiles(){ + return QQmlListProperty(this, &_tiles, &tilesPropAppend, + &tilesPropCount, &tilesPropAt, 0); +} + +MinehuntGame::MinehuntGame() +: numCols(9), numRows(9), playing(true), won(false) +{ + setObjectName("mainObject"); + srand(QTime(0,0,0).secsTo(QTime::currentTime())); + + //initialize array + for(int ii = 0; ii < numRows * numCols; ++ii) { + _tiles << new TileData; + } + reset(); + +} + +void MinehuntGame::setBoard() +{ + foreach(TileData* t, _tiles){ + t->setHasMine(false); + t->setHint(-1); + } + //place mines + int mines = nMines; + remaining = numRows*numCols-mines; + while ( mines ) { + int col = int((double(rand()) / double(RAND_MAX)) * numCols); + int row = int((double(rand()) / double(RAND_MAX)) * numRows); + + TileData* t = tile( row, col ); + + if (t && !t->hasMine()) { + t->setHasMine( true ); + mines--; + } + } + + //set hints + for (int r = 0; r < numRows; r++) + for (int c = 0; c < numCols; c++) { + TileData* t = tile(r, c); + if (t && !t->hasMine()) { + int hint = getHint(r,c); + t->setHint(hint); + } + } + + setPlaying(true); +} + +void MinehuntGame::reset() +{ + foreach(TileData* t, _tiles){ + t->unflip(); + t->setHasFlag(false); + } + nMines = 12; + nFlags = 0; + emit numMinesChanged(); + emit numFlagsChanged(); + setPlaying(false); + QTimer::singleShot(600,this, SLOT(setBoard())); +} + +int MinehuntGame::getHint(int row, int col) +{ + int hint = 0; + for (int c = col-1; c <= col+1; c++) + for (int r = row-1; r <= row+1; r++) { + TileData* t = tile(r, c); + if (t && t->hasMine()) + hint++; + } + return hint; +} + +bool MinehuntGame::flip(int row, int col) +{ + if(!playing) + return false; + + TileData *t = tile(row, col); + if (!t || t->hasFlag()) + return false; + + if(t->flipped()){ + int flags = 0; + for (int c = col-1; c <= col+1; c++) + for (int r = row-1; r <= row+1; r++) { + TileData *nearT = tile(r, c); + if(!nearT || nearT == t) + continue; + if(nearT->hasFlag()) + flags++; + } + if(!t->hint() || t->hint() != flags) + return false; + for (int c = col-1; c <= col+1; c++) + for (int r = row-1; r <= row+1; r++) { + TileData *nearT = tile(r, c); + if (nearT && !nearT->flipped() && !nearT->hasFlag()) { + flip( r, c ); + } + } + return true; + } + + t->flip(); + + if (t->hint() == 0) { + for (int c = col-1; c <= col+1; c++) + for (int r = row-1; r <= row+1; r++) { + TileData* t = tile(r, c); + if (t && !t->flipped()) { + flip( r, c ); + } + } + } + + if(t->hasMine()){ + for (int r = 0; r < numRows; r++)//Flip all other mines + for (int c = 0; c < numCols; c++) { + TileData* t = tile(r, c); + if (t && t->hasMine()) { + flip(r, c); + } + } + won = false; + hasWonChanged(); + setPlaying(false); + return true; + } + + remaining--; + if(!remaining){ + won = true; + hasWonChanged(); + setPlaying(false); + return true; + } + return true; +} + +bool MinehuntGame::flag(int row, int col) +{ + TileData *t = tile(row, col); + if(!t || !playing || t->flipped()) + return false; + + t->setHasFlag(!t->hasFlag()); + nFlags += (t->hasFlag()?1:-1); + emit numFlagsChanged(); + return true; +} diff --git a/examples/qml/minehunt/minehunt.h b/examples/qml/minehunt/minehunt.h new file mode 100644 index 0000000000..34bab71218 --- /dev/null +++ b/examples/qml/minehunt/minehunt.h @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include + +class TileData : public QObject +{ + Q_OBJECT +public: + TileData() : _hasFlag(false), _hasMine(false), _hint(-1), _flipped(false) {} + + Q_PROPERTY(bool hasFlag READ hasFlag WRITE setHasFlag NOTIFY hasFlagChanged) + bool hasFlag() const { return _hasFlag; } + + Q_PROPERTY(bool hasMine READ hasMine NOTIFY hasMineChanged) + bool hasMine() const { return _hasMine; } + + Q_PROPERTY(int hint READ hint NOTIFY hintChanged) + int hint() const { return _hint; } + + Q_PROPERTY(bool flipped READ flipped NOTIFY flippedChanged()) + bool flipped() const { return _flipped; } + + void setHasFlag(bool flag) {if(flag==_hasFlag) return; _hasFlag = flag; emit hasFlagChanged();} + void setHasMine(bool mine) {if(mine==_hasMine) return; _hasMine = mine; emit hasMineChanged();} + void setHint(int hint) { if(hint == _hint) return; _hint = hint; emit hintChanged(); } + void flip() { if (_flipped) return; _flipped = true; emit flippedChanged(); } + void unflip() { if(!_flipped) return; _flipped = false; emit flippedChanged(); } + +signals: + void flippedChanged(); + void hasFlagChanged(); + void hintChanged(); + void hasMineChanged(); + +private: + bool _hasFlag; + bool _hasMine; + int _hint; + bool _flipped; +}; + +class MinehuntGame : public QObject +{ + Q_OBJECT +public: + MinehuntGame(); + + Q_PROPERTY(QQmlListProperty tiles READ tiles CONSTANT) + QQmlListProperty tiles(); + + Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged) + bool isPlaying() {return playing;} + + Q_PROPERTY(bool hasWon READ hasWon NOTIFY hasWonChanged) + bool hasWon() {return won;} + + Q_PROPERTY(int numMines READ numMines NOTIFY numMinesChanged) + int numMines() const{return nMines;} + + Q_PROPERTY(int numFlags READ numFlags NOTIFY numFlagsChanged) + int numFlags() const{return nFlags;} + +public slots: + Q_INVOKABLE bool flip(int row, int col); + Q_INVOKABLE bool flag(int row, int col); + void setBoard(); + void reset(); + +signals: + void isPlayingChanged(); + void hasWonChanged(); + void numMinesChanged(); + void numFlagsChanged(); + +private: + bool onBoard( int r, int c ) const { return r >= 0 && r < numRows && c >= 0 && c < numCols; } + TileData *tile( int row, int col ) { return onBoard(row, col) ? _tiles[col+numRows*row] : 0; } + int getHint(int row, int col); + void setPlaying(bool b){if(b==playing) return; playing=b; emit isPlayingChanged();} + + QList _tiles; + int numCols; + int numRows; + bool playing; + bool won; + int remaining; + int nMines; + int nFlags; +}; diff --git a/examples/qml/minehunt/minehunt.pro b/examples/qml/minehunt/minehunt.pro new file mode 100644 index 0000000000..78e874d805 --- /dev/null +++ b/examples/qml/minehunt/minehunt.pro @@ -0,0 +1,5 @@ +QT += qml quick + +HEADERS += minehunt.h +SOURCES += main.cpp minehunt.cpp +RESOURCES = minehunt.qrc diff --git a/examples/qml/minehunt/minehunt.qml b/examples/qml/minehunt/minehunt.qml new file mode 100644 index 0000000000..42dc408fff --- /dev/null +++ b/examples/qml/minehunt/minehunt.qml @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "MinehuntCore" 2.0 + +Item { + id: field + property int clickx: 0 + property int clicky: 0 + + width: 450; height: 450 + + Image { source: "MinehuntCore/pics/background.png"; anchors.fill: parent; fillMode: Image.Tile } + + Grid { + anchors.horizontalCenter: parent.horizontalCenter + columns: 9; spacing: 1 + + Repeater { + id: repeater + model: tiles + delegate: Tile {} + } + } + + Row { + id: gamedata + x: 20; spacing: 20 + anchors.bottom: field.bottom; anchors.bottomMargin: 15 + + Image { + source: "MinehuntCore/pics/quit.png" + scale: quitMouse.pressed ? 0.8 : 1.0 + smooth: quitMouse.pressed + y: 10 + MouseArea { + id: quitMouse + anchors.fill: parent + anchors.margins: -20 + onClicked: Qt.quit() + } + } + Column { + spacing: 2 + Image { source: "MinehuntCore/pics/bomb-color.png" } + Text { anchors.horizontalCenter: parent.horizontalCenter; color: "white"; text: numMines } + } + + Column { + spacing: 2 + Image { source: "MinehuntCore/pics/flag-color.png" } + Text { anchors.horizontalCenter: parent.horizontalCenter; color: "white"; text: numFlags } + } + } + + Image { + anchors.bottom: field.bottom; anchors.bottomMargin: 15 + anchors.right: field.right; anchors.rightMargin: 20 + source: isPlaying ? 'MinehuntCore/pics/face-smile.png' : + hasWon ? 'MinehuntCore/pics/face-smile-big.png': 'MinehuntCore/pics/face-sad.png' + + MouseArea { anchors.fill: parent; onPressed: reset() } + } + Text { + anchors.centerIn: parent; width: parent.width - 20 + horizontalAlignment: Text.AlignHCenter + wrapMode: Text.WordWrap + text: "Minehunt demo has to be compiled to run.\n\nPlease see README." + color: "white"; font.bold: true; font.pixelSize: 14 + visible: tiles == undefined + } + +} diff --git a/examples/qml/minehunt/minehunt.qmlproject b/examples/qml/minehunt/minehunt.qmlproject new file mode 100644 index 0000000000..5aeb78f1ea --- /dev/null +++ b/examples/qml/minehunt/minehunt.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "minehunt.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/minehunt/minehunt.qrc b/examples/qml/minehunt/minehunt.qrc new file mode 100644 index 0000000000..fa8e27d383 --- /dev/null +++ b/examples/qml/minehunt/minehunt.qrc @@ -0,0 +1,20 @@ + + + minehunt.qml + MinehuntCore/Explosion.qml + MinehuntCore/Tile.qml + MinehuntCore/qmldir + MinehuntCore/pics/background.png + MinehuntCore/pics/back.png + MinehuntCore/pics/bomb-color.png + MinehuntCore/pics/bomb.png + MinehuntCore/pics/face-sad.png + MinehuntCore/pics/face-smile-big.png + MinehuntCore/pics/face-smile.png + MinehuntCore/pics/flag-color.png + MinehuntCore/pics/flag.png + MinehuntCore/pics/front.png + MinehuntCore/pics/quit.png + MinehuntCore/pics/star.png + + diff --git a/examples/qml/modelviews/abstractitemmodel/abstractitemmodel.pro b/examples/qml/modelviews/abstractitemmodel/abstractitemmodel.pro new file mode 100644 index 0000000000..f786d9356f --- /dev/null +++ b/examples/qml/modelviews/abstractitemmodel/abstractitemmodel.pro @@ -0,0 +1,10 @@ +TEMPLATE = app +TARGET = abstractitemmodel +DEPENDPATH += . +INCLUDEPATH += . +QT += qml quick + +HEADERS = model.h +SOURCES = main.cpp \ + model.cpp +RESOURCES += abstractitemmodel.qrc diff --git a/examples/qtquick/modelviews/abstractitemmodel/abstractitemmodel.qrc b/examples/qml/modelviews/abstractitemmodel/abstractitemmodel.qrc similarity index 100% rename from examples/qtquick/modelviews/abstractitemmodel/abstractitemmodel.qrc rename to examples/qml/modelviews/abstractitemmodel/abstractitemmodel.qrc diff --git a/examples/qml/modelviews/abstractitemmodel/main.cpp b/examples/qml/modelviews/abstractitemmodel/main.cpp new file mode 100644 index 0000000000..f5930ce840 --- /dev/null +++ b/examples/qml/modelviews/abstractitemmodel/main.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "model.h" + +#include +#include +#include +#include +#include +#include + +//![0] +int main(int argc, char ** argv) +{ + QGuiApplication app(argc, argv); + + AnimalModel model; + model.addAnimal(Animal("Wolf", "Medium")); + model.addAnimal(Animal("Polar bear", "Large")); + model.addAnimal(Animal("Quoll", "Small")); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + QQmlContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", &model); +//![0] + + view.setSource(QUrl("qrc:view.qml")); + view.show(); + + return app.exec(); +} + diff --git a/examples/qtquick/modelviews/abstractitemmodel/model.cpp b/examples/qml/modelviews/abstractitemmodel/model.cpp similarity index 100% rename from examples/qtquick/modelviews/abstractitemmodel/model.cpp rename to examples/qml/modelviews/abstractitemmodel/model.cpp diff --git a/examples/qtquick/modelviews/abstractitemmodel/model.h b/examples/qml/modelviews/abstractitemmodel/model.h similarity index 100% rename from examples/qtquick/modelviews/abstractitemmodel/model.h rename to examples/qml/modelviews/abstractitemmodel/model.h diff --git a/examples/qtquick/modelviews/abstractitemmodel/view.qml b/examples/qml/modelviews/abstractitemmodel/view.qml similarity index 100% rename from examples/qtquick/modelviews/abstractitemmodel/view.qml rename to examples/qml/modelviews/abstractitemmodel/view.qml diff --git a/examples/qtquick/modelviews/gridview/gridview-example.qml b/examples/qml/modelviews/gridview/gridview-example.qml similarity index 100% rename from examples/qtquick/modelviews/gridview/gridview-example.qml rename to examples/qml/modelviews/gridview/gridview-example.qml diff --git a/examples/qtquick/modelviews/gridview/pics/AddressBook_48.png b/examples/qml/modelviews/gridview/pics/AddressBook_48.png similarity index 100% rename from examples/qtquick/modelviews/gridview/pics/AddressBook_48.png rename to examples/qml/modelviews/gridview/pics/AddressBook_48.png diff --git a/examples/qtquick/modelviews/gridview/pics/AudioPlayer_48.png b/examples/qml/modelviews/gridview/pics/AudioPlayer_48.png similarity index 100% rename from examples/qtquick/modelviews/gridview/pics/AudioPlayer_48.png rename to examples/qml/modelviews/gridview/pics/AudioPlayer_48.png diff --git a/examples/qtquick/modelviews/gridview/pics/Camera_48.png b/examples/qml/modelviews/gridview/pics/Camera_48.png similarity index 100% rename from examples/qtquick/modelviews/gridview/pics/Camera_48.png rename to examples/qml/modelviews/gridview/pics/Camera_48.png diff --git a/examples/qtquick/modelviews/gridview/pics/DateBook_48.png b/examples/qml/modelviews/gridview/pics/DateBook_48.png similarity index 100% rename from examples/qtquick/modelviews/gridview/pics/DateBook_48.png rename to examples/qml/modelviews/gridview/pics/DateBook_48.png diff --git a/examples/qtquick/modelviews/gridview/pics/EMail_48.png b/examples/qml/modelviews/gridview/pics/EMail_48.png similarity index 100% rename from examples/qtquick/modelviews/gridview/pics/EMail_48.png rename to examples/qml/modelviews/gridview/pics/EMail_48.png diff --git a/examples/qtquick/modelviews/gridview/pics/TodoList_48.png b/examples/qml/modelviews/gridview/pics/TodoList_48.png similarity index 100% rename from examples/qtquick/modelviews/gridview/pics/TodoList_48.png rename to examples/qml/modelviews/gridview/pics/TodoList_48.png diff --git a/examples/qtquick/modelviews/gridview/pics/VideoPlayer_48.png b/examples/qml/modelviews/gridview/pics/VideoPlayer_48.png similarity index 100% rename from examples/qtquick/modelviews/gridview/pics/VideoPlayer_48.png rename to examples/qml/modelviews/gridview/pics/VideoPlayer_48.png diff --git a/examples/qtquick/modelviews/listview/content/PetsModel.qml b/examples/qml/modelviews/listview/content/PetsModel.qml similarity index 100% rename from examples/qtquick/modelviews/listview/content/PetsModel.qml rename to examples/qml/modelviews/listview/content/PetsModel.qml diff --git a/examples/qtquick/modelviews/listview/content/PressAndHoldButton.qml b/examples/qml/modelviews/listview/content/PressAndHoldButton.qml similarity index 100% rename from examples/qtquick/modelviews/listview/content/PressAndHoldButton.qml rename to examples/qml/modelviews/listview/content/PressAndHoldButton.qml diff --git a/examples/qtquick/modelviews/listview/content/RecipesModel.qml b/examples/qml/modelviews/listview/content/RecipesModel.qml similarity index 100% rename from examples/qtquick/modelviews/listview/content/RecipesModel.qml rename to examples/qml/modelviews/listview/content/RecipesModel.qml diff --git a/examples/qtquick/modelviews/listview/content/TextButton.qml b/examples/qml/modelviews/listview/content/TextButton.qml similarity index 100% rename from examples/qtquick/modelviews/listview/content/TextButton.qml rename to examples/qml/modelviews/listview/content/TextButton.qml diff --git a/examples/qml/modelviews/listview/content/ToggleButton.qml b/examples/qml/modelviews/listview/content/ToggleButton.qml new file mode 100644 index 0000000000..52f4988f03 --- /dev/null +++ b/examples/qml/modelviews/listview/content/ToggleButton.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: root + property alias label: text.text + property bool active: false + signal toggled + width: 149 + height: 30 + radius: 3 + color: active ? "green" : "lightgray" + border.width: 1 + Text { id: text; anchors.centerIn: parent; font.pixelSize: 14 } + MouseArea { + anchors.fill: parent + onClicked: { active = !active; root.toggled() } + } +} diff --git a/examples/qtquick/modelviews/listview/content/pics/arrow-down.png b/examples/qml/modelviews/listview/content/pics/arrow-down.png similarity index 100% rename from examples/qtquick/modelviews/listview/content/pics/arrow-down.png rename to examples/qml/modelviews/listview/content/pics/arrow-down.png diff --git a/examples/qtquick/modelviews/listview/content/pics/arrow-up.png b/examples/qml/modelviews/listview/content/pics/arrow-up.png similarity index 100% rename from examples/qtquick/modelviews/listview/content/pics/arrow-up.png rename to examples/qml/modelviews/listview/content/pics/arrow-up.png diff --git a/examples/qtquick/modelviews/listview/content/pics/fruit-salad.jpg b/examples/qml/modelviews/listview/content/pics/fruit-salad.jpg similarity index 100% rename from examples/qtquick/modelviews/listview/content/pics/fruit-salad.jpg rename to examples/qml/modelviews/listview/content/pics/fruit-salad.jpg diff --git a/examples/qtquick/modelviews/listview/content/pics/hamburger.jpg b/examples/qml/modelviews/listview/content/pics/hamburger.jpg similarity index 100% rename from examples/qtquick/modelviews/listview/content/pics/hamburger.jpg rename to examples/qml/modelviews/listview/content/pics/hamburger.jpg diff --git a/examples/qtquick/modelviews/listview/content/pics/lemonade.jpg b/examples/qml/modelviews/listview/content/pics/lemonade.jpg similarity index 100% rename from examples/qtquick/modelviews/listview/content/pics/lemonade.jpg rename to examples/qml/modelviews/listview/content/pics/lemonade.jpg diff --git a/examples/qtquick/modelviews/listview/content/pics/list-delete.png b/examples/qml/modelviews/listview/content/pics/list-delete.png similarity index 100% rename from examples/qtquick/modelviews/listview/content/pics/list-delete.png rename to examples/qml/modelviews/listview/content/pics/list-delete.png diff --git a/examples/qtquick/modelviews/listview/content/pics/minus-sign.png b/examples/qml/modelviews/listview/content/pics/minus-sign.png similarity index 100% rename from examples/qtquick/modelviews/listview/content/pics/minus-sign.png rename to examples/qml/modelviews/listview/content/pics/minus-sign.png diff --git a/examples/qtquick/modelviews/listview/content/pics/moreDown.png b/examples/qml/modelviews/listview/content/pics/moreDown.png similarity index 100% rename from examples/qtquick/modelviews/listview/content/pics/moreDown.png rename to examples/qml/modelviews/listview/content/pics/moreDown.png diff --git a/examples/qtquick/modelviews/listview/content/pics/moreUp.png b/examples/qml/modelviews/listview/content/pics/moreUp.png similarity index 100% rename from examples/qtquick/modelviews/listview/content/pics/moreUp.png rename to examples/qml/modelviews/listview/content/pics/moreUp.png diff --git a/examples/qtquick/modelviews/listview/content/pics/pancakes.jpg b/examples/qml/modelviews/listview/content/pics/pancakes.jpg similarity index 100% rename from examples/qtquick/modelviews/listview/content/pics/pancakes.jpg rename to examples/qml/modelviews/listview/content/pics/pancakes.jpg diff --git a/examples/qtquick/modelviews/listview/content/pics/plus-sign.png b/examples/qml/modelviews/listview/content/pics/plus-sign.png similarity index 100% rename from examples/qtquick/modelviews/listview/content/pics/plus-sign.png rename to examples/qml/modelviews/listview/content/pics/plus-sign.png diff --git a/examples/qtquick/modelviews/listview/content/pics/vegetable-soup.jpg b/examples/qml/modelviews/listview/content/pics/vegetable-soup.jpg similarity index 100% rename from examples/qtquick/modelviews/listview/content/pics/vegetable-soup.jpg rename to examples/qml/modelviews/listview/content/pics/vegetable-soup.jpg diff --git a/examples/qtquick/modelviews/listview/dynamiclist.qml b/examples/qml/modelviews/listview/dynamiclist.qml similarity index 100% rename from examples/qtquick/modelviews/listview/dynamiclist.qml rename to examples/qml/modelviews/listview/dynamiclist.qml diff --git a/examples/qtquick/modelviews/listview/expandingdelegates.qml b/examples/qml/modelviews/listview/expandingdelegates.qml similarity index 100% rename from examples/qtquick/modelviews/listview/expandingdelegates.qml rename to examples/qml/modelviews/listview/expandingdelegates.qml diff --git a/examples/qtquick/modelviews/listview/highlight.qml b/examples/qml/modelviews/listview/highlight.qml similarity index 100% rename from examples/qtquick/modelviews/listview/highlight.qml rename to examples/qml/modelviews/listview/highlight.qml diff --git a/examples/qtquick/modelviews/listview/highlightranges.qml b/examples/qml/modelviews/listview/highlightranges.qml similarity index 100% rename from examples/qtquick/modelviews/listview/highlightranges.qml rename to examples/qml/modelviews/listview/highlightranges.qml diff --git a/examples/qtquick/modelviews/listview/sections.qml b/examples/qml/modelviews/listview/sections.qml similarity index 100% rename from examples/qtquick/modelviews/listview/sections.qml rename to examples/qml/modelviews/listview/sections.qml diff --git a/examples/qtquick/modelviews/modelviews.pro b/examples/qml/modelviews/modelviews.pro similarity index 100% rename from examples/qtquick/modelviews/modelviews.pro rename to examples/qml/modelviews/modelviews.pro diff --git a/examples/qml/modelviews/modelviews.qml b/examples/qml/modelviews/modelviews.qml new file mode 100644 index 0000000000..86b10ca4ba --- /dev/null +++ b/examples/qml/modelviews/modelviews.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../shared" + +Item { + height: 480 + width: 480 + LauncherList { + id: ll + anchors.fill: parent + Component.onCompleted: { + addExample("Dynamic List", "A ListView harboring dynamic data", Qt.resolvedUrl("listview/dynamiclist.qml")); + addExample("Expanding Delegates", "Delegates that expand to fill the list when clicked", Qt.resolvedUrl("listview/expandingdelegates.qml")); + addExample("Highlight", "Adding a highlight to the current item", Qt.resolvedUrl("listview/highlight.qml")); + addExample("Sections", "A ListView with section headers", Qt.resolvedUrl("listview/sections.qml")); + addExample("GridView", "A view laid out in a grid", Qt.resolvedUrl("gridview/gridview-example.qml")); + addExample("PathView", "A view laid out along a path", Qt.resolvedUrl("pathview/pathview-example.qml")); + addExample("Package", "Using a package to transition items between views", Qt.resolvedUrl("package/view.qml")); + addExample("Parallax", "Adds a background and a parallax effect to a ListView", Qt.resolvedUrl("parallax/parallax.qml")); + addExample("Slideshow", "A model demonstrating delayed image loading", Qt.resolvedUrl("visualdatamodel/slideshow.qml")); + addExample("Sorted Model", "Two views on a model, one of which is sorted", Qt.resolvedUrl("visualdatamodel/sortedmodel.qml")); + addExample("VisualItemModel", "A model that consists of the actual Items", Qt.resolvedUrl("visualitemmodel/visualitemmodel.qml")); + } + } +} diff --git a/examples/qtquick/modelviews/modelviews.qmlproject b/examples/qml/modelviews/modelviews.qmlproject similarity index 100% rename from examples/qtquick/modelviews/modelviews.qmlproject rename to examples/qml/modelviews/modelviews.qmlproject diff --git a/examples/qtquick/modelviews/objectlistmodel/dataobject.cpp b/examples/qml/modelviews/objectlistmodel/dataobject.cpp similarity index 100% rename from examples/qtquick/modelviews/objectlistmodel/dataobject.cpp rename to examples/qml/modelviews/objectlistmodel/dataobject.cpp diff --git a/examples/qtquick/modelviews/objectlistmodel/dataobject.h b/examples/qml/modelviews/objectlistmodel/dataobject.h similarity index 100% rename from examples/qtquick/modelviews/objectlistmodel/dataobject.h rename to examples/qml/modelviews/objectlistmodel/dataobject.h diff --git a/examples/qml/modelviews/objectlistmodel/main.cpp b/examples/qml/modelviews/objectlistmodel/main.cpp new file mode 100644 index 0000000000..bb3895f7c0 --- /dev/null +++ b/examples/qml/modelviews/objectlistmodel/main.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include +#include +#include +#include + +#include "dataobject.h" + +/* + This example illustrates exposing a QList as a + model in QML +*/ + +//![0] +int main(int argc, char ** argv) +{ + QGuiApplication app(argc, argv); + + QList dataList; + dataList.append(new DataObject("Item 1", "red")); + dataList.append(new DataObject("Item 2", "green")); + dataList.append(new DataObject("Item 3", "blue")); + dataList.append(new DataObject("Item 4", "yellow")); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + QQmlContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); +//![0] + + view.setSource(QUrl("qrc:view.qml")); + view.show(); + + return app.exec(); +} + diff --git a/examples/qml/modelviews/objectlistmodel/objectlistmodel.pro b/examples/qml/modelviews/objectlistmodel/objectlistmodel.pro new file mode 100644 index 0000000000..7f323c3999 --- /dev/null +++ b/examples/qml/modelviews/objectlistmodel/objectlistmodel.pro @@ -0,0 +1,6 @@ +QT += qml quick + +SOURCES += main.cpp \ + dataobject.cpp +HEADERS += dataobject.h +RESOURCES += objectlistmodel.qrc diff --git a/examples/qtquick/modelviews/visualdatamodel/visualdatamodel.qmlproject b/examples/qml/modelviews/objectlistmodel/objectlistmodel.qmlproject similarity index 100% rename from examples/qtquick/modelviews/visualdatamodel/visualdatamodel.qmlproject rename to examples/qml/modelviews/objectlistmodel/objectlistmodel.qmlproject diff --git a/examples/qtquick/modelviews/objectlistmodel/objectlistmodel.qrc b/examples/qml/modelviews/objectlistmodel/objectlistmodel.qrc similarity index 100% rename from examples/qtquick/modelviews/objectlistmodel/objectlistmodel.qrc rename to examples/qml/modelviews/objectlistmodel/objectlistmodel.qrc diff --git a/examples/qtquick/modelviews/objectlistmodel/view.qml b/examples/qml/modelviews/objectlistmodel/view.qml similarity index 100% rename from examples/qtquick/modelviews/objectlistmodel/view.qml rename to examples/qml/modelviews/objectlistmodel/view.qml diff --git a/examples/qtquick/modelviews/package/Delegate.qml b/examples/qml/modelviews/package/Delegate.qml similarity index 100% rename from examples/qtquick/modelviews/package/Delegate.qml rename to examples/qml/modelviews/package/Delegate.qml diff --git a/examples/qml/modelviews/package/view.qml b/examples/qml/modelviews/package/view.qml new file mode 100644 index 0000000000..5b2fd9481c --- /dev/null +++ b/examples/qml/modelviews/package/view.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + color: "white" + width: 400 + height: 200 + + ListModel { + id: myModel + ListElement { display: "One" } + ListElement { display: "Two" } + ListElement { display: "Three" } + ListElement { display: "Four" } + ListElement { display: "Five" } + ListElement { display: "Six" } + ListElement { display: "Seven" } + ListElement { display: "Eight" } + } + //![0] + VisualDataModel { + id: visualModel + delegate: Delegate {} + model: myModel + } + + ListView { + width: 200; height:200 + model: visualModel.parts.list + } + GridView { + x: 200; width: 200; height:200 + cellHeight: 50 + model: visualModel.parts.grid + } + //![0] +} diff --git a/examples/qtquick/modelviews/parallax/content/ParallaxView.qml b/examples/qml/modelviews/parallax/content/ParallaxView.qml similarity index 100% rename from examples/qtquick/modelviews/parallax/content/ParallaxView.qml rename to examples/qml/modelviews/parallax/content/ParallaxView.qml diff --git a/examples/qtquick/modelviews/parallax/content/Smiley.qml b/examples/qml/modelviews/parallax/content/Smiley.qml similarity index 100% rename from examples/qtquick/modelviews/parallax/content/Smiley.qml rename to examples/qml/modelviews/parallax/content/Smiley.qml diff --git a/examples/qtquick/modelviews/parallax/content/pics/background.jpg b/examples/qml/modelviews/parallax/content/pics/background.jpg similarity index 100% rename from examples/qtquick/modelviews/parallax/content/pics/background.jpg rename to examples/qml/modelviews/parallax/content/pics/background.jpg diff --git a/examples/qtquick/shadereffects/content/face-smile.png b/examples/qml/modelviews/parallax/content/pics/face-smile.png similarity index 100% rename from examples/qtquick/shadereffects/content/face-smile.png rename to examples/qml/modelviews/parallax/content/pics/face-smile.png diff --git a/examples/qtquick/modelviews/parallax/content/pics/home-page.png b/examples/qml/modelviews/parallax/content/pics/home-page.png similarity index 100% rename from examples/qtquick/modelviews/parallax/content/pics/home-page.png rename to examples/qml/modelviews/parallax/content/pics/home-page.png diff --git a/examples/qtquick/modelviews/parallax/content/pics/home-page.svg b/examples/qml/modelviews/parallax/content/pics/home-page.svg similarity index 100% rename from examples/qtquick/modelviews/parallax/content/pics/home-page.svg rename to examples/qml/modelviews/parallax/content/pics/home-page.svg diff --git a/examples/qtquick/modelviews/parallax/content/pics/shadow.png b/examples/qml/modelviews/parallax/content/pics/shadow.png similarity index 100% rename from examples/qtquick/modelviews/parallax/content/pics/shadow.png rename to examples/qml/modelviews/parallax/content/pics/shadow.png diff --git a/examples/qtquick/modelviews/parallax/content/pics/yast-joystick.png b/examples/qml/modelviews/parallax/content/pics/yast-joystick.png similarity index 100% rename from examples/qtquick/modelviews/parallax/content/pics/yast-joystick.png rename to examples/qml/modelviews/parallax/content/pics/yast-joystick.png diff --git a/examples/qtquick/modelviews/parallax/content/pics/yast-wol.png b/examples/qml/modelviews/parallax/content/pics/yast-wol.png similarity index 100% rename from examples/qtquick/modelviews/parallax/content/pics/yast-wol.png rename to examples/qml/modelviews/parallax/content/pics/yast-wol.png diff --git a/examples/qml/modelviews/parallax/parallax.qml b/examples/qml/modelviews/parallax/parallax.qml new file mode 100644 index 0000000000..6981095a80 --- /dev/null +++ b/examples/qml/modelviews/parallax/parallax.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../../toys/clocks/content" // for loading the Clock element +import "content" + +Rectangle { + width: 320; height: 480 + + ParallaxView { + id: parallax + anchors.fill: parent + background: "content/pics/background.jpg" + + Item { + property url icon: "content/pics/yast-wol.png" + width: 320; height: 480 + Clock { anchors.centerIn: parent } + } + + Item { + property url icon: "content/pics/home-page.png" + width: 320; height: 480 + Smiley { } + } + + Item { + property url icon: "content/pics/yast-joystick.png" + width: 320; height: 480 + + Loader { + anchors { top: parent.top; topMargin: 10; horizontalCenter: parent.horizontalCenter } + width: 300; height: 400 + clip: true; + source: "../../samegame/samegame.qml" + } + } + } +} diff --git a/examples/qtquick/modelviews/pathview/pathview-example.qml b/examples/qml/modelviews/pathview/pathview-example.qml similarity index 100% rename from examples/qtquick/modelviews/pathview/pathview-example.qml rename to examples/qml/modelviews/pathview/pathview-example.qml diff --git a/examples/qtquick/modelviews/pathview/pics/AddressBook_48.png b/examples/qml/modelviews/pathview/pics/AddressBook_48.png similarity index 100% rename from examples/qtquick/modelviews/pathview/pics/AddressBook_48.png rename to examples/qml/modelviews/pathview/pics/AddressBook_48.png diff --git a/examples/qtquick/modelviews/pathview/pics/AudioPlayer_48.png b/examples/qml/modelviews/pathview/pics/AudioPlayer_48.png similarity index 100% rename from examples/qtquick/modelviews/pathview/pics/AudioPlayer_48.png rename to examples/qml/modelviews/pathview/pics/AudioPlayer_48.png diff --git a/examples/qtquick/modelviews/pathview/pics/Camera_48.png b/examples/qml/modelviews/pathview/pics/Camera_48.png similarity index 100% rename from examples/qtquick/modelviews/pathview/pics/Camera_48.png rename to examples/qml/modelviews/pathview/pics/Camera_48.png diff --git a/examples/qtquick/modelviews/pathview/pics/DateBook_48.png b/examples/qml/modelviews/pathview/pics/DateBook_48.png similarity index 100% rename from examples/qtquick/modelviews/pathview/pics/DateBook_48.png rename to examples/qml/modelviews/pathview/pics/DateBook_48.png diff --git a/examples/qtquick/modelviews/pathview/pics/EMail_48.png b/examples/qml/modelviews/pathview/pics/EMail_48.png similarity index 100% rename from examples/qtquick/modelviews/pathview/pics/EMail_48.png rename to examples/qml/modelviews/pathview/pics/EMail_48.png diff --git a/examples/qtquick/modelviews/pathview/pics/TodoList_48.png b/examples/qml/modelviews/pathview/pics/TodoList_48.png similarity index 100% rename from examples/qtquick/modelviews/pathview/pics/TodoList_48.png rename to examples/qml/modelviews/pathview/pics/TodoList_48.png diff --git a/examples/qtquick/modelviews/pathview/pics/VideoPlayer_48.png b/examples/qml/modelviews/pathview/pics/VideoPlayer_48.png similarity index 100% rename from examples/qtquick/modelviews/pathview/pics/VideoPlayer_48.png rename to examples/qml/modelviews/pathview/pics/VideoPlayer_48.png diff --git a/examples/qml/modelviews/stringlistmodel/main.cpp b/examples/qml/modelviews/stringlistmodel/main.cpp new file mode 100644 index 0000000000..12859316a3 --- /dev/null +++ b/examples/qml/modelviews/stringlistmodel/main.cpp @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include +#include +#include +#include +#include + + +/* + This example illustrates exposing a QStringList as a + model in QML +*/ + +int main(int argc, char ** argv) +{ + QGuiApplication app(argc, argv); + +//![0] + QStringList dataList; + dataList.append("Item 1"); + dataList.append("Item 2"); + dataList.append("Item 3"); + dataList.append("Item 4"); + + QQuickView view; + QQmlContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); +//![0] + + view.setSource(QUrl("qrc:view.qml")); + view.show(); + + return app.exec(); +} + diff --git a/examples/qml/modelviews/stringlistmodel/stringlistmodel.pro b/examples/qml/modelviews/stringlistmodel/stringlistmodel.pro new file mode 100644 index 0000000000..19e62cd1b7 --- /dev/null +++ b/examples/qml/modelviews/stringlistmodel/stringlistmodel.pro @@ -0,0 +1,4 @@ +QT += qml quick + +SOURCES += main.cpp +RESOURCES += stringlistmodel.qrc diff --git a/examples/qtquick/modelviews/stringlistmodel/stringlistmodel.qrc b/examples/qml/modelviews/stringlistmodel/stringlistmodel.qrc similarity index 100% rename from examples/qtquick/modelviews/stringlistmodel/stringlistmodel.qrc rename to examples/qml/modelviews/stringlistmodel/stringlistmodel.qrc diff --git a/examples/qtquick/modelviews/stringlistmodel/view.qml b/examples/qml/modelviews/stringlistmodel/view.qml similarity index 100% rename from examples/qtquick/modelviews/stringlistmodel/view.qml rename to examples/qml/modelviews/stringlistmodel/view.qml diff --git a/examples/qtquick/modelviews/visualdatamodel/dragselection.qml b/examples/qml/modelviews/visualdatamodel/dragselection.qml similarity index 100% rename from examples/qtquick/modelviews/visualdatamodel/dragselection.qml rename to examples/qml/modelviews/visualdatamodel/dragselection.qml diff --git a/examples/qtquick/modelviews/visualdatamodel/slideshow.qml b/examples/qml/modelviews/visualdatamodel/slideshow.qml similarity index 100% rename from examples/qtquick/modelviews/visualdatamodel/slideshow.qml rename to examples/qml/modelviews/visualdatamodel/slideshow.qml diff --git a/examples/qtquick/modelviews/visualdatamodel/sortedmodel.qml b/examples/qml/modelviews/visualdatamodel/sortedmodel.qml similarity index 100% rename from examples/qtquick/modelviews/visualdatamodel/sortedmodel.qml rename to examples/qml/modelviews/visualdatamodel/sortedmodel.qml diff --git a/examples/qml/modelviews/visualdatamodel/visualdatamodel.qmlproject b/examples/qml/modelviews/visualdatamodel/visualdatamodel.qmlproject new file mode 100644 index 0000000000..2bb4016996 --- /dev/null +++ b/examples/qml/modelviews/visualdatamodel/visualdatamodel.qmlproject @@ -0,0 +1,14 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/modelviews/visualitemmodel/visualitemmodel.qml b/examples/qml/modelviews/visualitemmodel/visualitemmodel.qml new file mode 100644 index 0000000000..3425150d9a --- /dev/null +++ b/examples/qml/modelviews/visualitemmodel/visualitemmodel.qml @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This example demonstrates placing items in a view using +// a VisualItemModel + +import QtQuick 2.0 + +Rectangle { + color: "lightgray" + width: 240 + height: 320 + property bool printDestruction: false + + VisualItemModel { + id: itemModel + + Rectangle { + width: view.width; height: view.height + color: "#FFFEF0" + Text { text: "Page 1"; font.bold: true; anchors.centerIn: parent } + + Component.onDestruction: if (printDestruction) print("destroyed 1") + } + Rectangle { + width: view.width; height: view.height + color: "#F0FFF7" + Text { text: "Page 2"; font.bold: true; anchors.centerIn: parent } + + Component.onDestruction: if (printDestruction) print("destroyed 2") + } + Rectangle { + width: view.width; height: view.height + color: "#F4F0FF" + Text { text: "Page 3"; font.bold: true; anchors.centerIn: parent } + + Component.onDestruction: if (printDestruction) print("destroyed 3") + } + } + + ListView { + id: view + anchors { fill: parent; bottomMargin: 30 } + model: itemModel + preferredHighlightBegin: 0; preferredHighlightEnd: 0 + highlightRangeMode: ListView.StrictlyEnforceRange + orientation: ListView.Horizontal + snapMode: ListView.SnapOneItem; flickDeceleration: 2000 + cacheBuffer: 200 + } + + Rectangle { + width: 240; height: 30 + anchors { top: view.bottom; bottom: parent.bottom } + color: "gray" + + Row { + anchors.centerIn: parent + spacing: 20 + + Repeater { + model: itemModel.count + + Rectangle { + width: 5; height: 5 + radius: 3 + color: view.currentIndex == index ? "blue" : "white" + + MouseArea { + width: 20; height: 20 + anchors.centerIn: parent + onClicked: view.currentIndex = index + } + } + } + } + } +} diff --git a/examples/qtquick/openglunderqml/main.cpp b/examples/qml/openglunderqml/main.cpp similarity index 100% rename from examples/qtquick/openglunderqml/main.cpp rename to examples/qml/openglunderqml/main.cpp diff --git a/examples/qtquick/openglunderqml/main.qml b/examples/qml/openglunderqml/main.qml similarity index 100% rename from examples/qtquick/openglunderqml/main.qml rename to examples/qml/openglunderqml/main.qml diff --git a/examples/qml/openglunderqml/openglunderqml.pro b/examples/qml/openglunderqml/openglunderqml.pro new file mode 100644 index 0000000000..64a58b3729 --- /dev/null +++ b/examples/qml/openglunderqml/openglunderqml.pro @@ -0,0 +1,6 @@ +QT += qml quick + +HEADERS += squircle.h +SOURCES += squircle.cpp main.cpp + +OTHER_FILES += main.qml diff --git a/examples/qtquick/openglunderqml/squircle.cpp b/examples/qml/openglunderqml/squircle.cpp similarity index 100% rename from examples/qtquick/openglunderqml/squircle.cpp rename to examples/qml/openglunderqml/squircle.cpp diff --git a/examples/qtquick/openglunderqml/squircle.h b/examples/qml/openglunderqml/squircle.h similarity index 100% rename from examples/qtquick/openglunderqml/squircle.h rename to examples/qml/openglunderqml/squircle.h diff --git a/examples/qtquick/painteditem/painteditem.pro b/examples/qml/painteditem/painteditem.pro similarity index 100% rename from examples/qtquick/painteditem/painteditem.pro rename to examples/qml/painteditem/painteditem.pro diff --git a/examples/qml/painteditem/smile/main.cpp b/examples/qml/painteditem/smile/main.cpp new file mode 100644 index 0000000000..1c7888b10b --- /dev/null +++ b/examples/qml/painteditem/smile/main.cpp @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +class MyPaintItem : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(QString face READ face WRITE setFace NOTIFY faceChanged) +public: + MyPaintItem() + : QQuickPaintedItem() + , m_face(QLatin1String(":-)")) + { + setAntialiasing(true); + } + QString face() const {return m_face;} + void setFace(const QString &face) { + if (m_face != face) { + m_face = face; + emit faceChanged(); + } + } + virtual void paint(QPainter *p) + { + QRectF rect(0, 0, width(), height()); + rect.adjust(10, 10, -10, -10); + p->setPen(QPen(Qt::black, 20)); + p->setBrush(Qt::yellow); + p->drawEllipse(rect); + p->setPen(Qt::black); + p->setFont(QFont(QLatin1String("Times"), qRound(rect.height() / 2))); + p->drawText(rect, Qt::AlignCenter, m_face); + } +signals: + void faceChanged(); +private: + QString m_face; +}; + +int main(int argc, char ** argv) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("MyModule", 1, 0, "MyPaintItem"); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("smile.qml")); + view.show(); + view.raise(); + + return app.exec(); +} + +#include "main.moc" diff --git a/examples/qml/painteditem/smile/smile.pro b/examples/qml/painteditem/smile/smile.pro new file mode 100644 index 0000000000..b1af4ee0ad --- /dev/null +++ b/examples/qml/painteditem/smile/smile.pro @@ -0,0 +1,11 @@ +TEMPLATE = app +TARGET = painteditem + +QT += qml quick + +macx: CONFIG -= app_bundle + +SOURCES += main.cpp + +CONFIG += console + diff --git a/examples/qtquick/painteditem/smile/smile.qml b/examples/qml/painteditem/smile/smile.qml similarity index 100% rename from examples/qtquick/painteditem/smile/smile.qml rename to examples/qml/painteditem/smile/smile.qml diff --git a/examples/qml/painteditem/textballoons/TextBalloonPlugin/plugin.h b/examples/qml/painteditem/textballoons/TextBalloonPlugin/plugin.h new file mode 100644 index 0000000000..e6523e15a9 --- /dev/null +++ b/examples/qml/painteditem/textballoons/TextBalloonPlugin/plugin.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "../textballoon.h" + +class TextBalloonPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT +public: + void registerTypes(const char *uri) + { + qmlRegisterType(uri, 1, 0, "TextBalloon"); + } +}; + +Q_EXPORT_PLUGIN2(qmltextballoonplugin, TextBalloonPlugin); diff --git a/examples/qtquick/painteditem/textballoons/TextBalloonPlugin/qmldir b/examples/qml/painteditem/textballoons/TextBalloonPlugin/qmldir similarity index 100% rename from examples/qtquick/painteditem/textballoons/TextBalloonPlugin/qmldir rename to examples/qml/painteditem/textballoons/TextBalloonPlugin/qmldir diff --git a/examples/qtquick/painteditem/textballoons/textballoon.cpp b/examples/qml/painteditem/textballoons/textballoon.cpp similarity index 100% rename from examples/qtquick/painteditem/textballoons/textballoon.cpp rename to examples/qml/painteditem/textballoons/textballoon.cpp diff --git a/examples/qtquick/painteditem/textballoons/textballoon.h b/examples/qml/painteditem/textballoons/textballoon.h similarity index 100% rename from examples/qtquick/painteditem/textballoons/textballoon.h rename to examples/qml/painteditem/textballoons/textballoon.h diff --git a/examples/qml/painteditem/textballoons/textballoons.pro b/examples/qml/painteditem/textballoons/textballoons.pro new file mode 100644 index 0000000000..9bc0f3c04a --- /dev/null +++ b/examples/qml/painteditem/textballoons/textballoons.pro @@ -0,0 +1,23 @@ +TEMPLATE = lib +CONFIG += qt plugin +QT += qml quick + +TARGET = qmltextballoonplugin + +HEADERS += TextBalloonPlugin/plugin.h \ + textballoon.h + +SOURCES += textballoon.cpp + +DESTDIR = TextBalloonPlugin + +qqmlsources.files += \ + TextBalloonPlugin/qmldir + +qqmlsources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem/textballoons/TextBalloonPlugin + +sources.files = textballoons.qml +sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem/textballoons +target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem/textballoons/TextBalloonPlugin + +INSTALLS = qqmlsources sources target diff --git a/examples/qtquick/painteditem/textballoons/textballoons.qml b/examples/qml/painteditem/textballoons/textballoons.qml similarity index 100% rename from examples/qtquick/painteditem/textballoons/textballoons.qml rename to examples/qml/painteditem/textballoons/textballoons.qml diff --git a/examples/qml/particles/affectors/age.qml b/examples/qml/particles/affectors/age.qml new file mode 100644 index 0000000000..1e7774b63b --- /dev/null +++ b/examples/qml/particles/affectors/age.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + id: root + width: 360 + height: 600 + color: "white" + + ParticleSystem { id: particles } + + ImageParticle { + system: particles + sprites: Sprite { + name: "snow" + source: "../images/snowflake.png" + frames: 51 + frameDuration: 40 + frameDurationVariation: 8 + } + } + + Emitter { + system: particles + emitRate: 20 + lifeSpan: 8000 + speed: PointDirection { y:80; yVariation: 40; } + acceleration: PointDirection { y: 4 } + size: 36 + endSize: 12 + sizeVariation: 8 + width: parent.width + height: 100 + } + + MouseArea { + id: ma + anchors.fill: parent + hoverEnabled: true + } + + Rectangle { + color: "#803333AA" + border.color: "black" + x: ma.mouseX - 36 + y: ma.mouseY - 36 + width: 72 + height: 72 + Age { + anchors.fill: parent + system: particles + once: true + lifeLeft: 1200 + advancePosition: false + } + } +} diff --git a/examples/qml/particles/affectors/attractor.qml b/examples/qml/particles/affectors/attractor.qml new file mode 100644 index 0000000000..460a497a92 --- /dev/null +++ b/examples/qml/particles/affectors/attractor.qml @@ -0,0 +1,213 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + id: root + width: 360 + height: 540 + color: "black" + property bool spacePressed: false + focus: true + Image { + source: "../images/finalfrontier.png" + anchors.centerIn:parent + } + Keys.onPressed: { + if (event.key == Qt.Key_Space) { + spacePressed = true; + event.accepted = true; + } + } + Keys.onReleased: { + if (event.key == Qt.Key_Space) { + spacePressed = false; + event.accepted = true; + } + } + + Emitter { + group: "stars" + system: particles + emitRate: 40 + lifeSpan: 4000 + enabled: true + size: 30 + sizeVariation: 10 + speed: PointDirection { x: 220; xVariation: 40 } + height: parent.height + } + Emitter { + group: "roids" + system: particles + emitRate: 10 + lifeSpan: 4000 + enabled: true + size: 30 + sizeVariation: 10 + speed: PointDirection { x: 220; xVariation: 40 } + height: parent.height + } + ParticleSystem { + id: particles + anchors.fill: parent + } + ImageParticle { + id: stars + groups: ["stars"] + system: particles + source: "../images/star.png" + color: "white" + colorVariation: 0.1 + alpha: 0 + } + ImageParticle { + id: roids + groups: ["roids"] + system: particles + sprites: Sprite { + id: spinState + name: "spinning" + source: "../images/meteor.png" + frames: 35 + frameDuration: 60 + } + } + ImageParticle { + id: shot + groups: ["shot"] + system: particles + source: "../images/star.png" + + color: "#0FF06600" + colorVariation: 0.3 + } + ImageParticle { + id: engine + groups: ["engine"] + system: particles + source: "../images/particle4.png" + + color: "orange" + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { + from: "red" + to: "cyan" + duration: 1000 + } + ColorAnimation { + from: "cyan" + to: "red" + duration: 1000 + } + } + + colorVariation: 0.2 + } + Attractor { + id: gs; pointX: root.width/2; pointY: root.height/2; strength: 4000000; + system: particles + affectedParameter: Attractor.Acceleration + proportionalToDistance: Attractor.InverseQuadratic + } + Age { + system: particles + x: gs.pointX - 8; + y: gs.pointY - 8; + width: 16 + height: 16 + } + Rectangle { + color: "black" + width: 8 + height: 8 + radius: 4 + x: gs.pointX - 4 + y: gs.pointY - 4 + } + + Image { + source:"../images/rocket2.png" + id: ship + width: 45 + height: 22 + MouseArea { + id: ma + anchors.fill: parent; + drag.axis: Drag.XandYAxis + drag.target: ship + } + } + Emitter { + group: "engine" + system: particles + emitRate: 200 + lifeSpan: 1000 + size: 10 + endSize: 4 + sizeVariation: 4 + speed: PointDirection { x: -128; xVariation: 32 } + height: ship.height + y: ship.y + x: ship.x + width: 20 + } + Emitter { + group: "shot" + system: particles + emitRate: 32 + lifeSpan: 2000 + enabled: spacePressed + size: 40 + speed: PointDirection { x: 256; } + x: ship.x + ship.width + y: ship.y + ship.height/2 + } + + Text { + color: "white" + anchors.bottom: parent.bottom + text:"Drag the ship, Spacebar to fire." + } +} + diff --git a/examples/qml/particles/affectors/customaffector.qml b/examples/qml/particles/affectors/customaffector.qml new file mode 100644 index 0000000000..3f98cd5b43 --- /dev/null +++ b/examples/qml/particles/affectors/customaffector.qml @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + width: 360 + height: 600 + + Image { + source: "../images/backgroundLeaves.jpg" + anchors.fill: parent + } + ParticleSystem { + id: sys + } + Emitter { + system: sys + width: parent.width + emitRate: 4 + lifeSpan: 14000 + size: 80 + speed: PointDirection { y: 60 } + } + Wander { + system: sys + anchors.fill: parent + anchors.bottomMargin: 100 + xVariance: 60 + pace: 60 + } + + Affector { + system: sys + property real coefficient: 0.1 + property real speed: 1.5 + width: parent.width + height: parent.height - 100 + onAffectParticles: { + /* //Linear movement + if (particle.r == 0) { + particle.r = Math.random() > 0.5 ? -1 : 1; + }else if (particle.r == 1) { + particle.rotation += speed * dt; + if(particle.rotation >= maxAngle) + particle.r = -1; + }else if (particle.r == -1) { + particle.rotation -= speed * dt; + if(particle.rotation <= -1 * maxAngle) + particle.r = 1; + } + */ + //Wobbly movement + for (var i=0; i 1.) + currentSize = 0.; + + highp vec2 pos = qt_ParticlePos + - currentSize / 2. + currentSize * qt_ParticleTex // adjust size + + qt_ParticleVec.xy * t * qt_ParticleData.y // apply speed vector.. + + 0.5 * qt_ParticleVec.zw * pow(t * qt_ParticleData.y, 2.); + + gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1); + + highp float fadeIn = min(t * 20., 1.); + highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.)); + + fFade = fadeIn * fadeOut * qt_Opacity; + fPos = vec2(pos.x/1024., pos.y/768.); + } + " + fragmentShader: " + varying highp vec2 fPos; + varying lowp float fFade; + varying highp vec2 qt_TexCoord0; + void main() {//*2 because this generates dark colors mostly + highp vec2 circlePos = qt_TexCoord0*2.0 - vec2(1.0,1.0); + highp float dist = length(circlePos); + highp float circleFactor = max(min(1.0 - dist, 1.0), 0.0); + gl_FragColor = vec4(fPos.x*2.0 - fPos.y, fPos.y*2.0 - fPos.x, fPos.x*fPos.y*2.0, 0.0) * circleFactor * fFade; + }" + + } +} diff --git a/examples/qml/particles/customparticle/imagecolors.qml b/examples/qml/particles/customparticle/imagecolors.qml new file mode 100644 index 0000000000..94e5123a0c --- /dev/null +++ b/examples/qml/particles/customparticle/imagecolors.qml @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: root + color: "white" + width: 310 + height: 300 + anchors.centerIn: parent + ParticleSystem { id: sys } + CustomParticle { + system: sys + property real maxWidth: root.width + property real maxHeight: root.height + ShaderEffectSource { + id: pictureSource + sourceItem: picture + hideSource: true + } + Image { + id: picture + source: "../images/starfish_3.png" + } + ShaderEffectSource { + id: particleSource + sourceItem: particle + hideSource: true + } + Image { + id: particle + source: "../images/particle4.png" + } + vertexShader:" + uniform highp float maxWidth; + uniform highp float maxHeight; + varying highp vec2 fTex2; + varying lowp float fFade; + uniform lowp float qt_Opacity; + + void main() { + fTex2 = vec2(qt_ParticlePos.x / maxWidth, qt_ParticlePos.y / maxHeight); + highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y; + fFade = min(t*4., (1.-t*t)*.75) * qt_Opacity; + defaultMain(); + } + " + property variant particleTexture: particleSource + property variant pictureTexture: pictureSource + fragmentShader: " + uniform sampler2D particleTexture; + uniform sampler2D pictureTexture; + varying highp vec2 qt_TexCoord0; + varying highp vec2 fTex2; + varying lowp float fFade; + void main() { + gl_FragColor = texture2D(pictureTexture, fTex2) * texture2D(particleTexture, qt_TexCoord0).w * fFade; + }" + } + + Emitter { + id: emitter + system: sys + enabled: false + lifeSpan: 8000 + maximumEmitted: 4000 + anchors.fill: parent + size: 16 + acceleration: PointDirection { xVariation: 12; yVariation: 12 } + } + MouseArea { + anchors.fill: parent + onClicked: emitter.burst(4000); + } + } +} diff --git a/examples/qml/particles/emitters/burstandpulse.qml b/examples/qml/particles/emitters/burstandpulse.qml new file mode 100644 index 0000000000..1b1c2a60c9 --- /dev/null +++ b/examples/qml/particles/emitters/burstandpulse.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + width: 360 + height: 540 + color: "black" + MouseArea { + id: ma + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: { + if (mouse.button == Qt.LeftButton) + emitter.burst(1000); + else + emitter.pulse(500); + } + } + + ParticleSystem { + id: particles + } + + ImageParticle { + anchors.fill: parent + system: particles + source: "../images/star.png" + alpha: 0 + colorVariation: 0.6 + } + + Emitter { + id: emitter + x: ma.mouseX + y: ma.mouseY + system: particles + emitRate: 2000 + lifeSpan: 2000 + enabled: false + speed: AngleDirection{magnitude: 64; angleVariation: 360} + size: 24 + sizeVariation: 8 + } +} diff --git a/examples/qml/particles/emitters/customemitter.qml b/examples/qml/particles/emitters/customemitter.qml new file mode 100644 index 0000000000..757c836106 --- /dev/null +++ b/examples/qml/particles/emitters/customemitter.qml @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +ParticleSystem { + id: sys + width: 360 + height: 600 + running: true + Rectangle { + z: -1 + anchors.fill: parent + color: "black" + } + + property real petalLength: 180 + property real petalRotation: 0 + NumberAnimation on petalRotation { + from: 0; + to: 360; + loops: -1; + running: true + duration: 24000 + } + + function convert(a) {return a*(Math.PI/180);} + Emitter { + lifeSpan: 4000 + emitRate: 120 + size: 12 + anchors.centerIn: parent + onEmitParticles: { + for (var i=0; i 400 ? 32 : 16 + } +} diff --git a/examples/qml/particles/imageparticle/colored.qml b/examples/qml/particles/imageparticle/colored.qml new file mode 100644 index 0000000000..ac760b6219 --- /dev/null +++ b/examples/qml/particles/imageparticle/colored.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + width: 360 + height: 540 + color: "black" + ParticleSystem { + anchors.fill: parent + ImageParticle { + groups: ["stars"] + anchors.fill: parent + source: "../images/star.png" + } + Emitter { + group: "stars" + emitRate: 800 + lifeSpan: 2400 + size: 24 + sizeVariation: 8 + anchors.fill: parent + } + + ImageParticle { + anchors.fill: parent + source: "../images/star.png" + alpha: 0 + alphaVariation: 0.2 + colorVariation: 1.0 + } + + Emitter { + anchors.centerIn: parent + emitRate: 400 + lifeSpan: 2400 + size: 48 + sizeVariation: 8 + speed: AngleDirection {angleVariation: 180; magnitude: 60} + } + + Turbulence { + anchors.fill: parent + strength: 2 + } + } +} diff --git a/examples/qml/particles/imageparticle/colortable.qml b/examples/qml/particles/imageparticle/colortable.qml new file mode 100644 index 0000000000..623029dae0 --- /dev/null +++ b/examples/qml/particles/imageparticle/colortable.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick.Particles 2.0 +import QtQuick 2.0 + +Rectangle { + id: root + width: 360 + height: 540 + color: "black" + + ParticleSystem { id: particles } + + ImageParticle { + system: particles + colorVariation: 0.5 + alpha: 0 + + source: "../images/particle.png" + colorTable: "../images/colortable.png" + sizeTable: "../images/colortable.png" + } + + Emitter { + system: particles + emitRate: 500 + lifeSpan: 2000 + + y: root.height / 2 + Math.sin(t * 2) * root.height * 0.3 + x: root.width / 2 + Math.cos(t) * root.width * 0.3 + property real t; + + NumberAnimation on t { + from: 0; to: Math.PI * 2; duration: 10000; loops: Animation.Infinite + } + + speedFromMovement: 20 + + speed: PointDirection { xVariation: 5; yVariation: 5;} + acceleration: PointDirection { xVariation: 5; yVariation: 5;} + + size: 16 + //endSize: 8 + //sizeVariation: 8 + } +} diff --git a/examples/qml/particles/imageparticle/deformation.qml b/examples/qml/particles/imageparticle/deformation.qml new file mode 100644 index 0000000000..e282927e78 --- /dev/null +++ b/examples/qml/particles/imageparticle/deformation.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "goldenrod" + width: 400 + height: 400 + ParticleSystem {id:sys} + + ImageParticle { + system: sys + groups: ["goingLeft", "goingRight"] + source: "../images/starfish_4.png" + rotation: 90 + rotationSpeed: 90 + autoRotation: true + } + ImageParticle { + system: sys + groups: ["goingDown"] + source: "../images/starfish_0.png" + rotation: 180 + yVector: PointDirection { y: 0.5; yVariation: 0.25; xVariation: 0.25; } + } + + Timer { + running: true + repeat: false + interval: 100 + onTriggered: emitA.enabled = true; + } + Timer { + running: true + repeat: false + interval: 4200 + onTriggered: emitB.enabled = true; + } + Timer { + running: true + repeat: false + interval: 8400 + onTriggered: emitC.enabled = true; + } + + Emitter { + id: emitA + x: 0 + y: 120 + system: sys + enabled: false + group: "goingRight" + speed: PointDirection { x: 100 } + lifeSpan: 4000 + emitRate: 1 + size: 128 + } + Emitter { + id: emitB + x: 400 + y: 240 + system: sys + enabled: false + group: "goingLeft" + speed: PointDirection { x: -100 } + lifeSpan: 4000 + emitRate: 1 + size: 128 + } + Emitter { + id: emitC + x: 0 + y: 360 + system: sys + enabled: false + group: "goingDown" + speed: PointDirection { x: 100 } + lifeSpan: 4000 + emitRate: 1 + size: 128 + } +} diff --git a/examples/qml/particles/imageparticle/rotation.qml b/examples/qml/particles/imageparticle/rotation.qml new file mode 100644 index 0000000000..3a75c379ed --- /dev/null +++ b/examples/qml/particles/imageparticle/rotation.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "goldenrod" + width: 2000 + height: 2000 + ParticleSystem {id: sys} + ImageParticle { + id: up + system: sys + source: "../images/starfish_2.png" + } + + Emitter { + anchors.centerIn: parent + system: sys + emitRate: 10 + size: 200 + lifeSpan: 10000 + speed: AngleDirection {angleVariation: 360; magnitudeVariation: 100;} + } + + MouseArea { + anchors.fill: parent + onClicked: { + up.autoRotation = !up.autoRotation + up.rotation = up.autoRotation ? -90 : 0 + } + } +} diff --git a/examples/qml/particles/imageparticle/sharing.qml b/examples/qml/particles/imageparticle/sharing.qml new file mode 100644 index 0000000000..27e08322d9 --- /dev/null +++ b/examples/qml/particles/imageparticle/sharing.qml @@ -0,0 +1,199 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This example shows how to create your own highlight delegate for a ListView +// that uses a SpringAnimation to provide custom movement when the +// highlight bar is moved between items. + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + property real delegateHeight: 65 + width: 200; height: 300 + gradient: Gradient { + GradientStop { position: 0.0; color: "#EEEEFF" } + GradientStop { position: 1.0; color: "lightblue" } + } + + // Define a delegate component. A component will be + // instantiated for each visible item in the list. + Component { + id: petDelegate + Item { + id: wrapper + width: 200; height: delegateHeight + z: 10 + Column { + Text {color: "white"; text: name; font.pixelSize: 18 } + Text {color: "white"; text: 'Type: ' + type; font.pixelSize: 14 } + Text {color: "white"; text: 'Age: ' + age; font.pixelSize: 14 } + } + // indent the item if it is the current item + states: State { + name: "Current" + when: wrapper.ListView.isCurrentItem + PropertyChanges { target: wrapper; x: 20 } + } + transitions: Transition { + NumberAnimation { properties: "x"; duration: 200 } + } + } + } + + // Define a highlight with customised movement between items. + Component { + id: highlightBar + Rectangle { + z: 0 + width: 200; height: delegateHeight + gradient: Gradient { + GradientStop { position: 0.0; color: "#99FF99" } + GradientStop { position: 1.0; color: "#88FF88" } + } + y: listView.currentItem.y; + Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } } + ImageParticle { + anchors.fill: parent + system: particles + source: "../images/flower.png" + color: "red" + clip: true + alpha: 1.0 + } + } + } + + ListView { + id: listView + width: 200; height: parent.height + + model: petsModel + delegate: petDelegate + focus: true + + // Set the highlight delegate. Note we must also set highlightFollowsCurrentItem + // to false so the highlight delegate can control how the highlight is moved. + highlight: highlightBar + highlightFollowsCurrentItem: false + + ParticleSystem { id: particles } + Emitter { + system: particles + anchors.fill: parent + emitRate: 1 + lifeSpan: 10000 + size: 24 + sizeVariation: 8 + speed: AngleDirection { angleVariation: 360; magnitude: 3 } + maximumEmitted: 10 + startTime: 5000 + } + + ImageParticle { + anchors.fill: parent + system: particles + source: "../images/flower.png" + alpha: 0.1 + color: "white" + rotationVariation: 180 + z: -1 + } + } + + ListModel { + id: petsModel + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Schrödinger" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" + } + } + +} diff --git a/examples/qml/particles/imageparticle/sprites.qml b/examples/qml/particles/imageparticle/sprites.qml new file mode 100644 index 0000000000..0fe4f31ea3 --- /dev/null +++ b/examples/qml/particles/imageparticle/sprites.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "lightsteelblue" + width: 800 + height: 800 + id: root + + SpriteImage { + sprites: Sprite { + name: "bear" + source: "../images/bear_tiles.png" + frames: 13 + frameDuration: 120 + } + width: 250 + height: 250 + x: 20 + anchors.bottom: parent.bottom + anchors.bottomMargin: 20 + z:4 + } + + ParticleSystem { id: sys } + + ImageParticle { + anchors.fill: parent + id: particles + system: sys + sprites: [Sprite { + name: "happy" + source: "../images/starfish_1.png" + frames: 1 + frameDuration: 260 + to: {"happy": 1, "silly": 1, "angry": 1} + }, Sprite { + name: "angry" + source: "../images/starfish_0.png" + frames: 1 + frameDuration: 260 + to: {"happy": 1, "silly": 1, "angry": 1} + }, Sprite { + name: "silly" + source: "../images/starfish_2.png" + frames: 1 + frameDuration: 260 + to: {"happy": 1, "silly": 1, "noticedbear": 0} + }, Sprite { + name: "noticedbear" + source: "../images/starfish_3.png" + frames: 1 + frameDuration: 2600 + }] + } + + Emitter { + system: sys + emitRate: 2 + lifeSpan: 10000 + speed: AngleDirection {angle: 90; magnitude: 60; angleVariation: 5} + acceleration: PointDirection { y: 10 } + size: 160 + sizeVariation: 40 + width: parent.width + height: 100 + } + + SpriteGoal { + system: sys + width: root.width; + height: root.height/2; + y: root.height/2; + goalState:"noticedbear" + } +} diff --git a/examples/qml/particles/images/_explo.png b/examples/qml/particles/images/_explo.png new file mode 100644 index 0000000000..4297245d49 Binary files /dev/null and b/examples/qml/particles/images/_explo.png differ diff --git a/examples/qml/particles/images/backgroundLeaves.jpg b/examples/qml/particles/images/backgroundLeaves.jpg new file mode 100755 index 0000000000..08be16751d Binary files /dev/null and b/examples/qml/particles/images/backgroundLeaves.jpg differ diff --git a/examples/qml/particles/images/bear_tiles.png b/examples/qml/particles/images/bear_tiles.png new file mode 100644 index 0000000000..6bbb2a9b6d Binary files /dev/null and b/examples/qml/particles/images/bear_tiles.png differ diff --git a/examples/qml/particles/images/candle.png b/examples/qml/particles/images/candle.png new file mode 100644 index 0000000000..8fa3193719 Binary files /dev/null and b/examples/qml/particles/images/candle.png differ diff --git a/examples/qml/particles/images/colortable.png b/examples/qml/particles/images/colortable.png new file mode 100644 index 0000000000..a62ceeb4a0 Binary files /dev/null and b/examples/qml/particles/images/colortable.png differ diff --git a/examples/qml/particles/images/finalfrontier.png b/examples/qml/particles/images/finalfrontier.png new file mode 100644 index 0000000000..2ba1815230 Binary files /dev/null and b/examples/qml/particles/images/finalfrontier.png differ diff --git a/examples/qml/particles/images/flower.png b/examples/qml/particles/images/flower.png new file mode 100644 index 0000000000..b5c606210e Binary files /dev/null and b/examples/qml/particles/images/flower.png differ diff --git a/examples/qml/particles/images/launcherIcons/allatonce.png b/examples/qml/particles/images/launcherIcons/allatonce.png new file mode 100644 index 0000000000..b61d2d50d8 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/allatonce.png differ diff --git a/examples/qml/particles/images/launcherIcons/attractor.png b/examples/qml/particles/images/launcherIcons/attractor.png new file mode 100644 index 0000000000..4bd8040c3b Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/attractor.png differ diff --git a/examples/qml/particles/images/launcherIcons/blurparticles.png b/examples/qml/particles/images/launcherIcons/blurparticles.png new file mode 100644 index 0000000000..4337f979cb Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/blurparticles.png differ diff --git a/examples/qml/particles/images/launcherIcons/close.png b/examples/qml/particles/images/launcherIcons/close.png new file mode 100644 index 0000000000..c37714ee8f Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/close.png differ diff --git a/examples/qml/particles/images/launcherIcons/colortable.png b/examples/qml/particles/images/launcherIcons/colortable.png new file mode 100644 index 0000000000..8841ea30f9 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/colortable.png differ diff --git a/examples/qml/particles/images/launcherIcons/customaffector.png b/examples/qml/particles/images/launcherIcons/customaffector.png new file mode 100644 index 0000000000..d02e7918fa Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/customaffector.png differ diff --git a/examples/qml/particles/images/launcherIcons/customemitter.png b/examples/qml/particles/images/launcherIcons/customemitter.png new file mode 100644 index 0000000000..6d492573d1 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/customemitter.png differ diff --git a/examples/qml/particles/images/launcherIcons/deformation.png b/examples/qml/particles/images/launcherIcons/deformation.png new file mode 100644 index 0000000000..d1b722df01 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/deformation.png differ diff --git a/examples/qml/particles/images/launcherIcons/delegates.png b/examples/qml/particles/images/launcherIcons/delegates.png new file mode 100644 index 0000000000..929414cd0e Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/delegates.png differ diff --git a/examples/qml/particles/images/launcherIcons/dynamicemitters.png b/examples/qml/particles/images/launcherIcons/dynamicemitters.png new file mode 100644 index 0000000000..0cdef9d21e Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/dynamicemitters.png differ diff --git a/examples/qml/particles/images/launcherIcons/emitmask.png b/examples/qml/particles/images/launcherIcons/emitmask.png new file mode 100644 index 0000000000..e943a4adb9 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/emitmask.png differ diff --git a/examples/qml/particles/images/launcherIcons/flickr.png b/examples/qml/particles/images/launcherIcons/flickr.png new file mode 100644 index 0000000000..4de2650280 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/flickr.png differ diff --git a/examples/qml/particles/images/launcherIcons/fragmentshader.png b/examples/qml/particles/images/launcherIcons/fragmentshader.png new file mode 100644 index 0000000000..7c6de498d5 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/fragmentshader.png differ diff --git a/examples/qml/particles/images/launcherIcons/gridsplosion.png b/examples/qml/particles/images/launcherIcons/gridsplosion.png new file mode 100644 index 0000000000..ec75453df6 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/gridsplosion.png differ diff --git a/examples/qml/particles/images/launcherIcons/groupgoal.png b/examples/qml/particles/images/launcherIcons/groupgoal.png new file mode 100644 index 0000000000..69c6f64e54 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/groupgoal.png differ diff --git a/examples/qml/particles/images/launcherIcons/imagecolors.png b/examples/qml/particles/images/launcherIcons/imagecolors.png new file mode 100644 index 0000000000..0ff13a346e Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/imagecolors.png differ diff --git a/examples/qml/particles/images/launcherIcons/list.png b/examples/qml/particles/images/launcherIcons/list.png new file mode 100644 index 0000000000..bc13263cff Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/list.png differ diff --git a/examples/qml/particles/images/launcherIcons/maximumemitted.png b/examples/qml/particles/images/launcherIcons/maximumemitted.png new file mode 100644 index 0000000000..4ef0435991 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/maximumemitted.png differ diff --git a/examples/qml/particles/images/launcherIcons/multiplepainters.png b/examples/qml/particles/images/launcherIcons/multiplepainters.png new file mode 100644 index 0000000000..a28e3c4f02 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/multiplepainters.png differ diff --git a/examples/qml/particles/images/launcherIcons/package.png b/examples/qml/particles/images/launcherIcons/package.png new file mode 100644 index 0000000000..eba8951c26 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/package.png differ diff --git a/examples/qml/particles/images/launcherIcons/particleview.png b/examples/qml/particles/images/launcherIcons/particleview.png new file mode 100644 index 0000000000..a74f9a0340 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/particleview.png differ diff --git a/examples/qml/particles/images/launcherIcons/plasmapatrol.png b/examples/qml/particles/images/launcherIcons/plasmapatrol.png new file mode 100644 index 0000000000..fda852b420 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/plasmapatrol.png differ diff --git a/examples/qml/particles/images/launcherIcons/remove.png b/examples/qml/particles/images/launcherIcons/remove.png new file mode 100644 index 0000000000..c37714ee8f Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/remove.png differ diff --git a/examples/qml/particles/images/launcherIcons/rotation.png b/examples/qml/particles/images/launcherIcons/rotation.png new file mode 100644 index 0000000000..6a8dbea236 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/rotation.png differ diff --git a/examples/qml/particles/images/launcherIcons/samegame.png b/examples/qml/particles/images/launcherIcons/samegame.png new file mode 100644 index 0000000000..d00698264b Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/samegame.png differ diff --git a/examples/qml/particles/images/launcherIcons/shapeanddirection.png b/examples/qml/particles/images/launcherIcons/shapeanddirection.png new file mode 100644 index 0000000000..9c1f910d0c Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/shapeanddirection.png differ diff --git a/examples/qml/particles/images/launcherIcons/spaceexplorer.png b/examples/qml/particles/images/launcherIcons/spaceexplorer.png new file mode 100644 index 0000000000..770584a0fa Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/spaceexplorer.png differ diff --git a/examples/qml/particles/images/launcherIcons/spritegoal.png b/examples/qml/particles/images/launcherIcons/spritegoal.png new file mode 100644 index 0000000000..77480c6f09 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/spritegoal.png differ diff --git a/examples/qml/particles/images/launcherIcons/sprites.png b/examples/qml/particles/images/launcherIcons/sprites.png new file mode 100644 index 0000000000..144216ac7c Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/sprites.png differ diff --git a/examples/qml/particles/images/launcherIcons/spritevariedparticles.png b/examples/qml/particles/images/launcherIcons/spritevariedparticles.png new file mode 100644 index 0000000000..495bb6beee Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/spritevariedparticles.png differ diff --git a/examples/qml/particles/images/launcherIcons/startstop.png b/examples/qml/particles/images/launcherIcons/startstop.png new file mode 100644 index 0000000000..0ff53196a6 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/startstop.png differ diff --git a/examples/qml/particles/images/launcherIcons/timedgroupchanges.png b/examples/qml/particles/images/launcherIcons/timedgroupchanges.png new file mode 100644 index 0000000000..ec9f826495 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/timedgroupchanges.png differ diff --git a/examples/qml/particles/images/launcherIcons/trailemitter.png b/examples/qml/particles/images/launcherIcons/trailemitter.png new file mode 100644 index 0000000000..39acf8b40d Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/trailemitter.png differ diff --git a/examples/qml/particles/images/launcherIcons/trails.png b/examples/qml/particles/images/launcherIcons/trails.png new file mode 100644 index 0000000000..0337ebcfd8 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/trails.png differ diff --git a/examples/qml/particles/images/launcherIcons/turbulence.png b/examples/qml/particles/images/launcherIcons/turbulence.png new file mode 100644 index 0000000000..2b9446ea90 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/turbulence.png differ diff --git a/examples/qml/particles/images/launcherIcons/velocityfrommotion.png b/examples/qml/particles/images/launcherIcons/velocityfrommotion.png new file mode 100644 index 0000000000..79baa08293 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/velocityfrommotion.png differ diff --git a/examples/qml/particles/images/launcherIcons/wander.png b/examples/qml/particles/images/launcherIcons/wander.png new file mode 100644 index 0000000000..d98e14b8ae Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/wander.png differ diff --git a/examples/qml/particles/images/matchmask.png b/examples/qml/particles/images/matchmask.png new file mode 100644 index 0000000000..e575875c55 Binary files /dev/null and b/examples/qml/particles/images/matchmask.png differ diff --git a/examples/qml/particles/images/meteor.png b/examples/qml/particles/images/meteor.png new file mode 100644 index 0000000000..e8c368aea7 Binary files /dev/null and b/examples/qml/particles/images/meteor.png differ diff --git a/examples/qml/particles/images/meteor_explo.png b/examples/qml/particles/images/meteor_explo.png new file mode 100644 index 0000000000..e659bfe2cf Binary files /dev/null and b/examples/qml/particles/images/meteor_explo.png differ diff --git a/examples/qml/particles/images/meteors.png b/examples/qml/particles/images/meteors.png new file mode 100644 index 0000000000..bada8a1407 Binary files /dev/null and b/examples/qml/particles/images/meteors.png differ diff --git a/examples/qml/particles/images/nullRock.png b/examples/qml/particles/images/nullRock.png new file mode 100644 index 0000000000..4076327a1a Binary files /dev/null and b/examples/qml/particles/images/nullRock.png differ diff --git a/examples/qml/particles/images/particle.png b/examples/qml/particles/images/particle.png new file mode 100644 index 0000000000..5c83896d22 Binary files /dev/null and b/examples/qml/particles/images/particle.png differ diff --git a/examples/qml/particles/images/particle2.png b/examples/qml/particles/images/particle2.png new file mode 100644 index 0000000000..36349c6c6e Binary files /dev/null and b/examples/qml/particles/images/particle2.png differ diff --git a/examples/qml/particles/images/particle3.png b/examples/qml/particles/images/particle3.png new file mode 100644 index 0000000000..905d8f37b8 Binary files /dev/null and b/examples/qml/particles/images/particle3.png differ diff --git a/examples/qml/particles/images/particle4.png b/examples/qml/particles/images/particle4.png new file mode 100644 index 0000000000..bc95b703c1 Binary files /dev/null and b/examples/qml/particles/images/particle4.png differ diff --git a/examples/qml/particles/images/particleA.png b/examples/qml/particles/images/particleA.png new file mode 100644 index 0000000000..c63acdee1f Binary files /dev/null and b/examples/qml/particles/images/particleA.png differ diff --git a/examples/qml/particles/images/portal_bg.png b/examples/qml/particles/images/portal_bg.png new file mode 100644 index 0000000000..3c59eeabb9 Binary files /dev/null and b/examples/qml/particles/images/portal_bg.png differ diff --git a/examples/qml/particles/images/realLeaf1.png b/examples/qml/particles/images/realLeaf1.png new file mode 100644 index 0000000000..6cabf29efd Binary files /dev/null and b/examples/qml/particles/images/realLeaf1.png differ diff --git a/examples/qml/particles/images/realLeaf2.png b/examples/qml/particles/images/realLeaf2.png new file mode 100644 index 0000000000..bfeca861d5 Binary files /dev/null and b/examples/qml/particles/images/realLeaf2.png differ diff --git a/examples/qml/particles/images/realLeaf3.png b/examples/qml/particles/images/realLeaf3.png new file mode 100644 index 0000000000..b1071e862b Binary files /dev/null and b/examples/qml/particles/images/realLeaf3.png differ diff --git a/examples/qml/particles/images/realLeaf4.png b/examples/qml/particles/images/realLeaf4.png new file mode 100644 index 0000000000..d61d53d10e Binary files /dev/null and b/examples/qml/particles/images/realLeaf4.png differ diff --git a/examples/qml/particles/images/rocket.png b/examples/qml/particles/images/rocket.png new file mode 100644 index 0000000000..a171610b03 Binary files /dev/null and b/examples/qml/particles/images/rocket.png differ diff --git a/examples/qml/particles/images/rocket2.png b/examples/qml/particles/images/rocket2.png new file mode 100644 index 0000000000..7110f8fdc6 Binary files /dev/null and b/examples/qml/particles/images/rocket2.png differ diff --git a/examples/qml/particles/images/sizeInOut.png b/examples/qml/particles/images/sizeInOut.png new file mode 100644 index 0000000000..0a306ea21a Binary files /dev/null and b/examples/qml/particles/images/sizeInOut.png differ diff --git a/examples/qml/particles/images/snowflake.png b/examples/qml/particles/images/snowflake.png new file mode 100644 index 0000000000..490887a82f Binary files /dev/null and b/examples/qml/particles/images/snowflake.png differ diff --git a/examples/qml/particles/images/sparkleSize.png b/examples/qml/particles/images/sparkleSize.png new file mode 100644 index 0000000000..752056541b Binary files /dev/null and b/examples/qml/particles/images/sparkleSize.png differ diff --git a/examples/qml/particles/images/star.png b/examples/qml/particles/images/star.png new file mode 100644 index 0000000000..0d592cfa87 Binary files /dev/null and b/examples/qml/particles/images/star.png differ diff --git a/examples/qml/particles/images/starfish_0.png b/examples/qml/particles/images/starfish_0.png new file mode 100644 index 0000000000..8747f0236e Binary files /dev/null and b/examples/qml/particles/images/starfish_0.png differ diff --git a/examples/qml/particles/images/starfish_1.png b/examples/qml/particles/images/starfish_1.png new file mode 100644 index 0000000000..1f3f159d5e Binary files /dev/null and b/examples/qml/particles/images/starfish_1.png differ diff --git a/examples/qml/particles/images/starfish_2.png b/examples/qml/particles/images/starfish_2.png new file mode 100644 index 0000000000..c6c7e5a676 Binary files /dev/null and b/examples/qml/particles/images/starfish_2.png differ diff --git a/examples/qml/particles/images/starfish_3.png b/examples/qml/particles/images/starfish_3.png new file mode 100644 index 0000000000..307a89f815 Binary files /dev/null and b/examples/qml/particles/images/starfish_3.png differ diff --git a/examples/qml/particles/images/starfish_4.png b/examples/qml/particles/images/starfish_4.png new file mode 100644 index 0000000000..d61c26545a Binary files /dev/null and b/examples/qml/particles/images/starfish_4.png differ diff --git a/examples/qml/particles/images/starfish_mask.png b/examples/qml/particles/images/starfish_mask.png new file mode 100644 index 0000000000..2ef74f902b Binary files /dev/null and b/examples/qml/particles/images/starfish_mask.png differ diff --git a/examples/qml/particles/itemparticle/content/Delegate.qml b/examples/qml/particles/itemparticle/content/Delegate.qml new file mode 100644 index 0000000000..97c7840cb4 --- /dev/null +++ b/examples/qml/particles/itemparticle/content/Delegate.qml @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//![0] +Package { + Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' } + Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' } + + Rectangle { + id: wrapper + width: 200; height: 25 + color: 'lightsteelblue' + + Text { text: display; anchors.centerIn: parent } + MouseArea { + anchors.fill: parent + onClicked: { + if (wrapper.state == 'inList') + wrapper.state = 'inGrid'; + else + wrapper.state = 'inList'; + } + } + + state: 'inList' + states: [ + State { + name: 'inList' + ParentChange { target: wrapper; parent: listDelegate } + }, + State { + name: 'inGrid' + ParentChange { + target: wrapper; parent: gridDelegate + x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height + } + } + ] + + transitions: [ + Transition { + ParentAnimation { + NumberAnimation { properties: 'x,y,width,height'; duration: 300 } + } + } + ] + } +} +//![0] diff --git a/examples/qml/particles/itemparticle/content/Delegate2.qml b/examples/qml/particles/itemparticle/content/Delegate2.qml new file mode 100644 index 0000000000..cf60d43dc2 --- /dev/null +++ b/examples/qml/particles/itemparticle/content/Delegate2.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//![0] +Package { + Item { id: gridDelegate; width: w; height: h; Package.name: 'grid' } + Item { id: particleDelegate; width: w; height: h; Package.name: 'particles' + + Rectangle { + id: wrapper + width: w; height: h; + color: col + rotation: Math.random()*360 + Behavior on rotation {RotationAnimation {}} + + states: State { + name: "gridded" + when: root.inGrid + PropertyChanges { + target: wrapper + rotation: 0 + } + ParentChange { + target: wrapper + parent: gridDelegate + x:0 + y:0 + } + } + transitions: [ + Transition { + ParentAnimation { + NumberAnimation { properties: 'x,y,width,height'; duration: 300 } + } + } + ] + } + } +} +//![0] diff --git a/examples/qml/particles/itemparticle/content/ExpandingDelegate.qml b/examples/qml/particles/itemparticle/content/ExpandingDelegate.qml new file mode 100644 index 0000000000..87f723d3f7 --- /dev/null +++ b/examples/qml/particles/itemparticle/content/ExpandingDelegate.qml @@ -0,0 +1,204 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../../../modelviews/listview/content" + +// This example illustrates expanding a list item to show a more detailed view. + + // Delegate for the recipes. This delegate has two modes: + // 1. List mode (default), which just shows the picture and title of the recipe. + // 2. Details mode, which also shows the ingredients and method. + Component { + id: recipeDelegate + + Item { + id: recipe + + // Create a property to contain the visibility of the details. + // We can bind multiple element's opacity to this one property, + // rather than having a "PropertyChanges" line for each element we + // want to fade. + property real detailsOpacity : 0 + + //this bit changed for aesthetics + width: 70 + height: 70 + // A simple rounded rectangle for the background + Rectangle { + id: background + x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2 + color: "ivory" + border.color: "orange" + radius: 5 + } + Image { + anchors.fill:parent + anchors.margins: -32 + source: "bubble.png" + } + + + // This mouse region covers the entire delegate. + // When clicked it changes mode to 'Details'. If we are already + // in Details mode, then no change will happen. + MouseArea { + anchors.fill: parent + onClicked: recipe.state = 'Details'; + } + + // Lay out the page: picture, title and ingredients at the top, and method at the + // bottom. Note that elements that should not be visible in the list + // mode have their opacity set to recipe.detailsOpacity. + Row { + id: topLayout + x: 10; y: 10; height: recipeImage.height; width: parent.width + spacing: 10 + + Image { + id: recipeImage + width: 50; height: 50 + source: "../../modelviews/listview/" + picture + } + + Column { + width: background.width - recipeImage.width - 20; height: recipeImage.height + spacing: 5 + + Text { + text: title + font.bold: true; font.pointSize: 16 + } + + Text { + text: "Ingredients" + font.pointSize: 12; font.bold: true + opacity: recipe.detailsOpacity + } + + Text { + text: ingredients + wrapMode: Text.WordWrap + width: parent.width + opacity: recipe.detailsOpacity + } + } + } + + Item { + id: details + x: 10; width: parent.width - 20 + anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 } + opacity: recipe.detailsOpacity + + Text { + id: methodTitle + anchors.top: parent.top + text: "Method" + font.pointSize: 12; font.bold: true + } + + Flickable { + id: flick + width: parent.width + anchors { top: methodTitle.bottom; bottom: parent.bottom } + contentHeight: methodText.height + clip: true + + Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width } + } + + Image { + anchors { right: flick.right; top: flick.top } + source: "../../modelviews/listview/" + "content/pics/moreUp.png" + opacity: flick.atYBeginning ? 0 : 1 + } + + Image { + anchors { right: flick.right; bottom: flick.bottom } + source: "../../modelviews/listview/" + "content/pics/moreDown.png" + opacity: flick.atYEnd ? 0 : 1 + } + } + + // A button to close the detailed view, i.e. set the state back to default (''). + TextButton { + y: 10 + anchors { right: background.right; rightMargin: 10 } + opacity: recipe.detailsOpacity + text: "Close" + + onClicked: recipe.state = ''; + } + + states: State { + name: "Details" + + PropertyChanges { target: background; color: "white" } + PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger + PropertyChanges { target: recipe; detailsOpacity: 1; x: 0; opacity: 1 } // Make details visible + PropertyChanges { target: recipe; height: root.height; width: root.height; x:0; y:0; z:100} // Fill the entire list area with the detailed view + + // Move the list so that this item is at the top. + //PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y } + + // Disallow flicking while we're in detailed view + //PropertyChanges { target: recipe.ListView.view; interactive: false } + } + + transitions: Transition { + //The only strictly necessary particle specific lines + to: "Details" + reversible: true + ScriptAction {script: { + if(state == "Details") + mp.freeze(index); + else + mp.unfreeze(index); + } + } + // Make the state changes smooth + ParallelAnimation { + ColorAnimation { property: "color"; duration: 500 } + NumberAnimation { duration: 300; properties: "detailsOpacity,opacity,x,y,height,width" } + } + } + } + } diff --git a/examples/qml/particles/itemparticle/content/RssModel.qml b/examples/qml/particles/itemparticle/content/RssModel.qml new file mode 100644 index 0000000000..46027600b3 --- /dev/null +++ b/examples/qml/particles/itemparticle/content/RssModel.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + property string tags : "" + + function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); } + + source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "") + query: "/feed/entry" + namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" + + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "content"; query: "content/string()" } + XmlRole { name: "hq"; query: "link[@rel='enclosure']/@href/string()" } +} diff --git a/examples/qml/particles/itemparticle/content/bubble.png b/examples/qml/particles/itemparticle/content/bubble.png new file mode 100644 index 0000000000..c7f479e9e3 Binary files /dev/null and b/examples/qml/particles/itemparticle/content/bubble.png differ diff --git a/examples/qml/particles/itemparticle/content/script.js b/examples/qml/particles/itemparticle/content/script.js new file mode 100644 index 0000000000..e8ef93a847 --- /dev/null +++ b/examples/qml/particles/itemparticle/content/script.js @@ -0,0 +1,27 @@ +.pragma library + +function getWidth(string) { + return (string.match(/width=\"([0-9]+)\"/))[1] +} + +function getHeight(string) { + return (string.match(/height=\"([0-9]+)\"/))[1] +} + +function getImagePath(string) { + var pattern = /src=\"http:\/\/(\S+)\"/ + return (string.match(pattern))[1] +} + +function calculateScale(width, height, cellSize) { + var widthScale = (cellSize * 1.0) / width + var heightScale = (cellSize * 1.0) / height + var scale = 0 + + if (widthScale <= heightScale) { + scale = widthScale; + } else if (heightScale < widthScale) { + scale = heightScale; + } + return scale; +} diff --git a/examples/qml/particles/itemparticle/delegates.qml b/examples/qml/particles/itemparticle/delegates.qml new file mode 100644 index 0000000000..58734d320a --- /dev/null +++ b/examples/qml/particles/itemparticle/delegates.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + id: root; + width: 360 + height: 600 + color: "black" + + function newPithySaying() { + switch (Math.floor(Math.random()*16)) { + case 0: return "Hello World"; + case 1: return "G'day Mate"; + case 2: return "Code Less"; + case 3: return "Create More"; + case 4: return "Deploy Everywhere"; + case 5: return "Qt Meta-object Language"; + case 6: return "Qt Magic Language"; + case 7: return "Fluid UIs"; + case 8: return "Touchable"; + case 9: return "How's it going?"; + case 10: return "Do you like text?"; + case 11: return "Enjoy!"; + case 12: return "ERROR: Out of pith"; + case 13: return "Punctuation Failure"; + case 14: return "I can go faster"; + case 15: return "I can go slower"; + default: return "OMGWTFBBQ"; + } + } + + ParticleSystem { + anchors.fill: parent + id: syssy + Emitter { + anchors.centerIn: parent + emitRate: 1 + lifeSpan: 4800 + lifeSpanVariation: 1600 + speed: AngleDirection {angleVariation: 360; magnitude: 40; magnitudeVariation: 20} + } + ItemParticle { + delegate: Text { + text: root.newPithySaying(); + color: "white" + font.pixelSize: 18 + font.bold: true + } + } + } +} diff --git a/examples/qml/particles/itemparticle/particleview.qml b/examples/qml/particles/itemparticle/particleview.qml new file mode 100644 index 0000000000..774539a958 --- /dev/null +++ b/examples/qml/particles/itemparticle/particleview.qml @@ -0,0 +1,274 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "content/script.js" as Script +import "content" + +Item { + id: root + width: 640 + height: 480 + Rectangle { + anchors.fill: parent + color: "black" + z: -1 + } + Item { + id: loading + Behavior on opacity {NumberAnimation {}} + anchors.fill: parent + Text { + anchors.centerIn: parent + text: "Loading" + color: "white" + } + } + ParticleSystem { + id: sys; + running: true + } + Emitter { + id: emitter + system: sys + height: parent.height - 132/2 + x: -132/2 + y: 132/2 + speed: PointDirection { x: 32; xVariation: 8 } + emitRate: 0.5 + lifeSpan: Emitter.InfiniteLife + group: "photos" + } + Age { + system: sys + x: parent.width + 132/2 + height: parent.height + width: 1000 + } + ImageParticle { + system: sys + groups: ["fireworks"] + source: "../trails/../images/star.png" + color: "lightsteelblue" + alpha: 0 + colorVariation: 0 + z: 1000 + } + ItemParticle { + id: mp + z: 0 + system: sys + fade: false + groups: ["photos"] + } + Component { + id: alertDelegate + Rectangle { + width: 132 + height: 132 + NumberAnimation on scale { + running: true + loops: 1 + from: 0.2 + to: 1 + } + Image { + source: "../asteroid/../images/rocket.png" + anchors.centerIn: parent + } + Text { + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + text: "A new ship has arrived!" + } + } + } + property Item alertItem; + function alert() { + //resetter.active = false + force.active = true; + alertItem = alertDelegate.createObject(root); + alertItem.x = root.width/2 - alertItem.width/2 + alertItem.y = root.height/2 - alertItem.height/2 + spawnFireworks.pulse(200); + stopAlert.start(); + } + focus: true + Keys.onSpacePressed: alert(); + Timer { + id: stopAlert + running: false + repeat: false + interval: 800 + onTriggered: { + force.active = false + //resetter.active = true; + mp.take(alertItem, true); + centerEmitter.burst(1); + } + } + Attractor { + id: force + system: sys + pointX: root.width/2 + pointY: root.height/2 + strength: -10000 + enabled: false + anchors.centerIn: parent + width: parent.width/2 + height: parent.height/2 + groups:["photos"] + affectedParameter: Attractor.Position + } + Emitter { + id: centerEmitter + speed: PointDirection { x: 32; xVariation: 8;} + emitRate: 0.5 + lifeSpan: 12000 //TODO: A -1 or something which does 'infinite'? (but need disable fade first) + maximumEmitted: 20 + group: "photos" + system: sys + anchors.centerIn: parent + enabled: false + + //TODO: Zoom in effect + } + Emitter { + id: spawnFireworks + group: "fireworks" + system: sys + maximumEmitted: 400 + emitRate: 400 + lifeSpan: 2800 + x: parent.width/2 + y: parent.height/2 - 64 + width: 8 + height: 8 + enabled: false + size: 32 + endSize: 8 + speed: AngleDirection { magnitude: 160; magnitudeVariation: 120; angleVariation: 90; angle: 270 } + acceleration: PointDirection { y: 160 } + } + Item { x: -1000; y: -1000 //offscreen + Repeater {//Load them here, add to system on completed + model: theModel + delegate: theDelegate + } + } + RssModel {id: theModel; tags:"particle,particles"} + Component { + id: theDelegate + Rectangle { + id: container + border.width: 2 + property real myRand: Math.random();//'depth' + z: Math.floor(myRand * 100) + scale: (myRand + 1.0)/2; + //TODO: Darken based on 'depth' + width: 132 + height: 132 + //ItemParticle.onAttached: console.log("I'm in" + x + "," + y + ":" + opacity); + ItemParticle.onDetached: mp.take(container);//respawns + function manage() + { + if (state == "selected") { + console.log("Taking " + index); + mp.freeze(container); + } else { + console.log("Returning " +index); + mp.unfreeze(container); + } + } + Image { + id: img + anchors.centerIn: parent + smooth: true; source: "http://" + Script.getImagePath(content); cache: true + fillMode: Image.PreserveAspectFit; + width: parent.width-4; height: parent.height-4 + onStatusChanged: if (img.status == Image.Ready) { + loading.opacity = 0; + mp.take(container); + } + } + Text { + anchors.bottom: parent.bottom + width: parent.width + horizontalAlignment: Text.AlignHCenter + elide: Text.ElideRight + text: title + color: "black" + } + MouseArea { + anchors.fill: parent + onClicked: container.state == "selected" ? container.state = "" : container.state = "selected" + } + states: State { + name: "selected" + ParentChange { + target: container + parent: root + x: 0 + y: 0 + } + PropertyChanges { + target: container + width: root.width + height: root.height + z: 101 + opacity: 1 + rotation: 0 + } + } + transitions: Transition { + to: "selected" + reversible: true + SequentialAnimation { + ScriptAction {script: container.manage();} + ParallelAnimation { + ParentAnimation {NumberAnimation { properties: "x,y" }}//Doesn't work, particles takes control of x,y instantly + NumberAnimation { properties: "width, height, z, rotation" } + } + } + } + } + } +} diff --git a/examples/qml/particles/plasmapatrol/PlasmaPatrol.qmlproject b/examples/qml/particles/plasmapatrol/PlasmaPatrol.qmlproject new file mode 100644 index 0000000000..548295243d --- /dev/null +++ b/examples/qml/particles/plasmapatrol/PlasmaPatrol.qmlproject @@ -0,0 +1,19 @@ +import QmlProject 1.1 + +Project { + mainFile: "plasmapatrol.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + Files { + paths: ["TODO"] + } +} diff --git a/examples/qml/particles/plasmapatrol/TODO b/examples/qml/particles/plasmapatrol/TODO new file mode 100644 index 0000000000..ef9d21a73d --- /dev/null +++ b/examples/qml/particles/plasmapatrol/TODO @@ -0,0 +1,10 @@ +Realistic Tasks: +Particle explosions on ship death. +Better help text (both content and styled a little nicer). +Hardpoint help showing them firing across the screen. +Endless Demo Mode + +Nice-but-i-doubt-it-will-get-done Tasks: +Particle Text for the winner. +Particle-based buttons. +Single player mode that is challenges (known opponents) to master the game with and earn achievements (in addition to 'skirmish'). diff --git a/examples/qml/particles/plasmapatrol/content/BlasterHardpoint.qml b/examples/qml/particles/plasmapatrol/content/BlasterHardpoint.qml new file mode 100644 index 0000000000..10c50d43c8 --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/BlasterHardpoint.qml @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + property variant target: {"y": -90, "x":12} + property Item targetObj: container + property Item hardpoint: container + property ParticleSystem system + property int blasts: 16 + property int bonusBlasts: 12 + property bool show: true + + width: 24 + height: 24 + Emitter { + id: visualization + group: "blaster" + system: container.system + enabled: show + anchors.fill: parent + shape: EllipseShape {} + speed: TargetDirection { targetX: width/2; targetY: width/2; magnitude: -1; proportionalMagnitude: true} + lifeSpan: 1000 + emitRate: 64 + + size: 24 + sizeVariation: 24 + endSize: 0 + } + + property int blastsLeft: 0 + function fireAt(targetArg, container) { + target = container.mapFromItem(targetArg, targetArg.width/2, targetArg.height/2); + targetObj = targetArg; + hardpoint = container; + blastsLeft = blasts; + rofTimer.repeat = true; + rofTimer.start(); + } + Timer { + id: rofTimer + interval: 30;//Has to be greater than 1 frame or they stack up + running: false + repeat: false + onTriggered: { + if (targetObj.hp <= 0) + return; + //TODO: calculate hit and damage at target, which must be a Ship + var hit; + if (blastsLeft >= bonusBlasts) + hit = Math.random() > targetObj.dodge; + else + hit = false; //purely aesthetic shots, because the damage isn't that fine grained + if (hit == true) { + switch (targetObj.shipType) { + case 1: hardpoint.damageDealt += 4; break; + case 2: hardpoint.damageDealt += 5; break; + case 3: hardpoint.damageDealt += 1; break; + default: hardpoint.damageDealt += 100; + } + } + blastVector.targetX = target.x; + blastVector.targetY = target.y; + if (!hit) {//TODO: Actual targetVariation + blastVector.targetX += (128 * Math.random() - 64); + blastVector.targetY += (128 * Math.random() - 64); + } + emitter.burst(1); + blastsLeft--; + if (!blastsLeft) + rofTimer.repeat = false; + } + } + Emitter { + id: emitter + group: "blaster" + enabled: false + system: container.system + anchors.centerIn: parent + + lifeSpan: 1000 + emitRate: 16 + maximumEmitted: blasts + size: 24 + endSize:16 + sizeVariation: 8 + speed: TargetDirection { + id: blastVector + targetX: target.x; targetY: target.y; magnitude: 1.1; proportionalMagnitude: true + } + } +} diff --git a/examples/qml/particles/plasmapatrol/content/Button.qml b/examples/qml/particles/plasmapatrol/content/Button.qml new file mode 100644 index 0000000000..992be295fc --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/Button.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +//TODO: Add particles to this component too +Rectangle { + id: container + property alias text: txt.text + signal clicked + //color: "lightsteelblue" + gradient: Gradient { + GradientStop { position: 0.0; color: "lightsteelblue" } + GradientStop { position: 1.0; color: "steelblue" } + } + height: 64 + radius: 16 + width: 128 + Text { + id: txt + anchors.centerIn: parent + font.pixelSize: 24 + color: "white" + } + MouseArea { + anchors.fill: parent + onClicked: container.clicked() + } +} diff --git a/examples/qml/particles/plasmapatrol/content/CannonHardpoint.qml b/examples/qml/particles/plasmapatrol/content/CannonHardpoint.qml new file mode 100644 index 0000000000..48eb9d171a --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/CannonHardpoint.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + property variant target: {"y": -90, "x":12} + property ParticleSystem system + property bool show: true + + width: 24 + height: 24 + Emitter { + id: visualization + group: "cannon" + enabled: container.show + system: container.system + anchors.centerIn: parent + lifeSpan: 2000 + emitRate: 1 + + size: 4 + endSize: 0 + } + + function fireAt(targetArg, hardpoint) { + target = container.mapFromItem(targetArg, targetArg.width/2, targetArg.height/2); + if (container.hp <= 0 || targetArg.hp <= 0) + return; + //TODO: calculate hit and damage at target, which must be a Ship + var hit = Math.random() > targetArg.dodge + if (hit) { + switch (targetArg.shipType) { + case 1: hardpoint.damageDealt += 8; break; + case 2: hardpoint.damageDealt += 10; break; + case 3: hardpoint.damageDealt += 16; break; + default: hardpoint.damageDealt += 1000; + } + } + emitter.burst(1); + } + Emitter { + id: emitter + group: "cannon" + enabled: false + system: container.system + anchors.centerIn: parent + + lifeSpan: 1000 + emitRate: 1 + size: 8 + endSize: 4 + speed: TargetDirection { + id: blastVector + targetX: target.x; targetY: target.y; magnitude: 1.1; proportionalMagnitude: true + } + } +} diff --git a/examples/qml/particles/plasmapatrol/content/ChoiceBox.qml b/examples/qml/particles/plasmapatrol/content/ChoiceBox.qml new file mode 100644 index 0000000000..6e21101f2e --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/ChoiceBox.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + width: 360 + height: 160 + property ParticleSystem system + Ship { + id: nully + system: system + } + property Item target: nully + /* + Component.onCompleted: { + container.target.shipType = 1 + container.target.gunType = 1 + } + */ + Row { + anchors.horizontalCenter: parent.horizontalCenter + height: parent.height + spacing: 8 + Button { + width: 80 + height: 80 + anchors.verticalCenter: parent.verticalCenter + text: "Cycle\nShip" + onClicked: { + var nextVal = container.target.shipType; + if(nextVal == 3) + nextVal = 1; + else + nextVal++; + container.target.shipType = nextVal; + } + } + Item { + width: 128 + height: 128 + anchors.verticalCenter: parent.verticalCenter + Ship { + hp: 20 + anchors.centerIn: parent + shipType: container.target.shipType + gunType: container.target.gunType + system: container.system + } + } + Button { + width: 80 + height: 80 + anchors.verticalCenter: parent.verticalCenter + text: "Cycle\nGun" + onClicked: { + var nextVal = container.target.gunType; + if(nextVal == 3) + nextVal = 1; + else + nextVal++; + container.target.gunType = nextVal; + } + } + } +} diff --git a/examples/qml/particles/plasmapatrol/content/Cruiser.qml b/examples/qml/particles/plasmapatrol/content/Cruiser.qml new file mode 100644 index 0000000000..c469eb46d2 --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/Cruiser.qml @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + property int maxHP: 100 + property int hp: maxHP + property real initialDodge: 0.01 + property real dodge: initialDodge + onHpChanged: if(hp <= 0) target = container; + property ParticleSystem system//TODO: Ship abstraction + property Item target: container + property string shipParticle: "default"//Per team colors? + property int gunType: 0 + width: 128 + height: 128 + Emitter { + //TODO: Cooler would be an 'orbiting' affector + //TODO: On the subject, opacity and size should be grouped type 'overLife' if we can cram that in the particles + system: container.system + group: container.shipParticle + anchors.centerIn: parent + width: 64 + height: 64 + shape: EllipseShape {} + + emitRate: hp > 0 ? hp * 1 + 20 : 0 + lifeSpan: 2400 + maximumEmitted: (maxHP * 1 + 20)*2.4 + + size: 48 + sizeVariation: 16 + endSize: 16 + + speed: AngleDirection {angleVariation:360; magnitudeVariation: 32} + } + Emitter { + system: container.system + group: "cruiserArmor" + anchors.fill: parent + shape: EllipseShape { fill: false } + enabled: hp>0 + + emitRate: 16 + lifeSpan: 2000 + + size: 48 + sizeVariation: 24 + + SpriteGoal { + id: destructor + system: container.system + enabled: container.hp <=0 + anchors.fill: parent + groups: ["cruiserArmor"] + goalState: "death" +// jump: true + once: true + } + } + + Timer { + id: fireControl + property int next: Math.floor(Math.random() * 3) + 1 + interval: 800 + running: root.readySetGo + repeat: true + onTriggered: { + if (next == 1) { + gun1.fireAt(container.target); + next = Math.floor(Math.random() * 3) + 1; + } else if (next == 2) { + gun2.fireAt(container.target); + next = Math.floor(Math.random() * 3) + 1; + } else if (next == 3) { + gun3.fireAt(container.target); + next = Math.floor(Math.random() * 3) + 1; + } + } + } + + Hardpoint {//TODO: Hardpoint abstraction + x: 112 - 12 - 8*2 + y: 128 - 12 - 12*2 + id: gun1 + system: container.system + show: hp > 0 + hardpointType: gunType + } + Hardpoint { + x: 64 - 12 + y: 0 - 12 + 12*2 + id: gun2 + system: container.system + show: hp > 0 + hardpointType: gunType + } + Hardpoint { + x: 16 - 12 + 8*2 + y: 128 - 12 - 12*2 + id: gun3 + system: container.system + show: hp > 0 + hardpointType: gunType + } +} diff --git a/examples/qml/particles/plasmapatrol/content/Frigate.qml b/examples/qml/particles/plasmapatrol/content/Frigate.qml new file mode 100644 index 0000000000..92c63b87d1 --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/Frigate.qml @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + property int maxHP: 100 + property int hp: maxHP + property real initialDodge: 0.2 + property real dodge: initialDodge + onHpChanged: if(hp <= 0) target = container; + property ParticleSystem system//TODO: Ship abstraction + property Item target: container + property string shipParticle: "default"//Per team colors? + property int gunType: 0 + width: 128 + height: 128 + Emitter { + system: container.system + group: "frigateShield" + anchors.centerIn: parent + size: 92 + emitRate: 1 + lifeSpan: 4800 + enabled: hp > 0 + } + Emitter { + system: container.system + group: container.shipParticle + anchors.centerIn: parent + width: 64 + height: 16 + shape: EllipseShape {} + + size: 16 + sizeVariation: 8 + endSize: 8 + emitRate: hp > 0 ? hp * 1 + 20 : 0 + lifeSpan: 1200 + maximumEmitted: (maxHP * 1 + 20)*2 + } + Timer { + id: fireControl + property int next: Math.floor(Math.random() * 2) + 1 + interval: 800 + running: root.readySetGo + repeat: true + onTriggered: { + if (next == 1) { + gun1.fireAt(container.target); + next = Math.floor(Math.random() * 2) + 1; + } else if (next == 2) { + gun2.fireAt(container.target); + next = Math.floor(Math.random() * 2) + 1; + } + } + } + + Hardpoint { + x: 128 - 32 - 12 + y: 64 - 12 + id: gun1 + system: container.system + show: hp > 0 + hardpointType: gunType + } + Hardpoint { + x: 0 + 32 - 12 + y: 64 - 12 + id: gun2 + system: container.system + show: hp > 0 + hardpointType: gunType + } +} diff --git a/examples/qml/particles/plasmapatrol/content/Hardpoint.qml b/examples/qml/particles/plasmapatrol/content/Hardpoint.qml new file mode 100644 index 0000000000..9e6057057d --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/Hardpoint.qml @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + //ReflectiveProperties + //TransferredProperties + property variant target: {"y": -90, "x":12} + property ParticleSystem system + property bool show: true + property int hardpointType: 0 //default is pea shooter - always bad. + + property Item targetObj: null + property int damageDealt: 0 + onDamageDealtChanged: dealDamageTimer.start(); + Timer { + id: dealDamageTimer + interval: 16 + running: false + repeat: false + onTriggered: {targetObj.hp -= damageDealt; damageDealt = 0;} + } + width: 24 + height: 24 + function fireAt(targetArg) {//Each implement own + if (targetArg != null) { + hardpointLoader.item.fireAt(targetArg, container); + targetObj = targetArg; + } + } + Loader { + id: hardpointLoader + sourceComponent: { + switch (hardpointType) { + case 1: laserComponent; break; + case 2: blasterComponent; break; + case 3: cannonComponent; break; + default: emptyComponent; + } + } + } + Component { + id: laserComponent + LaserHardpoint { + target: container.target + system: container.system + show: container.show + } + } + Component { + id: blasterComponent + BlasterHardpoint { + target: container.target + system: container.system + show: container.show + } + } + Component { + id: cannonComponent + CannonHardpoint { + target: container.target + system: container.system + show: container.show + } + } + Component { + id: emptyComponent + Item { + function fireAt(obj) { + console.log("Firing null weapon. It hurts."); + } + } + } +} diff --git a/examples/qml/particles/plasmapatrol/content/HelpScreens.qml b/examples/qml/particles/plasmapatrol/content/HelpScreens.qml new file mode 100644 index 0000000000..db70c6ee90 --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/HelpScreens.qml @@ -0,0 +1,268 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +SequentialLoader { + id: hLdr + signal exitDesired + Component.onCompleted: advance(); + ParticleSystem { id: helpSystem } + PlasmaPatrolParticles { sys: helpSystem } + pages: [ + Component {Item { + id: story + Text { + color: "white" + text: "Story" + font.pixelSize: 48 + } + /* + Flickable { + y: 60 + width: 360 + height: 500 + contentHeight: txt1.height + contentWidth: 360//TODO: Less magic numbers? + */ + Text { + id: txt1 + color: "white" + y: 60 + font.pixelSize: 18 + text: " +In a remote nebula, a race of energy beings formed and lived prosperous lives for millenia. Until the schism - when they became constantly at each other's energy-throats. War soon followed, crippling both sides, until a truce was formed. But while governments knew the desparate need for peace, the soldiers in the ion-field were still filled with rampant bloodlust. On the border, patrols are constantly engaging in minor skirmishes whenever they cross paths. + +You must select one such patrol unit for the border, heading into an inevitable skirmish, in Plasma Patrol: the game of energy being spaceship combat! + " + width: 360 + wrapMode: Text.WordWrap + } + // } + Button { + x: 20 + y: 560 + height: 40 + width: 120 + text: "Next" + onClicked: hLdr.advance(); + } + Button { + x: 220 + y: 560 + height: 40 + width: 120 + text: "Menu" + onClicked: hLdr.exitDesired(); + } + }}, + Component {Item { + id: ships + Text { + color: "white" + text: "Vessels" + font.pixelSize: 48 + } + Column { + spacing: 16 + y: 60 + Row { + height: 128 + Sloop { + system: helpSystem + } + Text { + text: "The nimble sloop" + color: "white" + font.pixelSize: 18 + } + } + Row { + height: 128 + Frigate { + system: helpSystem + } + Text { + text: "The versitile shield frigate" + color: "white" + font.pixelSize: 18 + } + } + Row { + height: 128 + Cruiser { + system: helpSystem + } + Text { + text: "The armored cruiser" + color: "white" + font.pixelSize: 18 + } + } + } + Button { + x: 20 + y: 560 + height: 40 + width: 120 + text: "Next" + onClicked: hLdr.advance(); + } + Button { + x: 220 + y: 560 + height: 40 + width: 120 + text: "Menu" + onClicked: hLdr.exitDesired(); + } + }}, + Component {Item { + id: guns + Text { + color: "white" + text: "Hardpoints" + font.pixelSize: 48 + } + Column { + spacing: 16 + y: 60 + Row { + height: 128 + LaserHardpoint { + system: helpSystem + } + Text { + text: "The laser hardpoint almost always hits the target, even the nimble sloop, but loses much of its potency against the frigate's shields" + width: 332 + wrapMode: Text.WordWrap + color: "white" + font.pixelSize: 18 + } + } + Row { + height: 128 + BlasterHardpoint { + system: helpSystem + } + Text { + text: "The blaster passes right through the frigate's shields but loses much of its impact against the armor of the cruiser" + width: 332 + wrapMode: Text.WordWrap + color: "white" + font.pixelSize: 18 + } + } + Row { + height: 128 + CannonHardpoint { + system: helpSystem + } + Text { + text: "The cannon has poor accuracy, often missing the nimble sloop, but can punch right through the armor of the cruiser" + width: 332 + wrapMode: Text.WordWrap + color: "white" + font.pixelSize: 18 + } + } + } + Button { + x: 20 + y: 560 + height: 40 + width: 120 + text: "Next" + onClicked: hLdr.advance(); + } + Button { + x: 220 + y: 560 + height: 40 + width: 120 + text: "Menu" + onClicked: hLdr.exitDesired(); + } + }}, + Component {Item { + id: strategy + Text { + color: "white" + text: "Strategy" + font.pixelSize: 48 + } + Flickable { + y: 60 + width: 360 + height: 500 + contentHeight: txt1.height + contentWidth: 360//TODO: Less magic numbers? + Text { + id: txt1 + color: "white" + font.pixelSize: 18 + text: " +Basic Strategy: Good luck, have fun - don't die. +More to come after thorough playtesting. + " + width: 360 + wrapMode: Text.WordWrap + } + } + Button { + x: 20 + y: 560 + height: 40 + width: 120 + text: "Story" + onClicked: {hLdr.at=0; hLdr.advance();} + } + Button { + x: 220 + y: 560 + height: 40 + width: 120 + text: "Menu" + onClicked: hLdr.exitDesired(); + } + }} + ] +} diff --git a/examples/qml/particles/plasmapatrol/content/LaserHardpoint.qml b/examples/qml/particles/plasmapatrol/content/LaserHardpoint.qml new file mode 100644 index 0000000000..a7baed604b --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/LaserHardpoint.qml @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + property variant target: {"y": -90, "x":12} + property ParticleSystem system + property bool show: true + + width: 24 + height: 24 + Emitter { + id: visualization + group: "laser" + system: container.system + anchors.fill: parent + enabled: container.show + shape: EllipseShape {} + speed: TargetDirection { targetX: width/2; targetY: width/2; magnitude: -1; proportionalMagnitude: true } + lifeSpan: 1000 + emitRate: 64 + + size: 24 + sizeVariation: 8 + endSize: 8 + } + + function fireAt(targetArg, hardpoint) { + if (targetArg.hp <= 0) + return; + //TODO: calculate hit and damage at target, which must be a Ship + var offset = 0; + if (Math.random() < 0.99) { + switch (targetArg.shipType) { + case 1: hardpoint.damageDealt += 16; break; + case 2: hardpoint.damageDealt += 4; break; + case 3: hardpoint.damageDealt += 8; break; + default: hardpoint.damageDealt += 500; //Really effective against unregistered vessels + } + } else {//Misses with Lasers are really rare + offset = Math.random() * 100; + } + target = container.mapFromItem(targetArg, offset + targetArg.width/2, offset + targetArg.height/2); + emitter.pulse(100); + // console.log("Fire box: " + Math.min(container.width/2, target.x) + "," + Math.min(container.height/2, target.y) + " " + (Math.max(container.width/2, target.x) - Math.min(container.width/2, target.x)) + "," + (Math.max(container.height/2, target.y) - Math.min(container.height/2, target.y))); + } + Emitter { + id: emitter + group: "laser" + enabled: false + system: container.system + x: Math.min(container.width/2, target.x); + width: Math.max(container.width/2, target.x) - x; + y: Math.min(container.height/2, target.y); + height: Math.max(container.height/2, target.y) - y; + shape: LineShape { + mirrored: (emitter.y < 0 || emitter.x < 0) && !(emitter.y < 0 && emitter.x < 0 )//I just want XOR + } + + lifeSpan: 1000 + emitRate: 8000 + maximumEmitted: 800 + size: 16 + endSize: 0 + + speed: PointDirection {xVariation: 4; yVariation: 4} + } +} diff --git a/examples/qml/particles/plasmapatrol/content/PlasmaPatrolParticles.qml b/examples/qml/particles/plasmapatrol/content/PlasmaPatrolParticles.qml new file mode 100644 index 0000000000..87809965b2 --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/PlasmaPatrolParticles.qml @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + property ParticleSystem sys + ImageParticle { + system: sys + groups: ["default"] + source: "pics/blur-circle3.png" + color: "#003A3A3A" + colorVariation: 0.1 + z: 0 + } + ImageParticle { + system: sys + groups: ["redTeam"] + source: "pics/blur-circle3.png" + color: "#0028060A" + colorVariation: 0.1 + z: 0 + } + ImageParticle { + system: sys + groups: ["greenTeam"] + source: "pics/blur-circle3.png" + color: "#0006280A" + colorVariation: 0.1 + z: 0 + } + ImageParticle { + system: sys + groups: ["blaster"] + source: "pics/star2.png" + //color: "#0F282406" + color: "#0F484416" + colorVariation: 0.2 + z: 2 + } + ImageParticle { + system: sys + groups: ["laser"] + source: "pics/star3.png" + //color: "#00123F68" + color: "#00428FF8" + colorVariation: 0.2 + z: 2 + } + ImageParticle { + system: sys + groups: ["cannon"] + source: "pics/particle.png" + color: "#80FFAAFF" + colorVariation: 0.1 + z: 2 + } + ImageParticle { + system: sys + groups: ["cannonCore"] + source: "pics/particle.png" + color: "#00666666" + colorVariation: 0.8 + z: 1 + } + ImageParticle { + system: sys + groups: ["cannonWake"] + source: "pics/star.png" + color: "#00CCCCCC" + colorVariation: 0.2 + z: 1 + } + ImageParticle { + system: sys + groups: ["frigateShield"] + source: "pics/blur-circle2.png" + color: "#00000000" + colorVariation: 0.05 + blueVariation: 0.5 + greenVariation: 0.1 + z: 3 + } + ImageParticle { + system: sys + groups: ["cruiserArmor"] + z: 1 + sprites:[Sprite { + id: spinState + name: "spinning" + source: "pics/meteor.png" + frames: 35 + frameDuration: 40 + to: {"death":0, "spinning":1} + },Sprite { + name: "death" + source: "pics/meteor_explo.png" + frames: 22 + frameDuration: 40 + to: {"null":1} + }, Sprite { + name: "null" + source: "pics/nullRock.png" + frames: 1 + frameDuration: 1000 + } + ] + } + TrailEmitter { + system: sys + group: "cannonWake" + follow: "cannon" + emitRatePerParticle: 64 + lifeSpan: 600 + speed: AngleDirection { angleVariation: 360; magnitude: 48} + size: 16 + endSize: 8 + sizeVariation: 2 + enabled: true + width: 1000//XXX: Terrible hack + height: 1000 + } + TrailEmitter { + system: sys + group: "cannonCore" + follow: "cannon" + emitRatePerParticle: 256 + lifeSpan: 128 + size: 24 + endSize: 8 + enabled: true + width: 1000//XXX: Terrible hack + height: 1000 + } +} diff --git a/examples/qml/particles/plasmapatrol/content/SequentialLoader.qml b/examples/qml/particles/plasmapatrol/content/SequentialLoader.qml new file mode 100644 index 0000000000..3707759ce3 --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/SequentialLoader.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Item { + id: container + //TODO: Somehow get particles into this? + property list pages + property Item cur: null + property int at: 0 + function advance() { + if(cur != null) + cur.destroy(); + cur = pages[at++].createObject(container); + } +} diff --git a/examples/qml/particles/plasmapatrol/content/Ship.qml b/examples/qml/particles/plasmapatrol/content/Ship.qml new file mode 100644 index 0000000000..bd023b1dc2 --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/Ship.qml @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: me + //Reflective Properties + width: shipLoader.width + height: shipLoader.height + //Transfered Properties + property int hp: 100//shipLoader.item.maxHP + property real dodge: shipLoader.item.initialDodge + property ParticleSystem system + property int targetIdx: 0 + property Item target: targets[targetIdx] == undefined?null:targets[targetIdx] + Connections { + target: me.target + onHpChanged: if (me.target.hp<=0) me.targetIdx++; + } + property list targets + property string shipParticle: "default"//Per team colors? + property int gunType: 0 + property int shipType: 0 + Component { + id: sloopComp + Sloop { + system: me.system + target: me.target + shipParticle: me.shipParticle + gunType: me.gunType + hp: me.hp + dodge: me.dodge + } + } + Component { + id: frigateComp + Frigate { + system: me.system + target: me.target + shipParticle: me.shipParticle + gunType: me.gunType + hp: me.hp + dodge: me.dodge + } + } + Component { + id: cruiserComp + Cruiser { + system: me.system + target: me.target + shipParticle: me.shipParticle + gunType: me.gunType + hp: me.hp + dodge: me.dodge + } + } + Component { + id: dumbComp + Item { + property int maxHP: 0 + property int initialDodge: 0 + } + } + Loader { + id: shipLoader + sourceComponent: { + switch (shipType) { + case 1: sloopComp; break; + case 2: frigateComp; break; + case 3: cruiserComp; break; + default: dumbComp; + } + } + } +} diff --git a/examples/qml/particles/plasmapatrol/content/Sloop.qml b/examples/qml/particles/plasmapatrol/content/Sloop.qml new file mode 100644 index 0000000000..3bc58a28b0 --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/Sloop.qml @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + property int maxHP: 100 + property int hp: maxHP + property real initialDodge: 0.5 + property real dodge: initialDodge + property int blinkInterval: 800 + onHpChanged: if(hp <= 0) target = container; + property ParticleSystem system//TODO: Ship abstraction + property Item target: container + property string shipParticle: "default"//Per team colors? + property int gunType: 0 + width: 128 + height: 128 + Emitter { + id: emitter + //TODO: Cooler would be an 'orbiting' affector + //TODO: On the subject, opacity and size should be grouped type 'overLife' if we can cram that in the particles + system: container.system + group: container.shipParticle + shape: EllipseShape {} + + emitRate: hp > 0 ? hp + 20 : 0 + lifeSpan: blinkInterval + maximumEmitted: (maxHP + 20) + + acceleration: AngleDirection {angleVariation: 360; magnitude: 8} + + size: 24 + endSize: 4 + sizeVariation: 8 + width: 16 + height: 16 + x: 64 + y: 64 + Behavior on x {NumberAnimation {duration:blinkInterval}} + Behavior on y {NumberAnimation {duration:blinkInterval}} + Timer { + interval: blinkInterval + running: true + repeat: true + onTriggered: { + emitter.x = Math.random() * 48 + 32 + emitter.y = Math.random() * 48 + 32 + } + } + } + Hardpoint { + anchors.centerIn: parent + id: gun2 + system: container.system + show: container.hp > 0 + hardpointType: gunType + } + Timer { + id: fireControl + interval: 800 + running: root.readySetGo + repeat: true + onTriggered: { + gun2.fireAt(container.target); + } + } + +} diff --git a/examples/qml/particles/plasmapatrol/content/pics/TitleText.png b/examples/qml/particles/plasmapatrol/content/pics/TitleText.png new file mode 100644 index 0000000000..dc3acebe39 Binary files /dev/null and b/examples/qml/particles/plasmapatrol/content/pics/TitleText.png differ diff --git a/examples/qml/particles/plasmapatrol/content/pics/blur-circle2.png b/examples/qml/particles/plasmapatrol/content/pics/blur-circle2.png new file mode 100644 index 0000000000..f7c9f3e98e Binary files /dev/null and b/examples/qml/particles/plasmapatrol/content/pics/blur-circle2.png differ diff --git a/examples/qml/particles/plasmapatrol/content/pics/blur-circle3.png b/examples/qml/particles/plasmapatrol/content/pics/blur-circle3.png new file mode 100644 index 0000000000..dbc39cb16e Binary files /dev/null and b/examples/qml/particles/plasmapatrol/content/pics/blur-circle3.png differ diff --git a/examples/qml/particles/plasmapatrol/content/pics/finalfrontier.png b/examples/qml/particles/plasmapatrol/content/pics/finalfrontier.png new file mode 100644 index 0000000000..2ba1815230 Binary files /dev/null and b/examples/qml/particles/plasmapatrol/content/pics/finalfrontier.png differ diff --git a/examples/qml/particles/plasmapatrol/content/pics/meteor.png b/examples/qml/particles/plasmapatrol/content/pics/meteor.png new file mode 100644 index 0000000000..e8c368aea7 Binary files /dev/null and b/examples/qml/particles/plasmapatrol/content/pics/meteor.png differ diff --git a/examples/qml/particles/plasmapatrol/content/pics/meteor_explo.png b/examples/qml/particles/plasmapatrol/content/pics/meteor_explo.png new file mode 100644 index 0000000000..4297245d49 Binary files /dev/null and b/examples/qml/particles/plasmapatrol/content/pics/meteor_explo.png differ diff --git a/examples/qml/particles/plasmapatrol/content/pics/nullRock.png b/examples/qml/particles/plasmapatrol/content/pics/nullRock.png new file mode 100644 index 0000000000..4076327a1a Binary files /dev/null and b/examples/qml/particles/plasmapatrol/content/pics/nullRock.png differ diff --git a/examples/qml/particles/plasmapatrol/content/pics/particle.png b/examples/qml/particles/plasmapatrol/content/pics/particle.png new file mode 100644 index 0000000000..5c83896d22 Binary files /dev/null and b/examples/qml/particles/plasmapatrol/content/pics/particle.png differ diff --git a/examples/qml/particles/plasmapatrol/content/pics/star.png b/examples/qml/particles/plasmapatrol/content/pics/star.png new file mode 100644 index 0000000000..0d592cfa87 Binary files /dev/null and b/examples/qml/particles/plasmapatrol/content/pics/star.png differ diff --git a/examples/qml/particles/plasmapatrol/content/pics/star2.png b/examples/qml/particles/plasmapatrol/content/pics/star2.png new file mode 100644 index 0000000000..bb55c44788 Binary files /dev/null and b/examples/qml/particles/plasmapatrol/content/pics/star2.png differ diff --git a/examples/qml/particles/plasmapatrol/content/pics/star3.png b/examples/qml/particles/plasmapatrol/content/pics/star3.png new file mode 100644 index 0000000000..636a25f480 Binary files /dev/null and b/examples/qml/particles/plasmapatrol/content/pics/star3.png differ diff --git a/examples/qml/particles/plasmapatrol/plasmapatrol.qml b/examples/qml/particles/plasmapatrol/plasmapatrol.qml new file mode 100644 index 0000000000..b14ac6385b --- /dev/null +++ b/examples/qml/particles/plasmapatrol/plasmapatrol.qml @@ -0,0 +1,386 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "content" + +Rectangle { + id: root + property bool readySetGo: false + //Debugging + property int hits: 0 + property int misses: 0 + property real ratio: hits/(misses?misses:1) + //Move to JS file? + property Ship redVar1: Ship {shipType: 1; gunType: 1} + property Ship redVar2: Ship {shipType: 1; gunType: 2} + property Ship redVar3: Ship {shipType: 1; gunType: 3} + property Ship greenVar1: Ship {shipType: 3; gunType: 1} + property Ship greenVar2: Ship {shipType: 2; gunType: 2} + property Ship greenVar3: Ship {shipType: 1; gunType: 3} + property string winner: "0" + property int players: 0 + function aiSet(ship) { + ship.gunType = Math.floor(Math.random() * 3) + 1 + ship.shipType = Math.floor(Math.random() * 3) + 1 + } + + width: 360 + height: 600 + color: "black" + SequentialLoader { + anchors.fill: parent + //General Children + Image { + anchors.centerIn: parent + source: "../images/finalfrontier.png" + } + ParticleSystem { + id: particles + } + PlasmaPatrolParticles { sys: particles; z: 100 }//Renders all particles on the one plane + //Component parts + id: pageControl + Component.onCompleted: advance(); + pages:[ + Component {Item { + id: menu + width: root.width + height: root.height + Column { + anchors.verticalCenter: parent.verticalCenter + width: parent.width + spacing: 8 + Item { + id: title + width: root.width + height: 240 + Emitter { + anchors.fill: parent + system: particles + enabled: true + group: "default" + emitRate: 1200 + lifeSpan: 1200 + shape: MaskShape {source:"content/pics/TitleText.png"} + size: 16 + endSize: 0 + sizeVariation: 8 + speed: AngleDirection {angleVariation:360; magnitudeVariation: 6} + } + } + Button { + text: "1P" + onClicked: {root.players = 1; pageControl.advance();} + anchors.horizontalCenter: parent.horizontalCenter + } + Button { + text: "2P" + onClicked: {root.players = 2; pageControl.advance();} + anchors.horizontalCenter: parent.horizontalCenter + } + Button { + text: "Demo" + anchors.horizontalCenter: parent.horizontalCenter + onClicked: {root.players = 0; + aiSet(redVar1); + aiSet(redVar2); + aiSet(redVar3); + aiSet(greenVar1); + aiSet(greenVar2); + aiSet(greenVar3); + pageControl.at = 5;//TODO: Not a magic number + pageControl.advance();} + } + Button { + text: "Help" + anchors.horizontalCenter: parent.horizontalCenter + onClicked: { + pageControl.at = 7;//TODO: Not a magic number + pageControl.advance(); + } + } + Button { + text: "Quit" + anchors.horizontalCenter: parent.horizontalCenter + onClicked: Qt.quit(); + } + } + }}, + Component {Item { + id: p1Screen + z: 101 + width: root.width + height: root.height + Rectangle { + anchors.fill: parent + color: "red" + } + Text { + anchors.centerIn: parent + color: "white" + font.pixelSize: 64 + font.bold: true + text: "Player\n 1" + horizontalAlignment: Text.AlignHCenter + } + MouseArea { + anchors.fill: parent + onClicked: pageControl.advance() + } + }}, + Component {Item { + id: p1Choices + z: 3 + width: root.width + height: root.height + Rectangle { + color: "black" + anchors.fill: parent + } + Column { + spacing: 16 + width: root.width + anchors.horizontalCenter: parent.horizontalCenter + ChoiceBox { + target: redVar1 + system: particles + } + ChoiceBox { + target: redVar2 + system: particles + } + ChoiceBox { + target: redVar3 + system: particles + } + Button { + anchors.horizontalCenter: parent.horizontalCenter + text: "Next" + onClicked: { + if (root.players < 2) { + aiSet(greenVar1); + aiSet(greenVar2); + aiSet(greenVar3); + pageControl.at = 5;//TODO: Not a magic number + } + pageControl.advance(); + } + } + } + }}, + Component {Item { + id: p2Screen + z: 101 + width: root.width + height: root.height + Rectangle { + anchors.fill: parent + color: "green" + } + Text { + anchors.centerIn: parent + color: "white" + font.pixelSize: 64 + font.bold: true + text: "Player\n 2" + horizontalAlignment: Text.AlignHCenter + } + MouseArea { + anchors.fill: parent + onClicked: pageControl.advance() + } + }}, + Component {Item { + id: p2Choices + z: 1 + width: root.width + height: root.height + Rectangle { + color: "black" + anchors.fill: parent + } + Column { + spacing: 16 + width: root.width + anchors.horizontalCenter: parent.horizontalCenter + ChoiceBox { + target: greenVar1 + system: particles + } + ChoiceBox { + target: greenVar2 + system: particles + } + ChoiceBox { + target: greenVar3 + system: particles + } + Button { + anchors.horizontalCenter: parent.horizontalCenter + text: "Next" + onClicked: pageControl.advance() + } + } + }}, + Component {Item { + id: arena + width: root.width + height: root.height + z: 0 + Component.onCompleted: root.readySetGo = true + Component.onDestruction: root.readySetGo = false + property bool victory: redShip3.hp <= 0 || greenShip3.hp <=0 + onVictoryChanged: { + if (redShip3.hp <= 0) { + if (greenShip3.hp <= 0) { + root.winner = "1&2" + }else { + root.winner = "2" + } + } else { + root.winner = "1" + } + winTimer.start() + } + Timer { + id: winTimer + interval: 1200 + repeat: false + running: false + onTriggered: pageControl.advance(); + } + Ship { + id: redShip1 + shipParticle: "redTeam" + system: particles + x: 180-64 + y: 128 + shipType: redVar1.shipType + gunType: redVar1.gunType + targets: [greenShip1, greenShip2, greenShip3] + } + Ship { + id: redShip2 + shipParticle: "redTeam" + system: particles + x: 0 + y: 0 + shipType: redVar2.shipType + gunType: redVar2.gunType + targets: [greenShip1, greenShip2, greenShip3] + } + Ship { + id: redShip3 + shipParticle: "redTeam" + system: particles + x: 360-128 + y: 0 + shipType: redVar3.shipType + gunType: redVar3.gunType + targets: [greenShip1, greenShip2, greenShip3] + } + + Ship { + id: greenShip1 + shipParticle: "greenTeam" + system: particles + x: 180-64 + y: 600 - 128 - 128 + shipType: greenVar1.shipType + gunType: greenVar1.gunType + targets: [redShip1, redShip2, redShip3] + } + Ship { + id: greenShip2 + shipParticle: "greenTeam" + system: particles + x: 0 + y: 600-128 + shipType: greenVar2.shipType + gunType: greenVar2.gunType + targets: [redShip1, redShip2, redShip3] + } + Ship { + id: greenShip3 + shipParticle: "greenTeam" + system: particles + x: 360 - 128 + y: 600 - 128 + shipType: greenVar3.shipType + gunType: greenVar3.gunType + targets: [redShip1, redShip2, redShip3] + } + }}, + Component {Item { + id: winScreen + z: 101 + width: root.width + height: root.height + /* + Rectangle { + anchors.fill: parent + color: "black" + } + */ + Text {//TODO: Particle Text? + anchors.fill: parent + color: "white" + font.pixelSize: 64 + font.bold: true + text: "Player " + root.winner + " wins!" + wrapMode: Text.WordWrap + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + MouseArea { + anchors.fill: parent + onClicked: {pageControl.at = 0; pageControl.advance();} + } + }}, + Component { + HelpScreens { + onExitDesired: {pageControl.at = 0; pageControl.advance();} + } + } + ] + } +} diff --git a/examples/qml/particles/simple/dynamiccomparison.qml b/examples/qml/particles/simple/dynamiccomparison.qml new file mode 100644 index 0000000000..a7cdb9b32a --- /dev/null +++ b/examples/qml/particles/simple/dynamiccomparison.qml @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + id: root + color: "black" + width: 640 + height: 480 + ParticleSystem { + id: sys + } + + ImageParticle { + system: sys + source: "../images/particle.png" + color: "white" + colorVariation: 1.0 + alpha: 0.1 + entryEffect: ImageParticle.None + } + + Emitter { + id: emitter + system: sys + width: parent.width/2 + speed: PointDirection {y: 72; yVariation: 24} + lifeSpan: 10000 + emitRate: 1000 + enabled: false + size: 32 + } + + Item { + id: fakeEmitter + function burst(number) { + while (number > 0) { + var item = fakeParticle.createObject(root); + item.lifeSpan = Math.random() * 5000 + 5000; + item.x = Math.random() * 320 + 320; + item.y = 0; + number--; + } + } + + Component { + id: fakeParticle + Image { + id: container + property int lifeSpan: 10000 + width: 32 + height: 32 + source: "../images/particle.png" + y: 0 + PropertyAnimation on y {from: -16; to: 480-16; duration: container.lifeSpan; running: true} + SequentialAnimation on opacity { + running: true + NumberAnimation { from:0; to: 1; duration: 500} + PauseAnimation { duration: container.lifeSpan - 1000} + NumberAnimation { from:1; to: 0; duration: 500} + ScriptAction { script: container.destroy(); } + } + } + } + } + + Text { + anchors.left: parent.left + anchors.bottom: parent.bottom + text: "1000 particles" + color: "white" + MouseArea { + anchors.fill: parent + onClicked: emitter.burst(1000); + } + } + Text { + anchors.right: parent.right + anchors.bottom: parent.bottom + text: "1000 items" + color: "white" + MouseArea { + anchors.fill: parent + onClicked: fakeEmitter.burst(1000); + } + } +} diff --git a/examples/qml/particles/simple/dynamicemitters.qml b/examples/qml/particles/simple/dynamicemitters.qml new file mode 100644 index 0000000000..4431ebe82e --- /dev/null +++ b/examples/qml/particles/simple/dynamicemitters.qml @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + id: root + color: "black" + width: 640 + height: 480 + ParticleSystem { + id: sys + } + ImageParticle { + system: sys + source: "../images/particle.png" + color: "white" + colorVariation: 1.0 + alpha: 0.1 + } + + Component { + id: emitterComp + Emitter { + id: container + Emitter { + id: emitMore + system: sys + emitRate: 128 + lifeSpan: 600 + size: 16 + endSize: 8 + speed: AngleDirection {angleVariation:360; magnitude: 60} + } + + property int life: 2600 + property real targetX: 0 + property real targetY: 0 + function go() { + xAnim.start(); + yAnim.start(); + container.enabled = true + } + system: sys + emitRate: 32 + lifeSpan: 600 + size: 24 + endSize: 8 + NumberAnimation on x { + id: xAnim; + to: targetX + duration: life + running: false + } + NumberAnimation on y { + id: yAnim; + to: targetY + duration: life + running: false + } + Timer { + interval: life + running: true + onTriggered: container.destroy(); + } + } + } + + MouseArea { + anchors.fill: parent + onClicked: { + for (var i=0; i<8; i++) { + var obj = emitterComp.createObject(root); + obj.x = mouse.x + obj.y = mouse.y + obj.targetX = Math.random() * 240 - 120 + obj.x + obj.targetY = Math.random() * 240 - 120 + obj.y + obj.life = Math.round(Math.random() * 2400) + 200 + obj.emitRate = Math.round(Math.random() * 32) + 32 + obj.go(); + } + } + } +} diff --git a/examples/qml/particles/simple/multiplepainters.qml b/examples/qml/particles/simple/multiplepainters.qml new file mode 100644 index 0000000000..c1b85caa2d --- /dev/null +++ b/examples/qml/particles/simple/multiplepainters.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + id: root + width: 360 + height: 600 + color: "darkblue" + property bool cloneMode: false + ParticleSystem { + id: sys + } + MouseArea { + anchors.fill: parent + onClicked: cloneMode = !cloneMode; + } + Emitter { + system: sys + y:root.height + 20 + width: root.width + emitRate: 200 + lifeSpan: 4000 + startTime: 4000 + speed: PointDirection { y: -120; } + } + + ImageParticle { + system: sys + visible: !cloneMode + source: "../images/particle2.png" + } + + ImageParticle { + system: sys + visible: cloneMode + z: 0 + source: "../images/particle3.png" + } + + ImageParticle { + system: sys + clip: true + visible: cloneMode + y: 120 + height: 240 + width: root.width + z: 1 + source: "../images/particle.png" + } +} diff --git a/examples/qml/particles/simple/startstop.qml b/examples/qml/particles/simple/startstop.qml new file mode 100644 index 0000000000..62105b28a0 --- /dev/null +++ b/examples/qml/particles/simple/startstop.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + width: 360 + height: 540 + color: "black" + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: { + if (mouse.button == Qt.LeftButton) + particles.running = !particles.running + else + particles.paused = !particles.paused; + } + } + + ParticleSystem { + id: particles + running: false + } + + ImageParticle { + anchors.fill: parent + system: particles + source: "../images/star.png" + sizeTable: "../images/sparkleSize.png" + alpha: 0 + colorVariation: 0.6 + } + + Emitter { + anchors.fill: parent + system: particles + emitRate: 2000 + lifeSpan: 2000 + size: 30 + sizeVariation: 10 + } +} diff --git a/examples/qml/photoviewer/PhotoViewerCore/AlbumDelegate.qml b/examples/qml/photoviewer/PhotoViewerCore/AlbumDelegate.qml new file mode 100644 index 0000000000..164f47faa9 --- /dev/null +++ b/examples/qml/photoviewer/PhotoViewerCore/AlbumDelegate.qml @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +Component { + id: albumDelegate + Package { + + Item { + Package.name: 'browser' + GridView { + id: photosGridView; model: visualModel.parts.grid; width: mainWindow.width; height: mainWindow.height - 21 + x: 0; y: 21; cellWidth: 160; cellHeight: 153; interactive: false + onCurrentIndexChanged: photosListView.positionViewAtIndex(currentIndex, ListView.Contain) + } + } + + Item { + Package.name: 'fullscreen' + ListView { + id: photosListView; model: visualModel.parts.list; orientation: Qt.Horizontal + width: mainWindow.width; height: mainWindow.height; interactive: false + onCurrentIndexChanged: photosGridView.positionViewAtIndex(currentIndex, GridView.Contain) + highlightRangeMode: ListView.StrictlyEnforceRange; snapMode: ListView.SnapOneItem + } + } + + Item { + Package.name: 'album' + id: albumWrapper; width: 210; height: 220 + + VisualDataModel { + id: visualModel; delegate: PhotoDelegate { } + model: RssModel { id: rssModel; tags: tag } + } + + BusyIndicator { + id: busyIndicator + anchors { centerIn: parent; verticalCenterOffset: -20 } + on: rssModel.status != XmlListModel.Ready + } + + PathView { + id: photosPathView; model: visualModel.parts.stack; pathItemCount: 5 + visible: !busyIndicator.visible + anchors.centerIn: parent; anchors.verticalCenterOffset: -30 + path: Path { + PathAttribute { name: 'z'; value: 9999.0 } + PathLine { x: 1; y: 1 } + PathAttribute { name: 'z'; value: 0.0 } + } + } + + MouseArea { + anchors.fill: parent + onClicked: mainWindow.editMode ? photosModel.remove(index) : albumWrapper.state = 'inGrid' + } + + Tag { + anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 10 } + frontLabel: tag; backLabel: qsTr("Remove"); flipped: mainWindow.editMode + onTagChanged: rssModel.tags = tag + onBackClicked: if (mainWindow.editMode) photosModel.remove(index); + } + + states: [ + State { + name: 'inGrid' + PropertyChanges { target: photosGridView; interactive: true } + PropertyChanges { target: albumsShade; opacity: 1 } + PropertyChanges { target: backButton; onClicked: albumWrapper.state = ''; y: 6 } + }, + State { + name: 'fullscreen'; extend: 'inGrid' + PropertyChanges { target: photosGridView; interactive: false } + PropertyChanges { target: photosListView; interactive: true } + PropertyChanges { target: photosShade; opacity: 1 } + PropertyChanges { target: backButton; y: -backButton.height - 8 } + } + ] + + GridView.onAdd: NumberAnimation { + target: albumWrapper; properties: "scale"; from: 0.0; to: 1.0; easing.type: Easing.OutQuad + } + GridView.onRemove: SequentialAnimation { + PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: true } + NumberAnimation { target: albumWrapper; property: "scale"; from: 1.0; to: 0.0; easing.type: Easing.OutQuad } + PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: false } + } + + transitions: [ + Transition { + from: '*'; to: 'inGrid' + SequentialAnimation { + NumberAnimation { properties: 'opacity'; duration: 250 } + PauseAnimation { duration: 350 } + NumberAnimation { target: backButton; properties: "y"; duration: 200; easing.type: Easing.OutQuad } + } + }, + Transition { + from: 'inGrid'; to: '*' + NumberAnimation { properties: "y,opacity"; easing.type: Easing.OutQuad; duration: 300 } + } + ] + } + } +} diff --git a/examples/qml/photoviewer/PhotoViewerCore/BusyIndicator.qml b/examples/qml/photoviewer/PhotoViewerCore/BusyIndicator.qml new file mode 100644 index 0000000000..867c268399 --- /dev/null +++ b/examples/qml/photoviewer/PhotoViewerCore/BusyIndicator.qml @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + id: container + property bool on: false + + source: "images/busy.png"; visible: container.on + NumberAnimation on rotation { running: container.on; from: 0; to: 360; loops: Animation.Infinite; duration: 1200 } +} diff --git a/examples/qml/photoviewer/PhotoViewerCore/Button.qml b/examples/qml/photoviewer/PhotoViewerCore/Button.qml new file mode 100644 index 0000000000..8f4177c097 --- /dev/null +++ b/examples/qml/photoviewer/PhotoViewerCore/Button.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + property alias label: labelText.text + property color tint: "transparent" + signal clicked + + width: labelText.width + 70 ; height: labelText.height + 18 + + BorderImage { + anchors { fill: container; leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 } + source: 'images/box-shadow.png'; smooth: true + border.left: 10; border.top: 10; border.right: 10; border.bottom: 10 + } + + Image { anchors.fill: parent; source: "images/cardboard.png"; smooth: true } + + Rectangle { + anchors.fill: container; color: container.tint; visible: container.tint != "" + opacity: 0.25; smooth: true + } + + Text { id: labelText; font.pixelSize: 15; anchors.centerIn: parent; smooth: true } + + MouseArea { + anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 } + onClicked: container.clicked() + } +} diff --git a/examples/qml/photoviewer/PhotoViewerCore/EditableButton.qml b/examples/qml/photoviewer/PhotoViewerCore/EditableButton.qml new file mode 100644 index 0000000000..435ad2644f --- /dev/null +++ b/examples/qml/photoviewer/PhotoViewerCore/EditableButton.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + property string label + signal clicked + signal labelChanged(string label) + + width: textInput.width + 70 ; height: textInput.height + 18 + + BorderImage { + anchors { fill: container; leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 } + source: 'images/box-shadow.png'; smooth: true + border.left: 10; border.top: 10; border.right: 10; border.bottom: 10 + } + + Image { anchors.fill: parent; source: "images/cardboard.png"; smooth: true } + + TextInput { + id: textInput; text: label; font.pixelSize: 15; anchors.centerIn: parent; smooth: true + Keys.onReturnPressed: { + container.labelChanged(textInput.text) + container.focus = true + } + Keys.onEnterPressed: { + container.labelChanged(textInput.text) + container.focus = true + } + Keys.onEscapePressed: { + textInput.text = container.label + container.focus = true + } + } + + Rectangle { + anchors.fill: container; border.color: "steelblue"; border.width: 4 + color: "transparent"; visible: textInput.focus; smooth: true + } + + MouseArea { + anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 } + onClicked: { textInput.forceActiveFocus(); textInput.openSoftwareInputPanel(); } + } +} diff --git a/examples/qml/photoviewer/PhotoViewerCore/PhotoDelegate.qml b/examples/qml/photoviewer/PhotoViewerCore/PhotoDelegate.qml new file mode 100644 index 0000000000..5d4e5aee5d --- /dev/null +++ b/examples/qml/photoviewer/PhotoViewerCore/PhotoDelegate.qml @@ -0,0 +1,188 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "script/script.js" as Script + +Package { + Item { id: stackItem; Package.name: 'stack'; width: 160; height: 153; z: stackItem.PathView.z } + Item { id: listItem; Package.name: 'list'; width: mainWindow.width + 40; height: 153 } + Item { id: gridItem; Package.name: 'grid'; width: 160; height: 153 } + + Item { + width: 160; height: 153 + + Item { + id: photoWrapper + + property double randomAngle: Math.random() * (2 * 6 + 1) - 6 + property double randomAngle2: Math.random() * (2 * 6 + 1) - 6 + + x: 0; y: 0; width: 140; height: 133 + z: stackItem.PathView.z; rotation: photoWrapper.randomAngle + + BorderImage { + anchors { + fill: originalImage.status == Image.Ready ? border : placeHolder + leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 + } + source: 'images/box-shadow.png'; smooth: true + border.left: 10; border.top: 10; border.right: 10; border.bottom: 10 + } + Rectangle { + id: placeHolder + + property int w: Script.getWidth(content) + property int h: Script.getHeight(content) + property double s: Script.calculateScale(w, h, photoWrapper.width) + + color: 'white'; anchors.centerIn: parent; smooth: true + width: w * s; height: h * s; visible: originalImage.status != Image.Ready + Rectangle { + color: "#878787"; smooth: true + anchors { fill: parent; topMargin: 3; bottomMargin: 3; leftMargin: 3; rightMargin: 3 } + } + } + Rectangle { + id: border; color: 'white'; anchors.centerIn: parent; smooth: true + width: originalImage.paintedWidth + 6; height: originalImage.paintedHeight + 6 + visible: !placeHolder.visible + } + BusyIndicator { anchors.centerIn: parent; on: originalImage.status != Image.Ready } + Image { + id: originalImage; smooth: true; source: "http://" + Script.getImagePath(content); cache: false + fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height + } + Image { + id: hqImage; smooth: true; source: ""; visible: false; cache: false + fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height + } + Binding { + target: mainWindow; property: "downloadProgress"; value: hqImage.progress + when: listItem.ListView.isCurrentItem + } + Binding { + target: mainWindow; property: "imageLoading" + value: (hqImage.status == Image.Loading) ? 1 : 0; when: listItem.ListView.isCurrentItem + } + MouseArea { + width: originalImage.paintedWidth; height: originalImage.paintedHeight; anchors.centerIn: originalImage + onClicked: { + if (albumWrapper.state == 'inGrid') { + gridItem.GridView.view.currentIndex = index; + albumWrapper.state = 'fullscreen' + } else { + gridItem.GridView.view.currentIndex = index; + albumWrapper.state = 'inGrid' + } + } + } + + states: [ + State { + name: 'stacked'; when: albumWrapper.state == '' + ParentChange { target: photoWrapper; parent: stackItem; x: 10; y: 10 } + PropertyChanges { target: photoWrapper; opacity: stackItem.PathView.onPath ? 1.0 : 0.0 } + }, + State { + name: 'inGrid'; when: albumWrapper.state == 'inGrid' + ParentChange { target: photoWrapper; parent: gridItem; x: 10; y: 10; rotation: photoWrapper.randomAngle2 } + }, + State { + name: 'fullscreen'; when: albumWrapper.state == 'fullscreen' + ParentChange { + target: photoWrapper; parent: listItem; x: 0; y: 0; rotation: 0 + width: mainWindow.width; height: mainWindow.height + } + PropertyChanges { target: border; opacity: 0 } + PropertyChanges { target: hqImage; source: listItem.ListView.isCurrentItem ? hq : ""; visible: true } + } + ] + + transitions: [ + Transition { + from: 'stacked'; to: 'inGrid' + SequentialAnimation { + PauseAnimation { duration: 10 * index } + ParentAnimation { + target: photoWrapper; via: foreground + NumberAnimation { + target: photoWrapper; properties: 'x,y,rotation,opacity'; duration: 600; easing.type: 'OutQuart' + } + } + } + }, + Transition { + from: 'inGrid'; to: 'stacked' + ParentAnimation { + target: photoWrapper; via: foreground + NumberAnimation { properties: 'x,y,rotation,opacity'; duration: 600; easing.type: 'OutQuart' } + } + }, + Transition { + from: 'inGrid'; to: 'fullscreen' + SequentialAnimation { + PauseAnimation { duration: gridItem.GridView.isCurrentItem ? 0 : 600 } + ParentAnimation { + target: photoWrapper; via: foreground + NumberAnimation { + targets: [ photoWrapper, border ] + properties: 'x,y,width,height,opacity,rotation' + duration: gridItem.GridView.isCurrentItem ? 600 : 1; easing.type: 'OutQuart' + } + } + } + }, + Transition { + from: 'fullscreen'; to: 'inGrid' + ParentAnimation { + target: photoWrapper; via: foreground + NumberAnimation { + targets: [ photoWrapper, border ] + properties: 'x,y,width,height,rotation,opacity' + duration: gridItem.GridView.isCurrentItem ? 600 : 1; easing.type: 'OutQuart' + } + } + } + ] + } + } +} diff --git a/examples/qml/photoviewer/PhotoViewerCore/ProgressBar.qml b/examples/qml/photoviewer/PhotoViewerCore/ProgressBar.qml new file mode 100644 index 0000000000..58beef57f3 --- /dev/null +++ b/examples/qml/photoviewer/PhotoViewerCore/ProgressBar.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + property real progress: 0 + + Behavior on opacity { NumberAnimation { duration: 600 } } + + Rectangle { anchors.fill: parent; color: "black"; opacity: 0.5 } + + Rectangle { + id: fill; color: "white"; height: container.height + width: container.width * container.progress + } +} diff --git a/examples/qml/photoviewer/PhotoViewerCore/RssModel.qml b/examples/qml/photoviewer/PhotoViewerCore/RssModel.qml new file mode 100644 index 0000000000..1598977bb1 --- /dev/null +++ b/examples/qml/photoviewer/PhotoViewerCore/RssModel.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + property string tags : "" + + function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); } + + source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "") + query: "/feed/entry" + namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" + + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "content"; query: "content/string()" } + XmlRole { name: "hq"; query: "link[@rel='enclosure']/@href/string()" } +} diff --git a/examples/qml/photoviewer/PhotoViewerCore/Tag.qml b/examples/qml/photoviewer/PhotoViewerCore/Tag.qml new file mode 100644 index 0000000000..ed4a248a7b --- /dev/null +++ b/examples/qml/photoviewer/PhotoViewerCore/Tag.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Flipable { + id: flipable + + property alias frontLabel: frontButton.label + property alias backLabel: backButton.label + + property int angle: 0 + property int randomAngle: Math.random() * (2 * 6 + 1) - 6 + property bool flipped: false + + signal frontClicked + signal backClicked + signal tagChanged(string tag) + + front: EditableButton { + id: frontButton; rotation: flipable.randomAngle + anchors { centerIn: parent; verticalCenterOffset: -20 } + onClicked: flipable.frontClicked() + onLabelChanged: flipable.tagChanged(label) + } + + back: Button { + id: backButton; tint: "red"; rotation: flipable.randomAngle + anchors { centerIn: parent; verticalCenterOffset: -20 } + onClicked: flipable.backClicked() + } + + transform: Rotation { + origin.x: flipable.width / 2; origin.y: flipable.height / 2 + axis.x: 0; axis.y: 1; axis.z: 0 + angle: flipable.angle + } + + states: State { + name: "back"; when: flipable.flipped + PropertyChanges { target: flipable; angle: 180 } + } + + transitions: Transition { + ParallelAnimation { + NumberAnimation { properties: "angle"; duration: 400 } + SequentialAnimation { + NumberAnimation { target: flipable; property: "scale"; to: 0.8; duration: 200 } + NumberAnimation { target: flipable; property: "scale"; to: 1.0; duration: 200 } + } + } + } +} diff --git a/examples/qml/photoviewer/PhotoViewerCore/images/box-shadow.png b/examples/qml/photoviewer/PhotoViewerCore/images/box-shadow.png new file mode 100644 index 0000000000..431af8545d Binary files /dev/null and b/examples/qml/photoviewer/PhotoViewerCore/images/box-shadow.png differ diff --git a/examples/qml/photoviewer/PhotoViewerCore/images/busy.png b/examples/qml/photoviewer/PhotoViewerCore/images/busy.png new file mode 100644 index 0000000000..664c2b1491 Binary files /dev/null and b/examples/qml/photoviewer/PhotoViewerCore/images/busy.png differ diff --git a/examples/qml/photoviewer/PhotoViewerCore/images/cardboard.png b/examples/qml/photoviewer/PhotoViewerCore/images/cardboard.png new file mode 100644 index 0000000000..1847ab528d Binary files /dev/null and b/examples/qml/photoviewer/PhotoViewerCore/images/cardboard.png differ diff --git a/examples/qml/photoviewer/PhotoViewerCore/qmldir b/examples/qml/photoviewer/PhotoViewerCore/qmldir new file mode 100644 index 0000000000..d3c247f21a --- /dev/null +++ b/examples/qml/photoviewer/PhotoViewerCore/qmldir @@ -0,0 +1,8 @@ +AlbumDelegate AlbumDelegate.qml +PhotoDelegate PhotoDelegate.qml +ProgressBar ProgressBar.qml +RssModel RssModel.qml +BusyIndicator BusyIndicator.qml +EditableButton EditableButton.qml +Button Button.qml +Tag Tag.qml diff --git a/examples/qml/photoviewer/PhotoViewerCore/script/script.js b/examples/qml/photoviewer/PhotoViewerCore/script/script.js new file mode 100644 index 0000000000..e8ef93a847 --- /dev/null +++ b/examples/qml/photoviewer/PhotoViewerCore/script/script.js @@ -0,0 +1,27 @@ +.pragma library + +function getWidth(string) { + return (string.match(/width=\"([0-9]+)\"/))[1] +} + +function getHeight(string) { + return (string.match(/height=\"([0-9]+)\"/))[1] +} + +function getImagePath(string) { + var pattern = /src=\"http:\/\/(\S+)\"/ + return (string.match(pattern))[1] +} + +function calculateScale(width, height, cellSize) { + var widthScale = (cellSize * 1.0) / width + var heightScale = (cellSize * 1.0) / height + var scale = 0 + + if (widthScale <= heightScale) { + scale = widthScale; + } else if (heightScale < widthScale) { + scale = heightScale; + } + return scale; +} diff --git a/examples/qml/photoviewer/i18n/base.ts b/examples/qml/photoviewer/i18n/base.ts new file mode 100644 index 0000000000..1accfd2f90 --- /dev/null +++ b/examples/qml/photoviewer/i18n/base.ts @@ -0,0 +1,30 @@ + + + + + AlbumDelegate + + + Remove + + + + + photoviewer + + + Add + + + + + Edit + + + + + Back + + + + diff --git a/examples/qml/photoviewer/i18n/qml_fr.qm b/examples/qml/photoviewer/i18n/qml_fr.qm new file mode 100644 index 0000000000..c24fcbc46c Binary files /dev/null and b/examples/qml/photoviewer/i18n/qml_fr.qm differ diff --git a/examples/qml/photoviewer/i18n/qml_fr.ts b/examples/qml/photoviewer/i18n/qml_fr.ts new file mode 100644 index 0000000000..9f892db616 --- /dev/null +++ b/examples/qml/photoviewer/i18n/qml_fr.ts @@ -0,0 +1,30 @@ + + + + + AlbumDelegate + + + Remove + Supprimer + + + + photoviewer + + + Add + Ajouter + + + + Edit + Éditer + + + + Back + Retour + + + diff --git a/examples/qml/photoviewer/photoviewer.qml b/examples/qml/photoviewer/photoviewer.qml new file mode 100644 index 0000000000..208720b9e6 --- /dev/null +++ b/examples/qml/photoviewer/photoviewer.qml @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "PhotoViewerCore" + +Rectangle { + id: mainWindow + + property real downloadProgress: 0 + property bool imageLoading: false + property bool editMode: false + + width: 800; height: 480; color: "#d5d6d8" + + ListModel { + id: photosModel + ListElement { tag: "Flowers" } + ListElement { tag: "Wildlife" } + ListElement { tag: "Prague" } + } + + VisualDataModel { id: albumVisualModel; model: photosModel; delegate: AlbumDelegate {} } + + GridView { + id: albumView; width: parent.width; height: parent.height; cellWidth: 210; cellHeight: 220 + model: albumVisualModel.parts.album; visible: albumsShade.opacity != 1.0 + } + + Column { + spacing: 20; anchors { bottom: parent.bottom; right: parent.right; rightMargin: 20; bottomMargin: 20 } + Button { + id: newButton; label: qsTr("Add"); rotation: 3 + anchors.horizontalCenter: parent.horizontalCenter + onClicked: { + mainWindow.editMode = false + photosModel.append( { tag: "" } ) + albumView.positionViewAtIndex(albumView.count - 1, GridView.Contain) + } + } + Button { + id: deleteButton; label: qsTr("Edit"); rotation: -2; + onClicked: mainWindow.editMode = !mainWindow.editMode + anchors.horizontalCenter: parent.horizontalCenter + } + Button { + id: quitButton; label: qsTr("Quit"); rotation: -2; + onClicked: Qt.quit() + anchors.horizontalCenter: parent.horizontalCenter + } + } + + Rectangle { + id: albumsShade; color: mainWindow.color + width: parent.width; height: parent.height; opacity: 0.0 + } + + ListView { anchors.fill: parent; model: albumVisualModel.parts.browser; interactive: false } + + Button { id: backButton; label: qsTr("Back"); rotation: 3; x: parent.width - backButton.width - 6; y: -backButton.height - 8 } + + Rectangle { id: photosShade; color: 'black'; width: parent.width; height: parent.height; opacity: 0; visible: opacity != 0.0 } + + ListView { anchors.fill: parent; model: albumVisualModel.parts.fullscreen; interactive: false } + + Item { id: foreground; anchors.fill: parent } + + ProgressBar { + progress: mainWindow.downloadProgress; width: parent.width; height: 4 + anchors.bottom: parent.bottom; opacity: mainWindow.imageLoading; visible: opacity != 0.0 + } +} diff --git a/examples/qml/photoviewer/photoviewer.qmlproject b/examples/qml/photoviewer/photoviewer.qmlproject new file mode 100644 index 0000000000..600bdb10f4 --- /dev/null +++ b/examples/qml/photoviewer/photoviewer.qmlproject @@ -0,0 +1,20 @@ +import QmlProject 1.1 + +Project { + mainFile: "photoviewer.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + Files { + filter: "*.ts" + directory: "i18n" + } +} diff --git a/examples/qtquick/positioners/content/Button.qml b/examples/qml/positioners/content/Button.qml similarity index 100% rename from examples/qtquick/positioners/content/Button.qml rename to examples/qml/positioners/content/Button.qml diff --git a/examples/qtquick/positioners/content/add.png b/examples/qml/positioners/content/add.png similarity index 100% rename from examples/qtquick/positioners/content/add.png rename to examples/qml/positioners/content/add.png diff --git a/examples/qtquick/positioners/content/del.png b/examples/qml/positioners/content/del.png similarity index 100% rename from examples/qtquick/positioners/content/del.png rename to examples/qml/positioners/content/del.png diff --git a/examples/qtquick/positioners/positioners-attachedproperties.qml b/examples/qml/positioners/positioners-attachedproperties.qml similarity index 100% rename from examples/qtquick/positioners/positioners-attachedproperties.qml rename to examples/qml/positioners/positioners-attachedproperties.qml diff --git a/examples/qml/positioners/positioners.qml b/examples/qml/positioners/positioners.qml new file mode 100644 index 0000000000..d9d16649ff --- /dev/null +++ b/examples/qml/positioners/positioners.qml @@ -0,0 +1,264 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + id: page + width: 420; height: 420 + + Column { + id: layout1 + y: 0 + move: Transition { + NumberAnimation { properties: "y"; easing.type: Easing.OutBounce } + } + add: Transition { + NumberAnimation { properties: "y"; easing.type: Easing.OutQuad } + } + + Rectangle { color: "red"; width: 100; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueV1 + visible: opacity != 0 + width: 100; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "green"; width: 100; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueV2 + visible: opacity != 0 + width: 100; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "orange"; width: 100; height: 50; border.color: "black"; radius: 15 } + } + + Row { + id: layout2 + y: 300 + move: Transition { + NumberAnimation { properties: "x"; easing.type: Easing.OutBounce } + } + add: Transition { + NumberAnimation { properties: "x"; easing.type: Easing.OutQuad } + } + + Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 } + + Rectangle { + id: blueH1 + visible: opacity != 0 + width: 50; height: 100 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "green"; width: 50; height: 100; border.color: "black"; radius: 15 } + + Rectangle { + id: blueH2 + visible: opacity != 0 + width: 50; height: 100 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "orange"; width: 50; height: 100; border.color: "black"; radius: 15 } + } + + Button { + x: 135; y: 90 + text: "Remove" + icon: "del.png" + + onClicked: { + blueH2.opacity = 0 + blueH1.opacity = 0 + blueV1.opacity = 0 + blueV2.opacity = 0 + blueG1.opacity = 0 + blueG2.opacity = 0 + blueG3.opacity = 0 + blueF1.opacity = 0 + blueF2.opacity = 0 + blueF3.opacity = 0 + } + } + + Button { + x: 145; y: 140 + text: "Add" + icon: "add.png" + + onClicked: { + blueH2.opacity = 1 + blueH1.opacity = 1 + blueV1.opacity = 1 + blueV2.opacity = 1 + blueG1.opacity = 1 + blueG2.opacity = 1 + blueG3.opacity = 1 + blueF1.opacity = 1 + blueF2.opacity = 1 + blueF3.opacity = 1 + } + } + + Grid { + x: 260; y: 0 + columns: 3 + + move: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } + } + + add: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } + } + + Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueG1 + visible: opacity != 0 + width: 50; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueG2 + visible: opacity != 0 + width: 50; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueG3 + visible: opacity != 0 + width: 50; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } + Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 } + Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } + } + + Flow { + id: layout4 + x: 260; y: 250; width: 150 + + move: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } + } + + add: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } + } + + Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueF1 + visible: opacity != 0 + width: 60; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "green"; width: 30; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueF2 + visible: opacity != 0 + width: 60; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueF3 + visible: opacity != 0 + width: 40; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "red"; width: 80; height: 50; border.color: "black"; radius: 15 } + } + +} diff --git a/examples/qtquick/righttoleft/layoutdirection/layoutdirection.qml b/examples/qml/righttoleft/layoutdirection/layoutdirection.qml similarity index 100% rename from examples/qtquick/righttoleft/layoutdirection/layoutdirection.qml rename to examples/qml/righttoleft/layoutdirection/layoutdirection.qml diff --git a/examples/qtquick/righttoleft/layoutdirection/layoutdirection.qmlproject b/examples/qml/righttoleft/layoutdirection/layoutdirection.qmlproject similarity index 100% rename from examples/qtquick/righttoleft/layoutdirection/layoutdirection.qmlproject rename to examples/qml/righttoleft/layoutdirection/layoutdirection.qmlproject diff --git a/examples/qtquick/righttoleft/layoutmirroring/layoutmirroring.qml b/examples/qml/righttoleft/layoutmirroring/layoutmirroring.qml similarity index 100% rename from examples/qtquick/righttoleft/layoutmirroring/layoutmirroring.qml rename to examples/qml/righttoleft/layoutmirroring/layoutmirroring.qml diff --git a/examples/qtquick/righttoleft/layoutmirroring/layoutmirroring.qmlproject b/examples/qml/righttoleft/layoutmirroring/layoutmirroring.qmlproject similarity index 100% rename from examples/qtquick/righttoleft/layoutmirroring/layoutmirroring.qmlproject rename to examples/qml/righttoleft/layoutmirroring/layoutmirroring.qmlproject diff --git a/examples/qtquick/righttoleft/textalignment/textalignment.qml b/examples/qml/righttoleft/textalignment/textalignment.qml similarity index 100% rename from examples/qtquick/righttoleft/textalignment/textalignment.qml rename to examples/qml/righttoleft/textalignment/textalignment.qml diff --git a/examples/qtquick/righttoleft/textalignment/textalignment.qmlproject b/examples/qml/righttoleft/textalignment/textalignment.qmlproject similarity index 100% rename from examples/qtquick/righttoleft/textalignment/textalignment.qmlproject rename to examples/qml/righttoleft/textalignment/textalignment.qmlproject diff --git a/examples/qml/rssnews/content/BusyIndicator.qml b/examples/qml/rssnews/content/BusyIndicator.qml new file mode 100644 index 0000000000..f1abd1119c --- /dev/null +++ b/examples/qml/rssnews/content/BusyIndicator.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + id: container + property bool on: false + + source: "images/busy.png"; visible: container.on + + NumberAnimation on rotation { + running: container.on; from: 0; to: 360; loops: Animation.Infinite; duration: 1200 + } +} diff --git a/examples/qml/rssnews/content/CategoryDelegate.qml b/examples/qml/rssnews/content/CategoryDelegate.qml new file mode 100644 index 0000000000..fe64238adb --- /dev/null +++ b/examples/qml/rssnews/content/CategoryDelegate.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: delegate + + width: delegate.ListView.view.width; height: 60 + + Text { + text: name + color: delegate.ListView.isCurrentItem ? "white" : "black" + font { family: "Helvetica"; pixelSize: 16; bold: true } + anchors { + left: parent.left; leftMargin: 15 + verticalCenter: parent.verticalCenter + } + } + + BusyIndicator { + scale: 0.6 + on: delegate.ListView.isCurrentItem && window.loading + anchors { right: parent.right; rightMargin: 10; verticalCenter: parent.verticalCenter } + } + + Rectangle { + width: delegate.width; height: 1; color: "#cccccc" + anchors.bottom: delegate.bottom + visible: delegate.ListView.isCurrentItem ? false : true + } + Rectangle { + width: delegate.width; height: 1; color: "white" + visible: delegate.ListView.isCurrentItem ? false : true + } + + MouseArea { + anchors.fill: delegate + onClicked: { + delegate.ListView.view.currentIndex = index + window.currentFeed = feed + } + } +} diff --git a/examples/qml/rssnews/content/NewsDelegate.qml b/examples/qml/rssnews/content/NewsDelegate.qml new file mode 100644 index 0000000000..59ab269d3b --- /dev/null +++ b/examples/qml/rssnews/content/NewsDelegate.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: delegate + height: column.height + 40 + width: delegate.ListView.view.width + + Column { + id: column + x: 20; y: 20 + width: parent.width - 40 + + Text { + id: titleText + text: title; width: parent.width; wrapMode: Text.WordWrap + font { bold: true; family: "Helvetica"; pointSize: 16 } + } + + Text { + id: descriptionText + width: parent.width; text: description + wrapMode: Text.WordWrap; font.family: "Helvetica" + } + } + + Rectangle { + width: parent.width; height: 1; color: "#cccccc" + anchors.bottom: parent.bottom + } +} diff --git a/examples/qml/rssnews/content/RssFeeds.qml b/examples/qml/rssnews/content/RssFeeds.qml new file mode 100644 index 0000000000..ed58ef3852 --- /dev/null +++ b/examples/qml/rssnews/content/RssFeeds.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListModel { + id: rssFeeds + + ListElement { name: "Top Stories"; feed: "rss.news.yahoo.com/rss/topstories" } + ListElement { name: "World"; feed: "rss.news.yahoo.com/rss/world" } + ListElement { name: "Europe"; feed: "rss.news.yahoo.com/rss/europe" } + ListElement { name: "Oceania"; feed: "rss.news.yahoo.com/rss/oceania" } + ListElement { name: "U.S. National"; feed: "rss.news.yahoo.com/rss/us" } + ListElement { name: "Politics"; feed: "rss.news.yahoo.com/rss/politics" } + ListElement { name: "Business"; feed: "rss.news.yahoo.com/rss/business" } + ListElement { name: "Technology"; feed: "rss.news.yahoo.com/rss/tech" } + ListElement { name: "Entertainment"; feed: "rss.news.yahoo.com/rss/entertainment" } + ListElement { name: "Health"; feed: "rss.news.yahoo.com/rss/health" } + ListElement { name: "Science"; feed: "rss.news.yahoo.com/rss/science" } + ListElement { name: "Sports"; feed: "rss.news.yahoo.com/rss/sports" } +} diff --git a/examples/qml/rssnews/content/ScrollBar.qml b/examples/qml/rssnews/content/ScrollBar.qml new file mode 100644 index 0000000000..7b1a2ac3e5 --- /dev/null +++ b/examples/qml/rssnews/content/ScrollBar.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + property variant scrollArea + property variant orientation: Qt.Vertical + + opacity: 0 + + function position() + { + var ny = 0; + if (container.orientation == Qt.Vertical) + ny = scrollArea.visibleArea.yPosition * container.height; + else + ny = scrollArea.visibleArea.xPosition * container.width; + if (ny > 2) return ny; else return 2; + } + + function size() + { + var nh, ny; + + if (container.orientation == Qt.Vertical) + nh = scrollArea.visibleArea.heightRatio * container.height; + else + nh = scrollArea.visibleArea.widthRatio * container.width; + + if (container.orientation == Qt.Vertical) + ny = scrollArea.visibleArea.yPosition * container.height; + else + ny = scrollArea.visibleArea.xPosition * container.width; + + if (ny > 3) { + var t; + if (container.orientation == Qt.Vertical) + t = Math.ceil(container.height - 3 - ny); + else + t = Math.ceil(container.width - 3 - ny); + if (nh > t) return t; else return nh; + } else return nh + ny; + } + + Rectangle { anchors.fill: parent; color: "Black"; opacity: 0.3 } + + BorderImage { + source: "images/scrollbar.png" + border { left: 1; right: 1; top: 1; bottom: 1 } + x: container.orientation == Qt.Vertical ? 2 : position() + width: container.orientation == Qt.Vertical ? container.width - 4 : size() + y: container.orientation == Qt.Vertical ? position() : 2 + height: container.orientation == Qt.Vertical ? size() : container.height - 4 + } + + states: State { + name: "visible" + when: container.orientation == Qt.Vertical ? scrollArea.movingVertically : scrollArea.movingHorizontally + PropertyChanges { target: container; opacity: 1.0 } + } + + transitions: Transition { + from: "visible"; to: "" + NumberAnimation { properties: "opacity"; duration: 600 } + } +} diff --git a/examples/qml/rssnews/content/images/busy.png b/examples/qml/rssnews/content/images/busy.png new file mode 100644 index 0000000000..664c2b1491 Binary files /dev/null and b/examples/qml/rssnews/content/images/busy.png differ diff --git a/examples/qml/rssnews/content/images/scrollbar.png b/examples/qml/rssnews/content/images/scrollbar.png new file mode 100644 index 0000000000..0228dcf9eb Binary files /dev/null and b/examples/qml/rssnews/content/images/scrollbar.png differ diff --git a/examples/qml/rssnews/rssnews.qml b/examples/qml/rssnews/rssnews.qml new file mode 100644 index 0000000000..d26b94b6d3 --- /dev/null +++ b/examples/qml/rssnews/rssnews.qml @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 +import "content" + +Rectangle { + id: window + width: 800; height: 480 + + property string currentFeed: "rss.news.yahoo.com/rss/topstories" + property bool loading: feedModel.status == XmlListModel.Loading + + RssFeeds { id: rssFeeds } + + XmlListModel { + id: feedModel + source: "http://" + window.currentFeed + query: "/rss/channel/item" + + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "link"; query: "link/string()" } + XmlRole { name: "description"; query: "description/string()" } + } + + Row { + Rectangle { + width: 220; height: window.height + color: "#efefef" + + ListView { + focus: true + id: categories + anchors.fill: parent + model: rssFeeds + footer: quitButtonDelegate + delegate: CategoryDelegate {} + highlight: Rectangle { color: "steelblue" } + highlightMoveSpeed: 9999999 + } + ScrollBar { + scrollArea: categories; height: categories.height; width: 8 + anchors.right: categories.right + } + } + ListView { + id: list + width: window.width - 220; height: window.height + model: feedModel + delegate: NewsDelegate {} + } + } + Component { + id: quitButtonDelegate + Item { + width: categories.width; height: 60 + Text { + text: "Quit" + font { family: "Helvetica"; pixelSize: 16; bold: true } + anchors { + left: parent.left; leftMargin: 15 + verticalCenter: parent.verticalCenter + } + } + MouseArea { + anchors.fill: parent + onClicked: Qt.quit() + } + } + } + ScrollBar { scrollArea: list; height: list.height; width: 8; anchors.right: window.right } + Rectangle { x: 220; height: window.height; width: 1; color: "#cccccc" } +} diff --git a/examples/qml/rssnews/rssnews.qmlproject b/examples/qml/rssnews/rssnews.qmlproject new file mode 100644 index 0000000000..5becbdaed0 --- /dev/null +++ b/examples/qml/rssnews/rssnews.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "rssnews.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/samegame/content/BoomBlock.qml b/examples/qml/samegame/content/BoomBlock.qml new file mode 100644 index 0000000000..a348368ae1 --- /dev/null +++ b/examples/qml/samegame/content/BoomBlock.qml @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: block + property bool dying: false + property bool spawned: false + property int type: 0 + property ParticleSystem particleSystem + + Behavior on x { + enabled: spawned; + SpringAnimation{ spring: 2; damping: 0.2 } + } + Behavior on y { + SpringAnimation{ spring: 2; damping: 0.2 } + } + + Image { + id: img + source: { + if(type == 0){ + "pics/redStone.png"; + } else if(type == 1) { + "pics/blueStone.png"; + } else { + "pics/greenStone.png"; + } + } + opacity: 0 + Behavior on opacity { NumberAnimation { duration: 200 } } + anchors.fill: parent + } + Emitter { + id: particles + system: particleSystem + group: { + if(type == 0){ + "red"; + } else if (type == 1) { + "blue"; + } else { + "green"; + } + } + anchors.fill: parent + + speed: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -60; magnitudeVariation: 60} + shape: EllipseShape{fill:true} + enabled: false; + lifeSpan: 700; lifeSpanVariation: 100 + emitRate: 1000 + maximumEmitted: 100 //only fires 0.1s bursts (still 2x old number) + size: 28 + endSize: 14 + } + + states: [ + State { + name: "AliveState"; when: spawned == true && dying == false + PropertyChanges { target: img; opacity: 1 } + }, + + State { + name: "DeathState"; when: dying == true + StateChangeScript { script: {particleSystem.paused = false; particles.pulse(100);} } + PropertyChanges { target: img; opacity: 0 } + StateChangeScript { script: block.destroy(1000); } + } + ] +} diff --git a/examples/qml/samegame/content/Button.qml b/examples/qml/samegame/content/Button.qml new file mode 100644 index 0000000000..2d1a993226 --- /dev/null +++ b/examples/qml/samegame/content/Button.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property string text: "Button" + + signal clicked + + width: buttonLabel.width + 20; height: buttonLabel.height + 20 + smooth: true + border { width: 1; color: Qt.darker(activePalette.button) } + radius: 8 + color: activePalette.button + + gradient: Gradient { + GradientStop { + position: 0.0 + color: { + if (mouseArea.pressed) + return activePalette.dark + else + return activePalette.light + } + } + GradientStop { position: 1.0; color: activePalette.button } + } + + MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() } + + Text { + id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText; font.pixelSize: 24 + } +} diff --git a/examples/qml/samegame/content/Dialog.qml b/examples/qml/samegame/content/Dialog.qml new file mode 100644 index 0000000000..c81580e6a5 --- /dev/null +++ b/examples/qml/samegame/content/Dialog.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: page + anchors.centerIn: parent + + property Item text: dialogText + property bool open: false + + signal closed + signal opened + function forceClose() { + if(!open) + return; //already closed + page.open = false; + page.closed(); + page.opacity = 0; + } + + function show(txt) { + page.open = true; + page.opened(); + dialogText.text = txt; + page.opacity = 1; + } + + width: dialogText.width + 20; height: dialogText.height + 20 + color: "white" + border.width: 1 + opacity: 0 + visible: opacity > 0 + Behavior on opacity { + NumberAnimation { duration: 1000 } + } + + Text { id: dialogText; anchors.centerIn: parent; text: "Hello World!" } + + MouseArea { anchors.fill: parent; onClicked: forceClose(); } +} + diff --git a/examples/qml/samegame/content/GameArea.qml b/examples/qml/samegame/content/GameArea.qml new file mode 100644 index 0000000000..3422582b21 --- /dev/null +++ b/examples/qml/samegame/content/GameArea.qml @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "samegame.js" as Logic + +Item { + id: gameCanvas + property int score: 0 + property int blockSize: 40 + property ParticleSystem ps: particleSystem + Image { + id: background + anchors.fill: parent + z: -1 + source: "pics/background.png" + fillMode: Image.PreserveAspectCrop + } + + width: 480 + height: 800 + MouseArea { + anchors.fill: parent; onClicked: Logic.handleClick(mouse.x,mouse.y); + } + ParticleSystem{ + id: particleSystem; + onEmptyChanged: if (empty) paused = true; + z:2 + ImageParticle { + groups: ["red"] + color: Qt.darker("red");//Actually want desaturated... + source: "pics/particle.png" + colorVariation: 0.4 + alpha: 0.1 + } + ImageParticle { + groups: ["green"] + color: Qt.darker("green");//Actually want desaturated... + source: "pics/particle.png" + colorVariation: 0.4 + alpha: 0.1 + } + ImageParticle { + groups: ["blue"] + color: Qt.darker("blue");//Actually want desaturated... + source: "pics/particle.png" + colorVariation: 0.4 + alpha: 0.1 + } + anchors.fill: parent + } +} + diff --git a/examples/qml/samegame/content/NameInputDialog.qml b/examples/qml/samegame/content/NameInputDialog.qml new file mode 100644 index 0000000000..7c3bfa274a --- /dev/null +++ b/examples/qml/samegame/content/NameInputDialog.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Dialog { + id: nameInputDialog + + property int initialWidth: 0 + property alias name: nameInputText.text + + anchors.centerIn: parent + z: 22; + + Behavior on width { + NumberAnimation {} + enabled: nameInputDialog.initialWidth != 0 + } + + signal accepted(string name) + onClosed: { + if (nameInputText.text != "") + accepted(name); + } + Text { + id: dialogText + anchors { left: nameInputDialog.left; leftMargin: 20; verticalCenter: parent.verticalCenter } + text: "You won! Please enter your name: " + } + MouseArea { + anchors.fill: parent + onClicked: { + if (nameInputText.text == "") + nameInputText.openSoftwareInputPanel(); + else + nameInputDialog.forceClose(); + } + } + + TextInput { + id: nameInputText + anchors { verticalCenter: parent.verticalCenter; left: dialogText.right } + focus: visible + autoScroll: false + maximumLength: 24 + onTextChanged: { + var newWidth = nameInputText.width + dialogText.width + 40; + if ( (newWidth > nameInputDialog.width && newWidth < screen.width) + || (nameInputDialog.width > nameInputDialog.initialWidth) ) + nameInputDialog.width = newWidth; + } + onAccepted: { + nameInputDialog.forceClose(); + } + } +} diff --git a/examples/qml/samegame/content/pics/background.png b/examples/qml/samegame/content/pics/background.png new file mode 100644 index 0000000000..3734a27744 Binary files /dev/null and b/examples/qml/samegame/content/pics/background.png differ diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/blueStone.png b/examples/qml/samegame/content/pics/blueStone.png similarity index 100% rename from tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/blueStone.png rename to examples/qml/samegame/content/pics/blueStone.png diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/greenStone.png b/examples/qml/samegame/content/pics/greenStone.png similarity index 100% rename from tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/greenStone.png rename to examples/qml/samegame/content/pics/greenStone.png diff --git a/examples/qml/samegame/content/pics/particle.png b/examples/qml/samegame/content/pics/particle.png new file mode 100644 index 0000000000..5c83896d22 Binary files /dev/null and b/examples/qml/samegame/content/pics/particle.png differ diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/redStone.png b/examples/qml/samegame/content/pics/redStone.png similarity index 100% rename from tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/redStone.png rename to examples/qml/samegame/content/pics/redStone.png diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/yellowStone.png b/examples/qml/samegame/content/pics/yellowStone.png similarity index 100% rename from tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/yellowStone.png rename to examples/qml/samegame/content/pics/yellowStone.png diff --git a/examples/qml/samegame/content/samegame.js b/examples/qml/samegame/content/samegame.js new file mode 100755 index 0000000000..611767584b --- /dev/null +++ b/examples/qml/samegame/content/samegame.js @@ -0,0 +1,290 @@ +/* This script file handles the game logic */ +.pragma library +.import QtQuick.LocalStorage 2.0 as Sql + +var maxColumn = 10; +var maxRow = 15; +var maxIndex = maxColumn*maxRow; +var board = new Array(maxIndex); +var blockSrc = "BoomBlock.qml"; +var scoresURL = ""; +var gameDuration; +var component = Qt.createComponent(blockSrc); +var highScoreBar = -1; +var gameCanvas; +var nameInputDialog = null; +var dialog = null; + +// Index function used instead of a 2D array +function index(column, row) +{ + return column + row * maxColumn; +} + +function timeStr(msecs) +{ + var secs = Math.floor(msecs/1000); + var m = Math.floor(secs/60); + var ret = "" + m + "m " + (secs%60) + "s"; + return ret; +} + +function startNewGame(gc) +{ + gameCanvas = gc; + // Delete blocks from previous game + for (var i = 0; i < maxIndex; i++) { + if (board[i] != null) + board[i].destroy(); + } + + // Calculate board size + maxColumn = Math.floor(gameCanvas.width/gameCanvas.blockSize); + maxRow = Math.floor(gameCanvas.height/gameCanvas.blockSize); + maxIndex = maxRow * maxColumn; + + // Close dialogs + if(nameInputDialog != null) + nameInputDialog.forceClose(); + if(dialog != null) + dialog.forceClose(); + + // Initialize Board + board = new Array(maxIndex); + gameCanvas.score = 0; + for (var column = 0; column < maxColumn; column++) { + for (var row = 0; row < maxRow; row++) { + board[index(column, row)] = null; + createBlock(column, row); + } + } + gameDuration = new Date(); +} + +var fillFound; // Set after a floodFill call to the number of blocks found +var floodBoard; // Set to 1 if the floodFill reaches off that node + +// NOTE: Be careful with vars named x,y, as the calling object's x,y are still in scope +function handleClick(x,y) +{ + if(gameCanvas == undefined){ + console.log("But the game hasn't started yet!"); + return; + } + var column = Math.floor(x/gameCanvas.blockSize); + var row = Math.floor(y/gameCanvas.blockSize); + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return; + if (board[index(column, row)] == null) + return; + // If it's a valid block, remove it and all connected (does nothing if it's not connected) + floodFill(column,row, -1); + if (fillFound <= 0) + return; + gameCanvas.score += (fillFound - 1) * (fillFound - 1); + shuffleDown(); + victoryCheck(); +} + +function floodFill(column,row,type) +{ + if (board[index(column, row)] == null) + return; + var first = false; + if (type == -1) { + first = true; + type = board[index(column,row)].type; + + // Flood fill initialization + fillFound = 0; + floodBoard = new Array(maxIndex); + } + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return; + if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type)) + return; + floodBoard[index(column, row)] = 1; + floodFill(column + 1, row, type); + floodFill(column - 1, row, type); + floodFill(column, row + 1, type); + floodFill(column, row - 1, type); + if (first == true && fillFound == 0) + return; // Can't remove single blocks + board[index(column, row)].dying = true; + board[index(column, row)] = null; + fillFound += 1; +} + +function shuffleDown() +{ + // Fall down + for (var column = 0; column < maxColumn; column++) { + var fallDist = 0; + for (var row = maxRow - 1; row >= 0; row--) { + if (board[index(column,row)] == null) { + fallDist += 1; + } else { + if (fallDist > 0) { + var obj = board[index(column, row)]; + obj.y = (row + fallDist) * gameCanvas.blockSize; + board[index(column, row + fallDist)] = obj; + board[index(column, row)] = null; + } + } + } + } + // Fall to the left + fallDist = 0; + for (column = 0; column < maxColumn; column++) { + if (board[index(column, maxRow - 1)] == null) { + fallDist += 1; + } else { + if (fallDist > 0) { + for (row = 0; row < maxRow; row++) { + obj = board[index(column, row)]; + if (obj == null) + continue; + obj.x = (column - fallDist) * gameCanvas.blockSize; + board[index(column - fallDist,row)] = obj; + board[index(column, row)] = null; + } + } + } + } +} + +function victoryCheck() +{ + // Awards bonuses for no blocks left + var deservesBonus = true; + for (var column = maxColumn - 1; column >= 0; column--) + if (board[index(column, maxRow - 1)] != null) + deservesBonus = false; + if (deservesBonus) + gameCanvas.score += 500; + // Checks for game over + if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) { + gameDuration = new Date() - gameDuration; + if(nameInputDialog == null){ + nameInputDialog = Qt.createQmlObject('import "."; import "samegame.js" as Logic; NameInputDialog{onAccepted: Logic.saveHighScore(name)}', gameCanvas, "highscoredialog.qml"); + } + if(dialog == null){ + dialog = Qt.createComponent("Dialog.qml").createObject(gameCanvas); + } + initHighScoreBar(); + if(gameCanvas.score > highScoreBar){ + nameInputDialog.show("You won! Please enter your name: "); + nameInputDialog.initialWidth = nameInputDialog.text.width + 20; + if (nameInputDialog.name == "") + nameInputDialog.width = nameInputDialog.initialWidth; + nameInputDialog.text.opacity = 0; // Just a spacer + }else{ + dialog.show("You won!"); + } + } +} + +// Only floods up and right, to see if it can find adjacent same-typed blocks +function floodMoveCheck(column, row, type) +{ + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return false; + if (board[index(column, row)] == null) + return false; + var myType = board[index(column, row)].type; + if (type == myType) + return true; + return floodMoveCheck(column + 1, row, myType) || + floodMoveCheck(column, row - 1, board[index(column, row)].type); +} + +function createBlock(column,row) +{ + // Note that we don't wait for the component to become ready. This will + // only work if the block QML is a local file. Otherwise the component will + // not be ready immediately. There is a statusChanged signal on the + // component you could use if you want to wait to load remote files. + if(component.status == 1){ + var dynamicObject = component.createObject(gameCanvas, + {"type": Math.floor(Math.random() * 3), + "x": column*gameCanvas.blockSize, + "width": gameCanvas.blockSize, + "height": gameCanvas.blockSize, + "particleSystem": gameCanvas.ps}); + if(dynamicObject == null){ + console.log("error creating block"); + console.log(component.errorString()); + return false; + } + dynamicObject.y = row*gameCanvas.blockSize; + dynamicObject.spawned = true; + + board[index(column,row)] = dynamicObject; + }else{ + console.log("error loading block component"); + console.log(component.errorString()); + return false; + } + return true; +} + +function initHighScoreBar() +{ + var db = Sql.openDatabaseSync( + "SameGameScores", + "1.0", + "Local SameGame High Scores", + 100 + ); + db.transaction( + function(tx) { + tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)'); + // Only show results for the current grid size + var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "' + + maxColumn + "x" + maxRow + '" ORDER BY score desc LIMIT 10'); + if(rs.rows.length < 10) + highScoreBar = 0; + else + highScoreBar = rs.rows.item(rs.rows.length - 1).score; + } + ); +} + +function saveHighScore(name) +{ + if (scoresURL != "") + sendHighScore(name); + // Offline storage + var db = Sql.openDatabaseSync( + "SameGameScores", + "1.0", + "Local SameGame High Scores", + 100 + ); + var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)"; + var data = [ + name, + gameCanvas.score, + maxColumn + "x" + maxRow, + Math.floor(gameDuration / 1000) + ]; + db.transaction( + function(tx) { + tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)'); + tx.executeSql(dataStr, data); + + // Only show results for the current grid size + var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "' + + maxColumn + "x" + maxRow + '" ORDER BY score desc LIMIT 10'); + var r = "\nHIGH SCORES for this grid size\n\n" + for (var i = 0; i < rs.rows.length; i++) { + r += (i+1) + ". " + rs.rows.item(i).name + ' got ' + + rs.rows.item(i).score + ' points in ' + + rs.rows.item(i).time + ' seconds.\n'; + } + if(rs.rows.length == 10) + highScoreBar = rs.rows.item(9).score; + dialog.show(r); + } + ); +} diff --git a/examples/qml/samegame/samegame.qml b/examples/qml/samegame/samegame.qml new file mode 100644 index 0000000000..b98b6a0074 --- /dev/null +++ b/examples/qml/samegame/samegame.qml @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "content" +import "content/samegame.js" as Logic + +Rectangle { + id: screen + width: 480; height: 640 + + SystemPalette { id: activePalette } + + GameArea { + id: gameCanvas + width: parent.width + anchors { top: parent.top; bottom: toolBar.top } + } + + Rectangle { + id: toolBar + width: parent.width; height: 80 + color: activePalette.window + anchors.bottom: screen.bottom + + Button { + id: newGameButton + anchors { left: parent.left; leftMargin: 12; verticalCenter: parent.verticalCenter } + text: "New Game" + onClicked: Logic.startNewGame(gameCanvas) + } + + Button { + text: "Quit" + anchors { left: newGameButton.right; leftMargin: 12; verticalCenter: parent.verticalCenter } + onClicked: Qt.quit(); + } + + Text { + id: score + anchors { right: parent.right; rightMargin: 12; verticalCenter: parent.verticalCenter } + text: "Score: " + gameCanvas.score + font.bold: true + font.pixelSize: 24 + color: activePalette.windowText + } + } +} diff --git a/examples/qml/samegame/samegame.qmlproject b/examples/qml/samegame/samegame.qmlproject new file mode 100644 index 0000000000..42ffacf4f8 --- /dev/null +++ b/examples/qml/samegame/samegame.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "samegame.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/script/shell/main.cpp b/examples/qml/script/shell/main.cpp index 9f0edf4a25..a4059122bf 100644 --- a/examples/qml/script/shell/main.cpp +++ b/examples/qml/script/shell/main.cpp @@ -46,7 +46,7 @@ #include -#include +#include #include diff --git a/examples/qml/script/shell/shell.pro b/examples/qml/script/shell/shell.pro index 00191ab3d0..5f6b23862b 100644 --- a/examples/qml/script/shell/shell.pro +++ b/examples/qml/script/shell/shell.pro @@ -1,4 +1,4 @@ -QT += declarative +QT += qml win32: CONFIG += console mac:CONFIG -= app_bundle diff --git a/examples/qtquick/shadereffects/content/Slider.qml b/examples/qml/shadereffects/content/Slider.qml similarity index 100% rename from examples/qtquick/shadereffects/content/Slider.qml rename to examples/qml/shadereffects/content/Slider.qml diff --git a/examples/qml/shadereffects/content/face-smile.png b/examples/qml/shadereffects/content/face-smile.png new file mode 100644 index 0000000000..3d66d72578 Binary files /dev/null and b/examples/qml/shadereffects/content/face-smile.png differ diff --git a/examples/qtquick/shadereffects/content/qt-logo.png b/examples/qml/shadereffects/content/qt-logo.png similarity index 100% rename from examples/qtquick/shadereffects/content/qt-logo.png rename to examples/qml/shadereffects/content/qt-logo.png diff --git a/examples/qml/shadereffects/shadereffects.qml b/examples/qml/shadereffects/shadereffects.qml new file mode 100644 index 0000000000..842e42b89f --- /dev/null +++ b/examples/qml/shadereffects/shadereffects.qml @@ -0,0 +1,300 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Declarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Image { + width: 640 + height: 360 + source: "../snake/content/pics/background.png" + + ShaderEffectSource { + id: theSource + sourceItem: theItem + smooth: true + } + + function saturate(x) { + return Math.min(Math.max(x, 0), 1) + } + + function sliderToColor(x) { + return Qt.rgba(saturate(Math.max(2 - 6 * x, 6 * x - 4)), + saturate(Math.min(6 * x, 4 - 6 * x)), + saturate(Math.min(6 * x - 2, 6 - 6 * x))) + } + + Grid { + anchors.centerIn: parent + columns: 3 + + Item { + id: theItem + width: 180 + height: 180 + ListView { + anchors.centerIn: parent + width: 160 + height: 140 + clip: true + snapMode: ListView.SnapOneItem + model: VisualItemModel { + Text { + width: 160 + height: 140 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + font.pixelSize: 120 + font.family: "Times" + color: "blue" + text: "Qt" + } + Image { + width: 160 + height: 140 + source: "content/qt-logo.png" + smooth: true + } + Image { + width: 160 + height: 140 + source: "content/face-smile.png" + smooth: true + } + } + } + } + ShaderEffect { + width: 180 + height: 180 + property variant source: theSource + property real amplitude: 0.04 * wobbleSlider.value + property real frequency: 20 + property real time: 0 + NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 } + fragmentShader: + "uniform lowp float qt_Opacity;" + + "uniform highp float amplitude;" + + "uniform highp float frequency;" + + "uniform highp float time;" + + "uniform sampler2D source;" + + "varying highp vec2 qt_TexCoord0;" + + "void main() {" + + " highp vec2 p = sin(time + frequency * qt_TexCoord0);" + + " gl_FragColor = texture2D(source, qt_TexCoord0 + amplitude * vec2(p.y, -p.x)) * qt_Opacity;" + + "}" + Slider { + id: wobbleSlider + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + height: 40 + } + } + ShaderEffect { + width: 180 + height: 180 + property variant source: theSource + property variant shadow: ShaderEffectSource { + smooth: true + sourceItem: ShaderEffect { + width: theItem.width + height: theItem.height + property variant delta: Qt.size(0.0, 1.0 / height) + property variant source: ShaderEffectSource { + smooth: true + sourceItem: ShaderEffect { + width: theItem.width + height: theItem.height + property variant delta: Qt.size(1.0 / width, 0.0) + property variant source: theSource + fragmentShader: " + uniform lowp float qt_Opacity; + uniform sampler2D source; + uniform highp vec2 delta; + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta) + + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta) + + 0.2466 * texture2D(source, qt_TexCoord0) + + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta) + + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity; + }" + } + } + fragmentShader: " + uniform lowp float qt_Opacity; + uniform sampler2D source; + uniform highp vec2 delta; + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta) + + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta) + + 0.2466 * texture2D(source, qt_TexCoord0) + + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta) + + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity; + }" + } + } + property real angle: 0 + property variant offset: Qt.point(15.0 * Math.cos(angle), 15.0 * Math.sin(angle)) + NumberAnimation on angle { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 6000 } + property variant delta: Qt.size(offset.x / width, offset.y / height) + property real darkness: shadowSlider.value + fragmentShader: " + uniform lowp float qt_Opacity; + uniform highp vec2 offset; + uniform sampler2D source; + uniform sampler2D shadow; + uniform highp float darkness; + uniform highp vec2 delta; + varying highp vec2 qt_TexCoord0; + void main() { + lowp vec4 fg = texture2D(source, qt_TexCoord0); + lowp vec4 bg = texture2D(shadow, qt_TexCoord0 + delta); + gl_FragColor = (fg + vec4(0., 0., 0., darkness * bg.a) * (1. - fg.a)) * qt_Opacity; + }" + Slider { + id: shadowSlider + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + height: 40 + } + } + ShaderEffect { + width: 180 + height: 180 + property variant source: theSource + property variant delta: Qt.size(0.5 / width, 0.5 / height) + fragmentShader: " + uniform sampler2D source; + uniform highp vec2 delta; + uniform highp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + void main() { + lowp vec4 tl = texture2D(source, qt_TexCoord0 - delta); + lowp vec4 tr = texture2D(source, qt_TexCoord0 + vec2(delta.x, -delta.y)); + lowp vec4 bl = texture2D(source, qt_TexCoord0 - vec2(delta.x, -delta.y)); + lowp vec4 br = texture2D(source, qt_TexCoord0 + delta); + lowp vec4 gx = (tl + bl) - (tr + br); + lowp vec4 gy = (tl + tr) - (bl + br); + gl_FragColor.xyz = vec3(0.); + gl_FragColor.w = clamp(dot(sqrt(gx * gx + gy * gy), vec4(1.)), 0., 1.) * qt_Opacity; + }" + } + ShaderEffect { + width: 180 + height: 180 + property variant source: theSource + property color tint: sliderToColor(colorizeSlider.value) + fragmentShader: " + uniform sampler2D source; + uniform lowp vec4 tint; + uniform lowp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + void main() { + lowp vec4 c = texture2D(source, qt_TexCoord0); + lowp float lo = min(min(c.x, c.y), c.z); + lowp float hi = max(max(c.x, c.y), c.z); + gl_FragColor = qt_Opacity * vec4(mix(vec3(lo), vec3(hi), tint.xyz), c.w); + }" + Slider { + id: colorizeSlider + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + height: 40 + } + } + ShaderEffect { + width: 180 + height: 180 + mesh: Qt.size(10, 10) + property variant source: theSource + property real bend: 0 + property real minimize: 0 + property real side: genieSlider.value + SequentialAnimation on bend { + loops: Animation.Infinite + NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine } + PauseAnimation { duration: 1600 } + NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine } + PauseAnimation { duration: 1000 } + } + SequentialAnimation on minimize { + loops: Animation.Infinite + PauseAnimation { duration: 300 } + NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine } + PauseAnimation { duration: 1000 } + NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine } + PauseAnimation { duration: 1300 } + } + vertexShader: " + uniform highp mat4 qt_Matrix; + uniform highp float bend; + uniform highp float minimize; + uniform highp float side; + uniform highp float width; + uniform highp float height; + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + varying highp vec2 qt_TexCoord0; + void main() { + qt_TexCoord0 = qt_MultiTexCoord0; + highp vec4 pos = qt_Vertex; + pos.y = mix(qt_Vertex.y, height, minimize); + highp float t = pos.y / height; + t = (3. - 2. * t) * t * t; + pos.x = mix(qt_Vertex.x, side * width, t * bend); + gl_Position = qt_Matrix * pos; + }" + Slider { + id: genieSlider + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + height: 40 + } + } + } +} diff --git a/examples/qml/shared/Button.qml b/examples/qml/shared/Button.qml new file mode 100644 index 0000000000..a899a1410b --- /dev/null +++ b/examples/qml/shared/Button.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + property string text: "Button" + property string subText: "Just a button" + signal clicked + + width: buttonLabel.width + 20; height: col.height + 12 + + MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() } + + Column { + spacing: 2 + id: col + Text { + id: buttonLabel; text: container.text; color: "black"; font.pixelSize: 24 + } + Text { + id: buttonLabel2; text: container.subText; color: "black"; font.pixelSize: 12 + } + } +} diff --git a/examples/qml/shared/LauncherList.qml b/examples/qml/shared/LauncherList.qml new file mode 100644 index 0000000000..782fcc7ddd --- /dev/null +++ b/examples/qml/shared/LauncherList.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +ListView { + //model is a list of {"name":"somename", "url":"file:///some/url/mainfile.qml"} + //function used to add to model A) to enforce scheme B) to allow Qt.resolveUrl in url assignments + function addExample(name, desc, url) + { + myModel.append({"name":name, "description":desc, "url":url}) + } + function hideExample() + { + ei.visible = false; + } + + clip: true + delegate: SimpleLauncherDelegate{exampleItem: ei} + model: ListModel {id:myModel} + Item { + id: ei + visible: false + clip: true + property url exampleUrl + onExampleUrlChanged: visible = (exampleUrl == '' ? false : true);//Setting exampleUrl automatically shows example + anchors.fill: parent + anchors.bottomMargin: 40 + Rectangle { + id: bg + anchors.fill: parent + color: "white" + } + MouseArea{ + anchors.fill: parent + enabled: ei.visible + //Eats mouse events + } + Loader{ + source: ei.exampleUrl + anchors.fill: parent + } + } + Rectangle { + id: bar + visible: ei.visible + anchors.bottom: parent.bottom + width: parent.width + height: 40 + MouseArea{ + anchors.fill: parent + enabled: ei.visible + //Eats mouse events + } + Image { + source: "back.png" + anchors.verticalCenter: parent.verticalCenter + x: 4 + MouseArea { + anchors.fill: parent + onClicked: ei.exampleUrl = ""; + } + } + } +} diff --git a/examples/qml/shared/README b/examples/qml/shared/README new file mode 100644 index 0000000000..bf16f238c7 --- /dev/null +++ b/examples/qml/shared/README @@ -0,0 +1,11 @@ +These files are shared between multiple examples as a set of common and +reusuable components. While they do demonstrate the building of reusable +components in QML, they are not official examples themselves. +Consequently they do not have entries in the Qt documentation, and are +documented only through the code comments within the files. Developers +new to QML are strongly encouraged to go through the official examples +before delving into this directory. + +For most application use, see the Qt Quick Components project to find +ready-made Components you can use in your own projects. Qt Declarative +examples do not use them only to avoid external dependencies. diff --git a/examples/qml/shared/SimpleLauncherDelegate.qml b/examples/qml/shared/SimpleLauncherDelegate.qml new file mode 100644 index 0000000000..c3708fe259 --- /dev/null +++ b/examples/qml/shared/SimpleLauncherDelegate.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Item { + id: container + property Item exampleItem + width: ListView.view.width + height: 64 + Button { + anchors.fill: parent + text: name + subText: description + onClicked: exampleItem.exampleUrl = url; + } +} diff --git a/examples/qml/shared/back.png b/examples/qml/shared/back.png new file mode 100644 index 0000000000..506ac42fcf Binary files /dev/null and b/examples/qml/shared/back.png differ diff --git a/examples/qml/snake/content/Button.qml b/examples/qml/snake/content/Button.qml new file mode 100644 index 0000000000..4f294556b3 --- /dev/null +++ b/examples/qml/snake/content/Button.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + signal clicked + property string text: "Button" + + color: activePalette.button; smooth: true + width: txtItem.width + 20; height: txtItem.height + 6 + border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8; + + gradient: Gradient { + GradientStop { + id: topGrad; position: 0.0 + color: if (mr.pressed) { activePalette.dark } else { activePalette.light } } + GradientStop { position: 1.0; color: activePalette.button } + } + + MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() } + + Text { + id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText + } +} diff --git a/examples/qml/snake/content/Cookie.qml b/examples/qml/snake/content/Cookie.qml new file mode 100644 index 0000000000..35ffe400b8 --- /dev/null +++ b/examples/qml/snake/content/Cookie.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: root + property bool dying: false + property int row; + property int column; + x: margin + column * gridSize + y: margin + row * gridSize + + width: gridSize + height: gridSize + property int value : 1; + + Image { + id: img + anchors.fill: parent + source: "pics/cookie.png" + opacity: 0 + Text { + font.bold: true + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + text: value + } + } + + + ParticleSystem { + width:1; height:1; anchors.centerIn: parent; + ImageParticle { + groups: ["star"] + source: "pics/yellowStar.png" + } + Emitter { + id: particles + anchors.fill: parent + group: "star" + emitRate: 50 + enabled: false + lifeSpan: 700 + acceleration: AngleDirection { angleVariation: 360; magnitude: 200 } + } + } + + states: [ + State{ name: "AliveState"; when: dying == false + PropertyChanges { target: img; opacity: 1 } + }, + State{ name: "DeathState"; when: dying == true + StateChangeScript { script: particles.burst(50); } + PropertyChanges { target: img; opacity: 0 } + } + ] + transitions: [ + Transition { + NumberAnimation { target: img; property: "opacity"; duration: 100 } + } + ] +} diff --git a/examples/qml/snake/content/HighScoreModel.qml b/examples/qml/snake/content/HighScoreModel.qml new file mode 100644 index 0000000000..734a661f5b --- /dev/null +++ b/examples/qml/snake/content/HighScoreModel.qml @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.LocalStorage 2.0 as Sql + +// Models a high score table. +// +// Use this component like this: +// +// HighScoreModel { +// id: highScores +// game: "MyCoolGame" +// } +// +// Then use either use the top-score properties: +// +// Text { text: "HI: " + highScores.topScore } +// +// or, use the model in a view: +// +// ListView { +// model: highScore +// delegate: Component { +// ... player ... score ... +// } +// } +// +// Add new scores via: +// +// saveScore(newScore) +// +// or: +// +// savePlayerScore(playerName,newScore) +// +// The best maxScore scores added by this method will be retained in an SQL database, +// and presented in the model and in the topScore/topPlayer properties. +// + +ListModel { + id: model + property string game: "" + property int topScore: 0 + property string topPlayer: "" + property int maxScores: 10 + + function __db() + { + return Sql.openDatabaseSync("HighScoreModel", "1.0", "Generic High Score Functionality for QML", 1000000); + } + function __ensureTables(tx) + { + tx.executeSql('CREATE TABLE IF NOT EXISTS HighScores(game TEXT, score INT, player TEXT)', []); + } + + function fillModel() { + __db().transaction( + function(tx) { + __ensureTables(tx); + var rs = tx.executeSql("SELECT score,player FROM HighScores WHERE game=? ORDER BY score DESC", [game]); + model.clear(); + if (rs.rows.length > 0) { + topScore = rs.rows.item(0).score + topPlayer = rs.rows.item(0).player + for (var i=0; i maxScores) + tx.executeSql("DELETE FROM HighScores WHERE game=? AND score <= ?", + [game, rs.rows.item(maxScores).score]); + } + } + ) + } + + function savePlayerScore(player,score) { + __db().transaction( + function(tx) { + __ensureTables(tx); + tx.executeSql("INSERT INTO HighScores VALUES(?,?,?)", [game,score,player]); + fillModel(); + } + ) + } + + function saveScore(score) { + savePlayerScore("player",score); + } + + function clearScores() { + __db().transaction( + function(tx) { + tx.executeSql("DELETE FROM HighScores WHERE game=?", [game]); + fillModel(); + } + ) + } + + Component.onCompleted: { fillModel() } +} diff --git a/examples/qml/snake/content/Link.qml b/examples/qml/snake/content/Link.qml new file mode 100644 index 0000000000..aab005afd5 --- /dev/null +++ b/examples/qml/snake/content/Link.qml @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { id:link + property bool dying: false + property bool spawned: false + property int type: 0 + property int row: 0 + property int column: 0 + property int rotation; + + width: 40; + height: 40 + + x: margin - 3 + gridSize * column + y: margin - 3 + gridSize * row + Behavior on x { NumberAnimation { duration: spawned ? heartbeatInterval : 0} } + Behavior on y { NumberAnimation { duration: spawned ? heartbeatInterval : 0 } } + + + Item { + id: img + anchors.fill: parent + Image { + source: { + if(type == 1) { + "pics/blueStone.png"; + } else if (type == 2) { + "pics/head.png"; + } else { + "pics/redStone.png"; + } + } + + transform: Rotation { + id: actualImageRotation + origin.x: width/2; origin.y: height/2; + angle: rotation * 90 + Behavior on angle { + RotationAnimation{ + direction: RotationAnimation.Shortest + duration: spawned ? 200 : 0 + } + } + } + } + + Image { + source: "pics/stoneShadow.png" + } + + opacity: 0 + } + + ParticleSystem { + width:1; height:1; anchors.centerIn: parent; + ImageParticle { + groups: ["star"] + source: type == 1 ? "pics/blueStar.png" : "pics/redStar.png" + } + Emitter { + id: particles + anchors.fill: parent + group: "star" + emitRate: 50 + enabled: false + lifeSpan: 700 + acceleration: AngleDirection { angleVariation: 360; magnitude: 200 } + } + } + + states: [ + State{ name: "AliveState"; when: spawned == true && dying == false + PropertyChanges { target: img; opacity: 1 } + }, + State{ name: "DeathState"; when: dying == true + StateChangeScript { script: particles.burst(50); } + PropertyChanges { target: img; opacity: 0 } + } + ] + + transitions: [ + Transition { + NumberAnimation { target: img; property: "opacity"; duration: 200 } + } + ] + +} diff --git a/examples/qml/snake/content/Skull.qml b/examples/qml/snake/content/Skull.qml new file mode 100644 index 0000000000..e3f77fdac6 --- /dev/null +++ b/examples/qml/snake/content/Skull.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + property bool spawned: false + property int row; + property int column; + property int verticalMovement; + property int horizontalMovement; + + x: margin + column * gridSize + 2 + y: margin + row * gridSize - 3 + Behavior on x { NumberAnimation { duration: spawned ? halfbeatInterval : 0} } + Behavior on y { NumberAnimation { duration: spawned ? halfbeatInterval : 0 } } + + opacity: spawned ? 1 : 0 + Behavior on opacity { NumberAnimation { duration: 200 } } + + source: "pics/skull.png" + width: 24 + height: 40 +} diff --git a/examples/qml/snake/content/pics/README b/examples/qml/snake/content/pics/README new file mode 100644 index 0000000000..0215132caa --- /dev/null +++ b/examples/qml/snake/content/pics/README @@ -0,0 +1 @@ +snake.jpg: This image is based on the picture "Eastern Green Mamba.jpg" from the free media databse Wikimedia Commons and is published under the terms of the GNU Free Documentation License. The original picture was taken by Danleo. diff --git a/examples/qml/snake/content/pics/background.png b/examples/qml/snake/content/pics/background.png new file mode 100644 index 0000000000..72dffaa843 Binary files /dev/null and b/examples/qml/snake/content/pics/background.png differ diff --git a/examples/qml/snake/content/pics/blueStar.png b/examples/qml/snake/content/pics/blueStar.png new file mode 100644 index 0000000000..ba7acabd26 Binary files /dev/null and b/examples/qml/snake/content/pics/blueStar.png differ diff --git a/examples/qml/snake/content/pics/blueStone.png b/examples/qml/snake/content/pics/blueStone.png new file mode 100644 index 0000000000..356affdd95 Binary files /dev/null and b/examples/qml/snake/content/pics/blueStone.png differ diff --git a/examples/qml/snake/content/pics/cookie.png b/examples/qml/snake/content/pics/cookie.png new file mode 100644 index 0000000000..aec2957f34 Binary files /dev/null and b/examples/qml/snake/content/pics/cookie.png differ diff --git a/examples/qml/snake/content/pics/eyes.svg b/examples/qml/snake/content/pics/eyes.svg new file mode 100644 index 0000000000..1078692725 --- /dev/null +++ b/examples/qml/snake/content/pics/eyes.svg @@ -0,0 +1,118 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/examples/qml/snake/content/pics/head.png b/examples/qml/snake/content/pics/head.png new file mode 100644 index 0000000000..550e002687 Binary files /dev/null and b/examples/qml/snake/content/pics/head.png differ diff --git a/examples/qml/snake/content/pics/pause.png b/examples/qml/snake/content/pics/pause.png new file mode 100644 index 0000000000..056d97dd17 Binary files /dev/null and b/examples/qml/snake/content/pics/pause.png differ diff --git a/examples/qml/snake/content/pics/redStar.png b/examples/qml/snake/content/pics/redStar.png new file mode 100644 index 0000000000..cd06854719 Binary files /dev/null and b/examples/qml/snake/content/pics/redStar.png differ diff --git a/examples/qml/snake/content/pics/redStone.png b/examples/qml/snake/content/pics/redStone.png new file mode 100644 index 0000000000..9bb7fe4277 Binary files /dev/null and b/examples/qml/snake/content/pics/redStone.png differ diff --git a/examples/qml/snake/content/pics/skull.png b/examples/qml/snake/content/pics/skull.png new file mode 100644 index 0000000000..63186167bd Binary files /dev/null and b/examples/qml/snake/content/pics/skull.png differ diff --git a/examples/qml/snake/content/pics/snake.jpg b/examples/qml/snake/content/pics/snake.jpg new file mode 100644 index 0000000000..e91a784f71 Binary files /dev/null and b/examples/qml/snake/content/pics/snake.jpg differ diff --git a/examples/qml/snake/content/pics/star.png b/examples/qml/snake/content/pics/star.png new file mode 100644 index 0000000000..defbde53ca Binary files /dev/null and b/examples/qml/snake/content/pics/star.png differ diff --git a/examples/qml/snake/content/pics/stoneShadow.png b/examples/qml/snake/content/pics/stoneShadow.png new file mode 100644 index 0000000000..1bd56afd04 Binary files /dev/null and b/examples/qml/snake/content/pics/stoneShadow.png differ diff --git a/examples/qml/snake/content/pics/yellowStar.png b/examples/qml/snake/content/pics/yellowStar.png new file mode 100644 index 0000000000..52fb9c4b78 Binary files /dev/null and b/examples/qml/snake/content/pics/yellowStar.png differ diff --git a/examples/qml/snake/content/pics/yellowStone.png b/examples/qml/snake/content/pics/yellowStone.png new file mode 100644 index 0000000000..c56124a895 Binary files /dev/null and b/examples/qml/snake/content/pics/yellowStone.png differ diff --git a/examples/qml/snake/content/snake.js b/examples/qml/snake/content/snake.js new file mode 100644 index 0000000000..107c9f4591 --- /dev/null +++ b/examples/qml/snake/content/snake.js @@ -0,0 +1,316 @@ + +var snake = new Array; +var board = new Array; +var links = new Array; +var scheduledDirections = new Array; +var numRows = 1; +var numColumns = 1; +var linkComponent = Qt.createComponent("Link.qml"); +var cookieComponent = Qt.createComponent("Cookie.qml"); +var cookie; +var linksToGrow = 0; +var linksToDie = 0; +var waitForCookie = 0; +var growType = 0; +var skullMovementsBeforeDirectionChange = 0; + + +function rand(n) +{ + return (Math.floor(Math.random() * n)); +} + +function scheduleDirection(dir) +{ + if (state == "starting") { + direction = dir; + headDirection = direction; + head.rotation = headDirection; + } else if (state == "running"){ + direction = dir; + if(scheduledDirections[scheduledDirections.length-1]!=direction) + scheduledDirections.push(direction); + } +} + +function startNewGame() +{ + if (state == "starting") { + return; + } + + if (activeGame) { + endGame(); + startNewGameTimer.running = true; + return; + } + + state = "starting"; + + numRows = numRowsAvailable; + numColumns = numColumnsAvailable; + board = new Array(numRows * numColumns); + snake = new Array; + scheduledDirections = new Array; + growType = 0; + + skull.z = numRows * numColumns + 1; + + for (var i = 0; i < numRows * numColumns; ++i) { + if (i < links.length) { + var link = links[i]; + link.spawned = false; + link.dying = false; + } else { + if(linkComponent.status != Component.Ready) { + if(linkComponent.status == Component.Error) + console.log(linkComponent.errorString()); + else + console.log("Still loading linkComponent"); + continue;//TODO: Better error handling? + } + var link = linkComponent.createObject(playfield); + link.z = numRows * numColumns + 1 - i; + link.type = i == 0 ? 2 : 0; + link.spawned = false; + link.dying = false; + links.push(link); + } + } + + head = links[0]; + snake.push(head); + head.row = numRows/2 -1; + head.column = numColumns/2 -1; + head.spawned = true; + + linksToGrow = 5; + linksToDie = 0; + waitForCookie = 5; + score = 0; + startHeartbeatTimer.running = true; +} + +function endGame() +{ + activeGame = false; + for(var i in snake) + snake[i].dying = true; + if (cookie) { + cookie.dying = true; + cookie = 0; + } + lastScore = score; + highScores.saveScore(lastScore); + state = ""; +} + +function move() { + + if (!head) + return; + + var dir = direction; + + if (scheduledDirections.length) { + dir = scheduledDirections.shift(); + } + + if (state == "starting") { + var turn = (dir - headDirection); + head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn ); + headDirection = dir; + return; + } + + var row = head.row; + var column = head.column; + + if (dir == 0) { + row = row - 1; + } else if (dir == 1) { + column = column + 1 + } else if (dir == 2) { + row = row + 1; + } else if (dir == 3) { + column = column - 1; + } + + //validate the new position + if (row < 0 || row >= numRows + || column < 0 || column >= numColumns + || (row == skull.row && column == skull.column) + || !isFree(row, column)) { + var turn = (dir - headDirection); + head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn ); + headDirection = dir; + endGame(); + return; + } + + var newLink; + if (linksToGrow > 0) { + --linksToGrow; + newLink = links[snake.length]; + newLink.spawned = false; + newLink.rotation = snake[snake.length-1].rotation; + newLink.type = growType; + newLink.dying = false; + snake.push(newLink); + } else { + var lastLink = snake[snake.length-1]; + board[lastLink.row * numColumns + lastLink.column] = undefined; + } + + if (waitForCookie > 0) { + if (--waitForCookie == 0) + createCookie(cookie? (cookie.value+1) : 1); + } + + for (var i = snake.length-1; i > 0; --i) { + snake[i].row = snake[i-1].row; + snake[i].column = snake[i-1].column; + snake[i].rotation = snake[i-1].rotation; + } + + if (newLink) { + newLink.spawned = true; + } + + // move the head + head.row = row; + head.column = column; + board[row * numColumns + column] = head; + + var turn = (dir - headDirection); + head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn ); + headDirection = dir; + + var value = testCookie(row, column); + if (value > 0) { + linksToGrow += value; + score += value; + } +} + +function isFree(row, column) +{ + return board[row * numColumns + column] == undefined; +} + +function isHead(row, column) +{ + return head.column == column && head.row == row; +} + +function testCookie(row, column) +{ + if (cookie && !cookie.dying && cookie.row == row && cookie.column == column) { + var value = cookie.value; + waitForCookie = value; + growType = snake[snake.length-1].type == 1 ? 0 : 1; + cookie.dying = true; + cookie.z = numRows * numColumns + 2; + return value; + } + return 0; +} + +function moveSkull() +{ + + if (linksToDie > 0) { + --linksToDie; + var link = snake.pop(); + link.dying = true; + board[link.row * numColumns + link.column] = undefined; + if (score > 0) + --score; + if (snake.length == 0) { + endGame(); + return; + } + } + + var row = skull.row; + var column = skull.column; + if (isHead(row, column)) { + endGame(); + return; + } + row += skull.verticalMovement; + column += skull.horizontalMovement; + + var attempts = 4; + + while (skullMovementsBeforeDirectionChange == 0 || row < 0 || row >= numRows + || column < 0 || column >= numColumns + || (!isFree(row, column) && !isHead(row, column))) { + var d = rand(8); + skull.verticalMovement = 0; + skull.horizontalMovement = 0; + skullMovementsBeforeDirectionChange = rand(20)+1; + if (d == 0) { + skull.verticalMovement = -1 + } else if (d == 1) { + skull.horizontalMovement = -1; + } else if (d == 2) { + skull.verticalMovement = 1 + } else if (d == 3){ + skull.horizontalMovement = 1; + } else if (cookie) { + var rd = cookie.row - skull.row; + var rc = cookie.column - skull.column; + if (Math.abs(rd) > Math.abs(rc)) { + skull.verticalMovement = rd > 0 ? 1 : -1; + skullMovementsBeforeDirectionChange = Math.abs(rd); + } else { + skull.horizontalMovement= rc > 0 ? 1 : -1; + skullMovementsBeforeDirectionChange = Math.abs(rc); + } + } + row = skull.row + skull.verticalMovement; + column = skull.column + skull.horizontalMovement; + if (--attempts == 0) + return; + } + + skull.row = row; + skull.column = column; + --skullMovementsBeforeDirectionChange; + var value = testCookie(row, column); + if (value > 0) + linksToDie += value/2; + + if (isHead(row, column)) + endGame(); +} + +function createCookie(value) { + if (numRows * numColumns - snake.length < 10) + return; + + var column = rand(numColumns); + var row = rand(numRows); + while (!isFree(row, column)) { + column++; + if (column == numColumns) { + column = 0; + row++; + if (row == numRows) + row = 0; + } + } + + if(cookieComponent.status != Component.Ready) { + if(cookieComponent.status == Component.Error) + console.log(cookieComponent.errorString()); + else + console.log("Still loading cookieComponent"); + return;//TODO: Better error handling? + } + cookie = cookieComponent.createObject(head.parent); + cookie.value = value; + cookie.row = row; + cookie.column = column; +} diff --git a/examples/qml/snake/snake.qml b/examples/qml/snake/snake.qml new file mode 100644 index 0000000000..d389077bde --- /dev/null +++ b/examples/qml/snake/snake.qml @@ -0,0 +1,272 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" as Content +import "content/snake.js" as Logic + +Rectangle { + id: screen; + SystemPalette { id: activePalette } + color: activePalette.window + property bool activeGame: false + + property int gridSize : 34 + property int margin: 4 + property int numRowsAvailable: Math.floor((height-32-2*margin)/gridSize) + property int numColumnsAvailable: Math.floor((width-2*margin)/gridSize) + + property int lastScore : 0 + + property int score: 0; + property int heartbeatInterval: 200 + property int halfbeatInterval: 160 + + width: 480 + height: 750 + + property int direction + property int headDirection + + property variant head; + + Content.HighScoreModel { + id: highScores + game: "Snake" + } + + Timer { + id: heartbeat; + interval: heartbeatInterval; + running: activeGame + repeat: true + onTriggered: { Logic.move() } + } + Timer { + id: halfbeat; + interval: halfbeatInterval; + repeat: true + running: heartbeat.running + onTriggered: { Logic.moveSkull() } + } + Timer { + id: startNewGameTimer; + interval: 700; + onTriggered: { Logic.startNewGame(); } + } + + Timer { + id: startHeartbeatTimer; + interval: 1000 ; + onTriggered: { state = "running"; activeGame = true; } + } + + Image{ + id: pauseDialog + z: 1 + source: "content/pics/pause.png" + anchors.centerIn: parent; + //opacity is deliberately not animated + opacity: 0 //Was !Qt.application.active && activeGame, but application doesn't work (QTBUG-23331) + } + + Image { + + Image { + id: title + source: "content/pics/snake.jpg" + fillMode: Image.PreserveAspectCrop + anchors.fill: parent + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + + Column { + spacing: 140 + anchors.verticalCenter: parent.verticalCenter; + anchors.left: parent.left; + anchors.right: parent.right; + + Text { + color: "white" + font.pointSize: 48 + font.italic: true; + font.bold: true; + text: "Snake" + anchors.horizontalCenter: parent.horizontalCenter; + } + + Text { + color: "white" + font.pointSize: 24 + anchors.horizontalCenter: parent.horizontalCenter; + //horizontalAlignment: Text.AlignHCenter + text: "Last Score:\t" + lastScore + "\nHighscore:\t" + highScores.topScore; + } + } + } + + source: "content/pics/background.png" + fillMode: Image.PreserveAspectCrop + + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: toolbar.top + + Rectangle { + id: playfield + border.width: 1 + border.color: "white" + color: "transparent" + anchors.horizontalCenter: parent.horizontalCenter + y: (screen.height - 32 - height)/2; + width: numColumnsAvailable * gridSize + 2*margin + height: numRowsAvailable * gridSize + 2*margin + + + Content.Skull { + id: skull + } + + MouseArea { + anchors.fill: parent + onPressed: { + if (screen.state == "") { + Logic.startNewGame(); + return; + } + if (direction == 0 || direction == 2) + Logic.scheduleDirection((mouseX > (head.x + head.width/2)) ? 1 : 3); + else + Logic.scheduleDirection((mouseY > (head.y + head.height/2)) ? 2 : 0); + } + } + } + + } + + Rectangle { + id: progressBar + opacity: 0 + Behavior on opacity { NumberAnimation { duration: 200 } } + color: "transparent" + border.width: 2 + border.color: "#221edd" + x: 50 + y: 50 + width: 200 + height: 30 + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenterOffset: 40 + + Rectangle { + id: progressIndicator + color: "#221edd"; + width: 0; + height: 30; + } + } + + Rectangle { + id: toolbar + color: activePalette.window + height: 32; width: parent.width + anchors.bottom: screen.bottom + + Content.Button { + id: btnA; text: "New Game"; onClicked: Logic.startNewGame(); + anchors.left: parent.left; anchors.leftMargin: 3 + anchors.verticalCenter: parent.verticalCenter + } + + Content.Button { + text: "Quit" + anchors { left: btnA.right; leftMargin: 3; verticalCenter: parent.verticalCenter } + onClicked: Qt.quit(); + } + + Text { + color: activePalette.text + text: "Score: " + score; font.bold: true + anchors.right: parent.right; anchors.rightMargin: 3 + anchors.verticalCenter: parent.verticalCenter + } + } + + focus: true + Keys.onSpacePressed: Logic.startNewGame(); + Keys.onLeftPressed: if (state == "starting" || direction != 1) Logic.scheduleDirection(3); + Keys.onRightPressed: if (state == "starting" || direction != 3) Logic.scheduleDirection(1); + Keys.onUpPressed: if (state == "starting" || direction != 2) Logic.scheduleDirection(0); + Keys.onDownPressed: if (state == "starting" || direction != 0) Logic.scheduleDirection(2); + + states: [ + State { + name: "starting" + PropertyChanges {target: progressIndicator; width: 200} + PropertyChanges {target: title; opacity: 0} + PropertyChanges {target: progressBar; opacity: 1} + }, + State { + name: "running" + PropertyChanges {target: progressIndicator; width: 200} + PropertyChanges {target: title; opacity: 0} + PropertyChanges {target: skull; row: 0; column: 0; } + PropertyChanges {target: skull; spawned: 1} + } + ] + + transitions: [ + Transition { + from: "*" + to: "starting" + NumberAnimation { target: progressIndicator; property: "width"; duration: 1000 } + NumberAnimation { property: "opacity"; duration: 200 } + }, + Transition { + to: "starting" + NumberAnimation { target: progressIndicator; property: "width"; duration: 1000 } + NumberAnimation { property: "opacity"; duration: 200 } + } + ] + +} diff --git a/examples/qml/snake/snake.qmlproject b/examples/qml/snake/snake.qmlproject new file mode 100644 index 0000000000..fb015465d1 --- /dev/null +++ b/examples/qml/snake/snake.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "snake.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/sqllocalstorage/hello.qml b/examples/qml/sqllocalstorage/hello.qml new file mode 100644 index 0000000000..3496b86bd9 --- /dev/null +++ b/examples/qml/sqllocalstorage/hello.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 +import QtQuick.LocalStorage 2.0 as LS + +Rectangle { + color: "white" + width: 200 + height: 100 + + Text { + text: "?" + anchors.horizontalCenter: parent.horizontalCenter + function findGreetings() { + var db = LS.openDatabaseSync("QDeclarativeExampleDB", "1.0", "The Example QML SQL!", 1000000); + + db.transaction( + function(tx) { + // Create the database if it doesn't already exist + tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)'); + + // Add (another) greeting row + tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); + + // Show all added greetings + var rs = tx.executeSql('SELECT * FROM Greeting'); + + var r = "" + for(var i = 0; i < rs.rows.length; i++) { + r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n" + } + text = r + } + ) + } + + Component.onCompleted: findGreetings() + } +} +//![0] diff --git a/examples/qtquick/text/fonts/availableFonts.qml b/examples/qml/text/fonts/availableFonts.qml similarity index 100% rename from examples/qtquick/text/fonts/availableFonts.qml rename to examples/qml/text/fonts/availableFonts.qml diff --git a/examples/qtquick/text/fonts/banner.qml b/examples/qml/text/fonts/banner.qml similarity index 100% rename from examples/qtquick/text/fonts/banner.qml rename to examples/qml/text/fonts/banner.qml diff --git a/examples/qtquick/text/fonts/content/fonts/tarzeau_ocr_a.ttf b/examples/qml/text/fonts/content/fonts/tarzeau_ocr_a.ttf similarity index 100% rename from examples/qtquick/text/fonts/content/fonts/tarzeau_ocr_a.ttf rename to examples/qml/text/fonts/content/fonts/tarzeau_ocr_a.ttf diff --git a/examples/qtquick/text/fonts/fonts.qml b/examples/qml/text/fonts/fonts.qml similarity index 100% rename from examples/qtquick/text/fonts/fonts.qml rename to examples/qml/text/fonts/fonts.qml diff --git a/examples/qtquick/text/fonts/hello.qml b/examples/qml/text/fonts/hello.qml similarity index 100% rename from examples/qtquick/text/fonts/hello.qml rename to examples/qml/text/fonts/hello.qml diff --git a/examples/qtquick/text/imgtag/TextWithImage.qml b/examples/qml/text/imgtag/TextWithImage.qml similarity index 100% rename from examples/qtquick/text/imgtag/TextWithImage.qml rename to examples/qml/text/imgtag/TextWithImage.qml diff --git a/examples/qtquick/text/imgtag/images/face-sad.png b/examples/qml/text/imgtag/images/face-sad.png similarity index 100% rename from examples/qtquick/text/imgtag/images/face-sad.png rename to examples/qml/text/imgtag/images/face-sad.png diff --git a/examples/qtquick/text/imgtag/images/face-smile-big.png b/examples/qml/text/imgtag/images/face-smile-big.png similarity index 100% rename from examples/qtquick/text/imgtag/images/face-smile-big.png rename to examples/qml/text/imgtag/images/face-smile-big.png diff --git a/examples/qtquick/text/imgtag/images/face-smile.png b/examples/qml/text/imgtag/images/face-smile.png similarity index 100% rename from examples/qtquick/text/imgtag/images/face-smile.png rename to examples/qml/text/imgtag/images/face-smile.png diff --git a/examples/qtquick/text/imgtag/images/heart200.png b/examples/qml/text/imgtag/images/heart200.png similarity index 100% rename from examples/qtquick/text/imgtag/images/heart200.png rename to examples/qml/text/imgtag/images/heart200.png diff --git a/examples/qtquick/text/imgtag/images/qtlogo.png b/examples/qml/text/imgtag/images/qtlogo.png similarity index 100% rename from examples/qtquick/text/imgtag/images/qtlogo.png rename to examples/qml/text/imgtag/images/qtlogo.png diff --git a/examples/qtquick/text/imgtag/images/starfish_2.png b/examples/qml/text/imgtag/images/starfish_2.png similarity index 100% rename from examples/qtquick/text/imgtag/images/starfish_2.png rename to examples/qml/text/imgtag/images/starfish_2.png diff --git a/examples/qtquick/text/imgtag/imgtag.qml b/examples/qml/text/imgtag/imgtag.qml similarity index 100% rename from examples/qtquick/text/imgtag/imgtag.qml rename to examples/qml/text/imgtag/imgtag.qml diff --git a/examples/qtquick/text/styledtext-layout.qml b/examples/qml/text/styledtext-layout.qml similarity index 100% rename from examples/qtquick/text/styledtext-layout.qml rename to examples/qml/text/styledtext-layout.qml diff --git a/examples/qml/text/text.qml b/examples/qml/text/text.qml new file mode 100644 index 0000000000..14a88d2e91 --- /dev/null +++ b/examples/qml/text/text.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../shared" + +Item { + height: 480 + width: 480 + LauncherList { + id: ll + anchors.fill: parent + Component.onCompleted: { + addExample("Hello", "An Animated Hello World", Qt.resolvedUrl("fonts/hello.qml")); + addExample("Fonts", "Using various fonts with a Text element", Qt.resolvedUrl("fonts/fonts.qml")); + addExample("Available Fonts", "A list of your available fonts", Qt.resolvedUrl("fonts/availableFonts.qml")); + addExample("Banner", "Large, scrolling text", Qt.resolvedUrl("fonts/banner.qml")); + } + } +} diff --git a/examples/qtquick/text/text.qmlproject b/examples/qml/text/text.qmlproject similarity index 100% rename from examples/qtquick/text/text.qmlproject rename to examples/qml/text/text.qmlproject diff --git a/examples/qtquick/text/textselection/pics/endHandle.png b/examples/qml/text/textselection/pics/endHandle.png similarity index 100% rename from examples/qtquick/text/textselection/pics/endHandle.png rename to examples/qml/text/textselection/pics/endHandle.png diff --git a/examples/qtquick/text/textselection/pics/endHandle.sci b/examples/qml/text/textselection/pics/endHandle.sci similarity index 100% rename from examples/qtquick/text/textselection/pics/endHandle.sci rename to examples/qml/text/textselection/pics/endHandle.sci diff --git a/examples/qtquick/text/textselection/pics/startHandle.png b/examples/qml/text/textselection/pics/startHandle.png similarity index 100% rename from examples/qtquick/text/textselection/pics/startHandle.png rename to examples/qml/text/textselection/pics/startHandle.png diff --git a/examples/qtquick/text/textselection/pics/startHandle.sci b/examples/qml/text/textselection/pics/startHandle.sci similarity index 100% rename from examples/qtquick/text/textselection/pics/startHandle.sci rename to examples/qml/text/textselection/pics/startHandle.sci diff --git a/examples/qtquick/text/textselection/textselection.qml b/examples/qml/text/textselection/textselection.qml similarity index 100% rename from examples/qtquick/text/textselection/textselection.qml rename to examples/qml/text/textselection/textselection.qml diff --git a/examples/qtquick/threading/threadedlistmodel/dataloader.js b/examples/qml/threading/threadedlistmodel/dataloader.js similarity index 100% rename from examples/qtquick/threading/threadedlistmodel/dataloader.js rename to examples/qml/threading/threadedlistmodel/dataloader.js diff --git a/examples/qtquick/threading/threadedlistmodel/threadedlistmodel.qmlproject b/examples/qml/threading/threadedlistmodel/threadedlistmodel.qmlproject similarity index 100% rename from examples/qtquick/threading/threadedlistmodel/threadedlistmodel.qmlproject rename to examples/qml/threading/threadedlistmodel/threadedlistmodel.qmlproject diff --git a/examples/qtquick/threading/threadedlistmodel/timedisplay.qml b/examples/qml/threading/threadedlistmodel/timedisplay.qml similarity index 100% rename from examples/qtquick/threading/threadedlistmodel/timedisplay.qml rename to examples/qml/threading/threadedlistmodel/timedisplay.qml diff --git a/examples/qtquick/threading/workerscript/workerscript.js b/examples/qml/threading/workerscript/workerscript.js similarity index 100% rename from examples/qtquick/threading/workerscript/workerscript.js rename to examples/qml/threading/workerscript/workerscript.js diff --git a/examples/qtquick/threading/workerscript/workerscript.qml b/examples/qml/threading/workerscript/workerscript.qml similarity index 100% rename from examples/qtquick/threading/workerscript/workerscript.qml rename to examples/qml/threading/workerscript/workerscript.qml diff --git a/examples/qtquick/threading/workerscript/workerscript.qmlproject b/examples/qml/threading/workerscript/workerscript.qmlproject similarity index 100% rename from examples/qtquick/threading/workerscript/workerscript.qmlproject rename to examples/qml/threading/workerscript/workerscript.qmlproject diff --git a/examples/qtquick/mousearea/mousearea-example.qml b/examples/qml/touchinteraction/mousearea/mousearea-example.qml similarity index 100% rename from examples/qtquick/mousearea/mousearea-example.qml rename to examples/qml/touchinteraction/mousearea/mousearea-example.qml diff --git a/examples/qtquick/touchinteraction/multipointtouch/bearwhack.qml b/examples/qml/touchinteraction/multipointtouch/bearwhack.qml similarity index 100% rename from examples/qtquick/touchinteraction/multipointtouch/bearwhack.qml rename to examples/qml/touchinteraction/multipointtouch/bearwhack.qml diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml b/examples/qml/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml similarity index 100% rename from examples/qtquick/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml rename to examples/qml/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/Bear0.png b/examples/qml/touchinteraction/multipointtouch/content/Bear0.png similarity index 100% rename from examples/qtquick/touchinteraction/multipointtouch/content/Bear0.png rename to examples/qml/touchinteraction/multipointtouch/content/Bear0.png diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/Bear1.png b/examples/qml/touchinteraction/multipointtouch/content/Bear1.png similarity index 100% rename from examples/qtquick/touchinteraction/multipointtouch/content/Bear1.png rename to examples/qml/touchinteraction/multipointtouch/content/Bear1.png diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/Bear2.png b/examples/qml/touchinteraction/multipointtouch/content/Bear2.png similarity index 100% rename from examples/qtquick/touchinteraction/multipointtouch/content/Bear2.png rename to examples/qml/touchinteraction/multipointtouch/content/Bear2.png diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/Bear3.png b/examples/qml/touchinteraction/multipointtouch/content/Bear3.png similarity index 100% rename from examples/qtquick/touchinteraction/multipointtouch/content/Bear3.png rename to examples/qml/touchinteraction/multipointtouch/content/Bear3.png diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/BearB.png b/examples/qml/touchinteraction/multipointtouch/content/BearB.png similarity index 100% rename from examples/qtquick/touchinteraction/multipointtouch/content/BearB.png rename to examples/qml/touchinteraction/multipointtouch/content/BearB.png diff --git a/examples/qml/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml b/examples/qml/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml new file mode 100644 index 0000000000..05d74ab0ea --- /dev/null +++ b/examples/qml/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml @@ -0,0 +1,180 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +ParticleSystem { + id: particleSystem + function explode(x,y) { + fireEmitter.burst(100,x,y); + } + + Emitter { + id: emitter + group: "bears" + width: parent.width + emitRate: 1 + NumberAnimation on emitRate { + id: goFaster + from: 1 + to: 16 + running: particleSystem.running + loops: 1 + duration: 60000 * 5 + easing.type: Easing.Linear + } + lifeSpan: 4000 + 800*(16-emitRate) + maximumEmitted: 128 + size: 64 + speed: PointDirection{ y: 40 + 10 * emitter.emitRate } + } + + Emitter { + id: fireEmitter + enabled: false + maximumEmitted: 6000 + group: "flame" + emitRate: 1000 + size: 16 + endSize: 8 + speed: CumulativeDirection { AngleDirection {angleVariation: 180; magnitudeVariation: 120;} PointDirection { y: -60 }} + lifeSpan: 400 + } + Emitter { + id: heartEmitter + enabled: false + maximumEmitted: 6000 + group: "hearts" + emitRate: 1000 + size: 16 + endSize: 8 + speed: AngleDirection {angleVariation: 180; magnitudeVariation: 180;} + lifeSpan: 600 + } + Emitter { + id: bloodEmitter + enabled: false + maximumEmitted: 6000 + group: "blood" + emitRate: 1000 + size: 16 + endSize: 8 + speed: CumulativeDirection { AngleDirection {angleVariation: 180; magnitudeVariation: 80;} PointDirection { y: 40 }} + lifeSpan: 600 + } + + Affector { + width: parent.width + height: 64 + once: true + y: parent.height - 32 + groups: "bears" + onAffectParticles: { + for (var i=0;i (window.height / 2 + window.centerOffset) + + source: image + opacity: onLand ? 1 : 0.25 + scale: Math.max((y + height - 250) * 0.01, 0.3) + smooth: true + + onCreatedChanged: { + if (created && !onLand) + rootItem.destroy(); + else + z = scaledBottom; + } + + onYChanged: z = scaledBottom; +} diff --git a/examples/qml/toys/dynamicscene/content/Sun.qml b/examples/qml/toys/dynamicscene/content/Sun.qml new file mode 100644 index 0000000000..b84516eecc --- /dev/null +++ b/examples/qml/toys/dynamicscene/content/Sun.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + id: sun + + property bool created: false + property string image: "images/sun.png" + + source: image + + // once item is created, start moving offscreen + NumberAnimation on y { + to: (window.height / 2) + window.centerOffset + running: created + onRunningChanged: { + if (running) + duration = (window.height + window.centerOffset - sun.y) * 10; + else + state = "OffScreen" + } + } + + states: State { + name: "OffScreen" + StateChangeScript { + script: { sun.created = false; sun.destroy() } + } + } + + onCreatedChanged: { + if (created) { + sun.z = 1; // above the sky but below the ground layer + window.activeSuns++; + } else { + window.activeSuns--; + } + } +} diff --git a/examples/qml/toys/dynamicscene/content/images/NOTE b/examples/qml/toys/dynamicscene/content/images/NOTE new file mode 100644 index 0000000000..fcd87f9132 --- /dev/null +++ b/examples/qml/toys/dynamicscene/content/images/NOTE @@ -0,0 +1 @@ +Images (except star.png) are from the KDE project. diff --git a/examples/qml/toys/dynamicscene/content/images/face-smile.png b/examples/qml/toys/dynamicscene/content/images/face-smile.png new file mode 100644 index 0000000000..3d66d72578 Binary files /dev/null and b/examples/qml/toys/dynamicscene/content/images/face-smile.png differ diff --git a/examples/qml/toys/dynamicscene/content/images/moon.png b/examples/qml/toys/dynamicscene/content/images/moon.png new file mode 100644 index 0000000000..1c0d6066a8 Binary files /dev/null and b/examples/qml/toys/dynamicscene/content/images/moon.png differ diff --git a/examples/qml/toys/dynamicscene/content/images/rabbit_brown.png b/examples/qml/toys/dynamicscene/content/images/rabbit_brown.png new file mode 100644 index 0000000000..ebfdeed332 Binary files /dev/null and b/examples/qml/toys/dynamicscene/content/images/rabbit_brown.png differ diff --git a/examples/qml/toys/dynamicscene/content/images/rabbit_bw.png b/examples/qml/toys/dynamicscene/content/images/rabbit_bw.png new file mode 100644 index 0000000000..7bff9b92ca Binary files /dev/null and b/examples/qml/toys/dynamicscene/content/images/rabbit_bw.png differ diff --git a/examples/qml/toys/dynamicscene/content/images/star.png b/examples/qml/toys/dynamicscene/content/images/star.png new file mode 100644 index 0000000000..27ef924267 Binary files /dev/null and b/examples/qml/toys/dynamicscene/content/images/star.png differ diff --git a/examples/qml/toys/dynamicscene/content/images/sun.png b/examples/qml/toys/dynamicscene/content/images/sun.png new file mode 100644 index 0000000000..7713ca5ce7 Binary files /dev/null and b/examples/qml/toys/dynamicscene/content/images/sun.png differ diff --git a/examples/qml/toys/dynamicscene/content/images/tree_s.png b/examples/qml/toys/dynamicscene/content/images/tree_s.png new file mode 100644 index 0000000000..6eac35a729 Binary files /dev/null and b/examples/qml/toys/dynamicscene/content/images/tree_s.png differ diff --git a/examples/qml/toys/dynamicscene/content/itemCreation.js b/examples/qml/toys/dynamicscene/content/itemCreation.js new file mode 100644 index 0000000000..40f5415f9f --- /dev/null +++ b/examples/qml/toys/dynamicscene/content/itemCreation.js @@ -0,0 +1,62 @@ +var itemComponent = null; +var draggedItem = null; +var startingMouse; +var posnInWindow; + +function startDrag(mouse) +{ + posnInWindow = paletteItem.mapToItem(window, 0, 0); + startingMouse = { x: mouse.x, y: mouse.y } + loadComponent(); +} + +//Creation is split into two functions due to an asynchronous wait while +//possible external files are loaded. + +function loadComponent() { + if (itemComponent != null) { // component has been previously loaded + createItem(); + return; + } + + itemComponent = Qt.createComponent(paletteItem.componentFile); + if (itemComponent.status == Component.Loading) //Depending on the content, it can be ready or error immediately + component.statusChanged.connect(createItem); + else + createItem(); +} + +function createItem() { + if (itemComponent.status == Component.Ready && draggedItem == null) { + draggedItem = itemComponent.createObject(window, {"image": paletteItem.image, "x": posnInWindow.x, "y": posnInWindow.y, "z": 3}); + // make sure created item is above the ground layer + } else if (itemComponent.status == Component.Error) { + draggedItem = null; + console.log("error creating component"); + console.log(itemComponent.errorString()); + } +} + +function continueDrag(mouse) +{ + if (draggedItem == null) + return; + + draggedItem.x = mouse.x + posnInWindow.x - startingMouse.x; + draggedItem.y = mouse.y + posnInWindow.y - startingMouse.y; +} + +function endDrag(mouse) +{ + if (draggedItem == null) + return; + + if (draggedItem.y < toolbox.height) { //Don't drop it in the toolbox + draggedItem.destroy(); + draggedItem = null; + } else { + draggedItem.created = true; + draggedItem = null; + } +} + diff --git a/examples/qml/toys/dynamicscene/dynamicscene.qml b/examples/qml/toys/dynamicscene/dynamicscene.qml new file mode 100644 index 0000000000..e64eb0fd0f --- /dev/null +++ b/examples/qml/toys/dynamicscene/dynamicscene.qml @@ -0,0 +1,275 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "content" + +Item { + id: window + + property int activeSuns: 0 + property int centerOffset: 72 + + height: 480; width: 360 + + + MouseArea { + anchors.fill: parent + onClicked: window.focus = false; + } + + //This is the message box that pops up when there's an error + Rectangle { + id: dialog + + opacity: 0 + anchors.centerIn: parent + width: dialogText.width + 6; height: dialogText.height + 6 + border.color: 'black' + color: 'lightsteelblue' + z: 65535 //Arbitrary number chosen to be above all the items, including the scaled perspective ones. + + function show(str){ + dialogText.text = str; + dialogAnim.start(); + } + + Text { + id: dialogText + x: 3; y: 3 + font.pixelSize: 14 + } + + SequentialAnimation { + id: dialogAnim + NumberAnimation { target: dialog; property:"opacity"; to: 1; duration: 1000 } + PauseAnimation { duration: 5000 } + NumberAnimation { target: dialog; property:"opacity"; to: 0; duration: 1000 } + } + } + + Item { + id: scene + anchors { top: sky.top; bottom: ground.bottom; left: parent.left; right: parent.right} + z: 10 + } + + // sky + Rectangle { + id: sky + anchors { left: parent.left; top: toolbox.bottom; right: parent.right; bottomMargin: -centerOffset; bottom: parent.verticalCenter } + gradient: Gradient { + GradientStop { id: gradientStopA; position: 0.0; color: "#0E1533" } + GradientStop { id: gradientStopB; position: 1.0; color: "#437284" } + } + } + + // stars (when there's no sun) + ParticleSystem { + id: particlesystem + anchors.fill: sky + + ImageParticle { + id: stars + source: "content/images/star.png" + groups: ["stars"] + opacity: .5 + } + + Emitter { + id: starsemitter + anchors.fill: parent + emitRate: parent.width / 50 + lifeSpan: 5000 + group: "stars" + } + } + + // ground + Rectangle { + id: ground + z: 2 // just above the sun so that the sun can set behind it + anchors { left: parent.left; top: parent.verticalCenter; topMargin: centerOffset; right: parent.right; bottom: parent.bottom } + gradient: Gradient { + GradientStop { position: 0.0; color: "ForestGreen" } + GradientStop { position: 1.0; color: "DarkGreen" } + } + } + + SystemPalette { id: activePalette } + + // right-hand panel + Rectangle { + id: toolbox + + height: centerOffset * 2 + color: activePalette.window + anchors { right: parent.right; top: parent.top; left: parent.left} + + Column { + anchors.centerIn: parent + spacing: 8 + + Text { text: "Drag an item into the scene." } + + Rectangle { + width: palette.width + 10; height: palette.height + 10 + border.color: "black" + + Row { + id: palette + anchors.centerIn: parent + spacing: 8 + + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "Sun.qml" + source: "content/images/sun.png" + image: "images/sun.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "GenericSceneItem.qml" + source: "content/images/moon.png" + image: "images/moon.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + source: "content/images/tree_s.png" + image: "images/tree_s.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + source: "content/images/rabbit_brown.png" + image: "images/rabbit_brown.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + source: "content/images/rabbit_bw.png" + image: "images/rabbit_bw.png" + } + } + } + + Text { text: "Active Suns: " + activeSuns } + } + } + + //Popup toolbox down the bottom + Rectangle { + id: popupToolbox + z: 1000 + width: parent.width + height: popupColumn.height + 16 + color: activePalette.window + + property bool poppedUp: false + property int downY: window.height - (createButton.height + 16) + property int upY: window.height - (popupColumn.height + 16) + y: poppedUp ? upY : downY + Behavior on y { NumberAnimation {}} + + Column { + id: popupColumn + y: 8 + anchors.centerIn: parent + spacing: 8 + + Row { + height: createButton.height + spacing: 8 + Text { text: "Custom QML:"; anchors.verticalCenter: parent.verticalCenter } + Button { + id: popupButton + text: popupToolbox.poppedUp ? "Hide" : "Show" + onClicked: popupToolbox.poppedUp = !popupToolbox.poppedUp + } + Button { + id: createButton + text: "Create" + onClicked: { + try { + Qt.createQmlObject(qmlText.text, scene, 'CustomObject'); + } catch(err) { + dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message); + } + } + } + + } + + Rectangle { + width: 360; height: 240 + + TextEdit { + id: qmlText + anchors.fill: parent; anchors.margins: 5 + readOnly: false + font.pixelSize: 14 + selectByMouse: true + wrapMode: TextEdit.WordWrap + + text: "import QtQuick 2.0\nImage {\n id: smile\n x: 360 * Math.random()\n y: 180 * Math.random() \n source: 'content/images/face-smile.png'\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n Component.onCompleted: smile.destroy(1500);\n}" + } + } + } + } + + //Day state, for when a sun is added to the scene + states: State { + name: "Day" + when: window.activeSuns > 0 + + PropertyChanges { target: gradientStopA; color: "DeepSkyBlue" } + PropertyChanges { target: gradientStopB; color: "SkyBlue" } + PropertyChanges { target: stars; opacity: 0 } + } + + //! [top-level transitions] + transitions: Transition { + PropertyAnimation { duration: 3000 } + ColorAnimation { duration: 3000 } + } + //! [top-level transitions] +} diff --git a/examples/qml/toys/tic-tac-toe/content/Button.qml b/examples/qml/toys/tic-tac-toe/content/Button.qml new file mode 100644 index 0000000000..6dd141f838 --- /dev/null +++ b/examples/qml/toys/tic-tac-toe/content/Button.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property string text + property bool pressed: false + + signal clicked + + width: buttonLabel.width + 20; height: buttonLabel.height + 6 + border { width: 1; color: Qt.darker(container.color) } + radius: 8 + color: "lightgray" + smooth: true + + gradient: Gradient { + GradientStop { + position: 0.0 + color: container.pressed ? "darkgray" : "white" + } + GradientStop { + position: 1.0 + color: container.color + } + } + + MouseArea { + anchors.fill: parent + onClicked: container.clicked() + } + + Text { + id: buttonLabel + anchors.centerIn: container + text: container.text + font.pixelSize: 14 + } +} diff --git a/examples/qml/toys/tic-tac-toe/content/TicTac.qml b/examples/qml/toys/tic-tac-toe/content/TicTac.qml new file mode 100644 index 0000000000..e74bc6bcda --- /dev/null +++ b/examples/qml/toys/tic-tac-toe/content/TicTac.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + signal clicked + + states: [ + State { name: "X"; PropertyChanges { target: image; source: "pics/x.png" } }, + State { name: "O"; PropertyChanges { target: image; source: "pics/o.png" } } + ] + + Image { + id: image + anchors.centerIn: parent + } + + MouseArea { + anchors.fill: parent + onClicked: parent.clicked() + } +} diff --git a/examples/qml/toys/tic-tac-toe/content/pics/board.png b/examples/qml/toys/tic-tac-toe/content/pics/board.png new file mode 100644 index 0000000000..7e5b7ba27c Binary files /dev/null and b/examples/qml/toys/tic-tac-toe/content/pics/board.png differ diff --git a/examples/qml/toys/tic-tac-toe/content/pics/o.png b/examples/qml/toys/tic-tac-toe/content/pics/o.png new file mode 100644 index 0000000000..abc7ee020b Binary files /dev/null and b/examples/qml/toys/tic-tac-toe/content/pics/o.png differ diff --git a/examples/qml/toys/tic-tac-toe/content/pics/x.png b/examples/qml/toys/tic-tac-toe/content/pics/x.png new file mode 100644 index 0000000000..ddc65c83b8 Binary files /dev/null and b/examples/qml/toys/tic-tac-toe/content/pics/x.png differ diff --git a/examples/qml/toys/tic-tac-toe/content/tic-tac-toe.js b/examples/qml/toys/tic-tac-toe/content/tic-tac-toe.js new file mode 100644 index 0000000000..5a166b750f --- /dev/null +++ b/examples/qml/toys/tic-tac-toe/content/tic-tac-toe.js @@ -0,0 +1,149 @@ +function winner(board) +{ + for (var i=0; i<3; ++i) { + if (board.children[i].state != "" + && board.children[i].state == board.children[i+3].state + && board.children[i].state == board.children[i+6].state) + return true + + if (board.children[i*3].state != "" + && board.children[i*3].state == board.children[i*3+1].state + && board.children[i*3].state == board.children[i*3+2].state) + return true + } + + if (board.children[0].state != "" + && board.children[0].state == board.children[4].state != "" + && board.children[0].state == board.children[8].state != "") + return true + + if (board.children[2].state != "" + && board.children[2].state == board.children[4].state != "" + && board.children[2].state == board.children[6].state != "") + return true + + return false +} + +function restartGame() +{ + game.running = true + + for (var i=0; i<9; ++i) + board.children[i].state = "" +} + +function makeMove(pos, player) +{ + board.children[pos].state = player + if (winner(board)) { + gameFinished(player + " wins") + return true + } else { + return false + } +} + +function canPlayAtPos(pos) +{ + return board.children[pos].state == "" +} + +function computerTurn() +{ + var r = Math.random(); + if (r < game.difficulty) + smartAI(); + else + randomAI(); +} + +function smartAI() +{ + function boardCopy(a) { + var ret = new Object; + ret.children = new Array(9); + for (var i = 0; i<9; i++) { + ret.children[i] = new Object; + ret.children[i].state = a.children[i].state; + } + return ret; + } + + for (var i=0; i<9; i++) { + var simpleBoard = boardCopy(board); + if (canPlayAtPos(i)) { + simpleBoard.children[i].state = "O"; + if (winner(simpleBoard)) { + makeMove(i, "O") + return + } + } + } + for (var i=0; i<9; i++) { + var simpleBoard = boardCopy(board); + if (canPlayAtPos(i)) { + simpleBoard.children[i].state = "X"; + if (winner(simpleBoard)) { + makeMove(i, "O") + return + } + } + } + + function thwart(a,b,c) { //If they are at a, try b or c + if (board.children[a].state == "X") { + if (canPlayAtPos(b)) { + makeMove(b, "O") + return true + } else if (canPlayAtPos(c)) { + makeMove(c, "O") + return true + } + } + return false; + } + + if (thwart(4,0,2)) return; + if (thwart(0,4,3)) return; + if (thwart(2,4,1)) return; + if (thwart(6,4,7)) return; + if (thwart(8,4,5)) return; + if (thwart(1,4,2)) return; + if (thwart(3,4,0)) return; + if (thwart(5,4,8)) return; + if (thwart(7,4,6)) return; + + for (var i =0; i<9; i++) { + if (canPlayAtPos(i)) { + makeMove(i, "O") + return + } + } + restartGame(); +} + +function randomAI() +{ + var unfilledPosns = new Array(); + + for (var i=0; i<9; ++i) { + if (canPlayAtPos(i)) + unfilledPosns.push(i); + } + + if (unfilledPosns.length == 0) { + restartGame(); + } else { + var choice = unfilledPosns[Math.floor(Math.random() * unfilledPosns.length)]; + makeMove(choice, "O"); + } +} + +function gameFinished(message) +{ + messageDisplay.text = message + messageDisplay.visible = true + game.running = false +} + diff --git a/examples/qml/toys/tic-tac-toe/tic-tac-toe.qml b/examples/qml/toys/tic-tac-toe/tic-tac-toe.qml new file mode 100644 index 0000000000..8d15233eaa --- /dev/null +++ b/examples/qml/toys/tic-tac-toe/tic-tac-toe.qml @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" +import "content/tic-tac-toe.js" as Logic + +Rectangle { + id: game + + property bool running: true + property real difficulty: 1.0 //chance it will actually think + + width: display.width; height: display.height + 10 + + Image { + id: boardImage + source: "content/pics/board.png" + } + + + Column { + id: display + + Grid { + id: board + width: boardImage.width; height: boardImage.height + columns: 3 + + Repeater { + model: 9 + + TicTac { + width: board.width/3 + height: board.height/3 + + onClicked: { + if (game.running && Logic.canPlayAtPos(index)) { + if (!Logic.makeMove(index, "X")) + Logic.computerTurn(); + } + } + } + } + } + + Row { + spacing: 4 + anchors.horizontalCenter: parent.horizontalCenter + + Button { + text: "Hard" + pressed: game.difficulty == 1.0 + onClicked: { game.difficulty = 1.0 } + } + Button { + text: "Moderate" + pressed: game.difficulty == 0.8 + onClicked: { game.difficulty = 0.8 } + } + Button { + text: "Easy" + pressed: game.difficulty == 0.2 + onClicked: { game.difficulty = 0.2 } + } + } + } + + + Text { + id: messageDisplay + anchors.centerIn: parent + color: "blue" + style: Text.Outline; styleColor: "white" + font.pixelSize: 50; font.bold: true + visible: false + + Timer { + running: messageDisplay.visible + onTriggered: { + messageDisplay.visible = false; + Logic.restartGame(); + } + } + } +} diff --git a/examples/qml/toys/tvtennis/tvtennis.qml b/examples/qml/toys/tvtennis/tvtennis.qml new file mode 100644 index 0000000000..63866e3ce6 --- /dev/null +++ b/examples/qml/toys/tvtennis/tvtennis.qml @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: page + width: 640; height: 480 + color: "Black" + + // Make a ball to bounce + Rectangle { + id: ball + + // Add a property for the target y coordinate + property variant direction : "right" + + x: 20; width: 20; height: 20; z: 1 + color: "Lime" + + // Move the ball to the right and back to the left repeatedly + SequentialAnimation on x { + loops: Animation.Infinite + NumberAnimation { to: page.width - 40; duration: 2000 } + PropertyAction { target: ball; property: "direction"; value: "left" } + NumberAnimation { to: 20; duration: 2000 } + PropertyAction { target: ball; property: "direction"; value: "right" } + } + + // Make y move with a velocity of 200 + Behavior on y { SpringAnimation{ velocity: 200; } + } + + Component.onCompleted: y = page.height-10; // start the ball motion + + // Detect the ball hitting the top or bottom of the view and bounce it + onYChanged: { + if (y <= 0) { + y = page.height - 20; + } else if (y >= page.height - 20) { + y = 0; + } + } + } + + // Place bats to the left and right of the view, following the y + // coordinates of the ball. + Rectangle { + id: leftBat + color: "Lime" + x: 2; width: 20; height: 90 + y: ball.direction == 'left' ? ball.y - 45 : page.height/2 -45; + Behavior on y { SpringAnimation{ velocity: 300 } } + } + Rectangle { + id: rightBat + color: "Lime" + x: page.width - 22; width: 20; height: 90 + y: ball.direction == 'right' ? ball.y - 45 : page.height/2 -45; + Behavior on y { SpringAnimation{ velocity: 300 } } + } + + // The rest, to make it look realistic, if neither ever scores... + Rectangle { color: "Lime"; x: page.width/2-80; y: 0; width: 40; height: 60 } + Rectangle { color: "Black"; x: page.width/2-70; y: 10; width: 20; height: 40 } + Rectangle { color: "Lime"; x: page.width/2+40; y: 0; width: 40; height: 60 } + Rectangle { color: "Black"; x: page.width/2+50; y: 10; width: 20; height: 40 } + Repeater { + model: page.height / 20 + Rectangle { color: "Lime"; x: page.width/2-5; y: index * 20; width: 10; height: 10 } + } +} diff --git a/examples/qml/tutorials/dynamicview/dynamicview1/PetsModel.qml b/examples/qml/tutorials/dynamicview/dynamicview1/PetsModel.qml new file mode 100644 index 0000000000..f07613c968 --- /dev/null +++ b/examples/qml/tutorials/dynamicview/dynamicview1/PetsModel.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +ListModel { + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } +//![0] + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Schrödinger" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" + } +//![1] +} +//![1] diff --git a/examples/qml/tutorials/dynamicview/dynamicview1/dynamicview.qml b/examples/qml/tutorials/dynamicview/dynamicview1/dynamicview.qml new file mode 100644 index 0000000000..1a9dd453ce --- /dev/null +++ b/examples/qml/tutorials/dynamicview/dynamicview1/dynamicview.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + id: root + + width: 300; height: 400 + +//![1] + Component { + id: dragDelegate + + Rectangle { + id: content + + anchors { left: parent.left; right: parent.right } + height: column.implicitHeight + 4 + + border.width: 1 + border.color: "lightsteelblue" + + radius: 2 + + Column { + id: column + anchors { fill: parent; margins: 2 } + + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + Text { text: 'Size: ' + size } + } + } + } +//![1] +//![2] + ListView { + id: view + + anchors { fill: parent; margins: 2 } + + model: PetsModel {} + delegate: dragDelegate + + spacing: 4 + cacheBuffer: 50 + } +//![2] +} +//![0] diff --git a/examples/qml/tutorials/dynamicview/dynamicview2/PetsModel.qml b/examples/qml/tutorials/dynamicview/dynamicview2/PetsModel.qml new file mode 100644 index 0000000000..4f2087d95e --- /dev/null +++ b/examples/qml/tutorials/dynamicview/dynamicview2/PetsModel.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListModel { + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Schrödinger" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" + } +} diff --git a/examples/qml/tutorials/dynamicview/dynamicview2/dynamicview.qml b/examples/qml/tutorials/dynamicview/dynamicview2/dynamicview.qml new file mode 100644 index 0000000000..9e654a685c --- /dev/null +++ b/examples/qml/tutorials/dynamicview/dynamicview2/dynamicview.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: root + + width: 300; height: 400 + +//![0] + Component { + id: dragDelegate + +//![1] + MouseArea { + id: dragArea + + property bool held: false + + anchors { left: parent.left; right: parent.right } + height: content.height + + drag.target: held ? content : undefined + drag.axis: Drag.YAxis + + onPressAndHold: held = true + onReleased: held = false + + Rectangle { + id: content +//![1] + anchors { + horizontalCenter: parent.horizontalCenter + verticalCenter: parent.verticalCenter + } + width: dragArea.width; height: column.implicitHeight + 4 + + border.width: 1 + border.color: "lightsteelblue" +//![3] + color: dragArea.held ? "lightsteelblue" : "white" + Behavior on color { ColorAnimation { duration: 100 } } +//![3] + radius: 2 +//![4] + states: State { + when: dragArea.held + + ParentChange { target: content; parent: root } + AnchorChanges { + target: content + anchors { horizontalCenter: undefined; verticalCenter: undefined } + } + } +//![4] + Column { + id: column + anchors { fill: parent; margins: 2 } + + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + Text { text: 'Size: ' + size } + } +//![2] + } + } +//![2] + } +//![0] + + ListView { + id: view + + anchors { fill: parent; margins: 2 } + + model: PetsModel {} + delegate: dragDelegate + + spacing: 4 + cacheBuffer: 50 + } +} diff --git a/examples/qml/tutorials/dynamicview/dynamicview3/PetsModel.qml b/examples/qml/tutorials/dynamicview/dynamicview3/PetsModel.qml new file mode 100644 index 0000000000..4f2087d95e --- /dev/null +++ b/examples/qml/tutorials/dynamicview/dynamicview3/PetsModel.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListModel { + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Schrödinger" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" + } +} diff --git a/examples/qml/tutorials/dynamicview/dynamicview3/dynamicview.qml b/examples/qml/tutorials/dynamicview/dynamicview3/dynamicview.qml new file mode 100644 index 0000000000..5a579f78d9 --- /dev/null +++ b/examples/qml/tutorials/dynamicview/dynamicview3/dynamicview.qml @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +//![0] +Rectangle { + id: root + + width: 300; height: 400 + + Component { + id: dragDelegate + + MouseArea { + id: dragArea + + property bool held: false + + anchors { left: parent.left; right: parent.right } + height: content.height + + drag.target: held ? content : undefined + drag.axis: Drag.YAxis + + onPressAndHold: held = true + onReleased: held = false + + Rectangle { + id: content +//![0] + anchors { + horizontalCenter: parent.horizontalCenter + verticalCenter: parent.verticalCenter + } + width: dragArea.width; height: column.implicitHeight + 4 + + border.width: 1 + border.color: "lightsteelblue" + + color: dragArea.held ? "lightsteelblue" : "white" + Behavior on color { ColorAnimation { duration: 100 } } + + radius: 2 +//![1] + Drag.active: dragArea.held + Drag.source: dragArea + Drag.hotSpot.x: width / 2 + Drag.hotSpot.y: height / 2 +//![1] + states: State { + when: dragArea.held + + ParentChange { target: content; parent: root } + AnchorChanges { + target: content + anchors { horizontalCenter: undefined; verticalCenter: undefined } + } + } + + Column { + id: column + anchors { fill: parent; margins: 2 } + + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + Text { text: 'Size: ' + size } + } +//![2] + } +//![3] + DropArea { + anchors { fill: parent; margins: 10 } + + onEntered: { + visualModel.items.move( + drag.source.VisualDataModel.itemsIndex, + dragArea.VisualDataModel.itemsIndex) + } + } +//![3] + } + } +//![2] +//![4] + VisualDataModel { + id: visualModel + + model: PetsModel {} + delegate: dragDelegate + } + + ListView { + id: view + + anchors { fill: parent; margins: 2 } + + model: visualModel + + spacing: 4 + cacheBuffer: 50 + } +//![4] +//![5] +} +//![5] diff --git a/examples/qml/tutorials/dynamicview/dynamicview4/ListSelector.qml b/examples/qml/tutorials/dynamicview/dynamicview4/ListSelector.qml new file mode 100644 index 0000000000..c6b8287beb --- /dev/null +++ b/examples/qml/tutorials/dynamicview/dynamicview4/ListSelector.qml @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: selector + + property alias list: view.model + property alias selectedIndex: view.currentIndex + property alias label: labelText.text + property bool expanded + + width: 100; height: labelText.implicitHeight + 26 + + Rectangle { + anchors { left: parent.left; right: parent.right; bottom: parent.bottom; } + + height: labelText.implicitHeight + 4 + (expanded ? 20 * view.count : 20) + Behavior on height { NumberAnimation { duration: 300 } } + + radius: 2 + border.width: 1 + border.color: "yellow" + color: "yellow" + + MouseArea { + anchors.fill: parent + + onClicked: selector.expanded = !selector.expanded + + Text { + id: labelText + anchors { left: parent.left; top: parent.top; margins: 2 } + } + + Rectangle { + anchors { + left: parent.left; top: labelText.bottom; + right: parent.right; bottom: parent.bottom; + margins: 2 + leftMargin: 10 + } + + radius: 2 + color: "white" + + ListView { + id: view + + anchors.fill: parent + + clip: true + + delegate: Text { + anchors { left: parent.left; right: parent.right } + height: 20 + + verticalAlignment: Text.AlignVCenter + + text: modelData + + MouseArea { + anchors.fill: parent + + onClicked: { + view.currentIndex = index + selector.expanded = !selector.expanded + } + } + } + highlight: Rectangle { + anchors { left: parent.left; right: parent.right } + height: 20 + radius: 2 + + color: "yellow" + } + } + } + } + } +} diff --git a/examples/qml/tutorials/dynamicview/dynamicview4/PetsModel.qml b/examples/qml/tutorials/dynamicview/dynamicview4/PetsModel.qml new file mode 100644 index 0000000000..4f2087d95e --- /dev/null +++ b/examples/qml/tutorials/dynamicview/dynamicview4/PetsModel.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListModel { + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Schrödinger" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" + } +} diff --git a/examples/qml/tutorials/dynamicview/dynamicview4/dynamicview.qml b/examples/qml/tutorials/dynamicview/dynamicview4/dynamicview.qml new file mode 100644 index 0000000000..9bd4e0c438 --- /dev/null +++ b/examples/qml/tutorials/dynamicview/dynamicview4/dynamicview.qml @@ -0,0 +1,219 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: root + + width: 300; height: 400 + + Component { + id: dragDelegate + + MouseArea { + id: dragArea + + property bool held: false + + anchors { left: parent.left; right: parent.right } + height: content.height + + enabled: visualModel.sortOrder == visualModel.lessThan.length + + drag.target: held ? content : undefined + drag.axis: Drag.YAxis + + onPressAndHold: held = true + onReleased: held = false + + Rectangle { + id: content + + anchors { + horizontalCenter: parent.horizontalCenter + verticalCenter: parent.verticalCenter + } + width: dragArea.width; height: column.implicitHeight + 4 + + border.width: 1 + border.color: "lightsteelblue" + + color: dragArea.held ? "lightsteelblue" : "white" + Behavior on color { ColorAnimation { duration: 100 } } + + radius: 2 + + Drag.active: dragArea.held + Drag.source: dragArea + Drag.hotSpot.x: width / 2 + Drag.hotSpot.y: height / 2 + + states: State { + when: dragArea.held + + ParentChange { target: content; parent: root } + AnchorChanges { + target: content + anchors { horizontalCenter: undefined; verticalCenter: undefined } + } + } + + Column { + id: column + anchors { fill: parent; margins: 2 } + + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + Text { text: 'Size: ' + size } + } + } + + DropArea { + anchors { fill: parent; margins: 10 } + + onEntered: { + visualModel.items.move( + drag.source.VisualDataModel.itemsIndex, + dragArea.VisualDataModel.itemsIndex) + } + } + } + } +//![0] + VisualDataModel { + id: visualModel +//![4] + property var lessThan: [ + function(left, right) { return left.name < right.name }, + function(left, right) { return left.type < right.type }, + function(left, right) { return left.age < right.age }, + function(left, right) { + if (left.size == "Small") + return true + else if (right.size == "Small") + return false + else if (left.size == "Medium") + return true + else + return false + } + ] +//![4] +//![6] + + property int sortOrder: orderSelector.selectedIndex + onSortOrderChanged: items.setGroups(0, items.count, "unsorted") + +//![6] +//![3] + function insertPosition(lessThan, item) { + var lower = 0 + var upper = items.count + while (lower < upper) { + var middle = Math.floor(lower + (upper - lower) / 2) + var result = lessThan(item.model, items.get(middle).model); + if (result) { + upper = middle + } else { + lower = middle + 1 + } + } + return lower + } + + function sort(lessThan) { + while (unsortedItems.count > 0) { + var item = unsortedItems.get(0) + var index = insertPosition(lessThan, item) + + item.groups = "items" + items.move(item.itemsIndex, index) + } + } +//![3] + +//![1] + items.includeByDefault: false +//![5] + groups: VisualDataGroup { + id: unsortedItems + name: "unsorted" + + includeByDefault: true +//![1] + onChanged: { + if (visualModel.sortOrder == visualModel.lessThan.length) + setGroups(0, count, "items") + else + visualModel.sort(visualModel.lessThan[visualModel.sortOrder]) + } +//![2] + } +//![2] +//![5] + model: PetsModel {} + delegate: dragDelegate + } +//![0] + ListView { + id: view + + anchors { + left: parent.left; top: parent.top; right: parent.right; bottom: orderSelector.top; + margins: 2 + } + + model: visualModel + + spacing: 4 + cacheBuffer: 50 + } + + ListSelector { + id: orderSelector + + anchors { left: parent.left; right: parent.right; bottom: parent.bottom; margins: 2 } + + label: "Sort By" + list: [ "Name", "Type", "Age", "Size", "Custom" ] + } +} diff --git a/examples/qml/tutorials/extending/chapter1-basics/app.qml b/examples/qml/tutorials/extending/chapter1-basics/app.qml new file mode 100644 index 0000000000..6f0c1d3a23 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter1-basics/app.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Charts 1.0 +import QtQuick 2.0 + +Item { + width: 300; height: 200 + + PieChart { + id: aPieChart + anchors.centerIn: parent + width: 100; height: 100 + name: "A simple pie chart" + color: "red" + } + + Text { + anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } + text: aPieChart.name + } +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter1-basics/chapter1-basics.pro b/examples/qml/tutorials/extending/chapter1-basics/chapter1-basics.pro new file mode 100644 index 0000000000..8ed66f8b66 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter1-basics/chapter1-basics.pro @@ -0,0 +1,5 @@ +QT += qml quick + +HEADERS += piechart.h +SOURCES += piechart.cpp \ + main.cpp diff --git a/examples/qml/tutorials/extending/chapter1-basics/main.cpp b/examples/qml/tutorials/extending/chapter1-basics/main.cpp new file mode 100644 index 0000000000..ed9e412bd6 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter1-basics/main.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +#include "piechart.h" +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("Charts", 1, 0, "PieChart"); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("app.qml")); + view.show(); + return app.exec(); +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter1-basics/piechart.cpp b/examples/qml/tutorials/extending/chapter1-basics/piechart.cpp new file mode 100644 index 0000000000..bc81d6a3a0 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter1-basics/piechart.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include + +//![0] +PieChart::PieChart(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} +//![0] + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +QColor PieChart::color() const +{ + return m_color; +} + +void PieChart::setColor(const QColor &color) +{ + m_color = color; +} + +//![1] +void PieChart::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::HighQualityAntialiasing, true); + painter->drawPie(boundingRect(), 90 * 16, 290 * 16); +} +//![1] + diff --git a/examples/qml/tutorials/extending/chapter1-basics/piechart.h b/examples/qml/tutorials/extending/chapter1-basics/piechart.h new file mode 100644 index 0000000000..71a8786e7d --- /dev/null +++ b/examples/qml/tutorials/extending/chapter1-basics/piechart.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIECHART_H +#define PIECHART_H + +//![0] +#include +#include + +class PieChart : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(QColor color READ color WRITE setColor) + +public: + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + + QColor color() const; + void setColor(const QColor &color); + + void paint(QPainter *painter); + +private: + QString m_name; + QColor m_color; +}; +//![0] + +#endif + diff --git a/examples/qml/tutorials/extending/chapter2-methods/app.qml b/examples/qml/tutorials/extending/chapter2-methods/app.qml new file mode 100644 index 0000000000..eee0933734 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter2-methods/app.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Charts 1.0 +import QtQuick 2.0 + +Item { + width: 300; height: 200 + + PieChart { + id: aPieChart + anchors.centerIn: parent + width: 100; height: 100 + color: "red" + + onChartCleared: console.log("The chart has been cleared") + } + + MouseArea { + anchors.fill: parent + onClicked: aPieChart.clearChart() + } + + Text { + anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } + text: "Click anywhere to clear the chart" + } +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter2-methods/chapter2-methods.pro b/examples/qml/tutorials/extending/chapter2-methods/chapter2-methods.pro new file mode 100644 index 0000000000..8ed66f8b66 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter2-methods/chapter2-methods.pro @@ -0,0 +1,5 @@ +QT += qml quick + +HEADERS += piechart.h +SOURCES += piechart.cpp \ + main.cpp diff --git a/examples/qml/tutorials/extending/chapter2-methods/main.cpp b/examples/qml/tutorials/extending/chapter2-methods/main.cpp new file mode 100644 index 0000000000..ed9e412bd6 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter2-methods/main.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +#include "piechart.h" +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("Charts", 1, 0, "PieChart"); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("app.qml")); + view.show(); + return app.exec(); +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter2-methods/piechart.cpp b/examples/qml/tutorials/extending/chapter2-methods/piechart.cpp new file mode 100644 index 0000000000..71be74e943 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter2-methods/piechart.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include + +PieChart::PieChart(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +QColor PieChart::color() const +{ + return m_color; +} + +void PieChart::setColor(const QColor &color) +{ + m_color = color; +} + +void PieChart::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::HighQualityAntialiasing, true); + painter->drawPie(boundingRect(), 90 * 16, 290 * 16); +} + +//![0] +void PieChart::clearChart() +{ + setColor(QColor(Qt::transparent)); + update(); + + emit chartCleared(); +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter2-methods/piechart.h b/examples/qml/tutorials/extending/chapter2-methods/piechart.h new file mode 100644 index 0000000000..7650d6e8d7 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter2-methods/piechart.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIECHART_H +#define PIECHART_H + +#include +#include + +//![0] +class PieChart : public QQuickPaintedItem +{ +//![0] + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(QColor color READ color WRITE setColor) + +//![1] +public: +//![1] + + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + + QColor color() const; + void setColor(const QColor &color); + + void paint(QPainter *painter); + +//![2] + Q_INVOKABLE void clearChart(); + +signals: + void chartCleared(); +//![2] + +private: + QString m_name; + QColor m_color; + +//![3] +}; +//![3] + +#endif + diff --git a/examples/qml/tutorials/extending/chapter3-bindings/app.qml b/examples/qml/tutorials/extending/chapter3-bindings/app.qml new file mode 100644 index 0000000000..4ad929132c --- /dev/null +++ b/examples/qml/tutorials/extending/chapter3-bindings/app.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Charts 1.0 +import QtQuick 2.0 + +Item { + width: 300; height: 200 + + Row { + anchors.centerIn: parent + spacing: 20 + + PieChart { + id: chartA + width: 100; height: 100 + color: "red" + } + + PieChart { + id: chartB + width: 100; height: 100 + color: chartA.color + } + } + + MouseArea { + anchors.fill: parent + onClicked: { chartA.color = "blue" } + } + + Text { + anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } + text: "Click anywhere to change the chart color" + } +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter3-bindings/chapter3-bindings.pro b/examples/qml/tutorials/extending/chapter3-bindings/chapter3-bindings.pro new file mode 100644 index 0000000000..8ed66f8b66 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter3-bindings/chapter3-bindings.pro @@ -0,0 +1,5 @@ +QT += qml quick + +HEADERS += piechart.h +SOURCES += piechart.cpp \ + main.cpp diff --git a/examples/qml/tutorials/extending/chapter3-bindings/main.cpp b/examples/qml/tutorials/extending/chapter3-bindings/main.cpp new file mode 100644 index 0000000000..ed9e412bd6 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter3-bindings/main.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +#include "piechart.h" +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("Charts", 1, 0, "PieChart"); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("app.qml")); + view.show(); + return app.exec(); +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter3-bindings/piechart.cpp b/examples/qml/tutorials/extending/chapter3-bindings/piechart.cpp new file mode 100644 index 0000000000..2a392125da --- /dev/null +++ b/examples/qml/tutorials/extending/chapter3-bindings/piechart.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include + +PieChart::PieChart(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +QColor PieChart::color() const +{ + return m_color; +} + +//![0] +void PieChart::setColor(const QColor &color) +{ + if (color != m_color) { + m_color = color; + update(); // repaint with the new color + emit colorChanged(); + } +} +//![0] + +void PieChart::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::HighQualityAntialiasing, true); + painter->drawPie(boundingRect(), 90 * 16, 290 * 16); +} + +void PieChart::clearChart() +{ + setColor(QColor(Qt::transparent)); + update(); +} diff --git a/examples/qml/tutorials/extending/chapter3-bindings/piechart.h b/examples/qml/tutorials/extending/chapter3-bindings/piechart.h new file mode 100644 index 0000000000..77075b5727 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter3-bindings/piechart.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIECHART_H +#define PIECHART_H + +#include +#include + +//![0] +class PieChart : public QQuickPaintedItem +{ +//![0] + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + +//![1] + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) +public: +//![1] + + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + + QColor color() const; + void setColor(const QColor &color); + + void paint(QPainter *painter); + + Q_INVOKABLE void clearChart(); + +//![2] +signals: + void colorChanged(); +//![2] + +private: + QString m_name; + QColor m_color; + +//![3] +}; +//![3] + +#endif + diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/app.qml b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/app.qml new file mode 100644 index 0000000000..06490773f4 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/app.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Charts 1.0 +import QtQuick 2.0 + +Item { + width: 300; height: 200 + + PieChart { + id: chart + anchors.centerIn: parent + width: 100; height: 100 + + pieSlice: PieSlice { + anchors.fill: parent + color: "red" + } + } + + Component.onCompleted: console.log("The pie is colored " + chart.pieSlice.color) +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro new file mode 100644 index 0000000000..23eb222ea3 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro @@ -0,0 +1,7 @@ +QT += qml quick + +HEADERS += piechart.h \ + pieslice.h +SOURCES += piechart.cpp \ + pieslice.cpp \ + main.cpp diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/main.cpp b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/main.cpp new file mode 100644 index 0000000000..537ea766fc --- /dev/null +++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/main.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include "pieslice.h" + +#include +#include + +//![0] +int main(int argc, char *argv[]) +{ +//![0] + QGuiApplication app(argc, argv); + + qmlRegisterType("Charts", 1, 0, "PieChart"); + +//![1] + qmlRegisterType("Charts", 1, 0, "PieSlice"); +//![1] + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("app.qml")); + view.show(); + return app.exec(); + +//![2] +} +//![2] diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp new file mode 100644 index 0000000000..3cf9bdc00c --- /dev/null +++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include "pieslice.h" + +PieChart::PieChart(QQuickItem *parent) + : QQuickItem(parent) +{ +} + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +PieSlice *PieChart::pieSlice() const +{ + return m_pieSlice; +} + +//![0] +void PieChart::setPieSlice(PieSlice *pieSlice) +{ + m_pieSlice = pieSlice; + pieSlice->setParentItem(this); +} +//![0] + diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.h b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.h new file mode 100644 index 0000000000..b89db5a2b1 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIECHART_H +#define PIECHART_H + +#include + +class PieSlice; + +//![0] +class PieChart : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(PieSlice* pieSlice READ pieSlice WRITE setPieSlice) +//![0] + Q_PROPERTY(QString name READ name WRITE setName) + +//![1] +public: +//![1] + + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + +//![2] + PieSlice *pieSlice() const; + void setPieSlice(PieSlice *pieSlice); +//![2] + +private: + QString m_name; + PieSlice *m_pieSlice; + +//![3] +}; +//![3] + +#endif + diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp new file mode 100644 index 0000000000..654a46fc8d --- /dev/null +++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "pieslice.h" + +#include + +PieSlice::PieSlice(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} + +QColor PieSlice::color() const +{ + return m_color; +} + +void PieSlice::setColor(const QColor &color) +{ + m_color = color; +} + +void PieSlice::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::HighQualityAntialiasing, true); + painter->drawPie(boundingRect(), 90 * 16, 290 * 16); +} + diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.h b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.h new file mode 100644 index 0000000000..8fc445d471 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIESLICE_H +#define PIESLICE_H + +#include +#include + +//![0] +class PieSlice : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(QColor color READ color WRITE setColor) + +public: + PieSlice(QQuickItem *parent = 0); + + QColor color() const; + void setColor(const QColor &color); + + void paint(QPainter *painter); + +private: + QColor m_color; +}; +//![0] + +#endif + diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/app.qml b/examples/qml/tutorials/extending/chapter5-listproperties/app.qml new file mode 100644 index 0000000000..37b0626948 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter5-listproperties/app.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Charts 1.0 +import QtQuick 2.0 + +Item { + width: 300; height: 200 + + PieChart { + anchors.centerIn: parent + width: 100; height: 100 + + slices: [ + PieSlice { + anchors.fill: parent + color: "red" + fromAngle: 0; angleSpan: 110 + }, + PieSlice { + anchors.fill: parent + color: "black" + fromAngle: 110; angleSpan: 50 + }, + PieSlice { + anchors.fill: parent + color: "blue" + fromAngle: 160; angleSpan: 100 + } + ] + } +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro b/examples/qml/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro new file mode 100644 index 0000000000..23eb222ea3 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro @@ -0,0 +1,7 @@ +QT += qml quick + +HEADERS += piechart.h \ + pieslice.h +SOURCES += piechart.cpp \ + pieslice.cpp \ + main.cpp diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/main.cpp b/examples/qml/tutorials/extending/chapter5-listproperties/main.cpp new file mode 100644 index 0000000000..59587733eb --- /dev/null +++ b/examples/qml/tutorials/extending/chapter5-listproperties/main.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include "pieslice.h" + +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("Charts", 1, 0, "PieChart"); + qmlRegisterType("Charts", 1, 0, "PieSlice"); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("app.qml")); + view.show(); + return app.exec(); +} diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/piechart.cpp b/examples/qml/tutorials/extending/chapter5-listproperties/piechart.cpp new file mode 100644 index 0000000000..9c2c6accf3 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter5-listproperties/piechart.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include "pieslice.h" + +PieChart::PieChart(QQuickItem *parent) + : QQuickItem(parent) +{ +} + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +//![0] +QQmlListProperty PieChart::slices() +{ + return QQmlListProperty(this, 0, &PieChart::append_slice); +} + +void PieChart::append_slice(QQmlListProperty *list, PieSlice *slice) +{ + PieChart *chart = qobject_cast(list->object); + if (chart) { + slice->setParentItem(chart); + chart->m_slices.append(slice); + } +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/piechart.h b/examples/qml/tutorials/extending/chapter5-listproperties/piechart.h new file mode 100644 index 0000000000..6c17bc1258 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter5-listproperties/piechart.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIECHART_H +#define PIECHART_H + +#include + +class PieSlice; + +//![0] +class PieChart : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty slices READ slices) +//![0] + Q_PROPERTY(QString name READ name WRITE setName) + +//![1] +public: +//![1] + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + +//![2] + QQmlListProperty slices(); + +private: + static void append_slice(QQmlListProperty *list, PieSlice *slice); + + QString m_name; + QList m_slices; +}; +//![2] + +#endif + diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.cpp b/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.cpp new file mode 100644 index 0000000000..5bca2d58d8 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "pieslice.h" + +#include + +PieSlice::PieSlice(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} + +QColor PieSlice::color() const +{ + return m_color; +} + +void PieSlice::setColor(const QColor &color) +{ + m_color = color; +} + +int PieSlice::fromAngle() const +{ + return m_fromAngle; +} + +void PieSlice::setFromAngle(int angle) +{ + m_fromAngle = angle; +} + +int PieSlice::angleSpan() const +{ + return m_angleSpan; +} + +void PieSlice::setAngleSpan(int angle) +{ + m_angleSpan = angle; +} + +void PieSlice::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::HighQualityAntialiasing, true); + painter->drawPie(boundingRect(), m_fromAngle * 16, m_angleSpan * 16); +} + diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.h b/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.h new file mode 100644 index 0000000000..f6497fcbae --- /dev/null +++ b/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIESLICE_H +#define PIESLICE_H + +#include +#include + +//![0] +class PieSlice : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle) + Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan) +//![0] + +public: + PieSlice(QQuickItem *parent = 0); + + QColor color() const; + void setColor(const QColor &color); + + int fromAngle() const; + void setFromAngle(int angle); + + int angleSpan() const; + void setAngleSpan(int span); + + void paint(QPainter *painter); + +private: + QColor m_color; + int m_fromAngle; + int m_angleSpan; +}; + +#endif + diff --git a/examples/qml/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir b/examples/qml/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir new file mode 100644 index 0000000000..72650d8243 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir @@ -0,0 +1 @@ +plugin chartsplugin \ No newline at end of file diff --git a/examples/qml/tutorials/extending/chapter6-plugins/app.qml b/examples/qml/tutorials/extending/chapter6-plugins/app.qml new file mode 100644 index 0000000000..b6eac44e27 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/app.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import "ChartsPlugin" 1.0 + +Item { + width: 300; height: 200 + + PieChart { + anchors.centerIn: parent + width: 100; height: 100 + + slices: [ + PieSlice { + anchors.fill: parent + color: "red" + fromAngle: 0; angleSpan: 110 + }, + PieSlice { + anchors.fill: parent + color: "black" + fromAngle: 110; angleSpan: 50 + }, + PieSlice { + anchors.fill: parent + color: "blue" + fromAngle: 160; angleSpan: 100 + } + ] + } +} + diff --git a/examples/qml/tutorials/extending/chapter6-plugins/chapter6-plugins.pro b/examples/qml/tutorials/extending/chapter6-plugins/chapter6-plugins.pro new file mode 100644 index 0000000000..75f88b2eaa --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/chapter6-plugins.pro @@ -0,0 +1,18 @@ +TEMPLATE = lib +CONFIG += qt plugin +QT += qml quick + +DESTDIR = ChartsPlugin +TARGET = chartsplugin + +OBJECTS_DIR = tmp +MOC_DIR = tmp + +HEADERS += piechart.h \ + pieslice.h \ + chartsplugin.h + +SOURCES += piechart.cpp \ + pieslice.cpp \ + chartsplugin.cpp + diff --git a/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.cpp b/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.cpp new file mode 100644 index 0000000000..f95cf1003b --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "chartsplugin.h" +//![0] +#include "piechart.h" +#include "pieslice.h" +#include + +void ChartsPlugin::registerTypes(const char *uri) +{ + qmlRegisterType(uri, 1, 0, "PieChart"); + qmlRegisterType(uri, 1, 0, "PieSlice"); +} + +Q_EXPORT_PLUGIN2(chartsplugin, ChartsPlugin); +//![0] + diff --git a/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.h b/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.h new file mode 100644 index 0000000000..2dc477f794 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef CHARTSPLUGIN_H +#define CHARTSPLUGIN_H + +//![0] +#include + +class ChartsPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT +public: + void registerTypes(const char *uri); +}; +//![0] + +#endif + diff --git a/examples/qml/tutorials/extending/chapter6-plugins/piechart.cpp b/examples/qml/tutorials/extending/chapter6-plugins/piechart.cpp new file mode 100644 index 0000000000..b00f4139be --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/piechart.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include "pieslice.h" + +PieChart::PieChart(QQuickItem *parent) + : QQuickItem(parent) +{ +} + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +QQmlListProperty PieChart::slices() +{ + return QQmlListProperty(this, 0, &PieChart::append_slice); +} + +void PieChart::append_slice(QQmlListProperty *list, PieSlice *slice) +{ + PieChart *chart = qobject_cast(list->object); + if (chart) { + slice->setParentItem(chart); + chart->m_slices.append(slice); + } +} + diff --git a/examples/qml/tutorials/extending/chapter6-plugins/piechart.h b/examples/qml/tutorials/extending/chapter6-plugins/piechart.h new file mode 100644 index 0000000000..2ee8108784 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/piechart.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIECHART_H +#define PIECHART_H + +#include + +class PieSlice; + +class PieChart : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty slices READ slices) + Q_PROPERTY(QString name READ name WRITE setName) + +public: + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + + QQmlListProperty slices(); + +private: + static void append_slice(QQmlListProperty *list, PieSlice *slice); + + QString m_name; + QList m_slices; +}; + +#endif + diff --git a/examples/qml/tutorials/extending/chapter6-plugins/pieslice.cpp b/examples/qml/tutorials/extending/chapter6-plugins/pieslice.cpp new file mode 100644 index 0000000000..5bca2d58d8 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/pieslice.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "pieslice.h" + +#include + +PieSlice::PieSlice(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} + +QColor PieSlice::color() const +{ + return m_color; +} + +void PieSlice::setColor(const QColor &color) +{ + m_color = color; +} + +int PieSlice::fromAngle() const +{ + return m_fromAngle; +} + +void PieSlice::setFromAngle(int angle) +{ + m_fromAngle = angle; +} + +int PieSlice::angleSpan() const +{ + return m_angleSpan; +} + +void PieSlice::setAngleSpan(int angle) +{ + m_angleSpan = angle; +} + +void PieSlice::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::HighQualityAntialiasing, true); + painter->drawPie(boundingRect(), m_fromAngle * 16, m_angleSpan * 16); +} + diff --git a/examples/qml/tutorials/extending/chapter6-plugins/pieslice.h b/examples/qml/tutorials/extending/chapter6-plugins/pieslice.h new file mode 100644 index 0000000000..8a636fb3e7 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/pieslice.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIESLICE_H +#define PIESLICE_H + +#include +#include + +class PieSlice : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle) + Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan) + +public: + PieSlice(QQuickItem *parent = 0); + + QColor color() const; + void setColor(const QColor &color); + + int fromAngle() const; + void setFromAngle(int angle); + + int angleSpan() const; + void setAngleSpan(int span); + + void paint(QPainter *painter); + +private: + QColor m_color; + int m_fromAngle; + int m_angleSpan; +}; + +#endif + diff --git a/examples/qml/tutorials/extending/extending.pro b/examples/qml/tutorials/extending/extending.pro new file mode 100644 index 0000000000..967473fda0 --- /dev/null +++ b/examples/qml/tutorials/extending/extending.pro @@ -0,0 +1,10 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + chapter1-basics \ + chapter2-methods \ + chapter3-bindings \ + chapter4-customPropertyTypes \ + chapter5-listproperties \ + chapter6-plugins + diff --git a/examples/qml/tutorials/helloworld/Cell.qml b/examples/qml/tutorials/helloworld/Cell.qml new file mode 100644 index 0000000000..7140dcb2c1 --- /dev/null +++ b/examples/qml/tutorials/helloworld/Cell.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +//![1] +Item { + id: container +//![4] + property alias cellColor: rectangle.color +//![4] +//![5] + signal clicked(color cellColor) +//![5] + + width: 40; height: 25 +//![1] + +//![2] + Rectangle { + id: rectangle + border.color: "white" + anchors.fill: parent + } +//![2] + +//![3] + MouseArea { + anchors.fill: parent + onClicked: container.clicked(container.cellColor) + } +//![3] +} +//![0] diff --git a/examples/qml/tutorials/helloworld/tutorial1.qml b/examples/qml/tutorials/helloworld/tutorial1.qml new file mode 100644 index 0000000000..f0eb42d696 --- /dev/null +++ b/examples/qml/tutorials/helloworld/tutorial1.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +//![3] +import QtQuick 2.0 +//![3] + +//![1] +Rectangle { + id: page + width: 500; height: 200 + color: "lightgray" +//![1] + +//![2] + Text { + id: helloText + text: "Hello world!" + y: 30 + anchors.horizontalCenter: page.horizontalCenter + font.pointSize: 24; font.bold: true + } +//![2] +} +//![0] diff --git a/examples/qml/tutorials/helloworld/tutorial2.qml b/examples/qml/tutorials/helloworld/tutorial2.qml new file mode 100644 index 0000000000..c5c045aace --- /dev/null +++ b/examples/qml/tutorials/helloworld/tutorial2.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + id: page + width: 500; height: 200 + color: "lightgray" + + Text { + id: helloText + text: "Hello world!" + y: 30 + anchors.horizontalCenter: page.horizontalCenter + font.pointSize: 24; font.bold: true + } + + Grid { + id: colorPicker + x: 4; anchors.bottom: page.bottom; anchors.bottomMargin: 4 + rows: 2; columns: 3; spacing: 3 + +//![1] + Cell { cellColor: "red"; onClicked: helloText.color = cellColor } +//![1] + Cell { cellColor: "green"; onClicked: helloText.color = cellColor } + Cell { cellColor: "blue"; onClicked: helloText.color = cellColor } + Cell { cellColor: "yellow"; onClicked: helloText.color = cellColor } + Cell { cellColor: "steelblue"; onClicked: helloText.color = cellColor } + Cell { cellColor: "black"; onClicked: helloText.color = cellColor } + } +} +//![0] diff --git a/examples/qml/tutorials/helloworld/tutorial3.qml b/examples/qml/tutorials/helloworld/tutorial3.qml new file mode 100644 index 0000000000..c804bfca1d --- /dev/null +++ b/examples/qml/tutorials/helloworld/tutorial3.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + id: page + width: 500; height: 200 + color: "lightgray" + + Text { + id: helloText + text: "Hello world!" + y: 30 + anchors.horizontalCenter: page.horizontalCenter + font.pointSize: 24; font.bold: true + +//![1] + MouseArea { id: mouseArea; anchors.fill: parent } +//![1] + +//![2] + states: State { + name: "down"; when: mouseArea.pressed == true + PropertyChanges { target: helloText; y: 160; rotation: 180; color: "red" } + } +//![2] + +//![3] + transitions: Transition { + from: ""; to: "down"; reversible: true + ParallelAnimation { + NumberAnimation { properties: "y,rotation"; duration: 500; easing.type: Easing.InOutQuad } + ColorAnimation { duration: 500 } + } + } +//![3] + } + + Grid { + id: colorPicker + x: 4; anchors.bottom: page.bottom; anchors.bottomMargin: 4 + rows: 2; columns: 3; spacing: 3 + + Cell { cellColor: "red"; onClicked: helloText.color = cellColor } + Cell { cellColor: "green"; onClicked: helloText.color = cellColor } + Cell { cellColor: "blue"; onClicked: helloText.color = cellColor } + Cell { cellColor: "yellow"; onClicked: helloText.color = cellColor } + Cell { cellColor: "steelblue"; onClicked: helloText.color = cellColor } + Cell { cellColor: "black"; onClicked: helloText.color = cellColor } + } +} +//![0] diff --git a/examples/qml/tutorials/samegame/samegame1/Block.qml b/examples/qml/tutorials/samegame/samegame1/Block.qml new file mode 100644 index 0000000000..32ef8c2bba --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame1/Block.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + id: block + + Image { + id: img + anchors.fill: parent + source: "../shared/pics/redStone.png" + } +} +//![0] diff --git a/examples/qml/tutorials/samegame/samegame1/Button.qml b/examples/qml/tutorials/samegame/samegame1/Button.qml new file mode 100644 index 0000000000..6d1d1268de --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame1/Button.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + id: container + + property string text: "Button" + + signal clicked + + width: buttonLabel.width + 20; height: buttonLabel.height + 5 + border { width: 1; color: Qt.darker(activePalette.button) } + smooth: true + radius: 8 + + // color the button with a gradient + gradient: Gradient { + GradientStop { + position: 0.0 + color: { + if (mouseArea.pressed) + return activePalette.dark + else + return activePalette.light + } + } + GradientStop { position: 1.0; color: activePalette.button } + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked(); + } + + Text { + id: buttonLabel + anchors.centerIn: container + color: activePalette.buttonText + text: container.text + } +} +//![0] diff --git a/examples/qml/tutorials/samegame/samegame1/samegame.qml b/examples/qml/tutorials/samegame/samegame1/samegame.qml new file mode 100644 index 0000000000..73e2cc31fd --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame1/samegame.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + id: screen + + width: 490; height: 720 + + SystemPalette { id: activePalette } + + Item { + width: parent.width + anchors { top: parent.top; bottom: toolBar.top } + + Image { + id: background + anchors.fill: parent + source: "../shared/pics/background.jpg" + fillMode: Image.PreserveAspectCrop + } + } + + Rectangle { + id: toolBar + width: parent.width; height: 30 + color: activePalette.window + anchors.bottom: screen.bottom + + Button { + anchors { left: parent.left; verticalCenter: parent.verticalCenter } + text: "New Game" + onClicked: console.log("This doesn't do anything yet...") + } + + Text { + id: score + anchors { right: parent.right; verticalCenter: parent.verticalCenter } + text: "Score: Who knows?" + } + } +} +//![0] diff --git a/examples/qml/tutorials/samegame/samegame1/samegame1.qmlproject b/examples/qml/tutorials/samegame/samegame1/samegame1.qmlproject new file mode 100644 index 0000000000..42ffacf4f8 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame1/samegame1.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "samegame.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/tutorials/samegame/samegame2/Block.qml b/examples/qml/tutorials/samegame/samegame2/Block.qml new file mode 100644 index 0000000000..8056b39480 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame2/Block.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: block + + Image { + id: img + anchors.fill: parent + source: "../shared/pics/redStone.png" + } +} diff --git a/examples/qml/tutorials/samegame/samegame2/Button.qml b/examples/qml/tutorials/samegame/samegame2/Button.qml new file mode 100644 index 0000000000..248c20cf0f --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame2/Button.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property string text: "Button" + + signal clicked + + width: buttonLabel.width + 20; height: buttonLabel.height + 5 + border { width: 1; color: Qt.darker(activePalette.button) } + smooth: true + radius: 8 + + // color the button with a gradient + gradient: Gradient { + GradientStop { + position: 0.0 + color: { + if (mouseArea.pressed) + return activePalette.dark + else + return activePalette.light + } + } + GradientStop { position: 1.0; color: activePalette.button } + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked(); + } + + Text { + id: buttonLabel + anchors.centerIn: container + color: activePalette.buttonText + text: container.text + } +} diff --git a/examples/qml/tutorials/samegame/samegame2/samegame.js b/examples/qml/tutorials/samegame/samegame2/samegame.js new file mode 100644 index 0000000000..c749dc17b1 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame2/samegame.js @@ -0,0 +1,63 @@ +//![0] +var blockSize = 40; +var maxColumn = 10; +var maxRow = 15; +var maxIndex = maxColumn * maxRow; +var board = new Array(maxIndex); +var component; + +//Index function used instead of a 2D array +function index(column, row) { + return column + (row * maxColumn); +} + +function startNewGame() { + //Delete blocks from previous game + for (var i = 0; i < maxIndex; i++) { + if (board[i] != null) + board[i].destroy(); + } + + //Calculate board size + maxColumn = Math.floor(background.width / blockSize); + maxRow = Math.floor(background.height / blockSize); + maxIndex = maxRow * maxColumn; + + //Initialize Board + board = new Array(maxIndex); + for (var column = 0; column < maxColumn; column++) { + for (var row = 0; row < maxRow; row++) { + board[index(column, row)] = null; + createBlock(column, row); + } + } +} + +function createBlock(column, row) { + if (component == null) + component = Qt.createComponent("Block.qml"); + + // Note that if Block.qml was not a local file, component.status would be + // Loading and we should wait for the component's statusChanged() signal to + // know when the file is downloaded and ready before calling createObject(). + if (component.status == Component.Ready) { + var dynamicObject = component.createObject(background); + if (dynamicObject == null) { + console.log("error creating block"); + console.log(component.errorString()); + return false; + } + dynamicObject.x = column * blockSize; + dynamicObject.y = row * blockSize; + dynamicObject.width = blockSize; + dynamicObject.height = blockSize; + board[index(column, row)] = dynamicObject; + } else { + console.log("error loading block component"); + console.log(component.errorString()); + return false; + } + return true; +} +//![0] + diff --git a/examples/qml/tutorials/samegame/samegame2/samegame.qml b/examples/qml/tutorials/samegame/samegame2/samegame.qml new file mode 100644 index 0000000000..c50010e97d --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame2/samegame.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +//![2] +import "samegame.js" as SameGame +//![2] + +Rectangle { + id: screen + + width: 490; height: 720 + + SystemPalette { id: activePalette } + + Item { + width: parent.width + anchors { top: parent.top; bottom: toolBar.top } + + Image { + id: background + anchors.fill: parent + source: "../shared/pics/background.jpg" + fillMode: Image.PreserveAspectCrop + } + } + + Rectangle { + id: toolBar + width: parent.width; height: 32 + color: activePalette.window + anchors.bottom: screen.bottom + +//![1] + Button { + anchors { left: parent.left; verticalCenter: parent.verticalCenter } + text: "New Game" + onClicked: SameGame.startNewGame() + } +//![1] + + Text { + id: score + anchors { right: parent.right; verticalCenter: parent.verticalCenter } + text: "Score: Who knows?" + } + } +} diff --git a/examples/qml/tutorials/samegame/samegame2/samegame2.qmlproject b/examples/qml/tutorials/samegame/samegame2/samegame2.qmlproject new file mode 100644 index 0000000000..42ffacf4f8 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame2/samegame2.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "samegame.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/tutorials/samegame/samegame3/Block.qml b/examples/qml/tutorials/samegame/samegame3/Block.qml new file mode 100644 index 0000000000..9c41048fcb --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame3/Block.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + id: block + + property int type: 0 + + Image { + id: img + + anchors.fill: parent + source: { + if (type == 0) + return "../shared/pics/redStone.png"; + else if (type == 1) + return "../shared/pics/blueStone.png"; + else + return "../shared/pics/greenStone.png"; + } + } +} +//![0] diff --git a/examples/qml/tutorials/samegame/samegame3/Button.qml b/examples/qml/tutorials/samegame/samegame3/Button.qml new file mode 100644 index 0000000000..248c20cf0f --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame3/Button.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property string text: "Button" + + signal clicked + + width: buttonLabel.width + 20; height: buttonLabel.height + 5 + border { width: 1; color: Qt.darker(activePalette.button) } + smooth: true + radius: 8 + + // color the button with a gradient + gradient: Gradient { + GradientStop { + position: 0.0 + color: { + if (mouseArea.pressed) + return activePalette.dark + else + return activePalette.light + } + } + GradientStop { position: 1.0; color: activePalette.button } + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked(); + } + + Text { + id: buttonLabel + anchors.centerIn: container + color: activePalette.buttonText + text: container.text + } +} diff --git a/examples/qml/tutorials/samegame/samegame3/Dialog.qml b/examples/qml/tutorials/samegame/samegame3/Dialog.qml new file mode 100644 index 0000000000..df1fa37d6a --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame3/Dialog.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + id: container + + function show(text) { + dialogText.text = text; + container.opacity = 1; + } + + function hide() { + container.opacity = 0; + } + + width: dialogText.width + 20 + height: dialogText.height + 20 + opacity: 0 + + Text { + id: dialogText + anchors.centerIn: parent + text: "" + } + + MouseArea { + anchors.fill: parent + onClicked: hide(); + } +} +//![0] diff --git a/examples/qml/tutorials/samegame/samegame3/samegame.js b/examples/qml/tutorials/samegame/samegame3/samegame.js new file mode 100644 index 0000000000..df5bdfb049 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame3/samegame.js @@ -0,0 +1,174 @@ +/* This script file handles the game logic */ +var maxColumn = 10; +var maxRow = 15; +var maxIndex = maxColumn * maxRow; +var board = new Array(maxIndex); +var component; + +//Index function used instead of a 2D array +function index(column, row) { + return column + (row * maxColumn); +} + +function startNewGame() { + //Calculate board size + maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize); + maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize); + maxIndex = maxRow * maxColumn; + + //Close dialogs + dialog.hide(); + + //Initialize Board + board = new Array(maxIndex); + gameCanvas.score = 0; + for (var column = 0; column < maxColumn; column++) { + for (var row = 0; row < maxRow; row++) { + board[index(column, row)] = null; + createBlock(column, row); + } + } +} + +function createBlock(column, row) { + if (component == null) + component = Qt.createComponent("Block.qml"); + + // Note that if Block.qml was not a local file, component.status would be + // Loading and we should wait for the component's statusChanged() signal to + // know when the file is downloaded and ready before calling createObject(). + if (component.status == Component.Ready) { + var dynamicObject = component.createObject(gameCanvas); + if (dynamicObject == null) { + console.log("error creating block"); + console.log(component.errorString()); + return false; + } + dynamicObject.type = Math.floor(Math.random() * 3); + dynamicObject.x = column * gameCanvas.blockSize; + dynamicObject.y = row * gameCanvas.blockSize; + dynamicObject.width = gameCanvas.blockSize; + dynamicObject.height = gameCanvas.blockSize; + board[index(column, row)] = dynamicObject; + } else { + console.log("error loading block component"); + console.log(component.errorString()); + return false; + } + return true; +} + +var fillFound; //Set after a floodFill call to the number of blocks found +var floodBoard; //Set to 1 if the floodFill reaches off that node + +//![1] +function handleClick(xPos, yPos) { + var column = Math.floor(xPos / gameCanvas.blockSize); + var row = Math.floor(yPos / gameCanvas.blockSize); + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return; + if (board[index(column, row)] == null) + return; + //If it's a valid block, remove it and all connected (does nothing if it's not connected) + floodFill(column, row, -1); + if (fillFound <= 0) + return; + gameCanvas.score += (fillFound - 1) * (fillFound - 1); + shuffleDown(); + victoryCheck(); +} +//![1] + +function floodFill(column, row, type) { + if (board[index(column, row)] == null) + return; + var first = false; + if (type == -1) { + first = true; + type = board[index(column, row)].type; + + //Flood fill initialization + fillFound = 0; + floodBoard = new Array(maxIndex); + } + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return; + if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type)) + return; + floodBoard[index(column, row)] = 1; + floodFill(column + 1, row, type); + floodFill(column - 1, row, type); + floodFill(column, row + 1, type); + floodFill(column, row - 1, type); + if (first == true && fillFound == 0) + return; //Can't remove single blocks + board[index(column, row)].opacity = 0; + board[index(column, row)] = null; + fillFound += 1; +} + +function shuffleDown() { + //Fall down + for (var column = 0; column < maxColumn; column++) { + var fallDist = 0; + for (var row = maxRow - 1; row >= 0; row--) { + if (board[index(column, row)] == null) { + fallDist += 1; + } else { + if (fallDist > 0) { + var obj = board[index(column, row)]; + obj.y += fallDist * gameCanvas.blockSize; + board[index(column, row + fallDist)] = obj; + board[index(column, row)] = null; + } + } + } + } + //Fall to the left + var fallDist = 0; + for (var column = 0; column < maxColumn; column++) { + if (board[index(column, maxRow - 1)] == null) { + fallDist += 1; + } else { + if (fallDist > 0) { + for (var row = 0; row < maxRow; row++) { + var obj = board[index(column, row)]; + if (obj == null) + continue; + obj.x -= fallDist * gameCanvas.blockSize; + board[index(column - fallDist, row)] = obj; + board[index(column, row)] = null; + } + } + } + } +} + +//![2] +function victoryCheck() { + //Award bonus points if no blocks left + var deservesBonus = true; + for (var column = maxColumn - 1; column >= 0; column--) + if (board[index(column, maxRow - 1)] != null) + deservesBonus = false; + if (deservesBonus) + gameCanvas.score += 500; + + //Check whether game has finished + if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) + dialog.show("Game Over. Your score is " + gameCanvas.score); +} +//![2] + +//only floods up and right, to see if it can find adjacent same-typed blocks +function floodMoveCheck(column, row, type) { + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return false; + if (board[index(column, row)] == null) + return false; + var myType = board[index(column, row)].type; + if (type == myType) + return true; + return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type); +} + diff --git a/examples/qml/tutorials/samegame/samegame3/samegame.qml b/examples/qml/tutorials/samegame/samegame3/samegame.qml new file mode 100644 index 0000000000..f14829ef63 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame3/samegame.qml @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 +import "samegame.js" as SameGame + +Rectangle { + id: screen + + width: 490; height: 720 + + SystemPalette { id: activePalette } + + Item { + width: parent.width + anchors { top: parent.top; bottom: toolBar.top } + + Image { + id: background + anchors.fill: parent + source: "../shared/pics/background.jpg" + fillMode: Image.PreserveAspectCrop + } + +//![1] + Item { + id: gameCanvas + + property int score: 0 + property int blockSize: 40 + + width: parent.width - (parent.width % blockSize) + height: parent.height - (parent.height % blockSize) + anchors.centerIn: parent + + MouseArea { + anchors.fill: parent + onClicked: SameGame.handleClick(mouse.x, mouse.y) + } + } +//![1] + } + +//![2] + Dialog { + id: dialog + anchors.centerIn: parent + z: 100 + } +//![2] + + Rectangle { + id: toolBar + width: parent.width; height: 30 + color: activePalette.window + anchors.bottom: screen.bottom + + Button { + anchors { left: parent.left; verticalCenter: parent.verticalCenter } + text: "New Game" + onClicked: SameGame.startNewGame() + } + + Text { + id: score + anchors { right: parent.right; verticalCenter: parent.verticalCenter } + text: "Score: Who knows?" + } + } +} +//![0] diff --git a/examples/qml/tutorials/samegame/samegame3/samegame3.qmlproject b/examples/qml/tutorials/samegame/samegame3/samegame3.qmlproject new file mode 100644 index 0000000000..42ffacf4f8 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame3/samegame3.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "samegame.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/tutorials/samegame/samegame4/content/BoomBlock.qml b/examples/qml/tutorials/samegame/samegame4/content/BoomBlock.qml new file mode 100644 index 0000000000..3786b9c0d1 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame4/content/BoomBlock.qml @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.labs.particles 1.0 + +Item { + id: block + + property int type: 0 + property bool dying: false + + //![1] + property bool spawned: false + + Behavior on x { + enabled: spawned; + SpringAnimation{ spring: 2; damping: 0.2 } + } + Behavior on y { + SpringAnimation{ spring: 2; damping: 0.2 } + } + //![1] + + //![2] + Image { + id: img + + anchors.fill: parent + source: { + if (type == 0) + return "../../shared/pics/redStone.png"; + else if (type == 1) + return "../../shared/pics/blueStone.png"; + else + return "../../shared/pics/greenStone.png"; + } + opacity: 0 + + Behavior on opacity { + NumberAnimation { properties:"opacity"; duration: 200 } + } + } + //![2] + + //![3] + Particles { + id: particles + + width: 1; height: 1 + anchors.centerIn: parent + + emissionRate: 0 + lifeSpan: 700; lifeSpanDeviation: 600 + angle: 0; angleDeviation: 360; + velocity: 100; velocityDeviation: 30 + source: { + if (type == 0) + return "../../shared/pics/redStar.png"; + else if (type == 1) + return "../../shared/pics/blueStar.png"; + else + return "../../shared/pics/greenStar.png"; + } + } + //![3] + + //![4] + states: [ + State { + name: "AliveState" + when: spawned == true && dying == false + PropertyChanges { target: img; opacity: 1 } + }, + + State { + name: "DeathState" + when: dying == true + StateChangeScript { script: particles.burst(50); } + PropertyChanges { target: img; opacity: 0 } + StateChangeScript { script: block.destroy(1000); } + } + ] + //![4] +} diff --git a/examples/qml/tutorials/samegame/samegame4/content/Button.qml b/examples/qml/tutorials/samegame/samegame4/content/Button.qml new file mode 100644 index 0000000000..248c20cf0f --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame4/content/Button.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property string text: "Button" + + signal clicked + + width: buttonLabel.width + 20; height: buttonLabel.height + 5 + border { width: 1; color: Qt.darker(activePalette.button) } + smooth: true + radius: 8 + + // color the button with a gradient + gradient: Gradient { + GradientStop { + position: 0.0 + color: { + if (mouseArea.pressed) + return activePalette.dark + else + return activePalette.light + } + } + GradientStop { position: 1.0; color: activePalette.button } + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked(); + } + + Text { + id: buttonLabel + anchors.centerIn: container + color: activePalette.buttonText + text: container.text + } +} diff --git a/examples/qml/tutorials/samegame/samegame4/content/Dialog.qml b/examples/qml/tutorials/samegame/samegame4/content/Dialog.qml new file mode 100644 index 0000000000..984b3ddb6a --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame4/content/Dialog.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//![0] +Rectangle { + id: container +//![0] + +//![1] + property string inputText: textInput.text + signal closed + + function show(text) { + dialogText.text = text; + container.opacity = 1; + textInput.opacity = 0; + } + + function showWithInput(text) { + show(text); + textInput.opacity = 1; + textInput.focus = true; + textInput.text = "" + } + + function hide() { + textInput.focus = false; + container.opacity = 0; + container.closed(); + } +//![1] + + width: dialogText.width + textInput.width + 20 + height: dialogText.height + 20 + opacity: 0 + visible: opacity > 0 + + Text { + id: dialogText + anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: 10 } + text: "" + } + +//![2] + TextInput { + id: textInput + anchors { verticalCenter: parent.verticalCenter; left: dialogText.right } + width: 80 + text: "" + + onAccepted: container.hide() // close dialog when Enter is pressed + } +//![2] + + MouseArea { + anchors.fill: parent + + onClicked: { + if (textInput.text == "" && textInput.opacity > 0) + textInput.openSoftwareInputPanel(); + else + hide(); + } + } + +//![3] +} +//![3] diff --git a/examples/qml/tutorials/samegame/samegame4/content/samegame.js b/examples/qml/tutorials/samegame/samegame4/content/samegame.js new file mode 100755 index 0000000000..7bb7243914 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame4/content/samegame.js @@ -0,0 +1,226 @@ +/* This script file handles the game logic */ +.import QtQuick.LocalStorage 2.0 as Sql + +var maxColumn = 10; +var maxRow = 15; +var maxIndex = maxColumn * maxRow; +var board = new Array(maxIndex); +var component; +var scoresURL = ""; +var gameDuration; + +//Index function used instead of a 2D array +function index(column, row) { + return column + (row * maxColumn); +} + +function startNewGame() { + //Delete blocks from previous game + for (var i = 0; i < maxIndex; i++) { + if (board[i] != null) + board[i].destroy(); + } + + //Calculate board size + maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize); + maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize); + maxIndex = maxRow * maxColumn; + + //Close dialogs + nameInputDialog.hide(); + dialog.hide(); + + //Initialize Board + board = new Array(maxIndex); + gameCanvas.score = 0; + for (var column = 0; column < maxColumn; column++) { + for (var row = 0; row < maxRow; row++) { + board[index(column, row)] = null; + createBlock(column, row); + } + } + + gameDuration = new Date(); +} + +function createBlock(column, row) { + if (component == null) + component = Qt.createComponent("content/BoomBlock.qml"); + + // Note that if Block.qml was not a local file, component.status would be + // Loading and we should wait for the component's statusChanged() signal to + // know when the file is downloaded and ready before calling createObject(). + if (component.status == Component.Ready) { + var dynamicObject = component.createObject(gameCanvas); + if (dynamicObject == null) { + console.log("error creating block"); + console.log(component.errorString()); + return false; + } + dynamicObject.type = Math.floor(Math.random() * 3); + dynamicObject.x = column * gameCanvas.blockSize; + dynamicObject.y = row * gameCanvas.blockSize; + dynamicObject.width = gameCanvas.blockSize; + dynamicObject.height = gameCanvas.blockSize; + dynamicObject.spawned = true; + board[index(column, row)] = dynamicObject; + } else { + console.log("error loading block component"); + console.log(component.errorString()); + return false; + } + return true; +} + +var fillFound; //Set after a floodFill call to the number of blocks found +var floodBoard; //Set to 1 if the floodFill reaches off that node + +function handleClick(xPos, yPos) { + var column = Math.floor(xPos / gameCanvas.blockSize); + var row = Math.floor(yPos / gameCanvas.blockSize); + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return; + if (board[index(column, row)] == null) + return; + //If it's a valid block, remove it and all connected (does nothing if it's not connected) + floodFill(column, row, -1); + if (fillFound <= 0) + return; + gameCanvas.score += (fillFound - 1) * (fillFound - 1); + shuffleDown(); + victoryCheck(); +} + +function floodFill(column, row, type) { + if (board[index(column, row)] == null) + return; + var first = false; + if (type == -1) { + first = true; + type = board[index(column, row)].type; + + //Flood fill initialization + fillFound = 0; + floodBoard = new Array(maxIndex); + } + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return; + if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type)) + return; + floodBoard[index(column, row)] = 1; + floodFill(column + 1, row, type); + floodFill(column - 1, row, type); + floodFill(column, row + 1, type); + floodFill(column, row - 1, type); + if (first == true && fillFound == 0) + return; //Can't remove single blocks + board[index(column, row)].dying = true; + board[index(column, row)] = null; + fillFound += 1; +} + +function shuffleDown() { + //Fall down + for (var column = 0; column < maxColumn; column++) { + var fallDist = 0; + for (var row = maxRow - 1; row >= 0; row--) { + if (board[index(column, row)] == null) { + fallDist += 1; + } else { + if (fallDist > 0) { + var obj = board[index(column, row)]; + obj.y = (row + fallDist) * gameCanvas.blockSize; + board[index(column, row + fallDist)] = obj; + board[index(column, row)] = null; + } + } + } + } + //Fall to the left + fallDist = 0; + for (column = 0; column < maxColumn; column++) { + if (board[index(column, maxRow - 1)] == null) { + fallDist += 1; + } else { + if (fallDist > 0) { + for (row = 0; row < maxRow; row++) { + obj = board[index(column, row)]; + if (obj == null) + continue; + obj.x = (column - fallDist) * gameCanvas.blockSize; + board[index(column - fallDist, row)] = obj; + board[index(column, row)] = null; + } + } + } + } +} + +//![3] +function victoryCheck() { +//![3] + //Award bonus points if no blocks left + var deservesBonus = true; + for (var column = maxColumn - 1; column >= 0; column--) + if (board[index(column, maxRow - 1)] != null) + deservesBonus = false; + if (deservesBonus) + gameCanvas.score += 500; + +//![4] + //Check whether game has finished + if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) { + gameDuration = new Date() - gameDuration; + nameInputDialog.showWithInput("You won! Please enter your name: "); + } +} +//![4] + +//only floods up and right, to see if it can find adjacent same-typed blocks +function floodMoveCheck(column, row, type) { + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return false; + if (board[index(column, row)] == null) + return false; + var myType = board[index(column, row)].type; + if (type == myType) + return true; + return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type); +} + +//![2] +function saveHighScore(name) { + if (scoresURL != "") + sendHighScore(name); + + var db = Sql.openDatabaseSync("SameGameScores", "1.0", "Local SameGame High Scores", 100); + var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)"; + var data = [name, gameCanvas.score, maxColumn + "x" + maxRow, Math.floor(gameDuration / 1000)]; + db.transaction(function(tx) { + tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)'); + tx.executeSql(dataStr, data); + + var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "12x17" ORDER BY score desc LIMIT 10'); + var r = "\nHIGH SCORES for a standard sized grid\n\n" + for (var i = 0; i < rs.rows.length; i++) { + r += (i + 1) + ". " + rs.rows.item(i).name + ' got ' + rs.rows.item(i).score + ' points in ' + rs.rows.item(i).time + ' seconds.\n'; + } + dialog.show(r); + }); +} +//![2] + +//![1] +function sendHighScore(name) { + var postman = new XMLHttpRequest() + var postData = "name=" + name + "&score=" + gameCanvas.score + "&gridSize=" + maxColumn + "x" + maxRow + "&time=" + Math.floor(gameDuration / 1000); + postman.open("POST", scoresURL, true); + postman.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + postman.onreadystatechange = function() { + if (postman.readyState == postman.DONE) { + dialog.show("Your score has been uploaded."); + } + } + postman.send(postData); +} +//![1] diff --git a/examples/qml/tutorials/samegame/samegame4/highscores/README b/examples/qml/tutorials/samegame/samegame4/highscores/README new file mode 100644 index 0000000000..eaa00fae37 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame4/highscores/README @@ -0,0 +1 @@ +The SameGame example can interface with a simple PHP script to store XML high score data on a remote server. We do not have a publically accessible server available for this use, but if you have access to a PHP capable webserver you can copy the files (score_data.xml, score.php, score_style.xsl) to it and alter the highscore_server variable at the top of the samegame.js file to point to it. diff --git a/examples/qml/tutorials/samegame/samegame4/highscores/score_data.xml b/examples/qml/tutorials/samegame/samegame4/highscores/score_data.xml new file mode 100755 index 0000000000..c3fd90d9cf --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame4/highscores/score_data.xml @@ -0,0 +1,2 @@ +1000000Alan the Tester0x00 +6213Alan12x1751 diff --git a/examples/qml/tutorials/samegame/samegame4/highscores/score_style.xsl b/examples/qml/tutorials/samegame/samegame4/highscores/score_style.xsl new file mode 100755 index 0000000000..670354c965 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame4/highscores/score_style.xsl @@ -0,0 +1,28 @@ + + + + + SameGame High Scores + +

SameGame High Scores

+ + + + + + + + + + + + + + + + +
NameScoreGrid SizeTime, s
+ + +
+
diff --git a/examples/qml/tutorials/samegame/samegame4/highscores/scores.php b/examples/qml/tutorials/samegame/samegame4/highscores/scores.php new file mode 100755 index 0000000000..daf480e21b --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame4/highscores/scores.php @@ -0,0 +1,31 @@ +"; + echo "SameGame High Scores"; + if($score > 0){#Sending in a new high score + $name = $_POST["name"]; + $grid = $_POST["gridSize"]; + $time = $_POST["time"]; + if($name == "") + $name = "Anonymous"; + $file = fopen("score_data.xml", "a"); + $ret = fwrite($file, "". $score . "" + . $name . "" . $grid . "" + . $time . "\n"); + echo "Your score has been recorded. Thanks for playing!"; + if($ret == False) + echo "
There was an error though, so don't expect to see that score again."; + }else{#Read high score list + #Now uses XSLT to display. So just print the file. With XML cruft added. + #Note that firefox at least won't apply the XSLT on a php file. So redirecting + $file = fopen("scores.xml", "w"); + $ret = fwrite($file, '' . "\n" + . '' . "\n" + . "\n" . file_get_contents("score_data.xml") . "\n"); + if($ret == False) + echo "There was an internal error. Sorry."; + else + echo ''; + } + echo ""; +?> diff --git a/examples/qml/tutorials/samegame/samegame4/samegame.qml b/examples/qml/tutorials/samegame/samegame4/samegame.qml new file mode 100644 index 0000000000..c21b8de8bd --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame4/samegame.qml @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" +import "content/samegame.js" as SameGame + +Rectangle { + id: screen + + width: 490; height: 720 + + SystemPalette { id: activePalette } + + Item { + width: parent.width + anchors { top: parent.top; bottom: toolBar.top } + + Image { + id: background + anchors.fill: parent + source: "../shared/pics/background.jpg" + fillMode: Image.PreserveAspectCrop + } + + Item { + id: gameCanvas + property int score: 0 + property int blockSize: 40 + + anchors.centerIn: parent + width: parent.width - (parent.width % blockSize); + height: parent.height - (parent.height % blockSize); + + MouseArea { + anchors.fill: parent; onClicked: SameGame.handleClick(mouse.x,mouse.y); + } + } + } + + Dialog { + id: dialog + anchors.centerIn: parent + z: 100 + } + + //![0] + Dialog { + id: nameInputDialog + anchors.centerIn: parent + z: 100 + + onClosed: { + if (nameInputDialog.inputText != "") + SameGame.saveHighScore(nameInputDialog.inputText); + } + } + //![0] + + Rectangle { + id: toolBar + width: parent.width; height: 30 + color: activePalette.window + anchors.bottom: screen.bottom + + Button { + anchors { left: parent.left; verticalCenter: parent.verticalCenter } + text: "New Game" + onClicked: SameGame.startNewGame() + } + + Text { + id: score + anchors { right: parent.right; verticalCenter: parent.verticalCenter } + text: "Score: " + gameCanvas.score + } + } +} diff --git a/examples/qml/tutorials/samegame/samegame4/samegame4.qmlproject b/examples/qml/tutorials/samegame/samegame4/samegame4.qmlproject new file mode 100644 index 0000000000..42ffacf4f8 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame4/samegame4.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "samegame.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/tutorials/samegame/shared/pics/background.jpg b/examples/qml/tutorials/samegame/shared/pics/background.jpg new file mode 100644 index 0000000000..903d395c8d Binary files /dev/null and b/examples/qml/tutorials/samegame/shared/pics/background.jpg differ diff --git a/examples/qml/tutorials/samegame/shared/pics/blueStar.png b/examples/qml/tutorials/samegame/shared/pics/blueStar.png new file mode 100644 index 0000000000..ff9588f80a Binary files /dev/null and b/examples/qml/tutorials/samegame/shared/pics/blueStar.png differ diff --git a/examples/qml/tutorials/samegame/shared/pics/blueStone.png b/examples/qml/tutorials/samegame/shared/pics/blueStone.png new file mode 100644 index 0000000000..20e43c75b6 Binary files /dev/null and b/examples/qml/tutorials/samegame/shared/pics/blueStone.png differ diff --git a/examples/qml/tutorials/samegame/shared/pics/greenStar.png b/examples/qml/tutorials/samegame/shared/pics/greenStar.png new file mode 100644 index 0000000000..cd06854719 Binary files /dev/null and b/examples/qml/tutorials/samegame/shared/pics/greenStar.png differ diff --git a/examples/qml/tutorials/samegame/shared/pics/greenStone.png b/examples/qml/tutorials/samegame/shared/pics/greenStone.png new file mode 100644 index 0000000000..b568a1900c Binary files /dev/null and b/examples/qml/tutorials/samegame/shared/pics/greenStone.png differ diff --git a/examples/qml/tutorials/samegame/shared/pics/redStar.png b/examples/qml/tutorials/samegame/shared/pics/redStar.png new file mode 100644 index 0000000000..0a4dffe583 Binary files /dev/null and b/examples/qml/tutorials/samegame/shared/pics/redStar.png differ diff --git a/examples/qml/tutorials/samegame/shared/pics/redStone.png b/examples/qml/tutorials/samegame/shared/pics/redStone.png new file mode 100644 index 0000000000..36b09a2686 Binary files /dev/null and b/examples/qml/tutorials/samegame/shared/pics/redStone.png differ diff --git a/examples/qml/tutorials/samegame/shared/pics/star.png b/examples/qml/tutorials/samegame/shared/pics/star.png new file mode 100644 index 0000000000..defbde53ca Binary files /dev/null and b/examples/qml/tutorials/samegame/shared/pics/star.png differ diff --git a/examples/qml/tutorials/samegame/shared/pics/yellowStone.png b/examples/qml/tutorials/samegame/shared/pics/yellowStone.png new file mode 100644 index 0000000000..b1ce76212c Binary files /dev/null and b/examples/qml/tutorials/samegame/shared/pics/yellowStone.png differ diff --git a/examples/qml/tutorials/tutorials.pro b/examples/qml/tutorials/tutorials.pro new file mode 100644 index 0000000000..0a82c1e704 --- /dev/null +++ b/examples/qml/tutorials/tutorials.pro @@ -0,0 +1,5 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + extending + diff --git a/examples/qml/tutorials/tutorials.qmlproject b/examples/qml/tutorials/tutorials.qmlproject new file mode 100644 index 0000000000..2bb4016996 --- /dev/null +++ b/examples/qml/tutorials/tutorials.qmlproject @@ -0,0 +1,14 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/twitter/TwitterCore/Button.qml b/examples/qml/twitter/TwitterCore/Button.qml new file mode 100644 index 0000000000..353b993742 --- /dev/null +++ b/examples/qml/twitter/TwitterCore/Button.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + signal clicked + + property string text + property bool keyUsing: false + + BorderImage { + id: buttonImage + source: "images/toolbutton.sci" + width: container.width; height: container.height + } + BorderImage { + id: pressed + opacity: 0 + source: "images/toolbutton.sci" + width: container.width; height: container.height + } + MouseArea { + id: mouseRegion + anchors.fill: buttonImage + onClicked: { container.clicked(); } + } + Text { + id: btnText + color: if(container.keyUsing){"#D0D0D0";} else {"#FFFFFF";} + anchors.centerIn: buttonImage; font.bold: true + text: container.text; style: Text.Raised; styleColor: "black" + font.pixelSize: 12 + } + states: [ + State { + name: "Pressed" + when: mouseRegion.pressed == true + PropertyChanges { target: pressed; opacity: 1 } + }, + State { + name: "Focused" + when: container.activeFocus == true + PropertyChanges { target: btnText; color: "#FFFFFF" } + } + ] + transitions: Transition { + ColorAnimation { target: btnText; } + } +} diff --git a/examples/qml/twitter/TwitterCore/FatDelegate.qml b/examples/qml/twitter/TwitterCore/FatDelegate.qml new file mode 100644 index 0000000000..4cb0dfc713 --- /dev/null +++ b/examples/qml/twitter/TwitterCore/FatDelegate.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Component { + id: listDelegate + Item { + id: wrapper; width: wrapper.ListView.view.width; height: if(txt.height > 60){txt.height+10}else{60} //50+5+5 + function handleLink(link){ + if(link.slice(0,3) == 'app'){ + screen.setUser(link.slice(7)); + }else if(link.slice(0,4) == 'http'){ + Qt.openUrlExternally(link); + } + } + function addTags(str){ + var ret = str.replace(/@[a-zA-Z0-9_]+/g, '$&');//click to jump to user? + var ret2 = ret.replace(/http:\/\/[^ \n\t]+/g, '$&');//surrounds http links with html link tags + return ret2; + } + + // Strip away paranthesis + function userName(str) { + var user = str.replace(/\([\S|\s]*\)/gi, ""); + return user.trim(); + } + + Item { + id: moveMe; height: parent.height + Rectangle { + id: blackRect + color: "black"; opacity: wrapper.ListView.index % 2 ? 0.2 : 0.3; height: wrapper.height-2; width: wrapper.width; y: 1 + } + Item { + id: image; x: 6; width: 48; height: 48; smooth: true + anchors.verticalCenter: parent.verticalCenter + + Loading { x: 1; y: 1; width: 48; height: 48; visible: realImage.status != Image.Ready } + Image { + id: realImage; + source: userImage; x: 1; y: 1; + width:48; height:48; opacity:0 ; + onStatusChanged: { + if(status==Image.Ready) + image.state="loaded" + } + } + states: State { + name: "loaded"; + PropertyChanges { target: realImage ; opacity:1 } + } + transitions: Transition { NumberAnimation { target: realImage; property: "opacity"; duration: 200 } } + + } + Text { id:txt; y:4; x: 56 + text: '' + + ''+userName(name) + " from " +source + + "
" + statusText + ""; + textFormat: Text.StyledText + color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap; linkColor: "#aaccaa" + anchors.left: image.right; anchors.right: blackRect.right; anchors.leftMargin: 6; anchors.rightMargin: 6 + onLinkActivated: wrapper.handleLink(link) + } + } + } +} diff --git a/examples/qml/twitter/TwitterCore/Input.qml b/examples/qml/twitter/TwitterCore/Input.qml new file mode 100644 index 0000000000..68b1c6186a --- /dev/null +++ b/examples/qml/twitter/TwitterCore/Input.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +FocusScope { + id:container + width: 220 + height: 28 + BorderImage { source: "images/lineedit.sci"; anchors.fill: parent } + signal accepted + property alias text: input.text + property alias item:input + TextInput{ + id: input + width: parent.width - 12 + anchors.centerIn: parent + maximumLength:21 + font.pixelSize: 16; + font.bold: true + color: "#151515"; selectionColor: "mediumseagreen" + focus: true + onAccepted:{container.accepted()} + text: "" + selectByMouse: true + } +} diff --git a/examples/qml/twitter/TwitterCore/Loading.qml b/examples/qml/twitter/TwitterCore/Loading.qml new file mode 100644 index 0000000000..566857b8b2 --- /dev/null +++ b/examples/qml/twitter/TwitterCore/Loading.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + id: loading; source: "images/loading.png" + NumberAnimation on rotation { + from: 0; to: 360; running: loading.visible == true; loops: Animation.Infinite; duration: 900 + } +} diff --git a/examples/qml/twitter/TwitterCore/MultiTitleBar.qml b/examples/qml/twitter/TwitterCore/MultiTitleBar.qml new file mode 100644 index 0000000000..3920520b7a --- /dev/null +++ b/examples/qml/twitter/TwitterCore/MultiTitleBar.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + TitleBar { id: titleBar; width: parent.width; height: 60; + y: -80 + untaggedString: "Latest tweets from everyone" + taggedString: "Latest tweets from " + } + states: [ + State { + name: "search"; when: screen.state!="search" + PropertyChanges { target: titleBar; y: 0 } + } + ] + transitions: [ + Transition { NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } } + ] +} + diff --git a/examples/qml/twitter/TwitterCore/RssModel.qml b/examples/qml/twitter/TwitterCore/RssModel.qml new file mode 100644 index 0000000000..27f7495be2 --- /dev/null +++ b/examples/qml/twitter/TwitterCore/RssModel.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +Item { id: wrapper + property variant model: xmlModel + property string from : "" + property string to : "" + property string phrase : "" + + property string mode : "everyone" + property int status: xmlModel.status + function reload() { xmlModel.reload(); } + + XmlListModel { + id: xmlModel + + function encodePhrase(x) { return encodeURIComponent(x); } + + source: (from=="" && to=="" && phrase=="") ? "" : + 'http://search.twitter.com/search.atom?from='+from+"&to="+to+"&phrase="+encodePhrase(phrase) + + namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom'; " + + "declare namespace twitter=\"http://api.twitter.com/\";"; + + query: "/feed/entry" + + XmlRole { name: "statusText"; query: "content/string()" } + XmlRole { name: "timestamp"; query: "published/string()" } + XmlRole { name: "source"; query: "twitter:source/string()" } + XmlRole { name: "name"; query: "author/name/string()" } + XmlRole { name: "userImage"; query: "link[@rel = 'image']/@href/string()" } + + } + Binding { + property: "mode" + target: wrapper + value: {if(wrapper.tags==''){"everyone";}else if(wrapper.tags=='my timeline'){"self";}else{"user";}} + } +} diff --git a/examples/qml/twitter/TwitterCore/SearchView.qml b/examples/qml/twitter/TwitterCore/SearchView.qml new file mode 100644 index 0000000000..7732e6f68d --- /dev/null +++ b/examples/qml/twitter/TwitterCore/SearchView.qml @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +FocusScope { + id: wrapper + Column { + anchors.centerIn: parent + spacing: 20 + Column{ + spacing: 4 + Text { + text: "Posted by:" + font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black" + horizontalAlignment: Qt.AlignRight + } + Input{ + id: fromIn + KeyNavigation.backtab: searchbutton + KeyNavigation.tab:toIn + onAccepted:searchbutton.doSearch(); + focus: true + } + Text { + text: "In reply to:" + font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black" + horizontalAlignment: Qt.AlignRight + } + Input{ + id: toIn + KeyNavigation.backtab: fromIn + KeyNavigation.tab:phraseIn + onAccepted:searchbutton.doSearch(); + } + Text { + text: "Search phrase:" + font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black" + horizontalAlignment: Qt.AlignRight + } + Input{ + id: phraseIn + KeyNavigation.backtab: toIn + KeyNavigation.tab:searchbutton + onAccepted:searchbutton.doSearch(); + text: "Qt Quick" + } + } + Button { + width: 100 + height: 32 + id: searchbutton + keyUsing: true; + opacity: 1 + text: "Search" + KeyNavigation.tab: fromIn + Keys.onReturnPressed: searchbutton.doSearch(); + Keys.onEnterPressed: searchbutton.doSearch(); + Keys.onSelectPressed: searchbutton.doSearch(); + Keys.onSpacePressed: searchbutton.doSearch(); + onClicked: searchbutton.doSearch(); + + function doSearch() { + // Search ! allowed + if (wrapper.state=="invalidinput") + return; + + rssModel.from=fromIn.text; + rssModel.to= toIn.text; + rssModel.phrase = phraseIn.text; + screen.focus = true; + screen.state = "" + } + } + } + states: + State { + name: "invalidinput" + when: fromIn.text=="" && toIn.text=="" && phraseIn.text=="" + PropertyChanges { target: searchbutton ; opacity: 0.6 ; } + } + transitions: + Transition { + NumberAnimation { target: searchbutton; property: "opacity"; duration: 200 } + } +} diff --git a/examples/qml/twitter/TwitterCore/TitleBar.qml b/examples/qml/twitter/TwitterCore/TitleBar.qml new file mode 100644 index 0000000000..3e0818b0dd --- /dev/null +++ b/examples/qml/twitter/TwitterCore/TitleBar.qml @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: titleBar + property string untaggedString: "Uploads from everyone" + property string taggedString: "Recent uploads tagged " + + BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } + + Item { + id: container + width: (parent.width * 2) - 55 ; height: parent.height + + function accept() { + titleBar.state = "" + background.state = "" + rssModel.tags = editor.text + } + + Item { + id:imageBox + x: 6; width: 0; height: 50; smooth: true + anchors.verticalCenter: parent.verticalCenter + + UserModel { user: rssModel.from; id: userModel } + Component { + id: imgDelegate; + Item { + id:imageitem + visible:true + Loading { width:48; height:48; visible: realImage.status != Image.Ready } + Image { id: realImage; source: image; width:48; height:48; opacity:0; } + states: + State { + name: "loaded" + when: (realImage.status == Image.Ready) + PropertyChanges { target: realImage; opacity:1 } + } + transitions: Transition { + NumberAnimation { target: realImage; property: "opacity"; duration: 200 } + } + } + } + ListView { id:view; model: userModel.model; x:1; y:1; delegate: imgDelegate } + states: + State { + when: !userModel.user=="" + PropertyChanges { target: imageBox; width: 50; } + } + transitions: + Transition { + NumberAnimation { target: imageBox; property: "width"; duration: 200 } + } + } + + Image { + id: quitButton + x: 5 + anchors.verticalCenter: parent.verticalCenter + source: "images/quit.png" + MouseArea { + anchors.fill: parent + onClicked: Qt.quit() + } + } + + Text { + id: categoryText + anchors { + left: quitButton.right; right: parent.right; leftMargin: 10; rightMargin: 10 + verticalCenter: parent.verticalCenter + } + elide: Text.ElideLeft + text: (rssModel.from=="" ? untaggedString : taggedString + rssModel.from) + font.bold: true; color: "White"; style: Text.Raised; styleColor: "Black" + font.pixelSize: 12 + } + } + + states: State { + name: "Tags" + PropertyChanges { target: container; x: -tagButton.x + 5 } + PropertyChanges { target: editor; focus: true } + } + + transitions: Transition { + NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad } + } +} diff --git a/examples/qml/twitter/TwitterCore/ToolBar.qml b/examples/qml/twitter/TwitterCore/ToolBar.qml new file mode 100644 index 0000000000..d4265f3e98 --- /dev/null +++ b/examples/qml/twitter/TwitterCore/ToolBar.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: toolbar + + property alias button1Label: button1.text + property alias button2Label: button2.text + signal button1Clicked + signal button2Clicked + focus:true + BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } + Button { + id: button1 + anchors.left: parent.left; anchors.leftMargin: 5; y: 3; width: 140; height: 32 + onClicked: toolbar.button1Clicked() + focus:true + } + Button { + id: button2 + anchors.right: parent.right; anchors.rightMargin: 5; y: 3; width: 140; height: 32 + onClicked: toolbar.button2Clicked() + } +} diff --git a/examples/qml/twitter/TwitterCore/UserModel.qml b/examples/qml/twitter/TwitterCore/UserModel.qml new file mode 100644 index 0000000000..428089b539 --- /dev/null +++ b/examples/qml/twitter/TwitterCore/UserModel.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +//This "model" gets the user information about the searched user. Mainly for the icon. + +Item { id: wrapper + property variant model: xmlModel + property string user : "" + property int status: xmlModel.status + function reload() { xmlModel.reload(); } + XmlListModel { + id: xmlModel + + source: user!= "" ? "http://twitter.com/users/show.xml?screen_name="+user : "" + query: "/user" + + XmlRole { name: "name"; query: "name/string()" } + XmlRole { name: "screenName"; query: "screen_name/string()" } + XmlRole { name: "image"; query: "profile_image_url/string()" } + XmlRole { name: "location"; query: "location/string()" } + XmlRole { name: "description"; query: "description/string()" } + XmlRole { name: "followers"; query: "followers_count/string()" } + //TODO: Could also get the user's color scheme, timezone and a few other things + } +} diff --git a/examples/qml/twitter/TwitterCore/images/gloss.png b/examples/qml/twitter/TwitterCore/images/gloss.png new file mode 100644 index 0000000000..5d370cd93d Binary files /dev/null and b/examples/qml/twitter/TwitterCore/images/gloss.png differ diff --git a/examples/qml/twitter/TwitterCore/images/lineedit.png b/examples/qml/twitter/TwitterCore/images/lineedit.png new file mode 100644 index 0000000000..2cc38dc35b Binary files /dev/null and b/examples/qml/twitter/TwitterCore/images/lineedit.png differ diff --git a/examples/qml/twitter/TwitterCore/images/lineedit.sci b/examples/qml/twitter/TwitterCore/images/lineedit.sci new file mode 100644 index 0000000000..054bff78be --- /dev/null +++ b/examples/qml/twitter/TwitterCore/images/lineedit.sci @@ -0,0 +1,5 @@ +border.left: 10 +border.top: 10 +border.bottom: 10 +border.right: 10 +source: lineedit.png diff --git a/examples/qml/twitter/TwitterCore/images/loading.png b/examples/qml/twitter/TwitterCore/images/loading.png new file mode 100644 index 0000000000..47a1589c5d Binary files /dev/null and b/examples/qml/twitter/TwitterCore/images/loading.png differ diff --git a/examples/qml/twitter/TwitterCore/images/quit.png b/examples/qml/twitter/TwitterCore/images/quit.png new file mode 100644 index 0000000000..5bda1b6e0d Binary files /dev/null and b/examples/qml/twitter/TwitterCore/images/quit.png differ diff --git a/examples/qml/twitter/TwitterCore/images/stripes.png b/examples/qml/twitter/TwitterCore/images/stripes.png new file mode 100644 index 0000000000..9f36727ea4 Binary files /dev/null and b/examples/qml/twitter/TwitterCore/images/stripes.png differ diff --git a/examples/qml/twitter/TwitterCore/images/titlebar.png b/examples/qml/twitter/TwitterCore/images/titlebar.png new file mode 100644 index 0000000000..51c90082d0 Binary files /dev/null and b/examples/qml/twitter/TwitterCore/images/titlebar.png differ diff --git a/examples/qml/twitter/TwitterCore/images/titlebar.sci b/examples/qml/twitter/TwitterCore/images/titlebar.sci new file mode 100644 index 0000000000..0418d94cd6 --- /dev/null +++ b/examples/qml/twitter/TwitterCore/images/titlebar.sci @@ -0,0 +1,5 @@ +border.left: 10 +border.top: 12 +border.bottom: 12 +border.right: 10 +source: titlebar.png diff --git a/examples/qml/twitter/TwitterCore/images/toolbutton.png b/examples/qml/twitter/TwitterCore/images/toolbutton.png new file mode 100644 index 0000000000..11310013ee Binary files /dev/null and b/examples/qml/twitter/TwitterCore/images/toolbutton.png differ diff --git a/examples/qml/twitter/TwitterCore/images/toolbutton.sci b/examples/qml/twitter/TwitterCore/images/toolbutton.sci new file mode 100644 index 0000000000..9e4f965307 --- /dev/null +++ b/examples/qml/twitter/TwitterCore/images/toolbutton.sci @@ -0,0 +1,5 @@ +border.left: 15 +border.top: 4 +border.bottom: 4 +border.right: 15 +source: toolbutton.png diff --git a/examples/qml/twitter/TwitterCore/qmldir b/examples/qml/twitter/TwitterCore/qmldir new file mode 100644 index 0000000000..452a648b23 --- /dev/null +++ b/examples/qml/twitter/TwitterCore/qmldir @@ -0,0 +1,10 @@ +SearchView 2.0 SearchView.qml +Button 2.0 Button.qml +Input 2.0 Input.qml +FatDelegate 2.0 FatDelegate.qml +Loading 2.0 Loading.qml +MultiTitleBar 2.0 MultiTitleBar.qml +TitleBar 2.0 TitleBar.qml +RssModel 2.0 RssModel.qml +UserModel 2.0 UserModel.qml +ToolBar 2.0 ToolBar.qml diff --git a/examples/qml/twitter/twitter.qml b/examples/qml/twitter/twitter.qml new file mode 100644 index 0000000000..aca0968cfb --- /dev/null +++ b/examples/qml/twitter/twitter.qml @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 +import "TwitterCore" 2.0 as Twitter + +Item { + id: screen; width: 320; height: 480 + property bool userView : false + property variant tmpStr + function setUser(str){hack.running = true; tmpStr = str} + function reallySetUser(){rssModel.from = tmpStr;rssModel.to = ""; rssModel.phrase = ""} + state:"searchquery" + //Workaround for bug 260266 + Timer{ interval: 1; running: false; repeat: false; onTriggered: screen.reallySetUser(); id:hack } + Keys.onEscapePressed: screen.state="searchquery" + Keys.onBacktabPressed: screen.state="searchquery" + Rectangle { + id: background + anchors.fill: parent; color: "#343434"; + + state:"searchquery" + Image { source: "TwitterCore/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 } + + MouseArea { + anchors.fill: parent + onClicked: screen.focus = false; + } + + Twitter.RssModel { id: rssModel } + Twitter.Loading { anchors.centerIn: parent; visible: rssModel.status==XmlListModel.Loading && state!='unauthed'} + Text { + width: 180 + text: "Could not access twitter using this screen name and password pair."; + color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap + visible: rssModel.status==XmlListModel.Error; anchors.centerIn: parent + } + + Item { + id: views + x: 2; width: parent.width - 4 + y:60 //Below the title bars + height: parent.height - 100 + + Text { + id:title + text: "Search Twitter" + anchors.horizontalCenter: parent.horizontalCenter + font.pixelSize: 20; font.bold: true; color: "#bbb"; style: Text.Raised; styleColor: "black" + opacity:0 + } + + Twitter.SearchView{ + id: searchView + anchors.verticalCenter: parent.verticalCenter + width: parent.width; height: parent.height-60; + x: -(screen.width * 1.5) + } + + Twitter.FatDelegate { id: fatDelegate } + ListView { + id: mainView; model: rssModel.model; delegate: fatDelegate; + width: parent.width; height: parent.height; x: 0; cacheBuffer: 100; + } + } + + Twitter.MultiTitleBar { id: titleBar; width: parent.width } + Twitter.ToolBar { id: toolBar; height: 40; + //anchors.bottom: parent.bottom; + //TODO: Use anchor changes instead of hard coding + y: screen.height - 40 + width: parent.width; opacity: 0.9 + button1Label: "New Search" + button2Label: "Update" + onButton1Clicked: + { + screen.state="searchquery" + } + onButton2Clicked: rssModel.reload(); + } + } + states: [ + State { + name: "searchquery"; + PropertyChanges { target: searchView; x: 0; focus:true} + PropertyChanges { target: mainView; x: -(parent.width * 1.5) } + PropertyChanges { target: titleBar; y: -80 } + PropertyChanges { target: toolBar; y: screen.height } + PropertyChanges { target: toolBar } + PropertyChanges { target: title; opacity:1} + } + ] + transitions: [ + Transition { NumberAnimation { properties: "x,y,opacity"; duration: 500; easing.type: Easing.InOutQuad } } + ] +} diff --git a/examples/qml/twitter/twitter.qmlproject b/examples/qml/twitter/twitter.qmlproject new file mode 100644 index 0000000000..b14f71fdfd --- /dev/null +++ b/examples/qml/twitter/twitter.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "twitter.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/ui-components/dialcontrol/content/Dial.qml b/examples/qml/ui-components/dialcontrol/content/Dial.qml new file mode 100644 index 0000000000..c61adee364 --- /dev/null +++ b/examples/qml/ui-components/dialcontrol/content/Dial.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root + property real value : 0 + + width: 210; height: 210 + + Image { source: "background.png" } + +//! [needle_shadow] + Image { + x: 96 + y: 35 + source: "needle_shadow.png" + transform: Rotation { + origin.x: 9; origin.y: 67 + angle: needleRotation.angle + } + } +//! [needle_shadow] +//! [needle] + Image { + id: needle + x: 98; y: 33 + smooth: true + source: "needle.png" + transform: Rotation { + id: needleRotation + origin.x: 5; origin.y: 65 + //! [needle angle] + angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133) + Behavior on angle { + SpringAnimation { + spring: 1.4 + damping: .15 + } + } + //! [needle angle] + } + } +//! [needle] +//! [overlay] + Image { x: 21; y: 18; source: "overlay.png" } +//! [overlay] +} diff --git a/examples/qml/ui-components/dialcontrol/content/QuitButton.qml b/examples/qml/ui-components/dialcontrol/content/QuitButton.qml new file mode 100644 index 0000000000..702b892d23 --- /dev/null +++ b/examples/qml/ui-components/dialcontrol/content/QuitButton.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +Image { + source: "quit.png" + scale: quitMouse.pressed ? 0.8 : 1.0 + smooth: quitMouse.pressed + MouseArea { + id: quitMouse + anchors.fill: parent + anchors.margins: -10 + onClicked: Qt.quit() + } +} diff --git a/examples/qml/ui-components/dialcontrol/content/background.png b/examples/qml/ui-components/dialcontrol/content/background.png new file mode 100644 index 0000000000..75d555d7ab Binary files /dev/null and b/examples/qml/ui-components/dialcontrol/content/background.png differ diff --git a/examples/qml/ui-components/dialcontrol/content/needle.png b/examples/qml/ui-components/dialcontrol/content/needle.png new file mode 100644 index 0000000000..2d19f75039 Binary files /dev/null and b/examples/qml/ui-components/dialcontrol/content/needle.png differ diff --git a/examples/qml/ui-components/dialcontrol/content/needle_shadow.png b/examples/qml/ui-components/dialcontrol/content/needle_shadow.png new file mode 100644 index 0000000000..8d8a928cc5 Binary files /dev/null and b/examples/qml/ui-components/dialcontrol/content/needle_shadow.png differ diff --git a/examples/qml/ui-components/dialcontrol/content/overlay.png b/examples/qml/ui-components/dialcontrol/content/overlay.png new file mode 100644 index 0000000000..3860a7b590 Binary files /dev/null and b/examples/qml/ui-components/dialcontrol/content/overlay.png differ diff --git a/examples/qml/ui-components/dialcontrol/content/quit.png b/examples/qml/ui-components/dialcontrol/content/quit.png new file mode 100644 index 0000000000..b822057d4e Binary files /dev/null and b/examples/qml/ui-components/dialcontrol/content/quit.png differ diff --git a/examples/qml/ui-components/dialcontrol/dialcontrol.qml b/examples/qml/ui-components/dialcontrol/dialcontrol.qml new file mode 100644 index 0000000000..d645b34aa4 --- /dev/null +++ b/examples/qml/ui-components/dialcontrol/dialcontrol.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [imports] +import QtQuick 2.0 +import "content" +//! [imports] + +//! [0] +Rectangle { + color: "#545454" + width: 300; height: 300 + + // Dial with a slider to adjust it + Dial { + id: dial + anchors.centerIn: parent + value: slider.x * 100 / (container.width - 34) + } + + Rectangle { + id: container + anchors { bottom: parent.bottom; left: parent.left + right: parent.right; leftMargin: 20; rightMargin: 20 + bottomMargin: 10 + } + height: 16 + + radius: 8 + opacity: 0.7 + smooth: true + gradient: Gradient { + GradientStop { position: 0.0; color: "gray" } + GradientStop { position: 1.0; color: "white" } + } + + Rectangle { + id: slider + x: 1; y: 1; width: 30; height: 14 + radius: 6 + smooth: true + gradient: Gradient { + GradientStop { position: 0.0; color: "#424242" } + GradientStop { position: 1.0; color: "black" } + } + + MouseArea { + anchors.fill: parent + anchors.margins: -16 // Increase mouse area a lot outside the slider + drag.target: parent; drag.axis: Drag.XAxis + drag.minimumX: 2; drag.maximumX: container.width - 32 + } + } + } + QuitButton { + anchors.right: parent.right + anchors.top: parent.top + anchors.margins: 10 + } +} +//! [0] diff --git a/examples/qml/ui-components/flipable/content/5_heart.png b/examples/qml/ui-components/flipable/content/5_heart.png new file mode 100644 index 0000000000..fb59d81453 Binary files /dev/null and b/examples/qml/ui-components/flipable/content/5_heart.png differ diff --git a/examples/qml/ui-components/flipable/content/9_club.png b/examples/qml/ui-components/flipable/content/9_club.png new file mode 100644 index 0000000000..2545001904 Binary files /dev/null and b/examples/qml/ui-components/flipable/content/9_club.png differ diff --git a/examples/qml/ui-components/flipable/content/Card.qml b/examples/qml/ui-components/flipable/content/Card.qml new file mode 100644 index 0000000000..6006ea14fc --- /dev/null +++ b/examples/qml/ui-components/flipable/content/Card.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Flipable { + id: container + + property alias source: frontImage.source + property bool flipped: true + property int xAxis: 0 + property int yAxis: 0 + property int angle: 0 + + width: front.width; height: front.height + + front: Image { id: frontImage; smooth: true } + back: Image { source: "back.png"; smooth: true } + + state: "back" + + MouseArea { anchors.fill: parent; onClicked: container.flipped = !container.flipped } + + transform: Rotation { + id: rotation; origin.x: container.width / 2; origin.y: container.height / 2 + axis.x: container.xAxis; axis.y: container.yAxis; axis.z: 0 + } + + states: State { + name: "back"; when: container.flipped + PropertyChanges { target: rotation; angle: container.angle } + } + + transitions: Transition { + ParallelAnimation { + NumberAnimation { target: rotation; properties: "angle"; duration: 600 } + SequentialAnimation { + NumberAnimation { target: container; property: "scale"; to: 0.75; duration: 300 } + NumberAnimation { target: container; property: "scale"; to: 1.0; duration: 300 } + } + } + } +} diff --git a/examples/qml/ui-components/flipable/content/back.png b/examples/qml/ui-components/flipable/content/back.png new file mode 100644 index 0000000000..f715d7487e Binary files /dev/null and b/examples/qml/ui-components/flipable/content/back.png differ diff --git a/examples/qml/ui-components/flipable/flipable.qml b/examples/qml/ui-components/flipable/flipable.qml new file mode 100644 index 0000000000..4af64afc53 --- /dev/null +++ b/examples/qml/ui-components/flipable/flipable.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + id: window + + width: 480; height: 320 + color: "darkgreen" + + Row { + anchors.centerIn: parent; spacing: 30 + Card { source: "content/9_club.png"; angle: 180; yAxis: 1 } + Card { source: "content/5_heart.png"; angle: 540; xAxis: 1 } + } +} diff --git a/examples/qml/ui-components/progressbar/content/ProgressBar.qml b/examples/qml/ui-components/progressbar/content/ProgressBar.qml new file mode 100644 index 0000000000..c9be8d7336 --- /dev/null +++ b/examples/qml/ui-components/progressbar/content/ProgressBar.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: progressbar + + property int minimum: 0 + property int maximum: 100 + property int value: 0 + property alias color: gradient1.color + property alias secondColor: gradient2.color + + width: 250; height: 23 + clip: true + + BorderImage { + source: "background.png" + width: parent.width; height: parent.height + border { left: 4; top: 4; right: 4; bottom: 4 } + } + + Rectangle { + id: highlight + + property int widthDest: ((progressbar.width * (value - minimum)) / (maximum - minimum) - 6) + + width: highlight.widthDest + Behavior on width { SmoothedAnimation { velocity: 1200 } } + + anchors { left: parent.left; top: parent.top; bottom: parent.bottom; margins: 3 } + radius: 1 + gradient: Gradient { + GradientStop { id: gradient1; position: 0.0 } + GradientStop { id: gradient2; position: 1.0 } + } + + } + Text { + anchors { right: highlight.right; rightMargin: 6; verticalCenter: parent.verticalCenter } + color: "white" + font.bold: true + text: Math.floor((value - minimum) / (maximum - minimum) * 100) + '%' + } +} diff --git a/examples/qml/ui-components/progressbar/content/background.png b/examples/qml/ui-components/progressbar/content/background.png new file mode 100644 index 0000000000..9044226f85 Binary files /dev/null and b/examples/qml/ui-components/progressbar/content/background.png differ diff --git a/examples/qml/ui-components/progressbar/main.qml b/examples/qml/ui-components/progressbar/main.qml new file mode 100644 index 0000000000..367e4c1265 --- /dev/null +++ b/examples/qml/ui-components/progressbar/main.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + id: main + + width: 600; height: 405 + color: "#edecec" + + Flickable { + anchors.fill: parent + contentHeight: column.height + 20 + + Column { + id: column + x: 10; y: 10 + spacing: 10 + + Repeater { + model: 25 + + ProgressBar { + property int r: Math.floor(Math.random() * 5000 + 1000) + width: main.width - 20 + + NumberAnimation on value { duration: r; from: 0; to: 100; loops: Animation.Infinite } + ColorAnimation on color { duration: r; from: "lightsteelblue"; to: "thistle"; loops: Animation.Infinite } + ColorAnimation on secondColor { duration: r; from: "steelblue"; to: "#CD96CD"; loops: Animation.Infinite } + } + } + } + } +} diff --git a/examples/qml/ui-components/scrollbar/ScrollBar.qml b/examples/qml/ui-components/scrollbar/ScrollBar.qml new file mode 100644 index 0000000000..a3d0d3841c --- /dev/null +++ b/examples/qml/ui-components/scrollbar/ScrollBar.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: scrollBar + + // The properties that define the scrollbar's state. + // position and pageSize are in the range 0.0 - 1.0. They are relative to the + // height of the page, i.e. a pageSize of 0.5 means that you can see 50% + // of the height of the view. + // orientation can be either Qt.Vertical or Qt.Horizontal + property real position + property real pageSize + property variant orientation : Qt.Vertical + + // A light, semi-transparent background + Rectangle { + id: background + anchors.fill: parent + radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) + color: "white" + opacity: 0.3 + } + + // Size the bar to the required size, depending upon the orientation. + Rectangle { + x: orientation == Qt.Vertical ? 1 : (scrollBar.position * (scrollBar.width-2) + 1) + y: orientation == Qt.Vertical ? (scrollBar.position * (scrollBar.height-2) + 1) : 1 + width: orientation == Qt.Vertical ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2)) + height: orientation == Qt.Vertical ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2) + radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) + color: "black" + opacity: 0.7 + } +} diff --git a/examples/qml/ui-components/scrollbar/main.qml b/examples/qml/ui-components/scrollbar/main.qml new file mode 100644 index 0000000000..a7d602b437 --- /dev/null +++ b/examples/qml/ui-components/scrollbar/main.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 640 + height: 480 + + // Create a flickable to view a large image. + Flickable { + id: view + anchors.fill: parent + contentWidth: picture.width + contentHeight: picture.height + + Image { + id: picture + source: "pics/niagara_falls.jpg" + asynchronous: true + } + + // Only show the scrollbars when the view is moving. + states: State { + name: "ShowBars" + when: view.movingVertically || view.movingHorizontally + PropertyChanges { target: verticalScrollBar; opacity: 1 } + PropertyChanges { target: horizontalScrollBar; opacity: 1 } + } + + transitions: Transition { + NumberAnimation { properties: "opacity"; duration: 400 } + } + } + + // Attach scrollbars to the right and bottom edges of the view. + ScrollBar { + id: verticalScrollBar + width: 12; height: view.height-12 + anchors.right: view.right + opacity: 0 + orientation: Qt.Vertical + position: view.visibleArea.yPosition + pageSize: view.visibleArea.heightRatio + } + + ScrollBar { + id: horizontalScrollBar + width: view.width-12; height: 12 + anchors.bottom: view.bottom + opacity: 0 + orientation: Qt.Horizontal + position: view.visibleArea.xPosition + pageSize: view.visibleArea.widthRatio + } +} diff --git a/examples/qml/ui-components/scrollbar/pics/niagara_falls.jpg b/examples/qml/ui-components/scrollbar/pics/niagara_falls.jpg new file mode 100644 index 0000000000..e625c0d3e6 Binary files /dev/null and b/examples/qml/ui-components/scrollbar/pics/niagara_falls.jpg differ diff --git a/examples/qml/ui-components/scrollbar/scrollbar.qmlproject b/examples/qml/ui-components/scrollbar/scrollbar.qmlproject new file mode 100644 index 0000000000..e5a8bf02ca --- /dev/null +++ b/examples/qml/ui-components/scrollbar/scrollbar.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "main.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/ui-components/searchbox/SearchBox.qml b/examples/qml/ui-components/searchbox/SearchBox.qml new file mode 100644 index 0000000000..6f6f486412 --- /dev/null +++ b/examples/qml/ui-components/searchbox/SearchBox.qml @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +FocusScope { + id: focusScope + width: 250; height: 28 + + BorderImage { + source: "images/lineedit-bg.png" + width: parent.width; height: parent.height + border { left: 4; top: 4; right: 4; bottom: 4 } + } + + BorderImage { + source: "images/lineedit-bg-focus.png" + width: parent.width; height: parent.height + border { left: 4; top: 4; right: 4; bottom: 4 } + visible: parent.activeFocus ? true : false + } + + Text { + id: typeSomething + anchors.fill: parent; anchors.leftMargin: 8 + verticalAlignment: Text.AlignVCenter + text: "Type something..." + color: "gray" + font.italic: true + } + + MouseArea { + anchors.fill: parent + onClicked: { focusScope.focus = true; textInput.openSoftwareInputPanel(); } + } + + TextInput { + id: textInput + anchors { left: parent.left; leftMargin: 8; right: clear.left; rightMargin: 8; verticalCenter: parent.verticalCenter } + focus: true + selectByMouse: true + } + + Image { + id: clear + anchors { right: parent.right; rightMargin: 8; verticalCenter: parent.verticalCenter } + source: "images/clear.png" + opacity: 0 + + MouseArea { + anchors.fill: parent + onClicked: { textInput.text = ''; focusScope.focus = true; textInput.openSoftwareInputPanel(); } + } + } + + states: State { + name: "hasText"; when: textInput.text != '' + PropertyChanges { target: typeSomething; opacity: 0 } + PropertyChanges { target: clear; opacity: 1 } + } + + transitions: [ + Transition { + from: ""; to: "hasText" + NumberAnimation { exclude: typeSomething; properties: "opacity" } + }, + Transition { + from: "hasText"; to: "" + NumberAnimation { properties: "opacity" } + } + ] +} diff --git a/examples/qml/ui-components/searchbox/images/clear.png b/examples/qml/ui-components/searchbox/images/clear.png new file mode 100644 index 0000000000..91eb270695 Binary files /dev/null and b/examples/qml/ui-components/searchbox/images/clear.png differ diff --git a/examples/qml/ui-components/searchbox/images/lineedit-bg-focus.png b/examples/qml/ui-components/searchbox/images/lineedit-bg-focus.png new file mode 100644 index 0000000000..bbfac38d2d Binary files /dev/null and b/examples/qml/ui-components/searchbox/images/lineedit-bg-focus.png differ diff --git a/examples/qml/ui-components/searchbox/images/lineedit-bg.png b/examples/qml/ui-components/searchbox/images/lineedit-bg.png new file mode 100644 index 0000000000..9044226f85 Binary files /dev/null and b/examples/qml/ui-components/searchbox/images/lineedit-bg.png differ diff --git a/examples/qml/ui-components/searchbox/main.qml b/examples/qml/ui-components/searchbox/main.qml new file mode 100644 index 0000000000..6e9731cf9c --- /dev/null +++ b/examples/qml/ui-components/searchbox/main.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: page + width: 500; height: 250 + color: "#edecec" + + MouseArea { + anchors.fill: parent + onClicked: page.focus = false; + } + Column { + anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter } + spacing: 10 + + SearchBox { id: search1; KeyNavigation.tab: search2; KeyNavigation.backtab: search3; focus: true } + SearchBox { id: search2; KeyNavigation.tab: search3; KeyNavigation.backtab: search1 } + SearchBox { id: search3; KeyNavigation.tab: search1; KeyNavigation.backtab: search2 } + } +} diff --git a/examples/qml/ui-components/searchbox/searchbox.qmlproject b/examples/qml/ui-components/searchbox/searchbox.qmlproject new file mode 100644 index 0000000000..e5a8bf02ca --- /dev/null +++ b/examples/qml/ui-components/searchbox/searchbox.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "main.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/ui-components/slideswitch/content/Switch.qml b/examples/qml/ui-components/slideswitch/content/Switch.qml new file mode 100644 index 0000000000..981fc16673 --- /dev/null +++ b/examples/qml/ui-components/slideswitch/content/Switch.qml @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + id: toggleswitch + width: background.width; height: background.height + +//![1] + property bool on: false +//![1] + +//![2] + function toggle() { + if (toggleswitch.state == "on") + toggleswitch.state = "off"; + else + toggleswitch.state = "on"; + } +//![2] + +//![3] + function releaseSwitch() { + if (knob.x == 1) { + if (toggleswitch.state == "off") return; + } + if (knob.x == 78) { + if (toggleswitch.state == "on") return; + } + toggle(); + } +//![3] + +//![4] + Image { + id: background + source: "background.png" + MouseArea { anchors.fill: parent; onClicked: toggle() } + } +//![4] + +//![5] + Image { + id: knob + x: 1; y: 2 + source: "knob.png" + + MouseArea { + anchors.fill: parent + drag.target: knob; drag.axis: Drag.XAxis; drag.minimumX: 1; drag.maximumX: 78 + onClicked: toggle() + onReleased: releaseSwitch() + } + } +//![5] + +//![6] + states: [ + State { + name: "on" + PropertyChanges { target: knob; x: 78 } + PropertyChanges { target: toggleswitch; on: true } + }, + State { + name: "off" + PropertyChanges { target: knob; x: 1 } + PropertyChanges { target: toggleswitch; on: false } + } + ] +//![6] + +//![7] + transitions: Transition { + NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad; duration: 200 } + } +//![7] +} +//![0] diff --git a/examples/qml/ui-components/slideswitch/content/background.png b/examples/qml/ui-components/slideswitch/content/background.png new file mode 100644 index 0000000000..d736815870 Binary files /dev/null and b/examples/qml/ui-components/slideswitch/content/background.png differ diff --git a/examples/qml/ui-components/slideswitch/content/background.svg b/examples/qml/ui-components/slideswitch/content/background.svg new file mode 100644 index 0000000000..f920d3e47a --- /dev/null +++ b/examples/qml/ui-components/slideswitch/content/background.svg @@ -0,0 +1,23 @@ + + + +]> + + + + + + + + + + + + + + diff --git a/examples/qml/ui-components/slideswitch/content/knob.png b/examples/qml/ui-components/slideswitch/content/knob.png new file mode 100644 index 0000000000..ee0a436f84 Binary files /dev/null and b/examples/qml/ui-components/slideswitch/content/knob.png differ diff --git a/examples/qml/ui-components/slideswitch/content/knob.svg b/examples/qml/ui-components/slideswitch/content/knob.svg new file mode 100644 index 0000000000..fb6933718e --- /dev/null +++ b/examples/qml/ui-components/slideswitch/content/knob.svg @@ -0,0 +1,867 @@ + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/qml/ui-components/slideswitch/slideswitch.qml b/examples/qml/ui-components/slideswitch/slideswitch.qml new file mode 100644 index 0000000000..60a331407c --- /dev/null +++ b/examples/qml/ui-components/slideswitch/slideswitch.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + color: "white" + width: 400; height: 250 + +//![0] + Switch { anchors.centerIn: parent; on: false } +//![0] +} diff --git a/examples/qml/ui-components/spinner/content/Spinner.qml b/examples/qml/ui-components/spinner/content/Spinner.qml new file mode 100644 index 0000000000..d7bbeb33ee --- /dev/null +++ b/examples/qml/ui-components/spinner/content/Spinner.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + property alias model: view.model + property alias delegate: view.delegate + property alias currentIndex: view.currentIndex + property real itemHeight: 30 + + source: "spinner-bg.png" + clip: true + + PathView { + id: view + anchors.fill: parent + + pathItemCount: height/itemHeight + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + highlight: Image { source: "spinner-select.png"; width: view.width; height: itemHeight+4 } + dragMargin: view.width/2 + + path: Path { + startX: view.width/2; startY: -itemHeight/2 + PathLine { x: view.width/2; y: view.pathItemCount*itemHeight + itemHeight } + } + } + + Keys.onDownPressed: view.incrementCurrentIndex() + Keys.onUpPressed: view.decrementCurrentIndex() +} diff --git a/examples/qml/ui-components/spinner/content/spinner-bg.png b/examples/qml/ui-components/spinner/content/spinner-bg.png new file mode 100644 index 0000000000..b3556f1f9f Binary files /dev/null and b/examples/qml/ui-components/spinner/content/spinner-bg.png differ diff --git a/examples/qml/ui-components/spinner/content/spinner-select.png b/examples/qml/ui-components/spinner/content/spinner-select.png new file mode 100644 index 0000000000..95a17a1fe2 Binary files /dev/null and b/examples/qml/ui-components/spinner/content/spinner-select.png differ diff --git a/examples/qml/ui-components/spinner/main.qml b/examples/qml/ui-components/spinner/main.qml new file mode 100644 index 0000000000..7584c98396 --- /dev/null +++ b/examples/qml/ui-components/spinner/main.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + width: 240; height: 320 + + Column { + y: 20; x: 20; spacing: 20 + + Spinner { + id: spinner + width: 200; height: 240 + focus: true + model: 20 + itemHeight: 30 + delegate: Text { font.pixelSize: 25; text: index; height: 30 } + } + + Text { text: "Current item index: " + spinner.currentIndex } + } +} diff --git a/examples/qml/ui-components/spinner/spinner.qmlproject b/examples/qml/ui-components/spinner/spinner.qmlproject new file mode 100644 index 0000000000..e5a8bf02ca --- /dev/null +++ b/examples/qml/ui-components/spinner/spinner.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "main.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/ui-components/tabwidget/TabWidget.qml b/examples/qml/ui-components/tabwidget/TabWidget.qml new file mode 100644 index 0000000000..560ed1f58a --- /dev/null +++ b/examples/qml/ui-components/tabwidget/TabWidget.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: tabWidget + + // Setting the default property to stack.children means any child items + // of the TabWidget are actually added to the 'stack' item's children. + // See the "Property Binding" + // documentation for details on default properties. + default property alias content: stack.children + + property int current: 0 + + onCurrentChanged: setOpacities() + Component.onCompleted: setOpacities() + + function setOpacities() { + for (var i = 0; i < stack.children.length; ++i) { + stack.children[i].opacity = (i == current ? 1 : 0) + } + } + + Row { + id: header + + Repeater { + model: stack.children.length + delegate: Rectangle { + width: tabWidget.width / stack.children.length; height: 36 + + Rectangle { + width: parent.width; height: 1 + anchors { bottom: parent.bottom; bottomMargin: 1 } + color: "#acb2c2" + } + BorderImage { + anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 } + border { left: 7; right: 7 } + source: "tab.png" + visible: tabWidget.current == index + } + Text { + horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter + anchors.fill: parent + text: stack.children[index].title + elide: Text.ElideRight + font.bold: tabWidget.current == index + } + MouseArea { + anchors.fill: parent + onClicked: tabWidget.current = index + } + } + } + } + + Item { + id: stack + width: tabWidget.width + anchors.top: header.bottom; anchors.bottom: tabWidget.bottom + } +} diff --git a/examples/qml/ui-components/tabwidget/main.qml b/examples/qml/ui-components/tabwidget/main.qml new file mode 100644 index 0000000000..df99c11b7d --- /dev/null +++ b/examples/qml/ui-components/tabwidget/main.qml @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +TabWidget { + id: tabs + width: 640; height: 480 + + Rectangle { + property string title: "Red" + anchors.fill: parent + color: "#e3e3e3" + + Rectangle { + anchors.fill: parent; anchors.margins: 20 + color: "#ff7f7f" + Text { + width: parent.width - 20 + anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter + text: "Roses are red" + font.pixelSize: 20 + wrapMode: Text.WordWrap + } + } + } + + Rectangle { + property string title: "Green" + anchors.fill: parent + color: "#e3e3e3" + + Rectangle { + anchors.fill: parent; anchors.margins: 20 + color: "#7fff7f" + Text { + width: parent.width - 20 + anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter + text: "Flower stems are green" + font.pixelSize: 20 + wrapMode: Text.WordWrap + } + } + } + + Rectangle { + property string title: "Blue" + anchors.fill: parent; color: "#e3e3e3" + + Rectangle { + anchors.fill: parent; anchors.margins: 20 + color: "#7f7fff" + Text { + width: parent.width - 20 + anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter + text: "Violets are blue" + font.pixelSize: 20 + wrapMode: Text.WordWrap + } + } + } +} diff --git a/examples/qml/ui-components/tabwidget/tab.png b/examples/qml/ui-components/tabwidget/tab.png new file mode 100644 index 0000000000..ad8021605f Binary files /dev/null and b/examples/qml/ui-components/tabwidget/tab.png differ diff --git a/examples/qml/ui-components/tabwidget/tabwidget.qmlproject b/examples/qml/ui-components/tabwidget/tabwidget.qmlproject new file mode 100644 index 0000000000..e5a8bf02ca --- /dev/null +++ b/examples/qml/ui-components/tabwidget/tabwidget.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "main.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/window/Window.qml b/examples/qml/window/Window.qml new file mode 100644 index 0000000000..48478458c6 --- /dev/null +++ b/examples/qml/window/Window.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Window 2.0 as Window + +Window.Window { + width: 640 + height: 480 + visible: true //It's false by default + property Component self + Component.onCompleted: self = Qt.createComponent("Window.qml") + Text{ + text: "Hello World!" + anchors.centerIn: parent + } + MouseArea{ + anchors.fill: parent + onClicked: self.createObject(); + } +} diff --git a/examples/qml/window/screen/screenInfo.qml b/examples/qml/window/screen/screenInfo.qml new file mode 100644 index 0000000000..54299ba4e0 --- /dev/null +++ b/examples/qml/window/screen/screenInfo.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Window 2.0 as Window + +Item { + id: root + width: 400 + height: 200 + Item { + id: main + state: "orientation " + Window.Screen.orientation + + property bool landscapeWindow: Window.Screen.primaryOrientation == Qt.LandscapeOrientation + property real baseWidth: landscapeWindow ? root.height : root.width + property real baseHeight: landscapeWindow ? root.width : root.height + property real rotationDelta: landscapeWindow ? -90 : 0 + + rotation: rotationDelta + width: main.baseWidth + height: main.baseHeight + anchors.centerIn: parent + + Text { + text: "Screen is " + Window.Screen.width + "x" + Window.Screen.height + " and primarily orientation " + Window.Screen.primaryOrientation + anchors.centerIn:parent + } + + + states: [ + State { + name: "orientation " + Qt.LandscapeOrientation + PropertyChanges { target: main; rotation: 90 + rotationDelta; width: main.baseHeight; height: main.baseWidth } + }, + State { + name: "orientation " + Qt.InvertedPortraitOrientation + PropertyChanges { target: main; rotation: 180 + rotationDelta; } + }, + State { + name: "orientation " + Qt.InvertedLandscapeOrientation + PropertyChanges { target: main; rotation: 270 + rotationDelta; width: main.baseHeight; height: main.baseWidth } + } + ] + + transitions: Transition { + SequentialAnimation { + RotationAnimation { direction: RotationAnimation.Shortest; duration: 300; easing.type: Easing.InOutQuint } + NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint } + } + } + } +} diff --git a/examples/qml/window/standalone.qml b/examples/qml/window/standalone.qml new file mode 100644 index 0000000000..335cf7b635 --- /dev/null +++ b/examples/qml/window/standalone.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Window 2.0 as Window + +Item { + width: 640 + height: 480 + Text { + anchors.centerIn: parent + text: "First Window" + } + MouseArea { + anchors.fill: parent + onClicked: Qt.quit() + } + Window.Window { + width: 640 + height: 480 + x: 640 + y: 480 + visible: true + color: "green" + Text { + anchors.centerIn: parent + text: "Second Window" + } + MouseArea{ + anchors.fill: parent + onClicked: Qt.quit() + } + } +} diff --git a/examples/qml/window/window.cpp b/examples/qml/window/window.cpp new file mode 100644 index 0000000000..2112ab8f45 --- /dev/null +++ b/examples/qml/window/window.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include + +int main(int argc, char* argv[]) +{ + QGuiApplication app(argc, argv); + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(QUrl::fromLocalFile("Window.qml")); + if ( component.isReady() ) + component.create(); + else + qWarning() << component.errorString(); + return app.exec(); +} diff --git a/examples/qml/window/window.pro b/examples/qml/window/window.pro new file mode 100644 index 0000000000..c4518418f6 --- /dev/null +++ b/examples/qml/window/window.pro @@ -0,0 +1,5 @@ +TEMPLATE = app +CONFIG += qt +QT += qml + +SOURCES += window.cpp diff --git a/examples/qml/xml/xmlhttprequest/data.xml b/examples/qml/xml/xmlhttprequest/data.xml new file mode 100644 index 0000000000..8b7f1e116d --- /dev/null +++ b/examples/qml/xml/xmlhttprequest/data.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/examples/qml/xml/xmlhttprequest/xmlhttprequest-example.qml b/examples/qml/xml/xmlhttprequest/xmlhttprequest-example.qml new file mode 100644 index 0000000000..28ba078160 --- /dev/null +++ b/examples/qml/xml/xmlhttprequest/xmlhttprequest-example.qml @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 350; height: 400 + + function showRequestInfo(text) { + log.text = log.text + "\n" + text + console.log(text) + } + + Text { id: log; anchors.fill: parent; anchors.margins: 10 } + + Rectangle { + id: button + anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom; anchors.margins: 10 + width: buttonText.width + 10; height: buttonText.height + 10 + border.width: mouseArea.pressed ? 2 : 1 + radius : 5; smooth: true + + Text { id: buttonText; anchors.centerIn: parent; text: "Request data.xml" } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { + log.text = "" + console.log("\n") + + var doc = new XMLHttpRequest(); + doc.onreadystatechange = function() { + if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) { + showRequestInfo("Headers -->"); + showRequestInfo(doc.getAllResponseHeaders ()); + showRequestInfo("Last modified -->"); + showRequestInfo(doc.getResponseHeader ("Last-Modified")); + + } else if (doc.readyState == XMLHttpRequest.DONE) { + var a = doc.responseXML.documentElement; + for (var ii = 0; ii < a.childNodes.length; ++ii) { + showRequestInfo(a.childNodes[ii].nodeName); + } + showRequestInfo("Headers -->"); + showRequestInfo(doc.getAllResponseHeaders ()); + showRequestInfo("Last modified -->"); + showRequestInfo(doc.getResponseHeader ("Last-Modified")); + } + } + + doc.open("GET", "data.xml"); + doc.send(); + } + } + } +} + diff --git a/examples/qtquick/accessibility/accessibility.qml b/examples/qtquick/accessibility/accessibility.qml deleted file mode 100644 index ff115ab4b3..0000000000 --- a/examples/qtquick/accessibility/accessibility.qml +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -/*! - \title QtQuick Examples - Accessibility - \example qtquick/accessibility - \brief This example has accessible buttons. - -*/ - -Rectangle { - id: window - - width: 320; height: 480 - color: "white" - - Column { - id: column - spacing: 6 - anchors.fill: parent - width: parent.width - Row { - spacing: 6 - width: column.width - Button { width: 100; height: column.h + 20; text: "Send" } - Button { width: 100; height: column.h + 20; text: "Discard" } - } - - Row { - spacing: 6 - width: column.width - height: column.h - Text { - id: subjectLabel - Accessible.role: Accessible.StaticText - Accessible.name: text - text: "Subject:" - } - Rectangle { - id: subjectBorder - Accessible.role: Accessible.EditableText - Accessible.name: subjectEdit.text - border.width: 1 - border.color: "black" - height: subjectEdit.height - width: 240 - TextInput { - id: subjectEdit - text: "Vacation plans" - } - } - } - Rectangle { - id: textBorder - Accessible.role: Accessible.EditableText - property alias text : textEdit.text - border.width: 1 - border.color: "black" - width: parent.width - 2 - height: parent.height - (textBorder.y + column.spacing) - TextEdit { - id: textEdit - text: "Hi, we're going to the Dolomites this summer. Weren't you also going to northern Italy? \n\nbest wishes, your friend Luke" - width: parent.width - wrapMode: TextEdit.WordWrap - } - } - } -} diff --git a/examples/qtquick/accessibility/content/Button.qml b/examples/qtquick/accessibility/content/Button.qml deleted file mode 100644 index 33cee8036c..0000000000 --- a/examples/qtquick/accessibility/content/Button.qml +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: button - - property bool checked: false - property alias text : buttonText.text - Accessible.name: text - Accessible.description: "This button does " + text - Accessible.role: Accessible.Button - - signal clicked - - width: buttonText.width + 20 - height: 30 - gradient: Gradient { - GradientStop { position: 0.0; color: "lightsteelblue" } - GradientStop { position: 1.0; color: "blue" } - } - border.width: 2 - border.color: "black"; - radius: 10 - - Text { - id: buttonText - text: parent.description - anchors.centerIn: parent - font.pixelSize: parent.height * .5 - style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true - } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: { - checked = !checked; - } - } -} diff --git a/examples/qtquick/animation/animation.pro b/examples/qtquick/animation/animation.pro deleted file mode 100644 index 7e4cf9ef66..0000000000 --- a/examples/qtquick/animation/animation.pro +++ /dev/null @@ -1,10 +0,0 @@ -TEMPLATE = app - -QT += quick declarative -SOURCES += main.cpp - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/animation -qml.files = animation.qml basics behaviors easing pathanimation pathinterpolator states -qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/animation -INSTALLS += target qml - diff --git a/examples/qtquick/canvas/stockchart/plugin.cpp b/examples/qtquick/canvas/stockchart/plugin.cpp deleted file mode 100644 index af64af4da8..0000000000 --- a/examples/qtquick/canvas/stockchart/plugin.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include "model.h" - -class QStockChartExampleQmlPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - void registerTypes(const char *uri) - { - Q_ASSERT(uri == QLatin1String("com.nokia.StockChartExample")); - qmlRegisterType(uri, 1, 0, "StockModel"); - qmlRegisterType(uri, 1, 0, "StockPrice"); - } -}; - -#include "plugin.moc" - -Q_EXPORT_PLUGIN2(qmlstockchartexampleplugin, QStockChartExampleQmlPlugin); diff --git a/examples/qtquick/canvas/stockchart/stockchart.pro b/examples/qtquick/canvas/stockchart/stockchart.pro deleted file mode 100644 index 4006b5dccf..0000000000 --- a/examples/qtquick/canvas/stockchart/stockchart.pro +++ /dev/null @@ -1,20 +0,0 @@ -TEMPLATE = lib -CONFIG += qt plugin -QT += declarative network - -DESTDIR = com/nokia/StockChartExample -TARGET = qmlstockchartexampleplugin - -SOURCES += model.cpp plugin.cpp -HEADERS += model.h -qdeclarativesources.files += \ - com/nokia/StockChartExample/qmldir \ - stock.qml - -qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins/com/nokia/StockChartExample - -sources.files += stockchart.pro model.h model.cpp plugin.cpp README -sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins -target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins/com/nokia/StockChartExample - -INSTALLS += qdeclarativesources sources target diff --git a/examples/qtquick/modelviews/abstractitemmodel/abstractitemmodel.pro b/examples/qtquick/modelviews/abstractitemmodel/abstractitemmodel.pro deleted file mode 100644 index eaf2b30c89..0000000000 --- a/examples/qtquick/modelviews/abstractitemmodel/abstractitemmodel.pro +++ /dev/null @@ -1,10 +0,0 @@ -TEMPLATE = app -TARGET = abstractitemmodel -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative quick - -HEADERS = model.h -SOURCES = main.cpp \ - model.cpp -RESOURCES += abstractitemmodel.qrc diff --git a/examples/qtquick/modelviews/abstractitemmodel/main.cpp b/examples/qtquick/modelviews/abstractitemmodel/main.cpp deleted file mode 100644 index b6ca2df26e..0000000000 --- a/examples/qtquick/modelviews/abstractitemmodel/main.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "model.h" - -#include -#include -#include -#include -#include -#include - -//![0] -int main(int argc, char ** argv) -{ - QGuiApplication app(argc, argv); - - AnimalModel model; - model.addAnimal(Animal("Wolf", "Medium")); - model.addAnimal(Animal("Polar bear", "Large")); - model.addAnimal(Animal("Quoll", "Small")); - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", &model); -//![0] - - view.setSource(QUrl("qrc:view.qml")); - view.show(); - - return app.exec(); -} - diff --git a/examples/qtquick/modelviews/listview/content/ToggleButton.qml b/examples/qtquick/modelviews/listview/content/ToggleButton.qml deleted file mode 100644 index 0754d9849b..0000000000 --- a/examples/qtquick/modelviews/listview/content/ToggleButton.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: root - property alias label: text.text - property bool active: false - signal toggled - width: 149 - height: 30 - radius: 3 - color: active ? "green" : "lightgray" - border.width: 1 - Text { id: text; anchors.centerIn: parent; font.pixelSize: 14 } - MouseArea { - anchors.fill: parent - onClicked: { active = !active; root.toggled() } - } -} diff --git a/examples/qtquick/modelviews/objectlistmodel/main.cpp b/examples/qtquick/modelviews/objectlistmodel/main.cpp deleted file mode 100644 index c8542976c3..0000000000 --- a/examples/qtquick/modelviews/objectlistmodel/main.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include -#include -#include -#include -#include - -#include "dataobject.h" - -/* - This example illustrates exposing a QList as a - model in QML -*/ - -//![0] -int main(int argc, char ** argv) -{ - QGuiApplication app(argc, argv); - - QList dataList; - dataList.append(new DataObject("Item 1", "red")); - dataList.append(new DataObject("Item 2", "green")); - dataList.append(new DataObject("Item 3", "blue")); - dataList.append(new DataObject("Item 4", "yellow")); - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); -//![0] - - view.setSource(QUrl("qrc:view.qml")); - view.show(); - - return app.exec(); -} - diff --git a/examples/qtquick/modelviews/objectlistmodel/objectlistmodel.pro b/examples/qtquick/modelviews/objectlistmodel/objectlistmodel.pro deleted file mode 100644 index 74dc5b1016..0000000000 --- a/examples/qtquick/modelviews/objectlistmodel/objectlistmodel.pro +++ /dev/null @@ -1,6 +0,0 @@ -QT += declarative quick - -SOURCES += main.cpp \ - dataobject.cpp -HEADERS += dataobject.h -RESOURCES += objectlistmodel.qrc diff --git a/examples/qtquick/modelviews/stringlistmodel/main.cpp b/examples/qtquick/modelviews/stringlistmodel/main.cpp deleted file mode 100644 index 47d7fdaa8c..0000000000 --- a/examples/qtquick/modelviews/stringlistmodel/main.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include -#include -#include -#include -#include - - -/* - This example illustrates exposing a QStringList as a - model in QML -*/ - -int main(int argc, char ** argv) -{ - QGuiApplication app(argc, argv); - -//![0] - QStringList dataList; - dataList.append("Item 1"); - dataList.append("Item 2"); - dataList.append("Item 3"); - dataList.append("Item 4"); - - QQuickView view; - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); -//![0] - - view.setSource(QUrl("qrc:view.qml")); - view.show(); - - return app.exec(); -} - diff --git a/examples/qtquick/modelviews/stringlistmodel/stringlistmodel.pro b/examples/qtquick/modelviews/stringlistmodel/stringlistmodel.pro deleted file mode 100644 index 540d8c71f0..0000000000 --- a/examples/qtquick/modelviews/stringlistmodel/stringlistmodel.pro +++ /dev/null @@ -1,4 +0,0 @@ -QT += declarative quick - -SOURCES += main.cpp -RESOURCES += stringlistmodel.qrc diff --git a/examples/qtquick/openglunderqml/openglunderqml.pro b/examples/qtquick/openglunderqml/openglunderqml.pro deleted file mode 100644 index 117ad0c33e..0000000000 --- a/examples/qtquick/openglunderqml/openglunderqml.pro +++ /dev/null @@ -1,6 +0,0 @@ -QT += declarative quick - -HEADERS += squircle.h -SOURCES += squircle.cpp main.cpp - -OTHER_FILES += main.qml diff --git a/examples/qtquick/painteditem/smile/main.cpp b/examples/qtquick/painteditem/smile/main.cpp deleted file mode 100644 index 1e6b42351d..0000000000 --- a/examples/qtquick/painteditem/smile/main.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -class MyPaintItem : public QQuickPaintedItem -{ - Q_OBJECT - Q_PROPERTY(QString face READ face WRITE setFace NOTIFY faceChanged) -public: - MyPaintItem() - : QQuickPaintedItem() - , m_face(QLatin1String(":-)")) - { - setAntialiasing(true); - } - QString face() const {return m_face;} - void setFace(const QString &face) { - if (m_face != face) { - m_face = face; - emit faceChanged(); - } - } - virtual void paint(QPainter *p) - { - QRectF rect(0, 0, width(), height()); - rect.adjust(10, 10, -10, -10); - p->setPen(QPen(Qt::black, 20)); - p->setBrush(Qt::yellow); - p->drawEllipse(rect); - p->setPen(Qt::black); - p->setFont(QFont(QLatin1String("Times"), qRound(rect.height() / 2))); - p->drawText(rect, Qt::AlignCenter, m_face); - } -signals: - void faceChanged(); -private: - QString m_face; -}; - -int main(int argc, char ** argv) -{ - QGuiApplication app(argc, argv); - - qmlRegisterType("MyModule", 1, 0, "MyPaintItem"); - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl::fromLocalFile("smile.qml")); - view.show(); - view.raise(); - - return app.exec(); -} - -#include "main.moc" diff --git a/examples/qtquick/painteditem/smile/smile.pro b/examples/qtquick/painteditem/smile/smile.pro deleted file mode 100644 index 780d351fe6..0000000000 --- a/examples/qtquick/painteditem/smile/smile.pro +++ /dev/null @@ -1,11 +0,0 @@ -TEMPLATE = app -TARGET = painteditem - -QT += declarative quick - -macx: CONFIG -= app_bundle - -SOURCES += main.cpp - -CONFIG += console - diff --git a/examples/qtquick/painteditem/textballoons/TextBalloonPlugin/plugin.h b/examples/qtquick/painteditem/textballoons/TextBalloonPlugin/plugin.h deleted file mode 100644 index f444d31f4e..0000000000 --- a/examples/qtquick/painteditem/textballoons/TextBalloonPlugin/plugin.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include "../textballoon.h" - -class TextBalloonPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "textballoon.json") -public: - void registerTypes(const char *uri) - { - qmlRegisterType(uri, 1, 0, "TextBalloon"); - } -}; diff --git a/examples/qtquick/painteditem/textballoons/textballoons.pro b/examples/qtquick/painteditem/textballoons/textballoons.pro deleted file mode 100644 index e0b9404f65..0000000000 --- a/examples/qtquick/painteditem/textballoons/textballoons.pro +++ /dev/null @@ -1,25 +0,0 @@ -TEMPLATE = lib -CONFIG += qt plugin -QT += declarative quick - -TARGET = qmltextballoonplugin - -HEADERS += TextBalloonPlugin/plugin.h \ - textballoon.h - -SOURCES += textballoon.cpp - -OTHER_FILES += textballoon.json - -DESTDIR = TextBalloonPlugin - -qdeclarativesources.files += \ - TextBalloonPlugin/qmldir - -qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/painteditem/textballoons/TextBalloonPlugin - -sources.files = textballoons.qml -sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/painteditem/textballoons -target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/painteditem/textballoons/TextBalloonPlugin - -INSTALLS = qdeclarativesources sources target diff --git a/examples/qtquick/shadereffects/shadereffects.qml b/examples/qtquick/shadereffects/shadereffects.qml deleted file mode 100644 index 70bcf1352a..0000000000 --- a/examples/qtquick/shadereffects/shadereffects.qml +++ /dev/null @@ -1,315 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Declarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Image { - width: 320 - height: 480 -/*! - \title QML Examples - Shader Effects - \example declarative/shadereffects - \image qml-shadereffects-example.png - \brief This is a shader effects example - - This example demonstrates a couple of visual effects that you can perform - with shaders in QtQuick 2.0 -*/ - source: "../snake/content/pics/background.png" - - Flickable { - anchors.fill: parent - contentWidth: 640 - contentHeight: 360 - - ShaderEffectSource { - id: theSource - sourceItem: theItem - smooth: true - } - - function saturate(x) { - return Math.min(Math.max(x, 0), 1) - } - - function sliderToColor(x) { - return Qt.rgba(saturate(Math.max(2 - 6 * x, 6 * x - 4)), - saturate(Math.min(6 * x, 4 - 6 * x)), - saturate(Math.min(6 * x - 2, 6 - 6 * x))) - } - - Grid { - anchors.centerIn: parent - columns: 3 - - Item { - id: theItem - width: 180 - height: 180 - ListView { - anchors.centerIn: parent - width: 160 - height: 140 - clip: true - snapMode: ListView.SnapOneItem - model: VisualItemModel { - Text { - width: 160 - height: 140 - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - font.pixelSize: 120 - font.family: "Times" - color: "blue" - text: "Qt" - } - Image { - width: 160 - height: 140 - source: "content/qt-logo.png" - smooth: true - } - Image { - width: 160 - height: 140 - source: "content/face-smile.png" - smooth: true - } - } - } - } - ShaderEffect { - width: 180 - height: 180 - property variant source: theSource - property real amplitude: 0.04 * wobbleSlider.value - property real frequency: 20 - property real time: 0 - NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 } - fragmentShader: - "uniform lowp float qt_Opacity;" + - "uniform highp float amplitude;" + - "uniform highp float frequency;" + - "uniform highp float time;" + - "uniform sampler2D source;" + - "varying highp vec2 qt_TexCoord0;" + - "void main() {" + - " highp vec2 p = sin(time + frequency * qt_TexCoord0);" + - " gl_FragColor = texture2D(source, qt_TexCoord0 + amplitude * vec2(p.y, -p.x)) * qt_Opacity;" + - "}" - Slider { - id: wobbleSlider - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - height: 40 - } - } - ShaderEffect { - width: 180 - height: 180 - property variant source: theSource - property variant shadow: ShaderEffectSource { - smooth: true - sourceItem: ShaderEffect { - width: theItem.width - height: theItem.height - property variant delta: Qt.size(0.0, 1.0 / height) - property variant source: ShaderEffectSource { - smooth: true - sourceItem: ShaderEffect { - width: theItem.width - height: theItem.height - property variant delta: Qt.size(1.0 / width, 0.0) - property variant source: theSource - fragmentShader: " - uniform lowp float qt_Opacity; - uniform sampler2D source; - uniform highp vec2 delta; - varying highp vec2 qt_TexCoord0; - void main() { - gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta) - + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta) - + 0.2466 * texture2D(source, qt_TexCoord0) - + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta) - + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity; - }" - } - } - fragmentShader: " - uniform lowp float qt_Opacity; - uniform sampler2D source; - uniform highp vec2 delta; - varying highp vec2 qt_TexCoord0; - void main() { - gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta) - + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta) - + 0.2466 * texture2D(source, qt_TexCoord0) - + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta) - + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity; - }" - } - } - property real angle: 0 - property variant offset: Qt.point(15.0 * Math.cos(angle), 15.0 * Math.sin(angle)) - NumberAnimation on angle { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 6000 } - property variant delta: Qt.size(offset.x / width, offset.y / height) - property real darkness: shadowSlider.value - fragmentShader: " - uniform lowp float qt_Opacity; - uniform highp vec2 offset; - uniform sampler2D source; - uniform sampler2D shadow; - uniform highp float darkness; - uniform highp vec2 delta; - varying highp vec2 qt_TexCoord0; - void main() { - lowp vec4 fg = texture2D(source, qt_TexCoord0); - lowp vec4 bg = texture2D(shadow, qt_TexCoord0 + delta); - gl_FragColor = (fg + vec4(0., 0., 0., darkness * bg.a) * (1. - fg.a)) * qt_Opacity; - }" - Slider { - id: shadowSlider - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - height: 40 - } - } - ShaderEffect { - width: 180 - height: 180 - property variant source: theSource - property variant delta: Qt.size(0.5 / width, 0.5 / height) - fragmentShader: " - uniform sampler2D source; - uniform highp vec2 delta; - uniform highp float qt_Opacity; - varying highp vec2 qt_TexCoord0; - void main() { - lowp vec4 tl = texture2D(source, qt_TexCoord0 - delta); - lowp vec4 tr = texture2D(source, qt_TexCoord0 + vec2(delta.x, -delta.y)); - lowp vec4 bl = texture2D(source, qt_TexCoord0 - vec2(delta.x, -delta.y)); - lowp vec4 br = texture2D(source, qt_TexCoord0 + delta); - lowp vec4 gx = (tl + bl) - (tr + br); - lowp vec4 gy = (tl + tr) - (bl + br); - gl_FragColor.xyz = vec3(0.); - gl_FragColor.w = clamp(dot(sqrt(gx * gx + gy * gy), vec4(1.)), 0., 1.) * qt_Opacity; - }" - } - ShaderEffect { - width: 180 - height: 180 - property variant source: theSource - property color tint: sliderToColor(colorizeSlider.value) - fragmentShader: " - uniform sampler2D source; - uniform lowp vec4 tint; - uniform lowp float qt_Opacity; - varying highp vec2 qt_TexCoord0; - void main() { - lowp vec4 c = texture2D(source, qt_TexCoord0); - lowp float lo = min(min(c.x, c.y), c.z); - lowp float hi = max(max(c.x, c.y), c.z); - gl_FragColor = qt_Opacity * vec4(mix(vec3(lo), vec3(hi), tint.xyz), c.w); - }" - Slider { - id: colorizeSlider - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - height: 40 - } - } - ShaderEffect { - width: 180 - height: 180 - mesh: Qt.size(10, 10) - property variant source: theSource - property real bend: 0 - property real minimize: 0 - property real side: genieSlider.value - SequentialAnimation on bend { - loops: Animation.Infinite - NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine } - PauseAnimation { duration: 1600 } - NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine } - PauseAnimation { duration: 1000 } - } - SequentialAnimation on minimize { - loops: Animation.Infinite - PauseAnimation { duration: 300 } - NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine } - PauseAnimation { duration: 1000 } - NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine } - PauseAnimation { duration: 1300 } - } - vertexShader: " - uniform highp mat4 qt_Matrix; - uniform highp float bend; - uniform highp float minimize; - uniform highp float side; - uniform highp float width; - uniform highp float height; - attribute highp vec4 qt_Vertex; - attribute highp vec2 qt_MultiTexCoord0; - varying highp vec2 qt_TexCoord0; - void main() { - qt_TexCoord0 = qt_MultiTexCoord0; - highp vec4 pos = qt_Vertex; - pos.y = mix(qt_Vertex.y, height, minimize); - highp float t = pos.y / height; - t = (3. - 2. * t) * t * t; - pos.x = mix(qt_Vertex.x, side * width, t * bend); - gl_Position = qt_Matrix * pos; - }" - Slider { - id: genieSlider - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - height: 40 - } - } - } - } -} diff --git a/examples/qtquick/accessibility/accessibility.pro b/examples/quick/accessibility/accessibility.pro similarity index 91% rename from examples/qtquick/accessibility/accessibility.pro rename to examples/quick/accessibility/accessibility.pro index 20d68e0c5c..2826161945 100644 --- a/examples/qtquick/accessibility/accessibility.pro +++ b/examples/quick/accessibility/accessibility.pro @@ -1,6 +1,6 @@ TEMPLATE = app -QT += quick declarative +QT += quick qml SOURCES += main.cpp target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/accessibility diff --git a/examples/quick/accessibility/accessibility.qml b/examples/quick/accessibility/accessibility.qml new file mode 100644 index 0000000000..2804d2abc8 --- /dev/null +++ b/examples/quick/accessibility/accessibility.qml @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +/*! + \title QtQuick Examples - Accessibility + \example qtquick/accessibility + \brief This example has accessible buttons. + +*/ + +Rectangle { + id: window + + width: 320; height: 480 + color: "white" + + Column { + id: column + spacing: 6 + anchors.fill: parent + width: parent.width + Row { + spacing: 6 + width: column.width + Button { width: 100; height: column.h + 20; text: "Send" } + Button { width: 100; height: column.h + 20; text: "Discard" } + } + + Row { + spacing: 6 + width: column.width + height: column.h + Text { + id: subjectLabel + Accessible.role: Accessible.StaticText + Accessible.name: text + text: "Subject:" + } + Rectangle { + id: subjectBorder + Accessible.role: Accessible.EditableText + Accessible.name: subjectEdit.text + border.width: 1 + border.color: "black" + height: subjectEdit.height + width: 240 + TextInput { + id: subjectEdit + text: "Vacation plans" + } + } + } + Rectangle { + id: textBorder + Accessible.role: Accessible.EditableText + property alias text : textEdit.text + border.width: 1 + border.color: "black" + width: parent.width - 2 + height: parent.height - (textBorder.y + column.spacing) + TextEdit { + id: textEdit + text: "Hi, we're going to the Dolomites this summer. Weren't you also going to northern Italy? \n\nbest wishes, your friend Luke" + width: parent.width + wrapMode: TextEdit.WordWrap + } + } + } +} diff --git a/examples/qtquick/accessibility/accessibility.qmlproject b/examples/quick/accessibility/accessibility.qmlproject similarity index 100% rename from examples/qtquick/accessibility/accessibility.qmlproject rename to examples/quick/accessibility/accessibility.qmlproject diff --git a/examples/quick/accessibility/content/Button.qml b/examples/quick/accessibility/content/Button.qml new file mode 100644 index 0000000000..2c203abe11 --- /dev/null +++ b/examples/quick/accessibility/content/Button.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: button + + property bool checked: false + property alias text : buttonText.text + Accessible.name: text + Accessible.description: "This button does " + text + Accessible.role: Accessible.Button + + signal clicked + + width: buttonText.width + 20 + height: 30 + gradient: Gradient { + GradientStop { position: 0.0; color: "lightsteelblue" } + GradientStop { position: 1.0; color: "blue" } + } + border.width: 2 + border.color: "black"; + radius: 10 + + Text { + id: buttonText + text: parent.description + anchors.centerIn: parent + font.pixelSize: parent.height * .5 + style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { + checked = !checked; + } + } +} diff --git a/examples/qtquick/accessibility/main.cpp b/examples/quick/accessibility/main.cpp similarity index 100% rename from examples/qtquick/accessibility/main.cpp rename to examples/quick/accessibility/main.cpp diff --git a/examples/quick/animation/animation.pro b/examples/quick/animation/animation.pro new file mode 100644 index 0000000000..cdf83f80c8 --- /dev/null +++ b/examples/quick/animation/animation.pro @@ -0,0 +1,10 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/animation +qml.files = animation.qml basics behaviors easing pathanimation pathinterpolator states +qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/animation +INSTALLS += target qml + diff --git a/examples/qtquick/animation/animation.qml b/examples/quick/animation/animation.qml similarity index 100% rename from examples/qtquick/animation/animation.qml rename to examples/quick/animation/animation.qml diff --git a/examples/quick/animation/animation.qmlproject b/examples/quick/animation/animation.qmlproject new file mode 100644 index 0000000000..2e96daa881 --- /dev/null +++ b/examples/quick/animation/animation.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "animation.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qtquick/animation/basics/color-animation.qml b/examples/quick/animation/basics/color-animation.qml similarity index 100% rename from examples/qtquick/animation/basics/color-animation.qml rename to examples/quick/animation/basics/color-animation.qml diff --git a/examples/quick/animation/basics/images/face-smile.png b/examples/quick/animation/basics/images/face-smile.png new file mode 100644 index 0000000000..3d66d72578 Binary files /dev/null and b/examples/quick/animation/basics/images/face-smile.png differ diff --git a/examples/quick/animation/basics/images/moon.png b/examples/quick/animation/basics/images/moon.png new file mode 100644 index 0000000000..9407b2b4f0 Binary files /dev/null and b/examples/quick/animation/basics/images/moon.png differ diff --git a/examples/quick/animation/basics/images/shadow.png b/examples/quick/animation/basics/images/shadow.png new file mode 100644 index 0000000000..8270565e87 Binary files /dev/null and b/examples/quick/animation/basics/images/shadow.png differ diff --git a/examples/quick/animation/basics/images/star.png b/examples/quick/animation/basics/images/star.png new file mode 100644 index 0000000000..27ef924267 Binary files /dev/null and b/examples/quick/animation/basics/images/star.png differ diff --git a/examples/quick/animation/basics/images/sun.png b/examples/quick/animation/basics/images/sun.png new file mode 100644 index 0000000000..7713ca5ce7 Binary files /dev/null and b/examples/quick/animation/basics/images/sun.png differ diff --git a/examples/quick/animation/basics/property-animation.qml b/examples/quick/animation/basics/property-animation.qml new file mode 100644 index 0000000000..4a4d3e3b2a --- /dev/null +++ b/examples/quick/animation/basics/property-animation.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: window + width: 320; height: 480 + + // Let's draw the sky... + Rectangle { + anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter } + gradient: Gradient { + GradientStop { position: 0.0; color: "DeepSkyBlue" } + GradientStop { position: 1.0; color: "LightSkyBlue" } + } + } + + // ...and the ground. + Rectangle { + anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom } + gradient: Gradient { + GradientStop { position: 0.0; color: "ForestGreen" } + GradientStop { position: 1.0; color: "DarkGreen" } + } + } + + // The shadow for the smiley face + Image { + anchors.horizontalCenter: parent.horizontalCenter + y: smiley.minHeight + 58 + source: "images/shadow.png" + + // The scale property depends on the y position of the smiley face. + scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight) + } + + Image { + id: smiley + property int maxHeight: window.height / 3 + property int minHeight: 2 * window.height / 3 + + anchors.horizontalCenter: parent.horizontalCenter + y: minHeight + source: "images/face-smile.png" + + // Animate the y property. Setting loops to Animation.Infinite makes the + // animation repeat indefinitely, otherwise it would only run once. + SequentialAnimation on y { + loops: Animation.Infinite + + // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function + NumberAnimation { + from: smiley.minHeight; to: smiley.maxHeight + easing.type: Easing.OutExpo; duration: 300 + } + + // Then move back to minHeight in 1 second, using the OutBounce easing function + NumberAnimation { + from: smiley.maxHeight; to: smiley.minHeight + easing.type: Easing.OutBounce; duration: 1000 + } + + // Then pause for 500ms + PauseAnimation { duration: 500 } + } + } +} diff --git a/examples/quick/animation/behaviors/SideRect.qml b/examples/quick/animation/behaviors/SideRect.qml new file mode 100644 index 0000000000..623c6965d8 --- /dev/null +++ b/examples/quick/animation/behaviors/SideRect.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: myRect + + property string text + + width: 75; height: 50 + radius: 6 + color: "#646464" + border.width: 4; border.color: "white" + + MouseArea { + anchors.fill: parent + hoverEnabled: true + onEntered: { + focusRect.x = myRect.x; + focusRect.y = myRect.y; + focusRect.text = myRect.text; + } + } +} diff --git a/examples/qtquick/animation/behaviors/behavior-example.qml b/examples/quick/animation/behaviors/behavior-example.qml similarity index 100% rename from examples/qtquick/animation/behaviors/behavior-example.qml rename to examples/quick/animation/behaviors/behavior-example.qml diff --git a/examples/qtquick/animation/behaviors/tvtennis.qml b/examples/quick/animation/behaviors/tvtennis.qml similarity index 100% rename from examples/qtquick/animation/behaviors/tvtennis.qml rename to examples/quick/animation/behaviors/tvtennis.qml diff --git a/examples/qtquick/animation/behaviors/wigglytext.qml b/examples/quick/animation/behaviors/wigglytext.qml similarity index 100% rename from examples/qtquick/animation/behaviors/wigglytext.qml rename to examples/quick/animation/behaviors/wigglytext.qml diff --git a/examples/quick/animation/easing/content/QuitButton.qml b/examples/quick/animation/easing/content/QuitButton.qml new file mode 100644 index 0000000000..702b892d23 --- /dev/null +++ b/examples/quick/animation/easing/content/QuitButton.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +Image { + source: "quit.png" + scale: quitMouse.pressed ? 0.8 : 1.0 + smooth: quitMouse.pressed + MouseArea { + id: quitMouse + anchors.fill: parent + anchors.margins: -10 + onClicked: Qt.quit() + } +} diff --git a/examples/quick/animation/easing/content/quit.png b/examples/quick/animation/easing/content/quit.png new file mode 100644 index 0000000000..b822057d4e Binary files /dev/null and b/examples/quick/animation/easing/content/quit.png differ diff --git a/examples/qtquick/animation/easing/easing.qml b/examples/quick/animation/easing/easing.qml similarity index 100% rename from examples/qtquick/animation/easing/easing.qml rename to examples/quick/animation/easing/easing.qml diff --git a/examples/qtquick/animation/main.cpp b/examples/quick/animation/main.cpp similarity index 100% rename from examples/qtquick/animation/main.cpp rename to examples/quick/animation/main.cpp diff --git a/examples/qtquick/animation/pathanimation/pathanimation.qml b/examples/quick/animation/pathanimation/pathanimation.qml similarity index 100% rename from examples/qtquick/animation/pathanimation/pathanimation.qml rename to examples/quick/animation/pathanimation/pathanimation.qml diff --git a/examples/qtquick/animation/pathinterpolator/pathinterpolator.qml b/examples/quick/animation/pathinterpolator/pathinterpolator.qml similarity index 100% rename from examples/qtquick/animation/pathinterpolator/pathinterpolator.qml rename to examples/quick/animation/pathinterpolator/pathinterpolator.qml diff --git a/tests/auto/qtquick2/qdeclarativestates/data/Implementation/images/qt-logo.png b/examples/quick/animation/states/qt-logo.png similarity index 100% rename from tests/auto/qtquick2/qdeclarativestates/data/Implementation/images/qt-logo.png rename to examples/quick/animation/states/qt-logo.png diff --git a/examples/quick/animation/states/states.qml b/examples/quick/animation/states/states.qml new file mode 100644 index 0000000000..7ca56a9295 --- /dev/null +++ b/examples/quick/animation/states/states.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: page + width: 640; height: 480 + color: "#343434" + + Image { + id: userIcon + x: topLeftRect.x; y: topLeftRect.y + source: "qt-logo.png" + } + + Rectangle { + id: topLeftRect + + anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } + width: 46; height: 54 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to the default state, returning the image to + // its initial position + MouseArea { anchors.fill: parent; onClicked: page.state = '' } + } + + Rectangle { + id: middleRightRect + + anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } + width: 46; height: 54 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to 'middleRight' + MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' } + } + + Rectangle { + id: bottomLeftRect + + anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } + width: 46; height: 54 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to 'bottomLeft' + MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' } + } + + states: [ + // In state 'middleRight', move the image to middleRightRect + State { + name: "middleRight" + PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y } + }, + + // In state 'bottomLeft', move the image to bottomLeftRect + State { + name: "bottomLeft" + PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y } + } + ] +} diff --git a/examples/quick/animation/states/transitions.qml b/examples/quick/animation/states/transitions.qml new file mode 100644 index 0000000000..d57924d6d2 --- /dev/null +++ b/examples/quick/animation/states/transitions.qml @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +/* + This is exactly the same as states.qml, except that we have appended + a set of transitions to apply animations when the item changes + between each state. +*/ + +Rectangle { + id: page + width: 640; height: 480 + color: "#343434" + + Image { + id: userIcon + x: topLeftRect.x; y: topLeftRect.y + source: "qt-logo.png" + } + + Rectangle { + id: topLeftRect + + anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } + width: 46; height: 54 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to the default state, returning the image to + // its initial position + MouseArea { anchors.fill: parent; onClicked: page.state = '' } + } + + Rectangle { + id: middleRightRect + + anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } + width: 46; height: 54 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to 'middleRight' + MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' } + } + + Rectangle { + id: bottomLeftRect + + anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } + width: 46; height: 54 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to 'bottomLeft' + MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' } + } + + states: [ + // In state 'middleRight', move the image to middleRightRect + State { + name: "middleRight" + PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y } + }, + + // In state 'bottomLeft', move the image to bottomLeftRect + State { + name: "bottomLeft" + PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y } + } + ] + + // Transitions define how the properties change when the item moves between each state + transitions: [ + + // When transitioning to 'middleRight' move x,y over a duration of 1 second, + // with OutBounce easing function. + Transition { + from: "*"; to: "middleRight" + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce; duration: 1000 } + }, + + // When transitioning to 'bottomLeft' move x,y over a duration of 2 seconds, + // with InOutQuad easing function. + Transition { + from: "*"; to: "bottomLeft" + NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; duration: 2000 } + }, + + // For any other state changes move x,y linearly over duration of 200ms. + Transition { + NumberAnimation { properties: "x,y"; duration: 200 } + } + ] +} diff --git a/examples/quick/canvas/bezierCurve/bezierCurve.qml b/examples/quick/canvas/bezierCurve/bezierCurve.qml new file mode 100644 index 0000000000..f57839b0a5 --- /dev/null +++ b/examples/quick/canvas/bezierCurve/bezierCurve.qml @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../contents" +Item { + id:container + width:360 + height:600 + + Column { + spacing:5 + anchors.fill:parent + Text { font.pointSize:25; text:"Bezier Curve"; anchors.horizontalCenter:parent.horizontalCenter} + + Canvas { + id:canvas + width:360 + height:360 + property string strokeStyle:"red" + property string fillStyle:"red" + property int lineWidth:lineWidthCtrl.value + property bool fill:true + property bool stroke:true + property real alpha:alphaCtrl.value + property real scaleX : scaleXCtrl.value + property real scaleY : scaleYCtrl.value + property real rotate : rotateCtrl.value + smooth:true + renderTarget:Canvas.Image + renderStrategy: Canvas.Immediate + + + Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } } + Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } + Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } + + onLineWidthChanged:requestPaint(); + onFillChanged:requestPaint(); + onStrokeChanged:requestPaint(); + onAlphaChanged:requestPaint(); + onScaleXChanged:requestPaint(); + onScaleYChanged:requestPaint(); + onRotateChanged:requestPaint(); + + onPaint: { + var ctx = canvas.getContext('2d'); + ctx.save(); + ctx.clearRect(0, 0, canvas.width, canvas.height); + ctx.globalAlpha = canvas.alpha; + ctx.strokeStyle = canvas.strokeStyle; + ctx.fillStyle = canvas.fillStyle; + ctx.lineWidth = canvas.lineWidth; + ctx.scale(canvas.scaleX, canvas.scaleY); + ctx.rotate(canvas.rotate); + ctx.beginPath(); + ctx.moveTo(75,40); + ctx.bezierCurveTo(75,37,70,25,50,25); + ctx.bezierCurveTo(20,25,20,62.5,20,62.5); + ctx.bezierCurveTo(20,80,40,102,75,120); + ctx.bezierCurveTo(110,102,130,80,130,62.5); + ctx.bezierCurveTo(130,62.5,130,25,100,25); + ctx.bezierCurveTo(85,25,75,37,75,40); + ctx.closePath(); + if (canvas.fill) + ctx.fill(); + if (canvas.stroke) + ctx.stroke(); + ctx.restore(); + } + } + + Rectangle { + id:controls + width:360 + height:160 + Column { + spacing:3 + Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"} + Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleX"} + Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"} + Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"} + Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} + } + } + } +} diff --git a/examples/quick/canvas/clip/clip.qml b/examples/quick/canvas/clip/clip.qml new file mode 100644 index 0000000000..d861ff0a46 --- /dev/null +++ b/examples/quick/canvas/clip/clip.qml @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../contents" +Item { + id:container + width:360 + height:600 + + Column { + spacing:5 + anchors.fill:parent + Text { font.pointSize:25; text:"Makes squircle icon with clip"; anchors.horizontalCenter:parent.horizontalCenter} + Canvas { + id:canvas + width:360 + height:360 + property string strokeStyle:"blue" + property string fillStyle:"steelblue" + property int lineWidth:2 + property int nSize:nCtrl.value + property real radius:rCtrl.value + property bool fill:true + property bool stroke:false + property real px:xCtrl.value + property real py:yCtrl.value + property real alpha:alphaCtrl.value + property string imagefile:"../contents/qt-logo.png" + smooth:true + renderTarget:Canvas.Image + renderStrategy: Canvas.Immediate + Component.onCompleted:loadImage(canvas.imagefile); + + onAlphaChanged:requestPaint(); + onRadiusChanged:requestPaint(); + onLineWidthChanged:requestPaint(); + onNSizeChanged:requestPaint(); + onFillChanged:requestPaint(); + onStrokeChanged:requestPaint(); + onPxChanged:requestPaint(); + onPyChanged:requestPaint(); + + onImageLoaded : requestPaint(); + + onPaint: squcirle(); + + function squcirle() { + var ctx = canvas.getContext("2d"); + var N = canvas.nSize; + var R = canvas.radius; + + N=Math.abs(N); + var M=N; + if (N>100) M=100; + if (N<0.00000000001) M=0.00000000001; + + ctx.save(); + ctx.globalAlpha =canvas.alpha; + ctx.fillStyle = "gray"; + ctx.fillRect(0, 0, canvas.width, canvas.height); + + ctx.strokeStyle = canvas.strokeStyle; + ctx.fillStyle = canvas.fillStyle; + ctx.lineWidth = canvas.lineWidth; + + ctx.beginPath(); + var i = 0, x, y; + for (i=0; i<(2*R+1); i++){ + x = Math.round(i-R) + canvas.px; + y = Math.round(Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(i-R),M)),1/M)) + canvas.py; + + if (i == 0) + ctx.moveTo(x, y); + else + ctx.lineTo(x, y); + } + + for (i=(2*R); i<(4*R+1); i++){ + x =Math.round(3*R-i)+canvas.px; + y = Math.round(-Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(3*R-i),M)),1/M)) + canvas.py; + ctx.lineTo(x, y); + } + ctx.closePath(); + if (canvas.stroke) { + ctx.stroke(); + } + + if (canvas.fill) { + ctx.fill(); + } + ctx.clip(); + + ctx.drawImage(canvas.imagefile, 0, 0); + ctx.restore(); + } + } + + Rectangle { + id:controls + width:360 + height:160 + Column { + spacing:3 + Slider {id:nCtrl; width:300; height:30; min:1; max:10; init:4; name:"N"} + Slider {id:rCtrl; width:300; height:30; min:30; max:180; init:100; name:"Radius"} + Slider {id:xCtrl; width:300; height:30; min:50; max:300; init:180; name:"X"} + Slider {id:yCtrl; width:300; height:30; min:30; max:300; init:220; name:"Y"} + Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} + } + } + } +} diff --git a/examples/quick/canvas/contents/Button.qml b/examples/quick/canvas/contents/Button.qml new file mode 100644 index 0000000000..1413cdb9fa --- /dev/null +++ b/examples/quick/canvas/contents/Button.qml @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + signal clicked + + property string text + width: buttonText.width + 28 + height: buttonText.height + 14 + + BorderImage { + id: buttonImage + source: "images/toolbutton.sci" + width: container.width - 10 + height: container.height + } + BorderImage { + id: pressed + opacity: 0 + source: "images/toolbutton.sci" + width: container.width - 10 + height: container.height + } + MouseArea { + id: mouseRegion + anchors.fill: buttonImage + onClicked: { container.clicked(); } + } + Text { + id: buttonText + color: "white" + anchors.centerIn: buttonImage + font.bold: true + font.pointSize: 15 + text: container.text + style: Text.Raised + styleColor: "black" + } + states: [ + State { + name: "Pressed" + when: mouseRegion.pressed == true + PropertyChanges { target: pressed; opacity: 1 } + } + ] +} \ No newline at end of file diff --git a/examples/quick/canvas/contents/ScrollBar.qml b/examples/quick/canvas/contents/ScrollBar.qml new file mode 100644 index 0000000000..98b8efee4a --- /dev/null +++ b/examples/quick/canvas/contents/ScrollBar.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: scrollBar + // The properties that define the scrollbar's state. + // position and pageSize are in the range 0.0 - 1.0. They are relative to the + // height of the page, i.e. a pageSize of 0.5 means that you can see 50% + // of the height of the view. + // orientation can be either 'Vertical' or 'Horizontal' + property real position + property real pageSize + property string orientation : "Vertical" + property alias bgColor: background.color + property alias fgColor: thumb.color + + // A light, semi-transparent background + Rectangle { + id: background + radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1) + color: "white"; opacity: 0.3 + anchors.fill: parent + } + // Size the bar to the required size, depending upon the orientation. + Rectangle { + id: thumb + opacity: 0.7 + color: "black" + radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1) + x: orientation == 'Vertical' ? 1 : (scrollBar.position * (scrollBar.width-2) + 1) + y: orientation == 'Vertical' ? (scrollBar.position * (scrollBar.height-2) + 1) : 1 + width: orientation == 'Vertical' ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2)) + height: orientation == 'Vertical' ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2) + } +} diff --git a/examples/quick/canvas/contents/Slider.qml b/examples/quick/canvas/contents/Slider.qml new file mode 100644 index 0000000000..093b9e40dd --- /dev/null +++ b/examples/quick/canvas/contents/Slider.qml @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id:slider + property real min:0 + property real max:1 + property real value: min + (max - min) * (bar.x / (foo.width - bar.width)) + property real init:min+(max-min)/2 + property string name:"Slider" + + Component.onCompleted: setValue(init) + function setValue(v) { + if (min < max) + bar.x = v/(max - min) * (foo.width - bar.width); + } + Rectangle { + id:sliderName + anchors.left:parent.left + height: childrenRect.height + width:childrenRect.width + anchors.verticalCenter:parent.verticalCenter + Text { + text:slider.name + font.pointSize:12 + } + } + Item { + id: foo + height: 6 + width: parent.width - 4 - sliderName.width + anchors.verticalCenter:parent.verticalCenter + anchors.left:sliderName.right + anchors.leftMargin:5 + Rectangle { + height: parent.height + anchors.left: parent.left + anchors.right: bar.horizontalCenter + color: "blue" + radius: 3 + } + Rectangle { + height: parent.height + anchors.left: bar.horizontalCenter + anchors.right: parent.right + color: "gray" + radius: 3 + } + Rectangle { + anchors.fill: parent + color: "transparent" + radius: 3 + border.width: 2 + border.color: "black" + } + + Rectangle { + id: bar + y: -7 + width: 20 + height: 20 + radius: 15 + color: "white" + border.width: 2 + border.color: "black" + MouseArea { + anchors.fill: parent + drag.target: parent + drag.axis: Drag.XAxis + drag.minimumX: 0 + drag.maximumX: foo.width - parent.width + } + } + } +} diff --git a/examples/quick/canvas/contents/Stocks.qml b/examples/quick/canvas/contents/Stocks.qml new file mode 100644 index 0000000000..043bca132e --- /dev/null +++ b/examples/quick/canvas/contents/Stocks.qml @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListModel { + id:stocks + //Data from : http://en.wikipedia.org/wiki/NASDAQ-100 + + ListElement {name:"Activision Blizzard"; stockId:"ATVI"} + ListElement {name:"Adobe Systems Incorporated"; stockId:"ADBE"} + ListElement {name:"Akamai Technologies, Inc"; stockId:"AKAM"} + ListElement {name:"Alexion Pharmaceuticals"; stockId:"ALXN"} + ListElement {name:"Altera Corporation"; stockId:"ALTR"} + ListElement {name:"Amazon.com, Inc."; stockId:"AMZN"} + ListElement {name:"Amgen Inc."; stockId:"AMGN"} + ListElement {name:"Apollo Group, Inc."; stockId:"APOL"} + ListElement {name:"Apple Inc."; stockId:"AAPL"} + ListElement {name:"Applied Materials, Inc."; stockId:"AMAT"} + ListElement {name:"Autodesk, Inc."; stockId:"ADSK"} + ListElement {name:"Automatic Data Processing, Inc."; stockId:"ADP"} + ListElement {name:"Baidu.com, Inc."; stockId:"BIDU"} + ListElement {name:"Bed Bath & Beyond Inc."; stockId:"BBBY"} + ListElement {name:"Biogen Idec, Inc"; stockId:"BIIB"} + ListElement {name:"BMC Software, Inc."; stockId:"BMC"} + ListElement {name:"Broadcom Corporation"; stockId:"BRCM"} + ListElement {name:"C. H. Robinson Worldwide, Inc."; stockId:"CHRW"} + ListElement {name:"CA, Inc."; stockId:"CA"} + ListElement {name:"Celgene Corporation"; stockId:"CELG"} + ListElement {name:"Cephalon, Inc."; stockId:"CEPH"} + ListElement {name:"Cerner Corporation"; stockId:"CERN"} + ListElement {name:"Check Point Software Technologies Ltd."; stockId:"CHKP"} + ListElement {name:"Cisco Systems, Inc."; stockId:"CSCO"} + ListElement {name:"Citrix Systems, Inc."; stockId:"CTXS"} + ListElement {name:"Cognizant Technology Solutions Corporation"; stockId:"CTSH"} + ListElement {name:"Comcast Corporation"; stockId:"CMCSA"} + ListElement {name:"Costco Wholesale Corporation"; stockId:"COST"} + ListElement {name:"Ctrip.com International, Ltd."; stockId:"CTRP"} + ListElement {name:"Dell Inc."; stockId:"DELL"} + ListElement {name:"DENTSPLY International Inc."; stockId:"XRAY"} + ListElement {name:"DirecTV"; stockId:"DTV"} + ListElement {name:"Dollar Tree, Inc."; stockId:"DLTR"} + ListElement {name:"eBay Inc."; stockId:"EBAY"} + ListElement {name:"Electronic Arts Inc."; stockId:"ERTS"} + ListElement {name:"Expedia, Inc."; stockId:"EXPE"} + ListElement {name:"Expeditors International of Washington, Inc."; stockId:"EXPD"} + ListElement {name:"Express Scripts, Inc."; stockId:"ESRX"} + ListElement {name:"F5 Networks, Inc."; stockId:"FFIV"} + ListElement {name:"Fastenal Company"; stockId:"FAST"} + ListElement {name:"First Solar, Inc."; stockId:"FSLR"} + ListElement {name:"Fiserv, Inc."; stockId:"FISV"} + ListElement {name:"Flextronics International Ltd."; stockId:"FLEX"} + ListElement {name:"FLIR Systems, Inc."; stockId:"FLIR"} + ListElement {name:"Garmin Ltd."; stockId:"GRMN"} + ListElement {name:"Gilead Sciences, Inc."; stockId:"GILD"} + ListElement {name:"Google Inc."; stockId:"GOOG"} + ListElement {name:"Green Mountain Coffee Roasters, Inc."; stockId:"GMCR"} + ListElement {name:"Henry Schein, Inc."; stockId:"HSIC"} + ListElement {name:"Illumina, Inc."; stockId:"ILMN"} + ListElement {name:"Infosys Technologies"; stockId:"INFY"} + ListElement {name:"Intel Corporation"; stockId:"INTC"} + ListElement {name:"Intuit, Inc."; stockId:"INTU"} + ListElement {name:"Intuitive Surgical Inc."; stockId:"ISRG"} + ListElement {name:"Joy Global Inc."; stockId:"JOYG"} + ListElement {name:"KLA Tencor Corporation"; stockId:"KLAC"} + ListElement {name:"Lam Research Corporation"; stockId:"LRCX"} + ListElement {name:"Liberty Media Corporation, Interactive Series A"; stockId:"LINTA"} + ListElement {name:"Life Technologies Corporation"; stockId:"LIFE"} + ListElement {name:"Linear Technology Corporation"; stockId:"LLTC"} + ListElement {name:"Marvell Technology Group, Ltd."; stockId:"MRVL"} + ListElement {name:"Mattel, Inc."; stockId:"MAT"} + ListElement {name:"Maxim Integrated Products"; stockId:"MXIM"} + ListElement {name:"Microchip Technology Incorporated"; stockId:"MCHP"} + ListElement {name:"Micron Technology, Inc."; stockId:"MU"} + ListElement {name:"Microsoft Corporation"; stockId:"MSFT"} + ListElement {name:"Mylan, Inc."; stockId:"MYL"} + ListElement {name:"NetApp, Inc."; stockId:"NTAP"} + ListElement {name:"Netflix, Inc."; stockId:"NFLX"} + ListElement {name:"News Corporation, Ltd."; stockId:"NWSA"} + ListElement {name:"NII Holdings, Inc."; stockId:"NIHD"} + ListElement {name:"NVIDIA Corporation"; stockId:"NVDA"} + ListElement {name:"O'Reilly Automotive, Inc."; stockId:"ORLY"} + ListElement {name:"Oracle Corporation"; stockId:"ORCL"} + ListElement {name:"PACCAR Inc."; stockId:"PCAR"} + ListElement {name:"Paychex, Inc."; stockId:"PAYX"} + ListElement {name:"Priceline.com, Incorporated"; stockId:"PCLN"} + ListElement {name:"Qiagen N.V."; stockId:"QGEN"} + ListElement {name:"QUALCOMM Incorporated"; stockId:"QCOM"} + ListElement {name:"Research in Motion Limited"; stockId:"RIMM"} + ListElement {name:"Ross Stores Inc."; stockId:"ROST"} + ListElement {name:"SanDisk Corporation"; stockId:"SNDK"} + ListElement {name:"Seagate Technology Holdings"; stockId:"STX"} + ListElement {name:"Sears Holdings Corporation"; stockId:"SHLD"} + ListElement {name:"Sigma-Aldrich Corporation"; stockId:"SIAL"} + ListElement {name:"Staples Inc."; stockId:"SPLS"} + ListElement {name:"Starbucks Corporation"; stockId:"SBUX"} + ListElement {name:"Stericycle, Inc"; stockId:"SRCL"} + ListElement {name:"Symantec Corporation"; stockId:"SYMC"} + ListElement {name:"Teva Pharmaceutical Industries Ltd."; stockId:"TEVA"} + ListElement {name:"Urban Outfitters, Inc."; stockId:"URBN"} + ListElement {name:"VeriSign, Inc."; stockId:"VRSN"} + ListElement {name:"Vertex Pharmaceuticals"; stockId:"VRTX"} + ListElement {name:"Virgin Media, Inc."; stockId:"VMED"} + ListElement {name:"Vodafone Group, plc."; stockId:"VOD"} + ListElement {name:"Warner Chilcott, Ltd."; stockId:"WCRX"} + ListElement {name:"Whole Foods Market, Inc."; stockId:"WFM"} + ListElement {name:"Wynn Resorts Ltd."; stockId:"WYNN"} + ListElement {name:"Xilinx, Inc."; stockId:"XLNX"} + ListElement {name:"Yahoo! Inc."; stockId:"YHOO"} +} diff --git a/examples/quick/canvas/contents/TitleBar.qml b/examples/quick/canvas/contents/TitleBar.qml new file mode 100644 index 0000000000..28edda2ae7 --- /dev/null +++ b/examples/quick/canvas/contents/TitleBar.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: titleBar + property string title: "" + + BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } + + Image { + id: quitButton + anchors.left: parent.left//; anchors.leftMargin: 0 + anchors.verticalCenter: parent.verticalCenter + source: "images/quit.png" + MouseArea { + anchors.fill: parent + onClicked: Qt.quit() + } + } + + Text { + id: categoryText + anchors { + left: quitButton.right; right: parent.right; //leftMargin: 10; rightMargin: 10 + verticalCenter: parent.verticalCenter + } + elide: Text.ElideLeft + text: title + font.bold: true; font.pointSize: 20; color: "White"; style: Text.Raised; styleColor: "Black" + } +} diff --git a/examples/quick/canvas/contents/ToolBar.qml b/examples/quick/canvas/contents/ToolBar.qml new file mode 100644 index 0000000000..7ae7391ddf --- /dev/null +++ b/examples/quick/canvas/contents/ToolBar.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: toolbar + + property variant labels + signal buttonClicked(int index) + + BorderImage { + source: "images/titlebar.sci" + width: parent.width + height: parent.height + 14 + y: -7 + } + + Row { + y: 3 + anchors.horizontalCenter: parent.horizontalCenter + Repeater { + model: toolbar.labels + delegate: + Button { + text: modelData + onClicked: toolbar.buttonClicked(model.index) + } + } + } + +} diff --git a/examples/quick/canvas/contents/images/button-pressed.png b/examples/quick/canvas/contents/images/button-pressed.png new file mode 100644 index 0000000000..e434d327f2 Binary files /dev/null and b/examples/quick/canvas/contents/images/button-pressed.png differ diff --git a/examples/quick/canvas/contents/images/button.png b/examples/quick/canvas/contents/images/button.png new file mode 100644 index 0000000000..56a63ce641 Binary files /dev/null and b/examples/quick/canvas/contents/images/button.png differ diff --git a/examples/quick/canvas/contents/images/default.svg b/examples/quick/canvas/contents/images/default.svg new file mode 100644 index 0000000000..248199cc4e --- /dev/null +++ b/examples/quick/canvas/contents/images/default.svg @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + weather-clear + January 2006 + + + Ryan Collier (pseudo) + + + + + http://www.tango-project.org + + + http://www.pseudocode.org + + + weather + applet + notification + + + + + + Garrett LeSage + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/quick/canvas/contents/images/gloss.png b/examples/quick/canvas/contents/images/gloss.png new file mode 100755 index 0000000000..5d370cd93d Binary files /dev/null and b/examples/quick/canvas/contents/images/gloss.png differ diff --git a/examples/quick/canvas/contents/images/lineedit.png b/examples/quick/canvas/contents/images/lineedit.png new file mode 100755 index 0000000000..2cc38dc35b Binary files /dev/null and b/examples/quick/canvas/contents/images/lineedit.png differ diff --git a/examples/quick/canvas/contents/images/lineedit.sci b/examples/quick/canvas/contents/images/lineedit.sci new file mode 100644 index 0000000000..054bff78be --- /dev/null +++ b/examples/quick/canvas/contents/images/lineedit.sci @@ -0,0 +1,5 @@ +border.left: 10 +border.top: 10 +border.bottom: 10 +border.right: 10 +source: lineedit.png diff --git a/examples/quick/canvas/contents/images/quit.png b/examples/quick/canvas/contents/images/quit.png new file mode 100755 index 0000000000..5bda1b6e0d Binary files /dev/null and b/examples/quick/canvas/contents/images/quit.png differ diff --git a/examples/quick/canvas/contents/images/stripes.png b/examples/quick/canvas/contents/images/stripes.png new file mode 100755 index 0000000000..9f36727ea4 Binary files /dev/null and b/examples/quick/canvas/contents/images/stripes.png differ diff --git a/examples/quick/canvas/contents/images/titlebar.png b/examples/quick/canvas/contents/images/titlebar.png new file mode 100755 index 0000000000..51c90082d0 Binary files /dev/null and b/examples/quick/canvas/contents/images/titlebar.png differ diff --git a/examples/quick/canvas/contents/images/titlebar.sci b/examples/quick/canvas/contents/images/titlebar.sci new file mode 100644 index 0000000000..0418d94cd6 --- /dev/null +++ b/examples/quick/canvas/contents/images/titlebar.sci @@ -0,0 +1,5 @@ +border.left: 10 +border.top: 12 +border.bottom: 12 +border.right: 10 +source: titlebar.png diff --git a/examples/quick/canvas/contents/images/toolbutton.png b/examples/quick/canvas/contents/images/toolbutton.png new file mode 100755 index 0000000000..11310013ee Binary files /dev/null and b/examples/quick/canvas/contents/images/toolbutton.png differ diff --git a/examples/quick/canvas/contents/images/toolbutton.sci b/examples/quick/canvas/contents/images/toolbutton.sci new file mode 100644 index 0000000000..9e4f965307 --- /dev/null +++ b/examples/quick/canvas/contents/images/toolbutton.sci @@ -0,0 +1,5 @@ +border.left: 15 +border.top: 4 +border.bottom: 4 +border.right: 15 +source: toolbutton.png diff --git a/examples/quick/canvas/contents/qt-logo.png b/examples/quick/canvas/contents/qt-logo.png new file mode 100644 index 0000000000..5ab3a1b0c4 Binary files /dev/null and b/examples/quick/canvas/contents/qt-logo.png differ diff --git a/examples/quick/canvas/quadraticCurveTo/quadraticCurveTo.qml b/examples/quick/canvas/quadraticCurveTo/quadraticCurveTo.qml new file mode 100644 index 0000000000..bc3ca0071a --- /dev/null +++ b/examples/quick/canvas/quadraticCurveTo/quadraticCurveTo.qml @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../contents" +Item { + id:container + width:360 + height:600 + + Column { + spacing:5 + anchors.fill:parent + Text { font.pointSize:25; text:"Quadratic Curve"; anchors.horizontalCenter:parent.horizontalCenter} + + Canvas { + id:canvas + width:360 + height:360 + property string strokeStyle:"steelblue" + property string fillStyle:"yellow" + property int lineWidth:lineWidthCtrl.value + property bool fill:true + property bool stroke:true + property real alpha:alphaCtrl.value + property real scaleX : scaleXCtrl.value + property real scaleY : scaleYCtrl.value + property real rotate : rotateCtrl.value + smooth:true + renderTarget:Canvas.Image + renderStrategy: Canvas.Immediate + + onLineWidthChanged:requestPaint(); + onFillChanged:requestPaint(); + onStrokeChanged:requestPaint(); + onAlphaChanged:requestPaint(); + onScaleXChanged:requestPaint(); + onScaleYChanged:requestPaint(); + onRotateChanged:requestPaint(); + Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } } + Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } + Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } + + onPaint: { + var ctx = canvas.getContext('2d'); + ctx.save(); + ctx.clearRect(0, 0, canvas.width, canvas.height); + ctx.globalAlpha = canvas.alpha; + ctx.strokeStyle = canvas.strokeStyle; + ctx.fillStyle = canvas.fillStyle; + ctx.lineWidth = canvas.lineWidth; + ctx.scale(canvas.scaleX, canvas.scaleY); + ctx.rotate(canvas.rotate); + ctx.beginPath(); + ctx.moveTo(75,25); + ctx.quadraticCurveTo(25,25,25,62.5); + ctx.quadraticCurveTo(25,100,50,100); + ctx.quadraticCurveTo(50,120,30,125); + ctx.quadraticCurveTo(60,120,65,100); + ctx.quadraticCurveTo(125,100,125,62.5); + ctx.quadraticCurveTo(125,25,75,25); + ctx.closePath(); + if (canvas.fill) + ctx.fill(); + if (canvas.stroke) + ctx.stroke(); + + + ctx.fillStyle="green"; + ctx.font = "Bold 15px"; + + ctx.fillText("QML酷毙了", 30, 60); + ctx.restore(); + } + } + + Rectangle { + id:controls + width:360 + height:160 + Column { + spacing:3 + Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"} + Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleX"} + Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"} + Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"} + Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} + } + } + } +} diff --git a/examples/quick/canvas/roundedrect/roundedrect.qml b/examples/quick/canvas/roundedrect/roundedrect.qml new file mode 100644 index 0000000000..fd86c63a3b --- /dev/null +++ b/examples/quick/canvas/roundedrect/roundedrect.qml @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../contents" +Item { + id:container + width:360 + height:600 + + Column { + spacing:5 + anchors.fill:parent + Text { font.pointSize:25; text:"Rounded rectangle"; anchors.horizontalCenter:parent.horizontalCenter} + Canvas { + id:canvas + width:360 + height:360 + smooth:true + renderTarget:Canvas.Image + renderStrategy: Canvas.Immediate + + property int radius: rCtrl.value + property int rectx: rxCtrl.value + property int recty: ryCtrl.value + property int rectWidth: width - 2*rectx + property int rectHeight: height - 2*recty + property string strokeStyle:"blue" + property string fillStyle:"steelblue" + property int lineWidth:lineWidthCtrl.value + property bool fill:true + property bool stroke:true + property real alpha:alphaCtrl.value + + onLineWidthChanged:requestPaint(); + onFillChanged:requestPaint(); + onStrokeChanged:requestPaint(); + onRadiusChanged:requestPaint(); + onRectxChanged:requestPaint(); + onRectyChanged:requestPaint(); + onAlphaChanged:requestPaint(); + + onPaint: { + var ctx = getContext("2d"); + ctx.save(); + ctx.clearRect(0,0,canvas.width, canvas.height); + ctx.strokeStyle = canvas.strokeStyle; + ctx.lineWidth = canvas.lineWidth + ctx.fillStyle = canvas.fillStyle + ctx.globalAlpha = canvas.alpha + ctx.beginPath(); + ctx.moveTo(rectx+radius,recty); // top side + ctx.lineTo(rectx+rectWidth-radius,recty); + // draw top right corner + ctx.arcTo(rectx+rectWidth,recty,rectx+rectWidth,recty+radius,radius); + ctx.lineTo(rectx+rectWidth,recty+rectHeight-radius); // right side + // draw bottom right corner + ctx.arcTo(rectx+rectWidth,recty+rectHeight,rectx+rectWidth-radius,recty+rectHeight,radius); + ctx.lineTo(rectx+radius,recty+rectHeight); // bottom side + // draw bottom left corner + ctx.arcTo(rectx,recty+rectHeight,rectx,recty+rectHeight-radius,radius); + ctx.lineTo(rectx,recty+radius); // left side + // draw top left corner + ctx.arcTo(rectx,recty,rectx+radius,recty,radius); + ctx.closePath(); + if (canvas.fill) + ctx.fill(); + if (canvas.stroke) + ctx.stroke(); + ctx.restore(); + } + } + + Rectangle { + id:controls + width:360 + height:160 + Column { + spacing:3 + Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"} + Slider {id:rxCtrl; width:300; height:30; min:5; max:30; init:10; name:"rectx"} + Slider {id:ryCtrl; width:300; height:30; min:5; max:30; init:10; name:"recty"} + Slider {id:rCtrl; width:300; height:30; min:10; max:100; init:40; name:"Radius"} + Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} + } + } + } +} diff --git a/examples/quick/canvas/smile/smile.qml b/examples/quick/canvas/smile/smile.qml new file mode 100644 index 0000000000..28a48a6c81 --- /dev/null +++ b/examples/quick/canvas/smile/smile.qml @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../contents" +Item { + id:container + width:360 + height:600 + + Column { + spacing:5 + anchors.fill:parent + Text { font.pointSize:25; text:"Smile with arcs"; anchors.horizontalCenter:parent.horizontalCenter} + + Canvas { + id:canvas + width:360 + height:360 + smooth:true + renderTarget:Canvas.Image + renderStrategy: Canvas.Immediate + + property string strokeStyle:"green" + property string fillStyle:"yellow" + property int lineWidth:lineWidthCtrl.value + property bool fill:true + property bool stroke:true + property real alpha:alphaCtrl.value + property real scaleX : scaleXCtrl.value + property real scaleY : scaleYCtrl.value + property real rotate : rotateCtrl.value + + onLineWidthChanged:requestPaint(); + onFillChanged:requestPaint(); + onStrokeChanged:requestPaint(); + onAlphaChanged:requestPaint(); + onScaleXChanged:requestPaint(); + onScaleYChanged:requestPaint(); + onRotateChanged:requestPaint(); + + Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } } + Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } + Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } + + onPaint: { + var ctx = canvas.getContext('2d'); + ctx.save(); + ctx.clearRect(0, 0, canvas.width, canvas.height); + ctx.globalAlpha = canvas.alpha; + ctx.strokeStyle = canvas.strokeStyle; + ctx.fillStyle = canvas.fillStyle; + ctx.lineWidth = canvas.lineWidth; + ctx.scale(canvas.scaleX, canvas.scaleY); + ctx.rotate(canvas.rotate); + ctx.beginPath(); + ctx.moveTo(75 + 50 * Math.cos(0), + 75 - 50 * Math.sin(Math.PI*2)); + ctx.arc(75,75,50,0,Math.PI*2,true); // Outer circle + ctx.moveTo(75,70); + ctx.arc(75,70,35,0,Math.PI,false); // Mouth (clockwise) + ctx.moveTo(60,65); + ctx.arc(60,65,5,0,Math.PI*2,true); // Left eye + ctx.moveTo(90 + 5 * Math.cos(0), + 65 - 5 * Math.sin(Math.PI*2)); + ctx.moveTo(90,65); + ctx.arc(90,65,5,0,Math.PI*2,true); // Right eye + ctx.closePath(); + if (canvas.fill) + ctx.fill(); + if (canvas.stroke) + ctx.stroke(); + ctx.restore(); + } + } + + Rectangle { + id:controls + width:360 + height:160 + Column { + spacing:3 + Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"} + Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleX"} + Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"} + Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"} + Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} + } + } + } +} diff --git a/examples/quick/canvas/squircle/squircle.png b/examples/quick/canvas/squircle/squircle.png new file mode 100644 index 0000000000..86c69d945f Binary files /dev/null and b/examples/quick/canvas/squircle/squircle.png differ diff --git a/examples/quick/canvas/squircle/squircle.qml b/examples/quick/canvas/squircle/squircle.qml new file mode 100644 index 0000000000..2fc65b67b3 --- /dev/null +++ b/examples/quick/canvas/squircle/squircle.qml @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../contents" +Item { + id:container + width:360 + height:600 + + Column { + spacing:5 + anchors.fill:parent + Text { font.pointSize:25; text:"Squircles"; anchors.horizontalCenter:parent.horizontalCenter} + Image { + anchors.horizontalCenter:parent.horizontalCenter + source:"squircle.png" + width:250 + height:25 + } + Canvas { + id:canvas + width:360 + height:360 + smooth:true + renderTarget:Canvas.Image + renderStrategy: Canvas.Immediate + + property string strokeStyle:"blue" + property string fillStyle:"steelblue" + property int lineWidth:2 + property int nSize:nCtrl.value + property real radius:rCtrl.value + property bool fill:true + property bool stroke:false + property real px:xCtrl.value + property real py:yCtrl.value + property real alpha:alphaCtrl.value + + onAlphaChanged:requestPaint(); + onRadiusChanged:requestPaint(); + onLineWidthChanged:requestPaint(); + onNSizeChanged:requestPaint(); + onFillChanged:requestPaint(); + onStrokeChanged:requestPaint(); + onPxChanged:requestPaint(); + onPyChanged:requestPaint(); + + + onPaint: squcirle(); + + function squcirle() { + var ctx = canvas.getContext("2d"); + var N = canvas.nSize; + var R = canvas.radius; + + N=Math.abs(N); + var M=N; + if (N>100) M=100; + if (N<0.00000000001) M=0.00000000001; + + ctx.save(); + ctx.globalAlpha =canvas.alpha; + ctx.fillStyle = "gray"; + ctx.fillRect(0, 0, canvas.width, canvas.height); + + ctx.strokeStyle = canvas.strokeStyle; + ctx.fillStyle = canvas.fillStyle; + ctx.lineWidth = canvas.lineWidth; + + ctx.beginPath(); + var i = 0, x, y; + for (i=0; i<(2*R+1); i++){ + x = Math.round(i-R) + canvas.px; + y = Math.round(Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(i-R),M)),1/M)) + canvas.py; + + if (i == 0) + ctx.moveTo(x, y); + else + ctx.lineTo(x, y); + } + + for (i=(2*R); i<(4*R+1); i++){ + x =Math.round(3*R-i)+canvas.px; + y = Math.round(-Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(3*R-i),M)),1/M)) + canvas.py; + ctx.lineTo(x, y); + } + ctx.closePath(); + if (canvas.stroke) { + ctx.stroke(); + } + + if (canvas.fill) { + ctx.fill(); + } + + ctx.fillStyle = "yellow"; + ctx.font = "Helvetica 16px"; + ctx.fillText("|X-" + Math.round(canvas.px) + "|^" + N + " + |Y-"+Math.round(canvas.py)+"|^" + N + " = |" + Math.round(R) + "|^" + N, canvas.px - 125, canvas.py); + ctx.restore(); + } + } + + Rectangle { + id:controls + width:360 + height:160 + Column { + spacing:3 + Slider {id:nCtrl; width:300; height:30; min:1; max:10; init:4; name:"N"} + Slider {id:rCtrl; width:300; height:30; min:30; max:180; init:100; name:"Radius"} + Slider {id:xCtrl; width:300; height:30; min:50; max:300; init:180; name:"X"} + Slider {id:yCtrl; width:300; height:30; min:30; max:300; init:220; name:"Y"} + Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} + } + } + } +} diff --git a/examples/quick/canvas/stockchart/README b/examples/quick/canvas/stockchart/README new file mode 100644 index 0000000000..2652866ed6 --- /dev/null +++ b/examples/quick/canvas/stockchart/README @@ -0,0 +1,5 @@ +To run: + + make install + QML_IMPORT_PATH=$PWD qmlscene stock.qml + diff --git a/examples/quick/canvas/stockchart/com/nokia/StockChartExample/qmldir b/examples/quick/canvas/stockchart/com/nokia/StockChartExample/qmldir new file mode 100644 index 0000000000..4c60e556d4 --- /dev/null +++ b/examples/quick/canvas/stockchart/com/nokia/StockChartExample/qmldir @@ -0,0 +1 @@ +plugin qmlstockchartexampleplugin diff --git a/examples/quick/canvas/stockchart/model.cpp b/examples/quick/canvas/stockchart/model.cpp new file mode 100644 index 0000000000..42eb2d592f --- /dev/null +++ b/examples/quick/canvas/stockchart/model.cpp @@ -0,0 +1,255 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "model.h" + +#include +#include +#include +#include +#include + +#include +#include + +StockModel::StockModel(QObject *parent) + : QAbstractListModel(parent) + , _startDate(QDate(1995, 4, 25)) + , _endDate(QDate::currentDate()) + , _dataCycle(StockModel::Daily) + , _manager(0) + , _updating(false) +{ + QHash roles; + roles[StockModel::DateRole] = "date"; + roles[StockModel::SectionRole] = "year"; + roles[StockModel::OpenPriceRole] = "openPrice"; + roles[StockModel::ClosePriceRole] = "closePrice"; + roles[StockModel::HighPriceRole] = "highPrice"; + roles[StockModel::LowPriceRole] = "lowPrice"; + roles[StockModel::VolumeRole] = "volume"; + roles[StockModel::AdjustedPriceRole] = "adjustedPrice"; + setRoleNames(roles); + + connect(this, SIGNAL(stockNameChanged()), SLOT(requestData())); + connect(this, SIGNAL(startDateChanged()), SLOT(requestData())); + connect(this, SIGNAL(endDateChanged()), SLOT(requestData())); + connect(this, SIGNAL(dataCycleChanged()), SLOT(requestData())); + + _manager = new QNetworkAccessManager(this); + connect(_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(update(QNetworkReply*))); + +} + +int StockModel::rowCount(const QModelIndex & parent) const { + Q_UNUSED(parent); + return _prices.count(); +} + +StockPrice* StockModel::stockPriceAtIndex(int idx) const +{ + if (idx >=0 && idx < _prices.size()) { + return _prices[idx]; + } + return 0; +} + + +void StockModel::requestData() +{ + if (!_updating) { + _updating = true; + QMetaObject::invokeMethod(this, "doRequest", Qt::QueuedConnection); + } +} + +void StockModel::doRequest() +{ + /* + Fetch stock data from yahoo finance: + url: http://ichart.finance.yahoo.com/table.csv?s=NOK&a=5&b=11&c=2010&d=7&e=23&f=2010&g=d&ignore=.csv + s:stock name/id, a:start day, b:start month, c:start year default: 25 April 1995, oldest c= 1962 + d:end day, e:end month, f:end year, default:today (data only available 3 days before today) + g:data cycle(d daily, w weekly, m monthly, v Dividend) + */ + if (_manager && !_stockName.isEmpty() && _endDate > _startDate) { + QString query("http://ichart.finance.yahoo.com/table.csv?s=%1&a=%2&b=%3&c=%4&d=%5&e=%6&f=%7&g=%8&ignore=.csv"); + query = query.arg(_stockName) + .arg(_startDate.day()).arg(_startDate.month()).arg(_startDate.year()) + .arg(_endDate.day()).arg(_endDate.month()).arg(_endDate.year()) + .arg(dataCycleString()); + + qDebug() << "request stock data:" << query; + QNetworkReply* reply = _manager->get(QNetworkRequest(QUrl(query))); + connect(reply, SIGNAL(downloadProgress(qint64,qint64)), SIGNAL(downloadProgress(qint64,qint64))); + } +} + +void StockModel::update(QNetworkReply *reply) +{ + _updating = false; + + if (reply) { + if (reply->error() == QNetworkReply::NoError) { + beginResetModel(); + + foreach (StockPrice* p, _prices) { + p->deleteLater(); + } + + _prices.clear(); + + while (!reply->atEnd()) { + QString line = reply->readLine(); + QStringList fields = line.split(','); + + //data format:Date,Open,High,Low,Close,Volume,Adjusted close price + //example: 2011-06-24,6.03,6.04,5.88,5.88,20465200,5.88 + if (fields.size() == 7) { + StockPrice* price = new StockPrice(this); + price->setDate(QDate::fromString(fields[0], Qt::ISODate)); + price->setOpenPrice(fields[1].toFloat()); + price->setHighPrice(fields[2].toFloat()); + price->setLowPrice(fields[3].toFloat()); + price->setClosePrice(fields[4].toFloat()); + price->setVolume(fields[5].toInt()); + price->setAdjustedPrice(fields[6].toFloat()); + _prices.prepend(price); + } + } + qDebug() << "get stock data successfully, total:" << _prices.count() << "records."; + } else { + qDebug() << "get stock data failed:" << reply->errorString(); + } + reply->deleteLater(); + endResetModel(); + emit dataChanged(QModelIndex(), QModelIndex()); + } +} + +QVariant StockModel::data(const QModelIndex & index, int role) const { + if (index.row() < 0 || index.row() > _prices.count()) + return QVariant(); + + const StockPrice* price = _prices[index.row()]; + if (role == StockModel::DateRole) + return price->date(); + else if (role == StockModel::OpenPriceRole) + return price->openPrice(); + else if (role == StockModel::ClosePriceRole) + return price->closePrice(); + else if (role == StockModel::HighPriceRole) + return price->highPrice(); + else if (role == StockModel::LowPriceRole) + return price->lowPrice(); + else if (role == StockModel::AdjustedPriceRole) + return price->adjustedPrice(); + else if (role == StockModel::VolumeRole) + return price->volume(); + else if (role == StockModel::SectionRole) + return price->date().year(); + return QVariant(); +} + +QString StockModel::stockName() const +{ + return _stockName; +} +void StockModel::setStockName(const QString& name) +{ + if (_stockName != name) { + _stockName = name; + emit stockNameChanged(); + } +} + +QDate StockModel::startDate() const +{ + return _startDate; +} +void StockModel::setStartDate(const QDate& date) +{ + if (_startDate.isValid() && _startDate != date) { + _startDate = date; + emit startDateChanged(); + } +} + +QDate StockModel::endDate() const +{ + return _endDate; +} +void StockModel::setEndDate(const QDate& date) +{ + if (_endDate.isValid() && _endDate != date) { + _endDate = date; + emit endDateChanged(); + } +} + +StockModel::StockDataCycle StockModel::dataCycle() const +{ + return _dataCycle; +} + +QString StockModel::dataCycleString() const +{ + switch (_dataCycle) { + case StockModel::Daily: + return QString('d'); + break; + case StockModel::Weekly: + return QString('w'); + case StockModel::Monthly: + return QString('m'); + case StockModel::Dividend: + return QString('v'); + } + + return QString('d'); +} + + +void StockModel::setDataCycle(StockModel::StockDataCycle cycle) +{ + if (_dataCycle != cycle) { + _dataCycle = cycle; + emit dataCycleChanged(); + } +} diff --git a/examples/quick/canvas/stockchart/model.h b/examples/quick/canvas/stockchart/model.h new file mode 100644 index 0000000000..95e6f4891c --- /dev/null +++ b/examples/quick/canvas/stockchart/model.h @@ -0,0 +1,166 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +class StockPrice : public QObject +{ + Q_OBJECT + Q_PROPERTY(QDate date READ date) + Q_PROPERTY(qreal openPrice READ openPrice) + Q_PROPERTY(qreal closePrice READ closePrice) + Q_PROPERTY(qreal highPrice READ highPrice) + Q_PROPERTY(qreal lowPrice READ lowPrice) + Q_PROPERTY(qint32 volume READ volume) + Q_PROPERTY(qreal adjustedPrice READ adjustedPrice) +public: + + StockPrice(QObject *parent = 0) + : QObject(parent) + , _openPrice(-1) + , _closePrice(-1) + , _highPrice(-1) + , _lowPrice(-1) + , _volume(-1) + , _adjustedPrice(-1) + { + } + QDate date() const {return _date;} + qreal openPrice() const {return _openPrice; } + qreal closePrice() const {return _closePrice;} + qreal highPrice() const {return _highPrice;} + qreal lowPrice() const{return _lowPrice;} + qreal adjustedPrice() const{return _adjustedPrice;} + qint32 volume() const{return _volume;} + + void setDate(const QDate& date){_date = date;} + void setOpenPrice(qreal price){_openPrice = price;} + void setClosePrice(qreal price){_closePrice = price;} + void setHighPrice(qreal price){_highPrice = price;} + void setLowPrice(qreal price){_lowPrice = price;} + void setAdjustedPrice(qreal price) {_adjustedPrice = price;} + void setVolume(qint32 volume) {_volume = volume;} + +private: + QDate _date; + qreal _openPrice; + qreal _closePrice; + qreal _highPrice; + qreal _lowPrice; + qint32 _volume; + qreal _adjustedPrice; +}; + +class QNetworkReply; +class QNetworkAccessManager; +class StockModel : public QAbstractListModel +{ + Q_OBJECT + + Q_PROPERTY(QString stockName READ stockName WRITE setStockName NOTIFY stockNameChanged) + Q_PROPERTY(QDate startDate READ startDate WRITE setStartDate NOTIFY startDateChanged) + Q_PROPERTY(QDate endDate READ endDate WRITE setEndDate NOTIFY endDateChanged) + Q_PROPERTY(StockDataCycle dataCycle READ dataCycle WRITE setDataCycle NOTIFY dataCycleChanged) + + Q_ENUMS(StockDataCycle) +public: + enum StockDataCycle { + Daily, + Weekly, + Monthly, + Dividend + }; + + enum StockModelRoles { + DateRole = Qt::UserRole + 1, + SectionRole, + OpenPriceRole, + ClosePriceRole, + HighPriceRole, + LowPriceRole, + VolumeRole, + AdjustedPriceRole + }; + + StockModel(QObject *parent = 0); + + QString stockName() const; + void setStockName(const QString& name); + + QDate startDate() const; + void setStartDate(const QDate& date); + + QDate endDate() const; + void setEndDate(const QDate& date); + + StockDataCycle dataCycle() const; + void setDataCycle(StockDataCycle cycle); + + int rowCount(const QModelIndex & parent = QModelIndex()) const; + + QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; + +signals: + void stockNameChanged(); + void startDateChanged(); + void endDateChanged(); + void dataCycleChanged(); + void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); + +public slots: + void requestData(); + StockPrice* stockPriceAtIndex(int idx) const; +private slots: + void doRequest(); + void update(QNetworkReply* reply); +private: + QString dataCycleString() const; + QList _prices; + QString _stockName; + QDate _startDate; + QDate _endDate; + StockDataCycle _dataCycle; + QNetworkAccessManager* _manager; + bool _updating; +}; + + + + diff --git a/examples/quick/canvas/stockchart/plugin.cpp b/examples/quick/canvas/stockchart/plugin.cpp new file mode 100644 index 0000000000..3b354e2b31 --- /dev/null +++ b/examples/quick/canvas/stockchart/plugin.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include "model.h" + +class QStockChartExampleQmlPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT +public: + void registerTypes(const char *uri) + { + Q_ASSERT(uri == QLatin1String("com.nokia.StockChartExample")); + qmlRegisterType(uri, 1, 0, "StockModel"); + qmlRegisterType(uri, 1, 0, "StockPrice"); + } +}; + +#include "plugin.moc" + +Q_EXPORT_PLUGIN2(qmlstockchartexampleplugin, QStockChartExampleQmlPlugin); diff --git a/examples/quick/canvas/stockchart/stock.qml b/examples/quick/canvas/stockchart/stock.qml new file mode 100644 index 0000000000..1c95fde2ce --- /dev/null +++ b/examples/quick/canvas/stockchart/stock.qml @@ -0,0 +1,726 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import com.nokia.StockChartExample 1.0 +import "../contents" + +Rectangle { + id:container + width: 360; height: 600 + color: "#343434"; + Image { source: "contents/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 1 } + + + TitleBar { + id: titleBar + width: parent.width + anchors.top : container.top + height: 40 + opacity: 0.9 + } + + StockModel { + id:stockModel + dataCycle: StockModel.Daily + function dataCycleName() { + if (dataCycle === StockModel.Weekly) + return "Weekly"; + else if (dataCycle === StockModel.Monthly) + return "Monthly"; + return "Daily"; + } + + onDataChanged: { + if (view.viewType == "chart") { + canvas.requestPaint(); + } + } + onDownloadProgress: { + if (bytesReceived == bytesTotal && bytesTotal != -1) { + progress.opacity = 0; + } else { + progress.opacity = 0.8; + progress.text = "downloading " + stockModel.dataCycleName() + " data ..."+ Math.round(bytesReceived/1000) + " KB"; + } + } + + property string description:""; + } + + Stocks {id:stocks} + + Rectangle { + id: header + width: parent.width + height: 20 + color: "steelblue" + opacity: 0 + Row { + spacing: 2 + Text { + id:t + font.pointSize:15 + horizontalAlignment:Text.AlignHCenter + font.bold: true + font.underline:true + } + Rectangle { + height:20 + width:50 + Text {text:"Stock list"; font.pointSize:15; font.bold: true} + } + } + } + + ListView { + id:stockList + width: parent.width + anchors.bottom: container.bottom + anchors.top : titleBar.bottom + focus: true + keyNavigationWraps: true + spacing:1 + opacity: 1 + model: stocks + + Component.onCompleted: opacity = 0.9; + onOpacityChanged: { + titleBar.title = "Top 100 NASDAQ stocks" + } + + + delegate : Rectangle { + height: 30 + width: view.width + color: { + if (ListView.isCurrentItem) + return focus ? "lightyellow" : "pink"; + return index % 2 == 0 ? "lightblue" : "lightsteelblue" + } + Text { + font.pointSize:20 + text: index + ". " + stockId + " \t(" + name + ")"; + } + MouseArea { + anchors.fill: parent; + onDoubleClicked: { + stockList.opacity = 0; + stockModel.stockName = stockId; + stockModel.description = "NASDAQ:" + stockId + " (" + name + ")"; + view.opacity = 1; + view.viewType = "chart"; + canvas.opacity = 0.7; + } + onClicked: stockList.currentIndex = index + }//mousearea + }//delegate + } + + ListView { + id:view + width: container.width + height: container.height - 50 + anchors.bottom: container.bottom + focus: true + keyNavigationWraps: true + + spacing:1 + opacity: 0 + model: stockModel + highlightFollowsCurrentItem: false + highlightRangeMode: ListView.StrictlyEnforceRange + preferredHighlightBegin:50 + preferredHighlightEnd : height - 50 + highlight: listHighlight + + //header : Text {} + delegate: listDelegate + snapMode: ListView.SnapToItem + + property string viewType : "list" + property int topIndex:indexAt(0,contentY); + property int bottomIndex:indexAt(0, contentY+height); + + onCountChanged: { + + titleBar.title = stockModel.description + " " + Qt.formatDate(stockModel.startDate, "yyyy-MM-dd") + " - " + + Qt.formatDate(stockModel.endDate, "yyyy-MM-dd") + " " + stockModel.dataCycleName() + + " records:" + view.count; + + } + + Component { + id: listDelegate + Rectangle { + height: 20 + width: view.width + border.color: "lightsteelblue" + border.width: 1 + color: { + if (ListView.isCurrentItem) + return focus ? "lightyellow" : "pink"; + + return index % 2 == 0 ? "lightblue" : "lightsteelblue" + } + Text { + font.pointSize:13 + text: index + ". " + Qt.formatDate(date, "yyyy-MM-dd") + + "\t " + Math.round(openPrice*100)/100 + + "\t " + Math.round(highPrice*100)/100 + + "\t " + Math.round(lowPrice*100)/100 + + "\t " + Math.round(closePrice*100)/100 + + "\t " + volume + "\t " + + Math.round(adjustedPrice*100)/100; + } + MouseArea {anchors.fill: parent; onClicked: view.currentIndex = index} + } + } + + Component { + id: chartDelegate + Rectangle { + height: 20 + width: view.width/view.count * canvas.scaleX + border.color: "lightsteelblue" + border.width: 1 + color: { + if (ListView.isCurrentItem) + return focus ? "lightyellow" : "pink"; + + return index % 2 == 0 ? "lightblue" : "lightsteelblue" + } + + Text { + anchors.bottom: parent.bottom + font.pointSize: { + if (parent.width <= 4) + return 1; + if (parent.width <= 50) + return parent.width/4; + return 15; + } + horizontalAlignment:Text.AlignHCenter + verticalAlignment:Text.AlignBottom + text:font.pointSize > 1 ? Qt.formatDate(date, "d/M/yy") : "" + } + MouseArea {anchors.fill: parent; onClicked: view.currentIndex = index} + } + } + + Component { + id:chartHighlight + Rectangle { radius: 5; width:40; height: 20; color: "lightsteelblue" } + } + + Component { + id:listHighlight + Rectangle { radius: 5; width:container.width; height: 20; color: "lightsteelblue" } + } + + + + + onViewTypeChanged : { + if (viewType == "list") { + view.orientation = ListView.Vertical; + view.delegate = listDelegate; +// view.section.property = "year"; +// view.section.criteria = ViewSection.FullString; +// view.section.delegate = sectionHeading; + view.highlight = listHighlight; + view.opacity = 1; + canvas.opacity = 0; + // comment.opacity = 0; + + } else if (viewType == "chart") { + view.orientation = ListView.Horizontal; + view.delegate = chartDelegate; + //comment.opacity = 0.6; + + view.opacity = 1; + view.height = 30 + + canvas.opacity = 0.7; + canvas.requestPaint(); + } else { + viewType = "list"; + } + } + + + onCurrentIndexChanged: { + //header.updateCurrent(stockModel.stockPriceAtIndex(view.currentIndex)); + if (viewType == "chart") { + canvas.first = Math.round(view.currentIndex - view.currentIndex / canvas.scaleX); + canvas.last = Math.round(view.currentIndex + (view.count - view.currentIndex) / canvas.scaleX); + + canvas.requestPaint(); + } + } + onContentYChanged: { // keep "current" item visible + topIndex = indexAt(0,contentY); + bottomIndex = indexAt(0, contentY+height); + + if (topIndex != -1 && currentIndex <= topIndex) + currentIndex = topIndex+1; + else if (bottomIndex != -1 && currentIndex >= bottomIndex) + currentIndex = bottomIndex-1; + if (viewType == "chart") + canvas.requestPaint(); + } + + onContentXChanged: { // keep "current" item visible + topIndex = indexAt(contentX,0); + bottomIndex = indexAt(contentX+width, 0); + + if (topIndex != -1 && currentIndex <= topIndex) + currentIndex = topIndex+1; + else if (bottomIndex != -1 && currentIndex >= bottomIndex) + currentIndex = bottomIndex-1; + if (viewType == "chart") + canvas.requestPaint(); + } + + MouseArea { + anchors.fill: parent + onDoubleClicked: { + if (view.viewType == "list") + view.viewType = "chart"; + else + view.viewType = "list"; + } + } + } + + + + Canvas { + id:canvas + anchors.top : titleBar.bottom + anchors.bottom : view.top + width:container.width; + opacity:0 + renderTarget: Canvas.Image + renderStrategy: Canvas.Immediate + property bool running:false + property int frames:first + property int mouseX:0; + property int mouseY:0; + property int mousePressedX:0; + property int mousePressedY:0; + property int movedY:0 + property real scaleX:1.0; + property real scaleY:1.0; + property int first:0; + property int last:view.count - 1; + + onOpacityChanged: { + if (opacity > 0) + requestPaint(); + } + Text { + id:comment + x:100 + y:50 + font.pointSize: 20 + color:"white" + opacity: 0.7 + focus:false + text: stockModel.description + function updateCurrent(price) + { + if (price !== undefined) { + text =stockModel.description + "\n" + + Qt.formatDate(price.date, "yyyy-MM-dd") + " OPEN:" + + Math.round(price.openPrice*100)/100 + " HIGH:" + + Math.round(price.highPrice*100)/100 + " LOW:" + + Math.round(price.lowPrice*100)/100 + " CLOSE:" + + Math.round(price.closePrice*100)/100 + " VOLUME:" + + price.volume; + } + } + } + + Text { + id:priceAxis + x:25 + y:25 + font.pointSize: 15 + color:"yellow" + opacity: 0.7 + focus: false + } + Text { + id:volumeAxis + x:canvas.width - 200 + y:25 + font.pointSize: 15 + color:"yellow" + opacity: 0.7 + } + + Rectangle { + id:progress + x:canvas.width/2 - 100 + y:canvas.height/2 + width:childrenRect.width + height: childrenRect.height + opacity: 0 + color:"white" + property string text; + Text { + text:parent.text + font.pointSize: 20 + } + } + + Button { + id:runButton + text:"Run this chart" + y:0 + x:canvas.width/2 - 50 + opacity: 0.5 + onClicked: { + if (canvas.running) { + canvas.running = false; + canvas.frames = canvas.first; + canvas.requestPaint(); + text = "Run this chart"; + comment.text = stockModel.description; + } else { + text = " Stop running "; + canvas.runChart(); + } + } + } + Button { + id:returnButton + text:"Stocks" + y:0 + anchors.left : runButton.right + anchors.leftMargin : 20 + opacity: 0.5 + onClicked: { + stockList.opacity = 1; + canvas.opacity = 0; + } + } + PinchArea { + anchors.fill: parent + onPinchUpdated : { + var current = pinch.center; + var scale = pinch.scale; + console.log("center:" + pinch.center + " scale:" + pinch.scale); + //canvas.requestPaint(); + } + } + + MouseArea { + anchors.fill: parent + + onDoubleClicked: { + if (stockModel.dataCycle == StockModel.Daily) + stockModel.dataCycle = StockModel.Weekly; + else if (stockModel.dataCycle == StockModel.Weekly) + stockModel.dataCycle = StockModel.Monthly; + else + stockModel.dataCycle = StockModel.Daily; + } + + onPositionChanged: { + if (mouse.modifiers & Qt.ControlModifier) { + if (canvas.mouseX == 0 && canvas.mouseY == 0) { + canvas.mouseX = mouse.x; + canvas.mouseY = mouse.y; + } + } else{ + var w = (view.width/view.count)*canvas.scaleX; + + //canvas.movedY += Math.round((canvas.mousePressedY - mouse.y)/2); + + var movedX = Math.round((canvas.mousePressedX - mouse.x)/w); + if (movedX != 0 || canvas.movedY != 0) { + if (canvas.first + movedX >= 0 && canvas.last + movedX < view.count) { + canvas.first += movedX; + canvas.last += movedX; + } + canvas.requestPaint(); + } + } + } + + onPressed: { + canvas.mousePressedX = mouse.x; + canvas.mousePressedY = mouse.y; + } + + onReleased : { + if (mouse.modifiers & Qt.ControlModifier) { + var sx = mouse.x - canvas.mouseX; + var sy = canvas.mouseY - mouse.y; + + if (Math.abs(sx) < 50) sx = 0; + if (Math.abs(sy) < 50) sy = 0; + + if (sx > 0) + canvas.scaleX *= sx/100 +1; + else + canvas.scaleX *= 1/(-sx/100 + 1); + + if (sy > 0) + canvas.scaleY *= sy/100 +1; + else + canvas.scaleY *= 1/(-sy/100 + 1); + + if (canvas.scaleX < 1) + canvas.scaleX = 1; + + //console.log("scaleX:" + canvas.scaleX + ", scaleY:" + canvas.scaleY); + + canvas.first = Math.round(view.currentIndex - view.currentIndex / canvas.scaleX); + canvas.last = Math.round(view.currentIndex + (view.count - view.currentIndex) / canvas.scaleX); + + canvas.mouseX = 0; + canvas.mouseY = 0; + canvas.mousePressedX = 0; + canvas.mousePressedY = 0; + canvas.requestPaint(); + } + } + } + + function runChart() { + canvas.running = true; + requestPaint(); + } + + function showPriceAt(x) { + var w = (view.width/view.count)*canvas.scaleX; + //header.updateCurrent(stockModel.stockPriceAtIndex(canvas.first + Math.round(x/w))); + //console.log("x:" + x + " w:" + w + " index:" + (canvas.first + Math.round(x/w))); + } + + function drawPrice(ctx, from, to, color, price, points, highest) + { + ctx.globalAlpha = 0.7; + ctx.strokeStyle = color; + ctx.lineWidth = 1; + ctx.beginPath(); + + //price x axis + priceAxis.text = "price:" + Math.round(highest); + ctx.font = "bold 12px sans-serif"; + + ctx.strokeText("price", 25, 25); + for (var j = 1; j < 30; j++) { + var val = (highest * j) / 30; + val = canvas.height * (1 - val/highest); + ctx.beginPath(); + + ctx.moveTo(10, val); + if (j % 5) + ctx.lineTo(15, val); + else + ctx.lineTo(20, val); + ctx.stroke(); + } + + ctx.beginPath(); + ctx.moveTo(10, 0); + ctx.lineTo(10, canvas.height); + ctx.stroke(); + + + var w = canvas.width/points.length; + var end = canvas.running? canvas.frames - canvas.first :points.length; + for (var i = 0; i < end; i++) { + var x = points[i].x; + var y = points[i][price]; + y += canvas.movedY; + + y = canvas.height * (1 - y/highest); + if (i == 0) { + ctx.moveTo(x+w/2, y); + } else { + ctx.lineTo(x+w/2, y); + } + } + ctx.stroke(); + } + + function drawKLine(ctx, from, to, points, highest) + { + ctx.globalAlpha = 0.4; + ctx.lineWidth = 2; + var end = canvas.running? canvas.frames - canvas.first :points.length; + for (var i = 0; i < end; i++) { + var x = points[i].x; + var open = canvas.height * (1 - points[i].open/highest) - canvas.movedY; + var close = canvas.height * (1 - points[i].close/highest) - canvas.movedY; + var high = canvas.height * (1 - points[i].high/highest) - canvas.movedY; + var low = canvas.height * (1 - points[i].low/highest) - canvas.movedY; + + var top, bottom; + if (close <= open) { + ctx.fillStyle = Qt.rgba(1, 0, 0, 1); + ctx.strokeStyle = Qt.rgba(1, 0, 0, 1); + top = close; + bottom = open; + } else { + ctx.fillStyle = Qt.rgba(0, 1, 0, 1); + ctx.strokeStyle = Qt.rgba(0, 1, 0, 1); + top = open; + bottom = close; + } + + var w1, w2; + w1 = canvas.width/points.length; + w2 = w1 > 10 ? w1/2 : w1; + + ctx.fillRect(x + (w1 - w2)/2, top, w2, bottom - top); + ctx.beginPath(); + ctx.moveTo(x+w1/2, high); + ctx.lineTo(x+w1/2, low); + ctx.stroke(); + } + ctx.globalAlpha = 1; + + } + + function drawVolume(ctx, from, to, color, price, points, highest) + { + ctx.fillStyle = color; + ctx.globalAlpha = 0.6; + ctx.strokeStyle = Qt.rgba(0.8, 0.8, 0.8, 1); + ctx.lineWidth = 1; + + //volume x axis + volumeAxis.text = "volume:" + Math.round(highest/(1000*100)) + "M"; + for (var j = 1; j < 30; j++) { + var val = (highest * j) / 30; + val = canvas.height * (1 - val/highest); + ctx.beginPath(); + if (j % 5) + ctx.moveTo(canvas.width - 15, val); + else + ctx.moveTo(canvas.width - 20, val); + ctx.lineTo(canvas.width - 10, val); + ctx.stroke(); + } + + ctx.beginPath(); + ctx.moveTo(canvas.width - 10, 0); + ctx.lineTo(canvas.width - 10, canvas.height); + ctx.stroke(); + + var end = canvas.running? canvas.frames - canvas.first :points.length; + for (var i = 0; i < end; i++) { + var x = points[i].x; + var y = points[i][price]; + y = canvas.height * (1 - y/highest); + ctx.fillRect(x, y, canvas.width/points.length, canvas.height - y); + } + } +/* + onPainted : { + if (canvas.running) { + if (frames >= last) { + canvas.running = false; + canvas.frames = first; + runButton.text = "Run this chart"; + comment.text = stockModel.description; + requestPaint(); + } else { + frames += Math.round(view.count / 100); + if (frames > last) frames = last; + var price = stockModel.stockPriceAtIndex(frames); + if (price) { + comment.updateCurrent(price); + } + + requestPaint(); + } + } + } +*/ + onPaint: { + if (view.currentIndex <= 0) + first = 0; + if (last >= view.count) + last = view.count - 1; + + //console.log("painting... first:" + first + ", last:" + last + " current:" + view.currentIndex); + var ctx = canvas.getContext("2d"); + ctx.save(); + + ctx.globalCompositeOperation = "source-over"; + ctx.lineWidth = 1; + ctx.lineJoin = "round"; + ctx.fillStyle = "rgba(0,0,0,0)"; + + ctx.fillRect(0, 0, canvas.width, canvas.height); + + + + var highestPrice = 500/canvas.scaleY; + var highestValume = 600 * 1000 * 1000/canvas.scaleY; + var points = []; + for (var i = 0; i <= last - first; i++) { + var price = stockModel.stockPriceAtIndex(i + first); + points.push({ + x: i*canvas.width/(last-first+1), + open: price.openPrice, + close: price.closePrice, + high:price.highPrice, + low:price.lowPrice, + volume:price.volume + }); + } + + drawPrice(ctx, first, last, Qt.rgba(1, 0, 0, 1),"high", points, highestPrice); + drawPrice(ctx, first, last, Qt.rgba(0, 1, 0, 1),"low", points, highestPrice); + drawPrice(ctx, first, last, Qt.rgba(0, 0, 1, 1),"open", points, highestPrice); + drawPrice(ctx, first, last, Qt.rgba(0.5, 0.5, 0.5, 1),"close", points, highestPrice); + drawVolume(ctx, first, last, Qt.rgba(0.3, 0.5, 0.7, 1),"volume", points, highestValume); + drawKLine(ctx, first, last, points, highestPrice); + ctx.restore(); + } + } +} diff --git a/examples/quick/canvas/stockchart/stockchart.pro b/examples/quick/canvas/stockchart/stockchart.pro new file mode 100644 index 0000000000..e368746db5 --- /dev/null +++ b/examples/quick/canvas/stockchart/stockchart.pro @@ -0,0 +1,20 @@ +TEMPLATE = lib +CONFIG += qt plugin +QT += qml network + +DESTDIR = com/nokia/StockChartExample +TARGET = qmlstockchartexampleplugin + +SOURCES += model.cpp plugin.cpp +HEADERS += model.h +qdeclarativesources.files += \ + com/nokia/StockChartExample/qmldir \ + stock.qml + +qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins/com/nokia/StockChartExample + +sources.files += stockchart.pro model.h model.cpp plugin.cpp README +sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins +target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins/com/nokia/StockChartExample + +INSTALLS += qdeclarativesources sources target diff --git a/examples/quick/canvas/tiger/tiger.js b/examples/quick/canvas/tiger/tiger.js new file mode 100644 index 0000000000..4be0d26c9d --- /dev/null +++ b/examples/quick/canvas/tiger/tiger.js @@ -0,0 +1,721 @@ +var tiger = [ + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-122.304 84.285C-122.304 84.285 -122.203 86.179 -123.027 86.16C-123.851 86.141 -140.305 38.066 -160.833 40.309C-160.833 40.309 -143.05 32.956 -122.304 84.285z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-118.774 81.262C-118.774 81.262 -119.323 83.078 -120.092 82.779C-120.86 82.481 -119.977 31.675 -140.043 26.801C-140.043 26.801 -120.82 25.937 -118.774 81.262z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-91.284 123.59C-91.284 123.59 -89.648 124.55 -90.118 125.227C-90.589 125.904 -139.763 113.102 -149.218 131.459C-149.218 131.459 -145.539 112.572 -91.284 123.59z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-94.093 133.801C-94.093 133.801 -92.237 134.197 -92.471 134.988C-92.704 135.779 -143.407 139.121 -146.597 159.522C-146.597 159.522 -149.055 140.437 -94.093 133.801z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-98.304 128.276C-98.304 128.276 -96.526 128.939 -96.872 129.687C-97.218 130.435 -147.866 126.346 -153.998 146.064C-153.998 146.064 -153.646 126.825 -98.304 128.276z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-109.009 110.072C-109.009 110.072 -107.701 111.446 -108.34 111.967C-108.979 112.488 -152.722 86.634 -166.869 101.676C-166.869 101.676 -158.128 84.533 -109.009 110.072z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-116.554 114.263C-116.554 114.263 -115.098 115.48 -115.674 116.071C-116.25 116.661 -162.638 95.922 -174.992 112.469C-174.992 112.469 -168.247 94.447 -116.554 114.263z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-119.154 118.335C-119.154 118.335 -117.546 119.343 -118.036 120.006C-118.526 120.669 -167.308 106.446 -177.291 124.522C-177.291 124.522 -173.066 105.749 -119.154 118.335z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-108.42 118.949C-108.42 118.949 -107.298 120.48 -107.999 120.915C-108.7 121.35 -148.769 90.102 -164.727 103.207C-164.727 103.207 -153.862 87.326 -108.42 118.949z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-128.2 90C-128.2 90 -127.6 91.8 -128.4 92C-129.2 92.2 -157.8 50.2 -177.001 57.8C-177.001 57.8 -161.8 46 -128.2 90z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-127.505 96.979C-127.505 96.979 -126.53 98.608 -127.269 98.975C-128.007 99.343 -164.992 64.499 -182.101 76.061C-182.101 76.061 -169.804 61.261 -127.505 96.979z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-127.62 101.349C-127.62 101.349 -126.498 102.88 -127.199 103.315C-127.9 103.749 -167.969 72.502 -183.927 85.607C-183.927 85.607 -173.062 69.726 -127.62 101.349z"} + , + {"fill": "#ffffff", "stroke":"#000000", + "path":"M-129.83 103.065C-129.327 109.113 -128.339 115.682 -126.6 118.801C-126.6 118.801 -130.2 131.201 -121.4 144.401C-121.4 144.401 -121.8 151.601 -120.2 154.801C-120.2 154.801 -116.2 163.201 -111.4 164.001C-107.516 164.648 -98.793 167.717 -88.932 169.121C-88.932 169.121 -71.8 183.201 -75 196.001C-75 196.001 -75.4 212.401 -79 214.001C-79 214.001 -67.4 202.801 -77 219.601L-81.4 238.401C-81.4 238.401 -55.8 216.801 -71.4 235.201L-81.4 261.201C-81.4 261.201 -61.8 242.801 -69 251.201L-72.2 260.001C-72.2 260.001 -29 232.801 -59.8 262.401C-59.8 262.401 -51.8 258.801 -47.4 261.601C-47.4 261.601 -40.6 260.401 -41.4 262.001C-41.4 262.001 -62.2 272.401 -65.8 290.801C-65.8 290.801 -57.4 280.801 -60.6 291.601L-60.2 303.201C-60.2 303.201 -56.2 281.601 -56.6 319.201C-56.6 319.201 -37.4 301.201 -49 322.001L-49 338.801C-49 338.801 -33.8 322.401 -40.2 335.201C-40.2 335.201 -30.2 326.401 -34.2 341.601C-34.2 341.601 -35 352.001 -30.6 340.801C-30.6 340.801 -14.6 310.201 -20.6 336.401C-20.6 336.401 -21.4 355.601 -16.6 340.801C-16.6 340.801 -16.2 351.201 -7 358.401C-7 358.401 -8.2 307.601 4.6 343.601L8.6 360.001C8.6 360.001 11.4 350.801 11 345.601C11 345.601 25.8 329.201 19 353.601C19 353.601 34.2 330.801 31 344.001C31 344.001 23.4 360.001 25 364.801C25 364.801 41.8 330.001 43 328.401C43 328.401 41 370.802 51.8 334.801C51.8 334.801 57.4 346.801 54.6 351.201C54.6 351.201 62.6 343.201 61.8 340.001C61.8 340.001 66.4 331.801 69.2 345.401C69.2 345.401 71 354.801 72.6 351.601C72.6 351.601 76.6 375.602 77.8 352.801C77.8 352.801 79.4 339.201 72.2 327.601C72.2 327.601 73 324.401 70.2 320.401C70.2 320.401 83.8 342.001 76.6 313.201C76.6 313.201 87.801 321.201 89.001 321.201C89.001 321.201 75.4 298.001 84.2 302.801C84.2 302.801 79 292.401 97.001 304.401C97.001 304.401 81 288.401 98.601 298.001C98.601 298.001 106.601 304.401 99.001 294.401C99.001 294.401 84.6 278.401 106.601 296.401C106.601 296.401 118.201 312.801 119.001 315.601C119.001 315.601 109.001 286.401 104.601 283.601C104.601 283.601 113.001 247.201 154.201 262.801C154.201 262.801 161.001 280.001 165.401 261.601C165.401 261.601 178.201 255.201 189.401 282.801C189.401 282.801 193.401 269.201 192.601 266.401C192.601 266.401 199.401 267.601 198.601 266.401C198.601 266.401 211.801 270.801 213.001 270.001C213.001 270.001 219.801 276.801 220.201 273.201C220.201 273.201 229.401 276.001 227.401 272.401C227.401 272.401 236.201 288.001 236.601 291.601L239.001 277.601L241.001 280.401C241.001 280.401 242.601 272.801 241.801 271.601C241.001 270.401 261.801 278.401 266.601 299.201L268.601 307.601C268.601 307.601 274.601 292.801 273.001 288.801C273.001 288.801 278.201 289.601 278.601 294.001C278.601 294.001 282.601 270.801 277.801 264.801C277.801 264.801 282.201 264.001 283.401 267.601L283.401 260.401C283.401 260.401 290.601 261.201 290.601 258.801C290.601 258.801 295.001 254.801 297.001 259.601C297.001 259.601 284.601 224.401 303.001 243.601C303.001 243.601 310.201 254.401 306.601 235.601C303.001 216.801 299.001 215.201 303.801 214.801C303.801 214.801 304.601 211.201 302.601 209.601C300.601 208.001 303.801 209.601 303.801 209.601C303.801 209.601 308.601 213.601 303.401 191.601C303.401 191.601 309.801 193.201 297.801 164.001C297.801 164.001 300.601 161.601 296.601 153.201C296.601 153.201 304.601 157.601 307.401 156.001C307.401 156.001 307.001 154.401 303.801 150.401C303.801 150.401 282.201 95.6 302.601 117.601C302.601 117.601 314.451 131.151 308.051 108.351C308.051 108.351 298.94 84.341 299.717 80.045L-129.83 103.065z"} + , + {"fill": "#cc7226", "stroke":"#000000", + "path":"M299.717 80.245C300.345 80.426 302.551 81.55 303.801 83.2C303.801 83.2 310.601 94 305.401 75.6C305.401 75.6 296.201 46.8 305.001 58C305.001 58 311.001 65.2 307.801 51.6C303.936 35.173 301.401 28.8 301.401 28.8C301.401 28.8 313.001 33.6 286.201 -6L295.001 -2.4C295.001 -2.4 275.401 -42 253.801 -47.2L245.801 -53.2C245.801 -53.2 284.201 -91.2 271.401 -128C271.401 -128 264.601 -133.2 255.001 -124C255.001 -124 248.601 -119.2 242.601 -120.8C242.601 -120.8 211.801 -119.6 209.801 -119.6C207.801 -119.6 173.001 -156.8 107.401 -139.2C107.401 -139.2 102.201 -137.2 97.801 -138.4C97.801 -138.4 79.4 -154.4 30.6 -131.6C30.6 -131.6 20.6 -129.6 19 -129.6C17.4 -129.6 14.6 -129.6 6.6 -123.2C-1.4 -116.8 -1.8 -116 -3.8 -114.4C-3.8 -114.4 -20.2 -103.2 -25 -102.4C-25 -102.4 -36.6 -96 -41 -86L-44.6 -84.8C-44.6 -84.8 -46.2 -77.6 -46.6 -76.4C-46.6 -76.4 -51.4 -72.8 -52.2 -67.2C-52.2 -67.2 -61 -61.2 -60.6 -56.8C-60.6 -56.8 -62.2 -51.6 -63 -46.8C-63 -46.8 -70.2 -42 -69.4 -39.2C-69.4 -39.2 -77 -25.2 -75.8 -18.4C-75.8 -18.4 -82.2 -18.8 -85 -16.4C-85 -16.4 -85.8 -11.6 -87.4 -11.2C-87.4 -11.2 -90.2 -10 -87.8 -6C-87.8 -6 -89.4 -3.2 -89.8 -1.6C-89.8 -1.6 -89 1.2 -93.4 6.8C-93.4 6.8 -99.8 25.6 -97.8 30.8C-97.8 30.8 -97.4 35.6 -100.2 37.2C-100.2 37.2 -103.8 36.8 -95.4 48.8C-95.4 48.8 -94.6 50 -97.8 52.4C-97.8 52.4 -115 56 -117.4 72.4C-117.4 72.4 -131 87.2 -131 92.4C-131 94.705 -130.729 97.852 -130.03 102.465C-130.03 102.465 -130.6 110.801 -103 111.601C-75.4 112.401 299.717 80.245 299.717 80.245z"} + , + {"fill": "#cc7226", + "path":"M-115.6 102.6C-140.6 63.2 -126.2 119.601 -126.2 119.601C-117.4 154.001 12.2 116.401 12.2 116.401C12.2 116.401 181.001 86 192.201 82C203.401 78 298.601 84.4 298.601 84.4L293.001 67.6C228.201 21.2 209.001 44.4 195.401 40.4C181.801 36.4 184.201 46 181.001 46.8C177.801 47.6 138.601 22.8 132.201 23.6C125.801 24.4 100.459 0.649 115.401 32.4C131.401 66.4 57 71.6 40.2 60.4C23.4 49.2 47.4 78.8 47.4 78.8C65.8 98.8 31.4 82 31.4 82C-3 69.2 -27 94.8 -30.2 95.6C-33.4 96.4 -38.2 99.6 -39 93.2C-39.8 86.8 -47.31 70.099 -79 96.4C-99 113.001 -112.8 91 -112.8 91L-115.6 102.6z"} + , + {"fill": "#e87f3a", + "path":"M133.51 25.346C127.11 26.146 101.743 2.407 116.71 34.146C133.31 69.346 58.31 73.346 41.51 62.146C24.709 50.946 48.71 80.546 48.71 80.546C67.11 100.546 32.709 83.746 32.709 83.746C-1.691 70.946 -25.691 96.546 -28.891 97.346C-32.091 98.146 -36.891 101.346 -37.691 94.946C-38.491 88.546 -45.87 72.012 -77.691 98.146C-98.927 115.492 -112.418 94.037 -112.418 94.037L-115.618 104.146C-140.618 64.346 -125.546 122.655 -125.546 122.655C-116.745 157.056 13.509 118.146 13.509 118.146C13.509 118.146 182.31 87.746 193.51 83.746C204.71 79.746 299.038 86.073 299.038 86.073L293.51 68.764C228.71 22.364 210.31 46.146 196.71 42.146C183.11 38.146 185.51 47.746 182.31 48.546C179.11 49.346 139.91 24.546 133.51 25.346z"} + , + {"fill": "#ea8c4d", + "path":"M134.819 27.091C128.419 27.891 103.685 3.862 118.019 35.891C134.219 72.092 59.619 75.092 42.819 63.892C26.019 52.692 50.019 82.292 50.019 82.292C68.419 102.292 34.019 85.492 34.019 85.492C-0.381 72.692 -24.382 98.292 -27.582 99.092C-30.782 99.892 -35.582 103.092 -36.382 96.692C-37.182 90.292 -44.43 73.925 -76.382 99.892C-98.855 117.983 -112.036 97.074 -112.036 97.074L-115.636 105.692C-139.436 66.692 -124.891 125.71 -124.891 125.71C-116.091 160.11 14.819 119.892 14.819 119.892C14.819 119.892 183.619 89.492 194.819 85.492C206.019 81.492 299.474 87.746 299.474 87.746L294.02 69.928C229.219 23.528 211.619 47.891 198.019 43.891C184.419 39.891 186.819 49.491 183.619 50.292C180.419 51.092 141.219 26.291 134.819 27.091z"} + , + {"fill": "#ec9961", + "path":"M136.128 28.837C129.728 29.637 104.999 5.605 119.328 37.637C136.128 75.193 60.394 76.482 44.128 65.637C27.328 54.437 51.328 84.037 51.328 84.037C69.728 104.037 35.328 87.237 35.328 87.237C0.928 74.437 -23.072 100.037 -26.272 100.837C-29.472 101.637 -34.272 104.837 -35.072 98.437C-35.872 92.037 -42.989 75.839 -75.073 101.637C-98.782 120.474 -111.655 100.11 -111.655 100.11L-115.655 107.237C-137.455 70.437 -124.236 128.765 -124.236 128.765C-115.436 163.165 16.128 121.637 16.128 121.637C16.128 121.637 184.928 91.237 196.129 87.237C207.329 83.237 299.911 89.419 299.911 89.419L294.529 71.092C229.729 24.691 212.929 49.637 199.329 45.637C185.728 41.637 188.128 51.237 184.928 52.037C181.728 52.837 142.528 28.037 136.128 28.837z"} + , + {"fill": "#eea575", + "path":"M137.438 30.583C131.037 31.383 106.814 7.129 120.637 39.383C137.438 78.583 62.237 78.583 45.437 67.383C28.637 56.183 52.637 85.783 52.637 85.783C71.037 105.783 36.637 88.983 36.637 88.983C2.237 76.183 -21.763 101.783 -24.963 102.583C-28.163 103.383 -32.963 106.583 -33.763 100.183C-34.563 93.783 -41.548 77.752 -73.763 103.383C-98.709 122.965 -111.273 103.146 -111.273 103.146L-115.673 108.783C-135.473 73.982 -123.582 131.819 -123.582 131.819C-114.782 166.22 17.437 123.383 17.437 123.383C17.437 123.383 186.238 92.983 197.438 88.983C208.638 84.983 300.347 91.092 300.347 91.092L295.038 72.255C230.238 25.855 214.238 51.383 200.638 47.383C187.038 43.383 189.438 52.983 186.238 53.783C183.038 54.583 143.838 29.783 137.438 30.583z"} + , + {"fill": "#f1b288", + "path":"M138.747 32.328C132.347 33.128 106.383 9.677 121.947 41.128C141.147 79.928 63.546 80.328 46.746 69.128C29.946 57.928 53.946 87.528 53.946 87.528C72.346 107.528 37.946 90.728 37.946 90.728C3.546 77.928 -20.454 103.528 -23.654 104.328C-26.854 105.128 -31.654 108.328 -32.454 101.928C-33.254 95.528 -40.108 79.665 -72.454 105.128C-98.636 125.456 -110.891 106.183 -110.891 106.183L-115.691 110.328C-133.691 77.128 -122.927 134.874 -122.927 134.874C-114.127 169.274 18.746 125.128 18.746 125.128C18.746 125.128 187.547 94.728 198.747 90.728C209.947 86.728 300.783 92.764 300.783 92.764L295.547 73.419C230.747 27.019 215.547 53.128 201.947 49.128C188.347 45.128 190.747 54.728 187.547 55.528C184.347 56.328 145.147 31.528 138.747 32.328z"} + , + {"fill": "#f3bf9c", + "path":"M140.056 34.073C133.655 34.873 107.313 11.613 123.255 42.873C143.656 82.874 64.855 82.074 48.055 70.874C31.255 59.674 55.255 89.274 55.255 89.274C73.655 109.274 39.255 92.474 39.255 92.474C4.855 79.674 -19.145 105.274 -22.345 106.074C-25.545 106.874 -30.345 110.074 -31.145 103.674C-31.945 97.274 -38.668 81.578 -71.145 106.874C-98.564 127.947 -110.509 109.219 -110.509 109.219L-115.709 111.874C-131.709 81.674 -122.273 137.929 -122.273 137.929C-113.473 172.329 20.055 126.874 20.055 126.874C20.055 126.874 188.856 96.474 200.056 92.474C211.256 88.474 301.22 94.437 301.22 94.437L296.056 74.583C231.256 28.183 216.856 54.874 203.256 50.874C189.656 46.873 192.056 56.474 188.856 57.274C185.656 58.074 146.456 33.273 140.056 34.073z"} + , + {"fill": "#f5ccb0", + "path":"M141.365 35.819C134.965 36.619 107.523 13.944 124.565 44.619C146.565 84.219 66.164 83.819 49.364 72.619C32.564 61.419 56.564 91.019 56.564 91.019C74.964 111.019 40.564 94.219 40.564 94.219C6.164 81.419 -17.836 107.019 -21.036 107.819C-24.236 108.619 -29.036 111.819 -29.836 105.419C-30.636 99.019 -37.227 83.492 -69.836 108.619C-98.491 130.438 -110.127 112.256 -110.127 112.256L-115.727 113.419C-130.128 85.019 -121.618 140.983 -121.618 140.983C-112.818 175.384 21.364 128.619 21.364 128.619C21.364 128.619 190.165 98.219 201.365 94.219C212.565 90.219 301.656 96.11 301.656 96.11L296.565 75.746C231.765 29.346 218.165 56.619 204.565 52.619C190.965 48.619 193.365 58.219 190.165 59.019C186.965 59.819 147.765 35.019 141.365 35.819z"} + , + {"fill": "#f8d8c4", + "path":"M142.674 37.565C136.274 38.365 108.832 15.689 125.874 46.365C147.874 85.965 67.474 85.565 50.674 74.365C33.874 63.165 57.874 92.765 57.874 92.765C76.274 112.765 41.874 95.965 41.874 95.965C7.473 83.165 -16.527 108.765 -19.727 109.565C-22.927 110.365 -27.727 113.565 -28.527 107.165C-29.327 100.765 -35.786 85.405 -68.527 110.365C-98.418 132.929 -109.745 115.293 -109.745 115.293L-115.745 114.965C-129.346 88.564 -120.963 144.038 -120.963 144.038C-112.163 178.438 22.673 130.365 22.673 130.365C22.673 130.365 191.474 99.965 202.674 95.965C213.874 91.965 302.093 97.783 302.093 97.783L297.075 76.91C232.274 30.51 219.474 58.365 205.874 54.365C192.274 50.365 194.674 59.965 191.474 60.765C188.274 61.565 149.074 36.765 142.674 37.565z"} + , + {"fill": "#fae5d7", + "path":"M143.983 39.31C137.583 40.11 110.529 17.223 127.183 48.11C149.183 88.91 68.783 87.31 51.983 76.11C35.183 64.91 59.183 94.51 59.183 94.51C77.583 114.51 43.183 97.71 43.183 97.71C8.783 84.91 -15.217 110.51 -18.417 111.31C-21.618 112.11 -26.418 115.31 -27.218 108.91C-28.018 102.51 -34.346 87.318 -67.218 112.11C-98.345 135.42 -109.363 118.329 -109.363 118.329L-115.764 116.51C-128.764 92.51 -120.309 147.093 -120.309 147.093C-111.509 181.493 23.983 132.11 23.983 132.11C23.983 132.11 192.783 101.71 203.983 97.71C215.183 93.71 302.529 99.456 302.529 99.456L297.583 78.074C232.783 31.673 220.783 60.11 207.183 56.11C193.583 52.11 195.983 61.71 192.783 62.51C189.583 63.31 150.383 38.51 143.983 39.31z"} + , + {"fill": "#fcf2eb", + "path":"M145.292 41.055C138.892 41.855 112.917 18.411 128.492 49.855C149.692 92.656 70.092 89.056 53.292 77.856C36.492 66.656 60.492 96.256 60.492 96.256C78.892 116.256 44.492 99.456 44.492 99.456C10.092 86.656 -13.908 112.256 -17.108 113.056C-20.308 113.856 -25.108 117.056 -25.908 110.656C-26.708 104.256 -32.905 89.232 -65.908 113.856C-98.273 137.911 -108.982 121.365 -108.982 121.365L-115.782 118.056C-128.582 94.856 -119.654 150.147 -119.654 150.147C-110.854 184.547 25.292 133.856 25.292 133.856C25.292 133.856 194.093 103.456 205.293 99.456C216.493 95.456 302.965 101.128 302.965 101.128L298.093 79.237C233.292 32.837 222.093 61.856 208.493 57.856C194.893 53.855 197.293 63.456 194.093 64.256C190.892 65.056 151.692 40.255 145.292 41.055z"} + , + {"fill": "#ffffff", + "path":"M-115.8 119.601C-128.6 97.6 -119 153.201 -119 153.201C-110.2 187.601 26.6 135.601 26.6 135.601C26.6 135.601 195.401 105.2 206.601 101.2C217.801 97.2 303.401 102.8 303.401 102.8L298.601 80.4C233.801 34 223.401 63.6 209.801 59.6C196.201 55.6 198.601 65.2 195.401 66C192.201 66.8 153.001 42 146.601 42.8C140.201 43.6 114.981 19.793 129.801 51.6C152.028 99.307 69.041 89.227 54.6 79.6C37.8 68.4 61.8 98 61.8 98C80.2 118.001 45.8 101.2 45.8 101.2C11.4 88.4 -12.6 114.001 -15.8 114.801C-19 115.601 -23.8 118.801 -24.6 112.401C-25.4 106 -31.465 91.144 -64.6 115.601C-98.2 140.401 -108.6 124.401 -108.6 124.401L-115.8 119.601z"} + , + {"fill": "#000000", + "path":"M-74.2 149.601C-74.2 149.601 -81.4 161.201 -60.6 174.401C-60.6 174.401 -59.2 175.801 -77.2 171.601C-77.2 171.601 -83.4 169.601 -85 159.201C-85 159.201 -89.8 154.801 -94.6 149.201C-99.4 143.601 -74.2 149.601 -74.2 149.601z"} + , + {"fill": "#cccccc", + "path":"M65.8 102C65.8 102 83.498 128.821 82.9 133.601C81.6 144.001 81.4 153.601 84.6 157.601C87.801 161.601 96.601 194.801 96.601 194.801C96.601 194.801 96.201 196.001 108.601 158.001C108.601 158.001 120.201 142.001 100.201 123.601C100.201 123.601 65 94.8 65.8 102z"} + , + {"fill": "#000000", + "path":"M-54.2 176.401C-54.2 176.401 -43 183.601 -57.4 214.801L-51 212.401C-51 212.401 -51.8 223.601 -55 226.001L-47.8 222.801C-47.8 222.801 -43 230.801 -47 235.601C-47 235.601 -30.2 243.601 -31 250.001C-31 250.001 -24.6 242.001 -28.6 235.601C-32.6 229.201 -39.8 233.201 -39 214.801L-47.8 218.001C-47.8 218.001 -42.2 209.201 -42.2 202.801L-50.2 205.201C-50.2 205.201 -34.731 178.623 -45.4 177.201C-51.4 176.401 -54.2 176.401 -54.2 176.401z"} + , + {"fill": "#cccccc", + "path":"M-21.8 193.201C-21.8 193.201 -19 188.801 -21.8 189.601C-24.6 190.401 -55.8 205.201 -61.8 214.801C-61.8 214.801 -27.4 190.401 -21.8 193.201z"} + , + {"fill": "#cccccc", + "path":"M-11.4 201.201C-11.4 201.201 -8.6 196.801 -11.4 197.601C-14.2 198.401 -45.4 213.201 -51.4 222.801C-51.4 222.801 -17 198.401 -11.4 201.201z"} + , + {"fill": "#cccccc", + "path":"M1.8 186.001C1.8 186.001 4.6 181.601 1.8 182.401C-1 183.201 -32.2 198.001 -38.2 207.601C-38.2 207.601 -3.8 183.201 1.8 186.001z"} + , + {"fill": "#cccccc", + "path":"M-21.4 229.601C-21.4 229.601 -21.4 223.601 -24.2 224.401C-27 225.201 -63 242.801 -69 252.401C-69 252.401 -27 226.801 -21.4 229.601z"} + , + {"fill": "#cccccc", + "path":"M-20.2 218.801C-20.2 218.801 -19 214.001 -21.8 214.801C-23.8 214.801 -50.2 226.401 -56.2 236.001C-56.2 236.001 -26.6 214.401 -20.2 218.801z"} + , + {"fill": "#cccccc", + "path":"M-34.6 266.401L-44.6 274.001C-44.6 274.001 -34.2 266.401 -30.6 267.601C-30.6 267.601 -37.4 278.801 -38.2 284.001C-38.2 284.001 -27.8 271.201 -22.2 271.601C-22.2 271.601 -14.6 272.001 -14.6 282.801C-14.6 282.801 -9 272.401 -5.8 272.801C-5.8 272.801 -4.6 279.201 -5.8 286.001C-5.8 286.001 -1.8 278.401 2.2 280.001C2.2 280.001 8.6 278.001 7.8 289.601C7.8 289.601 7.8 300.001 7 302.801C7 302.801 12.6 276.401 15 276.001C15 276.001 23 274.801 27.8 283.601C27.8 283.601 23.8 276.001 28.6 278.001C28.6 278.001 39.4 279.601 42.6 286.401C42.6 286.401 35.8 274.401 41.4 277.601C41.4 277.601 48.2 277.601 49.4 284.001C49.4 284.001 57.8 305.201 59.8 306.801C59.8 306.801 52.2 285.201 53.8 285.201C53.8 285.201 51.8 273.201 57 288.001C57 288.001 53.8 274.001 59.4 274.801C65 275.601 69.4 285.601 77.8 283.201C77.8 283.201 87.401 288.801 89.401 219.601L-34.6 266.401z"} + , + {"fill": "#000000", + "path":"M-29.8 173.601C-29.8 173.601 -15 167.601 25 173.601C25 173.601 32.2 174.001 39 165.201C45.8 156.401 72.6 149.201 79 151.201L88.601 157.601L89.401 158.801C89.401 158.801 101.801 169.201 102.201 176.801C102.601 184.401 87.801 232.401 78.2 248.401C68.6 264.401 59 276.801 39.8 274.401C39.8 274.401 19 270.401 -6.6 274.401C-6.6 274.401 -35.8 272.801 -38.6 264.801C-41.4 256.801 -27.4 241.601 -27.4 241.601C-27.4 241.601 -23 233.201 -24.2 218.801C-25.4 204.401 -25 176.401 -29.8 173.601z"} + , + {"fill": "#e5668c", + "path":"M-7.8 175.601C0.6 194.001 -29 259.201 -29 259.201C-31 260.801 -16.34 266.846 -6.2 264.401C4.746 261.763 45 266.001 45 266.001C68.6 250.401 81.4 206.001 81.4 206.001C81.4 206.001 91.801 182.001 74.2 178.801C56.6 175.601 -7.8 175.601 -7.8 175.601z"} + , + {"fill": "#b23259", + "path":"M-9.831 206.497C-6.505 193.707 -4.921 181.906 -7.8 175.601C-7.8 175.601 54.6 182.001 65.8 161.201C70.041 153.326 84.801 184.001 84.4 193.601C84.4 193.601 21.4 208.001 6.6 196.801L-9.831 206.497z"} + , + {"fill": "#a5264c", + "path":"M-5.4 222.801C-5.4 222.801 -3.4 230.001 -5.8 234.001C-5.8 234.001 -7.4 234.801 -8.6 235.201C-8.6 235.201 -7.4 238.801 -1.4 240.401C-1.4 240.401 0.6 244.801 3 245.201C5.4 245.601 10.2 251.201 14.2 250.001C18.2 248.801 29.4 244.801 29.4 244.801C29.4 244.801 35 241.601 43.8 245.201C43.8 245.201 46.175 244.399 46.6 240.401C47.1 235.701 50.2 232.001 52.2 230.001C54.2 228.001 63.8 215.201 62.6 214.801C61.4 214.401 -5.4 222.801 -5.4 222.801z"} + , + {"fill": "#ff727f", "stroke":"#000000", + "path":"M-9.8 174.401C-9.8 174.401 -12.6 196.801 -9.4 205.201C-6.2 213.601 -7 215.601 -7.8 219.601C-8.6 223.601 -4.2 233.601 1.4 239.601L13.4 241.201C13.4 241.201 28.6 237.601 37.8 240.401C37.8 240.401 46.794 241.744 50.2 226.801C50.2 226.801 55 220.401 62.2 217.601C69.4 214.801 76.6 173.201 72.6 165.201C68.6 157.201 54.2 152.801 38.2 168.401C22.2 184.001 20.2 167.201 -9.8 174.401z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-8.2 249.201C-8.2 249.201 -9 247.201 -13.4 246.801C-13.4 246.801 -35.8 243.201 -44.2 230.801C-44.2 230.801 -51 225.201 -46.6 236.801C-46.6 236.801 -36.2 257.201 -29.4 260.001C-29.4 260.001 -13 264.001 -8.2 249.201z"} + , + {"fill": "#cc3f4c", + "path":"M71.742 185.229C72.401 177.323 74.354 168.709 72.6 165.201C66.154 152.307 49.181 157.695 38.2 168.401C22.2 184.001 20.2 167.201 -9.8 174.401C-9.8 174.401 -11.545 188.364 -10.705 198.376C-10.705 198.376 26.6 186.801 27.4 192.401C27.4 192.401 29 189.201 38.2 189.201C47.4 189.201 70.142 188.029 71.742 185.229z"} + , + {"stroke":"#a51926", "width":2, + "path":"M28.6 175.201C28.6 175.201 33.4 180.001 29.8 189.601C29.8 189.601 15.4 205.601 17.4 219.601"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-19.4 260.001C-19.4 260.001 -23.8 247.201 -15 254.001C-15 254.001 -10.2 256.001 -11.4 257.601C-12.6 259.201 -18.2 263.201 -19.4 260.001z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-14.36 261.201C-14.36 261.201 -17.88 250.961 -10.84 256.401C-10.84 256.401 -6.419 258.849 -7.96 259.281C-12.52 260.561 -7.96 263.121 -14.36 261.201z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-9.56 261.201C-9.56 261.201 -13.08 250.961 -6.04 256.401C-6.04 256.401 -1.665 258.711 -3.16 259.281C-6.52 260.561 -3.16 263.121 -9.56 261.201z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-2.96 261.401C-2.96 261.401 -6.48 251.161 0.56 256.601C0.56 256.601 4.943 258.933 3.441 259.481C0.48 260.561 3.441 263.321 -2.96 261.401z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M3.52 261.321C3.52 261.321 0 251.081 7.041 256.521C7.041 256.521 10.881 258.121 9.921 259.401C8.961 260.681 9.921 263.241 3.52 261.321z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M10.2 262.001C10.2 262.001 5.4 249.601 14.6 256.001C14.6 256.001 19.4 258.001 18.2 259.601C17 261.201 18.2 264.401 10.2 262.001z"} + , + {"stroke":"#a5264c", "width":2, + "path":"M-18.2 244.801C-18.2 244.801 -5 242.001 1 245.201C1 245.201 7 246.401 8.2 246.001C9.4 245.601 12.6 245.201 12.6 245.201"} + , + {"stroke":"#a5264c", "width":2, + "path":"M15.8 253.601C15.8 253.601 27.8 240.001 39.8 244.401C46.816 246.974 45.8 243.601 46.6 240.801C47.4 238.001 47.6 233.801 52.6 230.801"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M33 237.601C33 237.601 29 226.801 26.2 239.601C23.4 252.401 20.2 256.001 18.6 258.801C18.6 258.801 18.6 264.001 27 263.601C27 263.601 37.8 263.201 38.2 260.401C38.6 257.601 37 246.001 33 237.601z"} + , + {"stroke":"#a5264c", "width":2, + "path":"M47 244.801C47 244.801 50.6 242.401 53 243.601"} + , + {"stroke":"#a5264c", "width":2, + "path":"M53.5 228.401C53.5 228.401 56.4 223.501 61.2 222.701"} + , + {"fill": "#b2b2b2", + "path":"M-25.8 265.201C-25.8 265.201 -7.8 268.401 -3.4 266.801C-3.4 266.801 5.4 266.801 -3 268.801C-3 268.801 -15.8 268.801 -23.8 267.601C-23.8 267.601 -35.4 262.001 -25.8 265.201z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-11.8 172.001C-11.8 172.001 5.8 172.001 7.8 172.801C7.8 172.801 15 203.601 11.4 211.201C11.4 211.201 10.2 214.001 7.4 208.401C7.4 208.401 -11 175.601 -14.2 173.601C-17.4 171.601 -13 172.001 -11.8 172.001z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-88.9 169.301C-88.9 169.301 -80 171.001 -67.4 173.601C-67.4 173.601 -62.6 196.001 -59.4 200.801C-56.2 205.601 -59.8 205.601 -63.4 202.801C-67 200.001 -81.8 186.001 -83.8 181.601C-85.8 177.201 -88.9 169.301 -88.9 169.301z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-67.039 173.818C-67.039 173.818 -61.239 175.366 -60.23 177.581C-59.222 179.795 -61.432 183.092 -61.432 183.092C-61.432 183.092 -62.432 186.397 -63.634 184.235C-64.836 182.072 -67.708 174.412 -67.039 173.818z"} + , + {"fill": "#000000", + "path":"M-67 173.601C-67 173.601 -63.4 178.801 -59.8 178.801C-56.2 178.801 -55.818 178.388 -53 179.001C-48.4 180.001 -48.8 178.001 -42.2 179.201C-39.56 179.681 -37 178.801 -34.2 180.001C-31.4 181.201 -28.2 180.401 -27 178.401C-25.8 176.401 -21 172.201 -21 172.201C-21 172.201 -33.8 174.001 -36.6 174.801C-36.6 174.801 -59 176.001 -67 173.601z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-22.4 173.801C-22.4 173.801 -28.85 177.301 -29.25 179.701C-29.65 182.101 -24 185.801 -24 185.801C-24 185.801 -21.25 190.401 -20.65 188.001C-20.05 185.601 -21.6 174.201 -22.4 173.801z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-59.885 179.265C-59.885 179.265 -52.878 190.453 -52.661 179.242C-52.661 179.242 -52.104 177.984 -53.864 177.962C-59.939 177.886 -58.418 173.784 -59.885 179.265z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-52.707 179.514C-52.707 179.514 -44.786 190.701 -45.422 179.421C-45.422 179.421 -45.415 179.089 -47.168 178.936C-51.915 178.522 -51.57 174.004 -52.707 179.514z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-45.494 179.522C-45.494 179.522 -37.534 190.15 -38.203 180.484C-38.203 180.484 -38.084 179.251 -39.738 178.95C-43.63 178.244 -43.841 174.995 -45.494 179.522z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-38.618 179.602C-38.618 179.602 -30.718 191.163 -30.37 181.382C-30.37 181.382 -28.726 180.004 -30.472 179.782C-36.29 179.042 -35.492 174.588 -38.618 179.602z"} + , + {"fill": "#e5e5b2", + "path":"M-74.792 183.132L-82.45 181.601C-85.05 176.601 -87.15 170.451 -87.15 170.451C-87.15 170.451 -80.8 171.451 -68.3 174.251C-68.3 174.251 -67.424 177.569 -65.952 183.364L-74.792 183.132z"} + , + {"fill": "#e5e5b2", + "path":"M-9.724 178.47C-11.39 175.964 -12.707 174.206 -13.357 173.8C-16.37 171.917 -12.227 172.294 -11.098 172.294C-11.098 172.294 5.473 172.294 7.356 173.047C7.356 173.047 7.88 175.289 8.564 178.68C8.564 178.68 -1.524 176.67 -9.724 178.47z"} + , + {"fill": "#cc7226", + "path":"M43.88 40.321C71.601 44.281 97.121 8.641 98.881 -1.04C100.641 -10.72 90.521 -22.6 90.521 -22.6C91.841 -25.68 87.001 -39.76 81.721 -49C76.441 -58.24 60.54 -57.266 43 -58.24C27.16 -59.12 8.68 -35.8 7.36 -34.04C6.04 -32.28 12.2 6.001 13.52 11.721C14.84 17.441 12.2 43.841 12.2 43.841C46.44 34.741 16.16 36.361 43.88 40.321z"} + , + {"fill": "#ea8e51", + "path":"M8.088 -33.392C6.792 -31.664 12.84 5.921 14.136 11.537C15.432 17.153 12.84 43.073 12.84 43.073C45.512 34.193 16.728 35.729 43.944 39.617C71.161 43.505 96.217 8.513 97.945 -0.992C99.673 -10.496 89.737 -22.16 89.737 -22.16C91.033 -25.184 86.281 -39.008 81.097 -48.08C75.913 -57.152 60.302 -56.195 43.08 -57.152C27.528 -58.016 9.384 -35.12 8.088 -33.392z"} + , + {"fill": "#efaa7c", + "path":"M8.816 -32.744C7.544 -31.048 13.48 5.841 14.752 11.353C16.024 16.865 13.48 42.305 13.48 42.305C44.884 33.145 17.296 35.097 44.008 38.913C70.721 42.729 95.313 8.385 97.009 -0.944C98.705 -10.272 88.953 -21.72 88.953 -21.72C90.225 -24.688 85.561 -38.256 80.473 -47.16C75.385 -56.064 60.063 -55.125 43.16 -56.064C27.896 -56.912 10.088 -34.44 8.816 -32.744z"} + , + {"fill": "#f4c6a8", + "path":"M9.544 -32.096C8.296 -30.432 14.12 5.761 15.368 11.169C16.616 16.577 14.12 41.537 14.12 41.537C43.556 32.497 17.864 34.465 44.072 38.209C70.281 41.953 94.409 8.257 96.073 -0.895C97.737 -10.048 88.169 -21.28 88.169 -21.28C89.417 -24.192 84.841 -37.504 79.849 -46.24C74.857 -54.976 59.824 -54.055 43.24 -54.976C28.264 -55.808 10.792 -33.76 9.544 -32.096z"} + , + {"fill": "#f9e2d3", + "path":"M10.272 -31.448C9.048 -29.816 14.76 5.681 15.984 10.985C17.208 16.289 14.76 40.769 14.76 40.769C42.628 31.849 18.432 33.833 44.136 37.505C69.841 41.177 93.505 8.129 95.137 -0.848C96.769 -9.824 87.385 -20.84 87.385 -20.84C88.609 -23.696 84.121 -36.752 79.225 -45.32C74.329 -53.888 59.585 -52.985 43.32 -53.888C28.632 -54.704 11.496 -33.08 10.272 -31.448z"} + , + {"fill": "#ffffff", + "path":"M44.2 36.8C69.4 40.4 92.601 8 94.201 -0.8C95.801 -9.6 86.601 -20.4 86.601 -20.4C87.801 -23.2 83.4 -36 78.6 -44.4C73.8 -52.8 59.346 -51.914 43.4 -52.8C29 -53.6 12.2 -32.4 11 -30.8C9.8 -29.2 15.4 5.6 16.6 10.8C17.8 16 15.4 40 15.4 40C40.9 31.4 19 33.2 44.2 36.8z"} + , + {"fill": "#cccccc", + "path":"M90.601 2.8C90.601 2.8 62.8 10.4 51.2 8.8C51.2 8.8 35.4 2.2 26.6 24C26.6 24 23 31.2 21 33.2C19 35.2 90.601 2.8 90.601 2.8z"} + , + {"fill": "#000000", + "path":"M94.401 0.6C94.401 0.6 65.4 12.8 55.4 12.4C55.4 12.4 39 7.8 30.6 22.4C30.6 22.4 22.2 31.6 19 33.2C19 33.2 18.6 34.8 25 30.8L35.4 36C35.4 36 50.2 45.6 59.8 29.6C59.8 29.6 63.8 18.4 63.8 16.4C63.8 14.4 85 8.8 86.601 8.4C88.201 8 94.801 3.8 94.401 0.6z"} + , + {"fill": "#99cc32", + "path":"M47 36.514C40.128 36.514 31.755 32.649 31.755 26.4C31.755 20.152 40.128 13.887 47 13.887C53.874 13.887 59.446 18.952 59.446 25.2C59.446 31.449 53.874 36.514 47 36.514z"} + , + {"fill": "#659900", + "path":"M43.377 19.83C38.531 20.552 33.442 22.055 33.514 21.839C35.054 17.22 41.415 13.887 47 13.887C51.296 13.887 55.084 15.865 57.32 18.875C57.32 18.875 52.004 18.545 43.377 19.83z"} + , + {"fill": "#ffffff", + "path":"M55.4 19.6C55.4 19.6 51 16.4 51 18.6C51 18.6 54.6 23 55.4 19.6z"} + , + {"fill": "#000000", + "path":"M45.4 27.726C42.901 27.726 40.875 25.7 40.875 23.2C40.875 20.701 42.901 18.675 45.4 18.675C47.9 18.675 49.926 20.701 49.926 23.2C49.926 25.7 47.9 27.726 45.4 27.726z"} + , + {"fill": "#cc7226", + "path":"M-58.6 14.4C-58.6 14.4 -61.8 -6.8 -59.4 -11.2C-59.4 -11.2 -48.6 -21.2 -49 -24.8C-49 -24.8 -49.4 -42.8 -50.6 -43.6C-51.8 -44.4 -59.4 -50.4 -65.4 -44C-65.4 -44 -75.8 -26 -75 -19.6L-75 -17.6C-75 -17.6 -82.6 -18 -84.2 -16C-84.2 -16 -85.4 -10.8 -86.6 -10.4C-86.6 -10.4 -89.4 -8 -87.4 -5.2C-87.4 -5.2 -89.4 -2.8 -89 1.2L-81.4 5.2C-81.4 5.2 -79.4 19.6 -68.6 24.8C-63.764 27.129 -60.6 20.4 -58.6 14.4z"} + , + {"fill": "#ffffff", + "path":"M-59.6 12.56C-59.6 12.56 -62.48 -6.52 -60.32 -10.48C-60.32 -10.48 -50.6 -19.48 -50.96 -22.72C-50.96 -22.72 -51.32 -38.92 -52.4 -39.64C-53.48 -40.36 -60.32 -45.76 -65.72 -40C-65.72 -40 -75.08 -23.8 -74.36 -18.04L-74.36 -16.24C-74.36 -16.24 -81.2 -16.6 -82.64 -14.8C-82.64 -14.8 -83.72 -10.12 -84.8 -9.76C-84.8 -9.76 -87.32 -7.6 -85.52 -5.08C-85.52 -5.08 -87.32 -2.92 -86.96 0.68L-80.12 4.28C-80.12 4.28 -78.32 17.24 -68.6 21.92C-64.248 24.015 -61.4 17.96 -59.6 12.56z"} + , + {"fill": "#eb955c", + "path":"M-51.05 -42.61C-52.14 -43.47 -59.63 -49.24 -65.48 -43C-65.48 -43 -75.62 -25.45 -74.84 -19.21L-74.84 -17.26C-74.84 -17.26 -82.25 -17.65 -83.81 -15.7C-83.81 -15.7 -84.98 -10.63 -86.15 -10.24C-86.15 -10.24 -88.88 -7.9 -86.93 -5.17C-86.93 -5.17 -88.88 -2.83 -88.49 1.07L-81.08 4.97C-81.08 4.97 -79.13 19.01 -68.6 24.08C-63.886 26.35 -60.8 19.79 -58.85 13.94C-58.85 13.94 -61.97 -6.73 -59.63 -11.02C-59.63 -11.02 -49.1 -20.77 -49.49 -24.28C-49.49 -24.28 -49.88 -41.83 -51.05 -42.61z"} + , + {"fill": "#f2b892", + "path":"M-51.5 -41.62C-52.48 -42.54 -59.86 -48.08 -65.56 -42C-65.56 -42 -75.44 -24.9 -74.68 -18.82L-74.68 -16.92C-74.68 -16.92 -81.9 -17.3 -83.42 -15.4C-83.42 -15.4 -84.56 -10.46 -85.7 -10.08C-85.7 -10.08 -88.36 -7.8 -86.46 -5.14C-86.46 -5.14 -88.36 -2.86 -87.98 0.94L-80.76 4.74C-80.76 4.74 -78.86 18.42 -68.6 23.36C-64.006 25.572 -61 19.18 -59.1 13.48C-59.1 13.48 -62.14 -6.66 -59.86 -10.84C-59.86 -10.84 -49.6 -20.34 -49.98 -23.76C-49.98 -23.76 -50.36 -40.86 -51.5 -41.62z"} + , + {"fill": "#f8dcc8", + "path":"M-51.95 -40.63C-52.82 -41.61 -60.09 -46.92 -65.64 -41C-65.64 -41 -75.26 -24.35 -74.52 -18.43L-74.52 -16.58C-74.52 -16.58 -81.55 -16.95 -83.03 -15.1C-83.03 -15.1 -84.14 -10.29 -85.25 -9.92C-85.25 -9.92 -87.84 -7.7 -85.99 -5.11C-85.99 -5.11 -87.84 -2.89 -87.47 0.81L-80.44 4.51C-80.44 4.51 -78.59 17.83 -68.6 22.64C-64.127 24.794 -61.2 18.57 -59.35 13.02C-59.35 13.02 -62.31 -6.59 -60.09 -10.66C-60.09 -10.66 -50.1 -19.91 -50.47 -23.24C-50.47 -23.24 -50.84 -39.89 -51.95 -40.63z"} + , + {"fill": "#ffffff", + "path":"M-59.6 12.46C-59.6 12.46 -62.48 -6.52 -60.32 -10.48C-60.32 -10.48 -50.6 -19.48 -50.96 -22.72C-50.96 -22.72 -51.32 -38.92 -52.4 -39.64C-53.16 -40.68 -60.32 -45.76 -65.72 -40C-65.72 -40 -75.08 -23.8 -74.36 -18.04L-74.36 -16.24C-74.36 -16.24 -81.2 -16.6 -82.64 -14.8C-82.64 -14.8 -83.72 -10.12 -84.8 -9.76C-84.8 -9.76 -87.32 -7.6 -85.52 -5.08C-85.52 -5.08 -87.32 -2.92 -86.96 0.68L-80.12 4.28C-80.12 4.28 -78.32 17.24 -68.6 21.92C-64.248 24.015 -61.4 17.86 -59.6 12.46z"} + , + {"fill": "#cccccc", + "path":"M-62.7 6.2C-62.7 6.2 -84.3 -4 -85.2 -4.8C-85.2 -4.8 -76.1 3.4 -75.3 3.4C-74.5 3.4 -62.7 6.2 -62.7 6.2z"} + , + {"fill": "#000000", + "path":"M-79.8 0C-79.8 0 -61.4 3.6 -61.4 8C-61.4 10.912 -61.643 24.331 -67 22.8C-75.4 20.4 -71.8 6 -79.8 0z"} + , + {"fill": "#99cc32", + "path":"M-71.4 3.8C-71.4 3.8 -62.422 5.274 -61.4 8C-60.8 9.6 -60.137 17.908 -65.6 19C-70.152 19.911 -72.382 9.69 -71.4 3.8z"} + , + {"fill": "#000000", + "path":"M14.595 46.349C14.098 44.607 15.409 44.738 17.2 44.2C19.2 43.6 31.4 39.8 32.2 37.2C33 34.6 46.2 39 46.2 39C48 39.8 52.4 42.4 52.4 42.4C57.2 43.6 63.8 44 63.8 44C66.2 45 69.6 47.8 69.6 47.8C84.2 58 96.601 50.8 96.601 50.8C116.601 44.2 110.601 27 110.601 27C107.601 18 110.801 14.6 110.801 14.6C111.001 10.8 118.201 17.2 118.201 17.2C120.801 21.4 121.601 26.4 121.601 26.4C129.601 37.6 126.201 19.8 126.201 19.8C126.401 18.8 123.601 15.2 123.601 14C123.601 12.8 121.801 9.4 121.801 9.4C118.801 6 121.201 -1 121.201 -1C123.001 -14.8 120.801 -13 120.801 -13C119.601 -14.8 110.401 -4.8 110.401 -4.8C108.201 -1.4 102.201 0.2 102.201 0.2C99.401 2 96.001 0.6 96.001 0.6C93.401 0.2 87.801 7.2 87.801 7.2C90.601 7 93.001 11.4 95.401 11.6C97.801 11.8 99.601 9.2 101.201 8.6C102.801 8 105.601 13.8 105.601 13.8C106.001 16.4 100.401 21.2 100.401 21.2C100.001 25.8 98.401 24.2 98.401 24.2C95.401 23.6 94.201 27.4 93.201 32C92.201 36.6 88.001 37 88.001 37C86.401 44.4 85.2 41.4 85.2 41.4C85 35.8 79 41.6 79 41.6C77.8 43.6 73.2 41.4 73.2 41.4C66.4 39.4 68.8 37.4 68.8 37.4C70.6 35.2 81.8 37.4 81.8 37.4C84 35.8 76 31.8 76 31.8C75.4 30 76.4 25.6 76.4 25.6C77.6 22.4 84.4 16.8 84.4 16.8C93.801 15.6 91.001 14 91.001 14C84.801 8.8 79 16.4 79 16.4C76.8 22.6 59.4 37.6 59.4 37.6C54.6 41 57.2 34.2 53.2 37.6C49.2 41 28.6 32 28.6 32C17.038 30.807 14.306 46.549 10.777 43.429C10.777 43.429 16.195 51.949 14.595 46.349z"} + , + {"fill": "#000000", + "path":"M209.401 -120C209.401 -120 183.801 -112 181.001 -93.2C181.001 -93.2 178.601 -70.4 199.001 -52.8C199.001 -52.8 199.401 -46.4 201.401 -43.2C201.401 -43.2 199.801 -38.4 218.601 -46L245.801 -54.4C245.801 -54.4 252.201 -56.8 257.401 -65.6C262.601 -74.4 277.801 -93.2 274.201 -118.4C274.201 -118.4 275.401 -129.6 269.401 -130C269.401 -130 261.001 -131.6 253.801 -124C253.801 -124 247.001 -120.8 244.601 -121.2L209.401 -120z"} + , + {"fill": "#000000", + "path":"M264.022 -120.99C264.022 -120.99 266.122 -129.92 261.282 -125.08C261.282 -125.08 254.242 -119.36 246.761 -119.36C246.761 -119.36 232.241 -117.16 227.841 -103.96C227.841 -103.96 223.881 -77.12 231.801 -71.4C231.801 -71.4 236.641 -63.92 243.681 -70.52C250.722 -77.12 266.222 -107.35 264.022 -120.99z"} + , + {"fill": "#323232", + "path":"M263.648 -120.632C263.648 -120.632 265.738 -129.376 260.986 -124.624C260.986 -124.624 254.074 -119.008 246.729 -119.008C246.729 -119.008 232.473 -116.848 228.153 -103.888C228.153 -103.888 224.265 -77.536 232.041 -71.92C232.041 -71.92 236.793 -64.576 243.705 -71.056C250.618 -77.536 265.808 -107.24 263.648 -120.632z"} + , + {"fill": "#666666", + "path":"M263.274 -120.274C263.274 -120.274 265.354 -128.832 260.69 -124.168C260.69 -124.168 253.906 -118.656 246.697 -118.656C246.697 -118.656 232.705 -116.536 228.465 -103.816C228.465 -103.816 224.649 -77.952 232.281 -72.44C232.281 -72.44 236.945 -65.232 243.729 -71.592C250.514 -77.952 265.394 -107.13 263.274 -120.274z"} + , + {"fill": "#999999", + "path":"M262.9 -119.916C262.9 -119.916 264.97 -128.288 260.394 -123.712C260.394 -123.712 253.738 -118.304 246.665 -118.304C246.665 -118.304 232.937 -116.224 228.777 -103.744C228.777 -103.744 225.033 -78.368 232.521 -72.96C232.521 -72.96 237.097 -65.888 243.753 -72.128C250.41 -78.368 264.98 -107.02 262.9 -119.916z"} + , + {"fill": "#cccccc", + "path":"M262.526 -119.558C262.526 -119.558 264.586 -127.744 260.098 -123.256C260.098 -123.256 253.569 -117.952 246.633 -117.952C246.633 -117.952 233.169 -115.912 229.089 -103.672C229.089 -103.672 225.417 -78.784 232.761 -73.48C232.761 -73.48 237.249 -66.544 243.777 -72.664C250.305 -78.784 264.566 -106.91 262.526 -119.558z"} + , + {"fill": "#ffffff", + "path":"M262.151 -119.2C262.151 -119.2 264.201 -127.2 259.801 -122.8C259.801 -122.8 253.401 -117.6 246.601 -117.6C246.601 -117.6 233.401 -115.6 229.401 -103.6C229.401 -103.6 225.801 -79.2 233.001 -74C233.001 -74 237.401 -67.2 243.801 -73.2C250.201 -79.2 264.151 -106.8 262.151 -119.2z"} + , + {"fill": "#992600", + "path":"M50.6 84C50.6 84 30.2 64.8 22.2 64C22.2 64 -12.2 60 -27 78C-27 78 -9.4 57.6 18.2 63.2C18.2 63.2 -3.4 58.8 -15.8 62C-15.8 62 -32.6 62 -42.2 76L-45 80.8C-45 80.8 -41 66 -22.6 60C-22.6 60 0.2 55.2 11 60C11 60 -10.6 53.2 -20.6 55.2C-20.6 55.2 -51 52.8 -63.8 79.2C-63.8 79.2 -59.8 64.8 -45 57.6C-45 57.6 -31.4 48.8 -11 51.6C-11 51.6 3.4 54.8 8.6 57.2C13.8 59.6 12.6 56.8 4.2 52C4.2 52 -1.4 42 -15.4 42.4C-15.4 42.4 -58.2 46 -68.6 58C-68.6 58 -55 46.8 -44.6 44C-44.6 44 -22.2 36 -13.8 36.8C-13.8 36.8 11 37.8 18.6 33.8C18.6 33.8 7.4 38.8 10.6 42C13.8 45.2 20.6 52.8 20.6 54C20.6 55.2 44.8 77.3 48.4 81.7L50.6 84z"} + , + {"fill": "#cccccc", + "path":"M189 278C189 278 173.5 241.5 161 232C161 232 187 248 190.5 266C190.5 266 190.5 276 189 278z"} + , + {"fill": "#cccccc", + "path":"M236 285.5C236 285.5 209.5 230.5 191 206.5C191 206.5 234.5 244 239.5 270.5L240 276L237 273.5C237 273.5 236.5 282.5 236 285.5z"} + , + {"fill": "#cccccc", + "path":"M292.5 237C292.5 237 230 177.5 228.5 175C228.5 175 289 241 292 248.5C292 248.5 290 239.5 292.5 237z"} + , + {"fill": "#cccccc", + "path":"M104 280.5C104 280.5 123.5 228.5 142.5 251C142.5 251 157.5 261 157 264C157 264 153 257.5 135 258C135 258 116 255 104 280.5z"} + , + {"fill": "#cccccc", + "path":"M294.5 153C294.5 153 249.5 124.5 242 123C230.193 120.639 291.5 152 296.5 162.5C296.5 162.5 298.5 160 294.5 153z"} + , + {"fill": "#000000", + "path":"M143.801 259.601C143.801 259.601 164.201 257.601 171.001 250.801L175.401 254.401L193.001 216.001L196.601 221.201C196.601 221.201 211.001 206.401 210.201 198.401C209.401 190.401 223.001 204.401 223.001 204.401C223.001 204.401 222.201 192.801 229.401 199.601C229.401 199.601 227.001 184.001 235.401 192.001C235.401 192.001 224.864 161.844 247.401 187.601C253.001 194.001 248.601 187.201 248.601 187.201C248.601 187.201 222.601 139.201 244.201 153.601C244.201 153.601 246.201 130.801 245.001 126.401C243.801 122.001 241.801 99.6 237.001 94.4C232.201 89.2 237.401 87.6 243.001 92.8C243.001 92.8 231.801 68.8 245.001 80.8C245.001 80.8 241.401 65.6 237.001 62.8C237.001 62.8 231.401 45.6 246.601 56.4C246.601 56.4 242.201 44 239.001 40.8C239.001 40.8 227.401 13.2 234.601 18L239.001 21.6C239.001 21.6 232.201 7.6 238.601 12C245.001 16.4 245.001 16 245.001 16C245.001 16 223.801 -17.2 244.201 0.4C244.201 0.4 236.042 -13.518 232.601 -20.4C232.601 -20.4 213.801 -40.8 228.201 -34.4L233.001 -32.8C233.001 -32.8 224.201 -42.8 216.201 -44.4C208.201 -46 218.601 -52.4 225.001 -50.4C231.401 -48.4 247.001 -40.8 247.001 -40.8C247.001 -40.8 259.801 -22 263.801 -21.6C263.801 -21.6 243.801 -29.2 249.801 -21.2C249.801 -21.2 264.201 -7.2 257.001 -7.6C257.001 -7.6 251.001 -0.4 255.801 8.4C255.801 8.4 237.342 -9.991 252.201 15.6L259.001 32C259.001 32 234.601 7.2 245.801 29.2C245.801 29.2 263.001 52.8 265.001 53.2C267.001 53.6 271.401 62.4 271.401 62.4L267.001 60.4L272.201 69.2C272.201 69.2 261.001 57.2 267.001 70.4L272.601 84.8C272.601 84.8 252.201 62.8 265.801 92.4C265.801 92.4 249.401 87.2 258.201 104.4C258.201 104.4 256.601 120.401 257.001 125.601C257.401 130.801 258.601 159.201 254.201 167.201C249.801 175.201 260.201 194.401 262.201 198.401C264.201 202.401 267.801 213.201 259.001 204.001C250.201 194.801 254.601 200.401 256.601 209.201C258.601 218.001 264.601 233.601 263.801 239.201C263.801 239.201 262.601 240.401 259.401 236.801C259.401 236.801 244.601 214.001 246.201 228.401C246.201 228.401 245.001 236.401 241.801 245.201C241.801 245.201 238.601 256.001 238.601 247.201C238.601 247.201 235.401 230.401 232.601 238.001C229.801 245.601 226.201 251.601 223.401 254.001C220.601 256.401 215.401 233.601 214.201 244.001C214.201 244.001 202.201 231.601 197.401 248.001L185.801 264.401C185.801 264.401 185.401 252.001 184.201 258.001C184.201 258.001 154.201 264.001 143.801 259.601z"} + , + {"fill": "#000000", + "path":"M109.401 -97.2C109.401 -97.2 97.801 -105.2 93.801 -104.8C89.801 -104.4 121.401 -113.6 162.601 -86C162.601 -86 167.401 -83.2 171.001 -83.6C171.001 -83.6 174.201 -81.2 171.401 -77.6C171.401 -77.6 162.601 -68 173.801 -56.8C173.801 -56.8 192.201 -50 186.601 -58.8C186.601 -58.8 197.401 -54.8 199.801 -50.8C202.201 -46.8 201.001 -50.8 201.001 -50.8C201.001 -50.8 194.601 -58 188.601 -63.2C188.601 -63.2 183.401 -65.2 180.601 -73.6C177.801 -82 175.401 -92 179.801 -95.2C179.801 -95.2 175.801 -90.8 176.601 -94.8C177.401 -98.8 181.001 -102.4 182.601 -102.8C184.201 -103.2 200.601 -119 207.401 -119.4C207.401 -119.4 198.201 -118 195.201 -119C192.201 -120 165.601 -131.4 159.601 -132.6C159.601 -132.6 142.801 -139.2 154.801 -137.2C154.801 -137.2 190.601 -133.4 208.801 -120.2C208.801 -120.2 201.601 -128.6 183.201 -135.6C183.201 -135.6 161.001 -148.2 125.801 -143.2C125.801 -143.2 108.001 -140 100.201 -138.2C100.201 -138.2 97.601 -138.8 97.001 -139.2C96.401 -139.6 84.6 -148.6 57 -141.6C57 -141.6 40 -137 31.4 -132.2C31.4 -132.2 16.2 -131 12.6 -127.8C12.6 -127.8 -6 -113.2 -8 -112.4C-10 -111.6 -21.4 -104 -22.2 -103.6C-22.2 -103.6 2.4 -110.2 4.8 -112.6C7.2 -115 24.6 -117.6 27 -116.2C29.4 -114.8 37.8 -115.4 28.2 -114.8C28.2 -114.8 103.801 -100 104.601 -98C105.401 -96 109.401 -97.2 109.401 -97.2z"} + , + {"fill": "#cc7226", + "path":"M180.801 -106.4C180.801 -106.4 170.601 -113.8 168.601 -113.8C166.601 -113.8 154.201 -124 150.001 -123.6C145.801 -123.2 133.601 -133.2 106.201 -125C106.201 -125 105.601 -127 109.201 -127.8C109.201 -127.8 115.601 -130 116.001 -130.6C116.001 -130.6 136.201 -134.8 143.401 -131.2C143.401 -131.2 152.601 -128.6 158.801 -122.4C158.801 -122.4 170.001 -119.2 173.201 -120.2C173.201 -120.2 182.001 -118 182.401 -116.2C182.401 -116.2 188.201 -113.2 186.401 -110.6C186.401 -110.6 186.801 -109 180.801 -106.4z"} + , + {"fill": "#cc7226", + "path":"M168.33 -108.509C169.137 -107.877 170.156 -107.779 170.761 -106.97C170.995 -106.656 170.706 -106.33 170.391 -106.233C169.348 -105.916 168.292 -106.486 167.15 -105.898C166.748 -105.691 166.106 -105.873 165.553 -106.022C163.921 -106.463 162.092 -106.488 160.401 -105.8C158.416 -106.929 156.056 -106.345 153.975 -107.346C153.917 -107.373 153.695 -107.027 153.621 -107.054C150.575 -108.199 146.832 -107.916 144.401 -110.2C141.973 -110.612 139.616 -111.074 137.188 -111.754C135.37 -112.263 133.961 -113.252 132.341 -114.084C130.964 -114.792 129.507 -115.314 127.973 -115.686C126.11 -116.138 124.279 -116.026 122.386 -116.546C122.293 -116.571 122.101 -116.227 122.019 -116.254C121.695 -116.362 121.405 -116.945 121.234 -116.892C119.553 -116.37 118.065 -117.342 116.401 -117C115.223 -118.224 113.495 -117.979 111.949 -118.421C108.985 -119.269 105.831 -117.999 102.801 -119C106.914 -120.842 111.601 -119.61 115.663 -121.679C117.991 -122.865 120.653 -121.763 123.223 -122.523C123.71 -122.667 124.401 -122.869 124.801 -122.2C124.935 -122.335 125.117 -122.574 125.175 -122.546C127.625 -121.389 129.94 -120.115 132.422 -119.049C132.763 -118.903 133.295 -119.135 133.547 -118.933C135.067 -117.717 137.01 -117.82 138.401 -116.6C140.099 -117.102 141.892 -116.722 143.621 -117.346C143.698 -117.373 143.932 -117.032 143.965 -117.054C145.095 -117.802 146.25 -117.531 147.142 -117.227C147.48 -117.112 148.143 -116.865 148.448 -116.791C149.574 -116.515 150.43 -116.035 151.609 -115.852C151.723 -115.834 151.908 -116.174 151.98 -116.146C153.103 -115.708 154.145 -115.764 154.801 -114.6C154.936 -114.735 155.101 -114.973 155.183 -114.946C156.21 -114.608 156.859 -113.853 157.96 -113.612C158.445 -113.506 159.057 -112.88 159.633 -112.704C162.025 -111.973 163.868 -110.444 166.062 -109.549C166.821 -109.239 167.697 -109.005 168.33 -108.509z"} + , + {"fill": "#cc7226", + "path":"M91.696 -122.739C89.178 -124.464 86.81 -125.57 84.368 -127.356C84.187 -127.489 83.827 -127.319 83.625 -127.441C82.618 -128.05 81.73 -128.631 80.748 -129.327C80.209 -129.709 79.388 -129.698 78.88 -129.956C76.336 -131.248 73.707 -131.806 71.2 -133C71.882 -133.638 73.004 -133.394 73.6 -134.2C73.795 -133.92 74.033 -133.636 74.386 -133.827C76.064 -134.731 77.914 -134.884 79.59 -134.794C81.294 -134.702 83.014 -134.397 84.789 -134.125C85.096 -134.078 85.295 -133.555 85.618 -133.458C87.846 -132.795 90.235 -133.32 92.354 -132.482C93.945 -131.853 95.515 -131.03 96.754 -129.755C97.006 -129.495 96.681 -129.194 96.401 -129C96.789 -129.109 97.062 -128.903 97.173 -128.59C97.257 -128.351 97.257 -128.049 97.173 -127.81C97.061 -127.498 96.782 -127.397 96.408 -127.346C95.001 -127.156 96.773 -128.536 96.073 -128.088C94.8 -127.274 95.546 -125.868 94.801 -124.6C94.521 -124.794 94.291 -125.012 94.401 -125.4C94.635 -124.878 94.033 -124.588 93.865 -124.272C93.48 -123.547 92.581 -122.132 91.696 -122.739z"} + , + {"fill": "#cc7226", + "path":"M59.198 -115.391C56.044 -116.185 52.994 -116.07 49.978 -117.346C49.911 -117.374 49.688 -117.027 49.624 -117.054C48.258 -117.648 47.34 -118.614 46.264 -119.66C45.351 -120.548 43.693 -120.161 42.419 -120.648C42.095 -120.772 41.892 -121.284 41.591 -121.323C40.372 -121.48 39.445 -122.429 38.4 -123C40.736 -123.795 43.147 -123.764 45.609 -124.148C45.722 -124.166 45.867 -123.845 46 -123.845C46.136 -123.845 46.266 -124.066 46.4 -124.2C46.595 -123.92 46.897 -123.594 47.154 -123.848C47.702 -124.388 48.258 -124.198 48.798 -124.158C48.942 -124.148 49.067 -123.845 49.2 -123.845C49.336 -123.845 49.467 -124.156 49.6 -124.156C49.736 -124.155 49.867 -123.845 50 -123.845C50.136 -123.845 50.266 -124.066 50.4 -124.2C51.092 -123.418 51.977 -123.972 52.799 -123.793C53.837 -123.566 54.104 -122.418 55.178 -122.12C59.893 -120.816 64.03 -118.671 68.393 -116.584C68.7 -116.437 68.91 -116.189 68.8 -115.8C69.067 -115.8 69.38 -115.888 69.57 -115.756C70.628 -115.024 71.669 -114.476 72.366 -113.378C72.582 -113.039 72.253 -112.632 72.02 -112.684C67.591 -113.679 63.585 -114.287 59.198 -115.391z"} + , + {"fill": "#cc7226", + "path":"M45.338 -71.179C43.746 -72.398 43.162 -74.429 42.034 -76.221C41.82 -76.561 42.094 -76.875 42.411 -76.964C42.971 -77.123 43.514 -76.645 43.923 -76.443C45.668 -75.581 47.203 -74.339 49.2 -74.2C51.19 -71.966 55.45 -71.581 55.457 -68.2C55.458 -67.341 54.03 -68.259 53.6 -67.4C51.149 -68.403 48.76 -68.3 46.38 -69.767C45.763 -70.148 46.093 -70.601 45.338 -71.179z"} + , + {"fill": "#cc7226", + "path":"M17.8 -123.756C17.935 -123.755 24.966 -123.522 24.949 -123.408C24.904 -123.099 17.174 -122.05 16.81 -122.22C16.646 -122.296 9.134 -119.866 9 -120C9.268 -120.135 17.534 -123.756 17.8 -123.756z"} + , + {"fill": "#000000", + "path":"M33.2 -114C33.2 -114 18.4 -112.2 14 -111C9.6 -109.8 -9 -102.2 -12 -100.2C-12 -100.2 -25.4 -94.8 -42.4 -74.8C-42.4 -74.8 -34.8 -78.2 -32.6 -81C-32.6 -81 -19 -93.6 -19.2 -91C-19.2 -91 -7 -99.6 -7.6 -97.4C-7.6 -97.4 16.8 -108.6 14.8 -105.4C14.8 -105.4 36.4 -110 35.4 -108C35.4 -108 54.2 -103.6 51.4 -103.4C51.4 -103.4 45.6 -102.2 52 -98.6C52 -98.6 48.6 -94.2 43.2 -98.2C37.8 -102.2 40.8 -100 35.8 -99C35.8 -99 33.2 -98.2 28.6 -102.2C28.6 -102.2 23 -106.8 14.2 -103.2C14.2 -103.2 -16.4 -90.6 -18.4 -90C-18.4 -90 -22 -87.2 -24.4 -83.6C-24.4 -83.6 -30.2 -79.2 -33.2 -77.8C-33.2 -77.8 -46 -66.2 -47.2 -64.8C-47.2 -64.8 -50.6 -59.6 -51.4 -59.2C-51.4 -59.2 -45 -63 -43 -65C-43 -65 -29 -75 -23.6 -75.8C-23.6 -75.8 -19.2 -78.8 -18.4 -80.2C-18.4 -80.2 -4 -89.4 0.2 -89.4C0.2 -89.4 9.4 -84.2 11.8 -91.2C11.8 -91.2 17.6 -93 23.2 -91.8C23.2 -91.8 26.4 -94.4 25.6 -96.6C25.6 -96.6 27.2 -98.4 28.2 -94.6C28.2 -94.6 31.6 -91 36.4 -93C36.4 -93 40.4 -93.2 38.4 -90.8C38.4 -90.8 34 -87 22.2 -86.8C22.2 -86.8 9.8 -86.2 -6.6 -78.6C-6.6 -78.6 -36.4 -68.2 -45.6 -57.8C-45.6 -57.8 -52 -49 -57.4 -47.8C-57.4 -47.8 -63.2 -47 -69.2 -39.6C-69.2 -39.6 -59.4 -45.4 -50.4 -45.4C-50.4 -45.4 -46.4 -47.8 -50.2 -44.2C-50.2 -44.2 -53.8 -36.6 -52.2 -31.2C-52.2 -31.2 -52.8 -26 -53.6 -24.4C-53.6 -24.4 -61.4 -11.6 -61.4 -9.2C-61.4 -6.8 -60.2 3 -59.8 3.6C-59.4 4.2 -60.8 2 -57 4.4C-53.2 6.8 -50.4 8.4 -49.6 11.2C-48.8 14 -51.6 5.8 -51.8 4C-52 2.2 -56.2 -5 -55.4 -7.4C-55.4 -7.4 -54.4 -6.4 -53.6 -5C-53.6 -5 -54.2 -5.6 -53.6 -9.2C-53.6 -9.2 -52.8 -14.4 -51.4 -17.6C-50 -20.8 -48 -24.6 -47.6 -25.4C-47.2 -26.2 -47.2 -32 -45.8 -29.4L-42.4 -26.8C-42.4 -26.8 -45.2 -29.4 -43 -31.6C-43 -31.6 -44 -37.2 -42.2 -39.8C-42.2 -39.8 -35.2 -48.2 -33.6 -49.2C-32 -50.2 -33.4 -49.8 -33.4 -49.8C-33.4 -49.8 -27.4 -54 -33.2 -52.4C-33.2 -52.4 -37.2 -50.8 -40.2 -50.8C-40.2 -50.8 -47.8 -48.8 -43.8 -53C-39.8 -57.2 -29.8 -62.6 -26 -62.4L-25.2 -60.8L-14 -63.2L-15.2 -62.4C-15.2 -62.4 -15.4 -62.6 -11.2 -63C-7 -63.4 -1.2 -62 0.2 -63.8C1.6 -65.6 5 -66.6 4.6 -65.2C4.2 -63.8 4 -61.8 4 -61.8C4 -61.8 9 -67.6 8.4 -65.4C7.8 -63.2 -0.4 -58 -1.8 -51.8L8.6 -60L12.2 -63C12.2 -63 15.8 -60.8 16 -62.4C16.2 -64 20.8 -69.8 22 -69.6C23.2 -69.4 25.2 -72.2 25 -69.6C24.8 -67 32.4 -61.6 32.4 -61.6C32.4 -61.6 35.6 -63.4 37 -62C38.4 -60.6 42.6 -81.8 42.6 -81.8L67.6 -92.4L111.201 -95.8L94.201 -102.6L33.2 -114z"} + , + {"stroke":"#4c0000", "width":2, + "path":"M51.4 85C51.4 85 36.4 68.2 28 65.6C28 65.6 14.6 58.8 -10 66.6"} + , + {"stroke":"#4c0000", "width":2, + "path":"M24.8 64.2C24.8 64.2 -0.4 56.2 -15.8 60.4C-15.8 60.4 -34.2 62.4 -42.6 76.2"} + , + {"stroke":"#4c0000", "width":2, + "path":"M21.2 63C21.2 63 4.2 55.8 -10.6 53.6C-10.6 53.6 -27.2 51 -43.8 58.2C-43.8 58.2 -56 64.2 -61.4 74.4"} + , + {"stroke":"#4c0000", "width":2, + "path":"M22.2 63.4C22.2 63.4 6.8 52.4 5.8 51C5.8 51 -1.2 40 -14.2 39.6C-14.2 39.6 -35.6 40.4 -52.8 48.4"} + , + {"fill": "#000000", + "path":"M20.895 54.407C22.437 55.87 49.4 84.8 49.4 84.8C84.6 121.401 56.6 87.2 56.6 87.2C49 82.4 39.8 63.6 39.8 63.6C38.6 60.8 53.8 70.8 53.8 70.8C57.8 71.6 71.4 90.8 71.4 90.8C64.6 88.4 69.4 95.6 69.4 95.6C72.2 97.6 92.601 113.201 92.601 113.201C96.201 117.201 100.201 118.801 100.201 118.801C114.201 113.601 107.801 126.801 107.801 126.801C110.201 133.601 115.801 122.001 115.801 122.001C127.001 105.2 110.601 107.601 110.601 107.601C80.6 110.401 73.8 94.4 73.8 94.4C71.4 92 80.2 94.4 80.2 94.4C88.601 96.4 73 82 73 82C75.4 82 84.6 88.8 84.6 88.8C95.001 98 97.001 96 97.001 96C115.001 87.2 125.401 94.8 125.401 94.8C127.401 96.4 121.801 103.2 123.401 108.401C125.001 113.601 129.801 126.001 129.801 126.001C127.401 127.601 127.801 138.401 127.801 138.401C144.601 161.601 135.001 159.601 135.001 159.601C119.401 159.201 134.201 166.801 134.201 166.801C137.401 168.801 146.201 176.001 146.201 176.001C143.401 174.801 141.801 180.001 141.801 180.001C146.601 184.001 143.801 188.801 143.801 188.801C137.801 190.001 136.601 194.001 136.601 194.001C143.401 202.001 133.401 202.401 133.401 202.401C137.001 206.801 132.201 218.801 132.201 218.801C127.401 218.801 121.001 224.401 121.001 224.401C123.401 229.201 113.001 234.801 113.001 234.801C104.601 236.401 107.401 243.201 107.401 243.201C99.401 249.201 97.001 265.201 97.001 265.201C96.201 275.601 93.801 278.801 99.001 276.801C104.201 274.801 103.401 262.401 103.401 262.401C98.601 246.801 141.401 230.801 141.401 230.801C145.401 229.201 146.201 224.001 146.201 224.001C148.201 224.401 157.001 232.001 157.001 232.001C164.601 243.201 165.001 234.001 165.001 234.001C166.201 230.401 164.601 224.401 164.601 224.401C170.601 202.801 156.601 196.401 156.601 196.401C146.601 162.801 160.601 171.201 160.601 171.201C163.401 176.801 174.201 182.001 174.201 182.001L177.801 179.601C176.201 174.801 184.601 168.801 184.601 168.801C187.401 175.201 193.401 167.201 193.401 167.201C197.001 142.801 209.401 157.201 209.401 157.201C213.401 158.401 214.601 151.601 214.601 151.601C218.201 141.201 214.601 127.601 214.601 127.601C218.201 127.201 227.801 133.201 227.801 133.201C230.601 129.601 221.401 112.801 225.401 115.201C229.401 117.601 233.801 119.201 233.801 119.201C234.601 117.201 224.601 104.801 224.601 104.801C220.201 102 215.001 81.6 215.001 81.6C222.201 85.2 212.201 70 212.201 70C212.201 66.8 218.201 55.6 218.201 55.6C217.401 48.8 218.201 49.2 218.201 49.2C221.001 50.4 229.001 52 222.201 45.6C215.401 39.2 223.001 34.4 223.001 34.4C227.401 31.6 213.801 32 213.801 32C208.601 27.6 209.001 23.6 209.001 23.6C217.001 25.6 202.601 11.2 200.201 7.6C197.801 4 207.401 -1.2 207.401 -1.2C220.601 -4.8 209.001 -8 209.001 -8C189.401 -7.6 200.201 -18.4 200.201 -18.4C206.201 -18 204.601 -20.4 204.601 -20.4C199.401 -21.6 189.801 -28 189.801 -28C185.801 -31.6 189.401 -30.8 189.401 -30.8C206.201 -29.6 177.401 -40.8 177.401 -40.8C185.401 -40.8 167.401 -51.2 167.401 -51.2C165.401 -52.8 162.201 -60.4 162.201 -60.4C156.201 -65.6 151.401 -72.4 151.401 -72.4C151.001 -76.8 146.201 -81.6 146.201 -81.6C134.601 -95.2 129.001 -94.8 129.001 -94.8C114.201 -98.4 109.001 -97.6 109.001 -97.6L56.2 -93.2C29.8 -80.4 37.6 -59.4 37.6 -59.4C44 -51 53.2 -54.8 53.2 -54.8C57.8 -61 69.4 -58.8 69.4 -58.8C89.801 -55.6 87.201 -59.2 87.201 -59.2C84.801 -63.8 68.6 -70 68.4 -70.6C68.2 -71.2 59.4 -74.6 59.4 -74.6C56.4 -75.8 52 -85 52 -85C48.8 -88.4 64.6 -82.6 64.6 -82.6C63.4 -81.6 70.8 -77.6 70.8 -77.6C88.201 -78.6 98.801 -67.8 98.801 -67.8C109.601 -51.2 109.801 -59.4 109.801 -59.4C112.601 -68.8 100.801 -90 100.801 -90C101.201 -92 109.401 -85.4 109.401 -85.4C110.801 -87.4 111.601 -81.6 111.601 -81.6C111.801 -79.2 115.601 -71.2 115.601 -71.2C118.401 -58.2 122.001 -65.6 122.001 -65.6L126.601 -56.2C128.001 -53.6 122.001 -46 122.001 -46C121.801 -43.2 122.601 -43.4 117.001 -35.8C111.401 -28.2 114.801 -23.8 114.801 -23.8C113.401 -17.2 122.201 -17.6 122.201 -17.6C124.801 -15.4 128.201 -15.4 128.201 -15.4C130.001 -13.4 132.401 -14 132.401 -14C134.001 -17.8 140.201 -15.8 140.201 -15.8C141.601 -18.2 149.801 -18.6 149.801 -18.6C150.801 -21.2 151.201 -22.8 154.601 -23.4C158.001 -24 133.401 -67 133.401 -67C139.801 -67.8 131.601 -80.2 131.601 -80.2C129.401 -86.8 140.801 -72.2 143.001 -70.8C145.201 -69.4 146.201 -67.2 144.601 -67.4C143.001 -67.6 141.201 -65.4 142.601 -65.2C144.001 -65 157.001 -50 160.401 -39.8C163.801 -29.6 169.801 -25.6 176.001 -19.6C182.201 -13.6 181.401 10.6 181.401 10.6C181.001 19.4 187.001 30 187.001 30C189.001 33.8 184.801 52 184.801 52C182.801 54.2 184.201 55 184.201 55C185.201 56.2 192.001 69.4 192.001 69.4C190.201 69.2 193.801 72.8 193.801 72.8C199.001 78.8 192.601 75.8 192.601 75.8C186.601 74.2 193.601 84 193.601 84C194.801 85.8 185.801 81.2 185.801 81.2C176.601 80.6 188.201 87.8 188.201 87.8C196.801 95 185.401 90.6 185.401 90.6C180.801 88.8 184.001 95.6 184.001 95.6C187.201 97.2 204.401 104.2 204.401 104.2C204.801 108.001 201.801 113.001 201.801 113.001C202.201 117.001 200.001 120.401 200.001 120.401C198.801 128.601 198.201 129.401 198.201 129.401C194.001 129.601 186.601 143.401 186.601 143.401C184.801 146.001 174.601 158.001 174.601 158.001C172.601 165.001 154.601 157.801 154.601 157.801C148.001 161.201 150.001 157.801 150.001 157.801C149.601 155.601 154.401 149.601 154.401 149.601C161.401 147.001 158.801 136.201 158.801 136.201C162.801 134.801 151.601 132.001 151.801 130.801C152.001 129.601 157.801 128.201 157.801 128.201C165.801 126.201 161.401 123.801 161.401 123.801C160.801 119.801 163.801 114.201 163.801 114.201C175.401 113.401 163.801 97.2 163.801 97.2C153.001 89.6 152.001 83.8 152.001 83.8C164.601 75.6 156.401 63.2 156.601 59.6C156.801 56 158.001 34.4 158.001 34.4C156.001 28.2 153.001 14.6 153.001 14.6C155.201 9.4 162.601 -3.2 162.601 -3.2C165.401 -7.4 174.201 -12.2 172.001 -15.2C169.801 -18.2 162.001 -16.4 162.001 -16.4C154.201 -17.8 154.801 -12.6 154.801 -12.6C153.201 -11.6 152.401 -6.6 152.401 -6.6C151.68 1.333 142.801 7.6 142.801 7.6C131.601 13.8 140.801 17.8 140.801 17.8C146.801 24.4 137.001 24.6 137.001 24.6C126.001 22.8 134.201 33 134.201 33C145.001 45.8 142.001 48.6 142.001 48.6C131.801 49.6 144.401 58.8 144.401 58.8C144.401 58.8 143.601 56.8 143.801 58.6C144.001 60.4 147.001 64.6 147.801 66.6C148.601 68.6 144.601 68.8 144.601 68.8C145.201 78.4 129.801 74.2 129.801 74.2C129.801 74.2 129.801 74.2 128.201 74.4C126.601 74.6 115.401 73.8 109.601 71.6C103.801 69.4 97.001 69.4 97.001 69.4C97.001 69.4 93.001 71.2 85.4 71C77.8 70.8 69.8 73.6 69.8 73.6C65.4 73.2 74 68.8 74.2 69C74.4 69.2 80 63.6 72 64.2C50.203 65.835 39.4 55.6 39.4 55.6C37.4 54.2 34.8 51.4 34.8 51.4C24.8 49.4 36.2 63.8 36.2 63.8C37.4 65.2 36 66.2 36 66.2C35.2 64.6 27.4 59.2 27.4 59.2C24.589 58.227 23.226 56.893 20.895 54.407z"} + , + {"fill": "#4c0000", + "path":"M-3 42.8C-3 42.8 8.6 48.4 11.2 51.2C13.8 54 27.8 65.4 27.8 65.4C27.8 65.4 22.4 63.4 19.8 61.6C17.2 59.8 6.4 51.6 6.4 51.6C6.4 51.6 2.6 45.6 -3 42.8z"} + , + {"fill": "#99cc32", + "path":"M-61.009 11.603C-60.672 11.455 -61.196 8.743 -61.4 8.2C-62.422 5.474 -71.4 4 -71.4 4C-71.627 5.365 -71.682 6.961 -71.576 8.599C-71.576 8.599 -66.708 14.118 -61.009 11.603z"} + , + {"fill": "#659900", + "path":"M-61.009 11.403C-61.458 11.561 -61.024 8.669 -61.2 8.2C-62.222 5.474 -71.4 3.9 -71.4 3.9C-71.627 5.265 -71.682 6.861 -71.576 8.499C-71.576 8.499 -67.308 13.618 -61.009 11.403z"} + , + {"fill": "#000000", + "path":"M-65.4 11.546C-66.025 11.546 -66.531 10.406 -66.531 9C-66.531 7.595 -66.025 6.455 -65.4 6.455C-64.775 6.455 -64.268 7.595 -64.268 9C-64.268 10.406 -64.775 11.546 -65.4 11.546z"} + , + {"fill": "#000000", + "path":"M-65.4 9z"} + , + {"fill": "#000000", + "path":"M-111 109.601C-111 109.601 -116.6 119.601 -91.8 113.601C-91.8 113.601 -77.8 112.401 -75.4 110.001C-74.2 110.801 -65.834 113.734 -63 114.401C-56.2 116.001 -47.8 106 -47.8 106C-47.8 106 -43.2 95.5 -40.4 95.5C-37.6 95.5 -40.8 97.1 -40.8 97.1C-40.8 97.1 -47.4 107.201 -47 108.801C-47 108.801 -52.2 128.801 -68.2 129.601C-68.2 129.601 -84.35 130.551 -83 136.401C-83 136.401 -74.2 134.001 -71.8 136.401C-71.8 136.401 -61 136.001 -69 142.401L-75.8 154.001C-75.8 154.001 -75.66 157.919 -85.8 154.401C-95.6 151.001 -105.9 138.101 -105.9 138.101C-105.9 138.101 -121.85 123.551 -111 109.601z"} + , + {"fill": "#e59999", + "path":"M-112.2 113.601C-112.2 113.601 -114.2 123.201 -77.4 112.801C-77.4 112.801 -73 112.801 -70.6 113.601C-68.2 114.401 -56.2 117.201 -54.2 116.001C-54.2 116.001 -61.4 129.601 -73 128.001C-73 128.001 -86.2 129.601 -85.8 134.401C-85.8 134.401 -81.8 141.601 -77 144.001C-77 144.001 -74.2 146.401 -74.6 149.601C-75 152.801 -77.8 154.401 -79.8 155.201C-81.8 156.001 -85 152.801 -86.6 152.801C-88.2 152.801 -96.6 146.401 -101 141.601C-105.4 136.801 -113.8 124.801 -113.4 122.001C-113 119.201 -112.2 113.601 -112.2 113.601z"} + , + {"fill": "#b26565", + "path":"M-109 131.051C-106.4 135.001 -103.2 139.201 -101 141.601C-96.6 146.401 -88.2 152.801 -86.6 152.801C-85 152.801 -81.8 156.001 -79.8 155.201C-77.8 154.401 -75 152.801 -74.6 149.601C-74.2 146.401 -77 144.001 -77 144.001C-80.066 142.468 -82.806 138.976 -84.385 136.653C-84.385 136.653 -84.2 139.201 -89.4 138.401C-94.6 137.601 -99.8 134.801 -101.4 131.601C-103 128.401 -105.4 126.001 -103.8 129.601C-102.2 133.201 -99.8 136.801 -98.2 137.201C-96.6 137.601 -97 138.801 -99.4 138.401C-101.8 138.001 -104.6 137.601 -109 132.401z"} + , + {"fill": "#992600", + "path":"M-111.6 110.001C-111.6 110.001 -109.8 96.4 -108.6 92.4C-108.6 92.4 -109.4 85.6 -107 81.4C-104.6 77.2 -102.6 71 -99.6 65.6C-96.6 60.2 -96.4 56.2 -92.4 54.6C-88.4 53 -82.4 44.4 -79.6 43.4C-76.8 42.4 -77 43.2 -77 43.2C-77 43.2 -70.2 28.4 -56.6 32.4C-56.6 32.4 -72.8 29.6 -57 20.2C-57 20.2 -61.8 21.3 -58.5 14.3C-56.299 9.632 -56.8 16.4 -67.8 28.2C-67.8 28.2 -72.8 36.8 -78 39.8C-83.2 42.8 -95.2 49.8 -96.4 53.6C-97.6 57.4 -100.8 63.2 -102.8 64.8C-104.8 66.4 -107.6 70.6 -108 74C-108 74 -109.2 78 -110.6 79.2C-112 80.4 -112.2 83.6 -112.2 85.6C-112.2 87.6 -114.2 90.4 -114 92.8C-114 92.8 -113.2 111.801 -113.6 113.801L-111.6 110.001z"} + , + {"fill": "#ffffff", + "path":"M-120.2 114.601C-120.2 114.601 -122.2 113.201 -126.6 119.201C-126.6 119.201 -119.3 152.201 -119.3 153.601C-119.3 153.601 -118.2 151.501 -119.5 144.301C-120.8 137.101 -121.7 124.401 -121.7 124.401L-120.2 114.601z"} + , + {"fill": "#992600", + "path":"M-98.6 54C-98.6 54 -116.2 57.2 -115.8 86.4L-116.6 111.201C-116.6 111.201 -117.8 85.6 -119 84C-120.2 82.4 -116.2 71.2 -119.4 77.2C-119.4 77.2 -133.4 91.2 -125.4 112.401C-125.4 112.401 -123.9 115.701 -126.9 111.101C-126.9 111.101 -131.5 98.5 -130.4 92.1C-130.4 92.1 -130.2 89.9 -128.3 87.1C-128.3 87.1 -119.7 75.4 -117 73.1C-117 73.1 -115.2 58.7 -99.8 53.5C-99.8 53.5 -94.1 51.2 -98.6 54z"} + , + {"fill": "#000000", + "path":"M40.8 -12.2C41.46 -12.554 41.451 -13.524 42.031 -13.697C43.18 -14.041 43.344 -15.108 43.862 -15.892C44.735 -17.211 44.928 -18.744 45.51 -20.235C45.782 -20.935 45.809 -21.89 45.496 -22.55C44.322 -25.031 43.62 -27.48 42.178 -29.906C41.91 -30.356 41.648 -31.15 41.447 -31.748C40.984 -33.132 39.727 -34.123 38.867 -35.443C38.579 -35.884 39.104 -36.809 38.388 -36.893C37.491 -36.998 36.042 -37.578 35.809 -36.552C35.221 -33.965 36.232 -31.442 37.2 -29C36.418 -28.308 36.752 -27.387 36.904 -26.62C37.614 -23.014 36.416 -19.662 35.655 -16.188C35.632 -16.084 35.974 -15.886 35.946 -15.824C34.724 -13.138 33.272 -10.693 31.453 -8.312C30.695 -7.32 29.823 -6.404 29.326 -5.341C28.958 -4.554 28.55 -3.588 28.8 -2.6C25.365 0.18 23.115 4.025 20.504 7.871C20.042 8.551 20.333 9.76 20.884 10.029C21.697 10.427 22.653 9.403 23.123 8.557C23.512 7.859 23.865 7.209 24.356 6.566C24.489 6.391 24.31 5.972 24.445 5.851C27.078 3.504 28.747 0.568 31.2 -1.8C33.15 -2.129 34.687 -3.127 36.435 -4.14C36.743 -4.319 37.267 -4.07 37.557 -4.265C39.31 -5.442 39.308 -7.478 39.414 -9.388C39.464 -10.272 39.66 -11.589 40.8 -12.2z"} + , + {"fill": "#000000", + "path":"M31.959 -16.666C32.083 -16.743 31.928 -17.166 32.037 -17.382C32.199 -17.706 32.602 -17.894 32.764 -18.218C32.873 -18.434 32.71 -18.814 32.846 -18.956C35.179 -21.403 35.436 -24.427 34.4 -27.4C35.424 -28.02 35.485 -29.282 35.06 -30.129C34.207 -31.829 34.014 -33.755 33.039 -35.298C32.237 -36.567 30.659 -37.811 29.288 -36.508C28.867 -36.108 28.546 -35.321 28.824 -34.609C28.888 -34.446 29.173 -34.3 29.146 -34.218C29.039 -33.894 28.493 -33.67 28.487 -33.398C28.457 -31.902 27.503 -30.391 28.133 -29.062C28.905 -27.433 29.724 -25.576 30.4 -23.8C29.166 -21.684 30.199 -19.235 28.446 -17.358C28.31 -17.212 28.319 -16.826 28.441 -16.624C28.733 -16.138 29.139 -15.732 29.625 -15.44C29.827 -15.319 30.175 -15.317 30.375 -15.441C30.953 -15.803 31.351 -16.29 31.959 -16.666z"} + , + {"fill": "#000000", + "path":"M94.771 -26.977C96.16 -25.185 96.45 -22.39 94.401 -21C94.951 -17.691 98.302 -19.67 100.401 -20.2C100.292 -20.588 100.519 -20.932 100.802 -20.937C101.859 -20.952 102.539 -21.984 103.601 -21.8C104.035 -23.357 105.673 -24.059 106.317 -25.439C108.043 -29.134 107.452 -33.407 104.868 -36.653C104.666 -36.907 104.883 -37.424 104.759 -37.786C104.003 -39.997 101.935 -40.312 100.001 -41C98.824 -44.875 98.163 -48.906 96.401 -52.6C94.787 -52.85 94.089 -54.589 92.752 -55.309C91.419 -56.028 90.851 -54.449 90.892 -53.403C90.899 -53.198 91.351 -52.974 91.181 -52.609C91.105 -52.445 90.845 -52.334 90.845 -52.2C90.846 -52.065 91.067 -51.934 91.201 -51.8C90.283 -50.98 88.86 -50.503 88.565 -49.358C87.611 -45.648 90.184 -42.523 91.852 -39.322C92.443 -38.187 91.707 -36.916 90.947 -35.708C90.509 -35.013 90.617 -33.886 90.893 -33.03C91.645 -30.699 93.236 -28.96 94.771 -26.977z"} + , + {"fill": "#000000", + "path":"M57.611 -8.591C56.124 -6.74 52.712 -4.171 55.629 -2.243C55.823 -2.114 56.193 -2.11 56.366 -2.244C58.387 -3.809 60.39 -4.712 62.826 -5.294C62.95 -5.323 63.224 -4.856 63.593 -5.017C65.206 -5.72 67.216 -5.662 68.4 -7C72.167 -6.776 75.732 -7.892 79.123 -9.2C80.284 -9.648 81.554 -10.207 82.755 -10.709C84.131 -11.285 85.335 -12.213 86.447 -13.354C86.58 -13.49 86.934 -13.4 87.201 -13.4C87.161 -14.263 88.123 -14.39 88.37 -15.012C88.462 -15.244 88.312 -15.64 88.445 -15.742C90.583 -17.372 91.503 -19.39 90.334 -21.767C90.049 -22.345 89.8 -22.963 89.234 -23.439C88.149 -24.35 87.047 -23.496 86 -23.8C85.841 -23.172 85.112 -23.344 84.726 -23.146C83.867 -22.707 82.534 -23.292 81.675 -22.854C80.313 -22.159 79.072 -21.99 77.65 -21.613C77.338 -21.531 76.56 -21.627 76.4 -21C76.266 -21.134 76.118 -21.368 76.012 -21.346C74.104 -20.95 72.844 -20.736 71.543 -19.044C71.44 -18.911 70.998 -19.09 70.839 -18.955C69.882 -18.147 69.477 -16.913 68.376 -16.241C68.175 -16.118 67.823 -16.286 67.629 -16.157C66.983 -15.726 66.616 -15.085 65.974 -14.638C65.645 -14.409 65.245 -14.734 65.277 -14.99C65.522 -16.937 66.175 -18.724 65.6 -20.6C67.677 -23.12 70.194 -25.069 72 -27.8C72.015 -29.966 72.707 -32.112 72.594 -34.189C72.584 -34.382 72.296 -35.115 72.17 -35.462C71.858 -36.316 72.764 -37.382 71.92 -38.106C70.516 -39.309 69.224 -38.433 68.4 -37C66.562 -36.61 64.496 -35.917 62.918 -37.151C61.911 -37.938 61.333 -38.844 60.534 -39.9C59.549 -41.202 59.884 -42.638 59.954 -44.202C59.96 -44.33 59.645 -44.466 59.645 -44.6C59.646 -44.735 59.866 -44.866 60 -45C59.294 -45.626 59.019 -46.684 58 -47C58.305 -48.092 57.629 -48.976 56.758 -49.278C54.763 -49.969 53.086 -48.057 51.194 -47.984C50.68 -47.965 50.213 -49.003 49.564 -49.328C49.132 -49.544 48.428 -49.577 48.066 -49.311C47.378 -48.807 46.789 -48.693 46.031 -48.488C44.414 -48.052 43.136 -46.958 41.656 -46.103C40.171 -45.246 39.216 -43.809 38.136 -42.489C37.195 -41.337 37.059 -38.923 38.479 -38.423C40.322 -37.773 41.626 -40.476 43.592 -40.15C43.904 -40.099 44.11 -39.788 44 -39.4C44.389 -39.291 44.607 -39.52 44.8 -39.8C45.658 -38.781 46.822 -38.444 47.76 -37.571C48.73 -36.667 50.476 -37.085 51.491 -36.088C53.02 -34.586 52.461 -31.905 54.4 -30.6C53.814 -29.287 53.207 -28.01 52.872 -26.583C52.59 -25.377 53.584 -24.18 54.795 -24.271C56.053 -24.365 56.315 -25.124 56.8 -26.2C57.067 -25.933 57.536 -25.636 57.495 -25.42C57.038 -23.033 56.011 -21.04 55.553 -18.609C55.494 -18.292 55.189 -18.09 54.8 -18.2C54.332 -14.051 50.28 -11.657 47.735 -8.492C47.332 -7.99 47.328 -6.741 47.737 -6.338C49.14 -4.951 51.1 -6.497 52.8 -7C53.013 -8.206 53.872 -9.148 55.204 -9.092C55.46 -9.082 55.695 -9.624 56.019 -9.754C56.367 -9.892 56.869 -9.668 57.155 -9.866C58.884 -11.061 60.292 -12.167 62.03 -13.356C62.222 -13.487 62.566 -13.328 62.782 -13.436C63.107 -13.598 63.294 -13.985 63.617 -14.17C63.965 -14.37 64.207 -14.08 64.4 -13.8C63.754 -13.451 63.75 -12.494 63.168 -12.292C62.393 -12.024 61.832 -11.511 61.158 -11.064C60.866 -10.871 60.207 -11.119 60.103 -10.94C59.505 -9.912 58.321 -9.474 57.611 -8.591z"} + , + {"fill": "#000000", + "path":"M2.2 -58C2.2 -58 -7.038 -60.872 -18.2 -35.2C-18.2 -35.2 -20.6 -30 -23 -28C-25.4 -26 -36.6 -22.4 -38.6 -18.4L-49 -2.4C-49 -2.4 -34.2 -18.4 -31 -20.8C-31 -20.8 -23 -29.2 -26.2 -22.4C-26.2 -22.4 -40.2 -11.6 -39 -2.4C-39 -2.4 -44.6 12 -45.4 14C-45.4 14 -29.4 -18 -27 -19.2C-24.6 -20.4 -23.4 -20.4 -24.6 -16.8C-25.8 -13.2 -26.2 3.2 -29 5.2C-29 5.2 -21 -15.2 -21.8 -18.4C-21.8 -18.4 -18.6 -22 -16.2 -16.8L-17.4 -0.8L-13 11.2C-13 11.2 -15.4 0 -13.8 -15.6C-13.8 -15.6 -15.8 -26 -11.8 -20.4C-7.8 -14.8 1.8 -8.8 1.8 -4C1.8 -4 -3.4 -21.6 -12.6 -26.4L-16.6 -20.4L-17.8 -22.4C-17.8 -22.4 -21.4 -23.2 -17 -30C-12.6 -36.8 -13 -37.6 -13 -37.6C-13 -37.6 -6.6 -30.4 -5 -30.4C-5 -30.4 8.2 -38 9.4 -13.6C9.4 -13.6 16.2 -28 7 -34.8C7 -34.8 -7.8 -36.8 -6.6 -42L0.6 -54.4C4.2 -59.6 2.6 -56.8 2.6 -56.8z"} + , + {"fill": "#000000", + "path":"M-17.8 -41.6C-17.8 -41.6 -30.6 -41.6 -33.8 -36.4L-41 -26.8C-41 -26.8 -23.8 -36.8 -19.8 -38C-15.8 -39.2 -17.8 -41.6 -17.8 -41.6z"} + , + {"fill": "#000000", + "path":"M-57.8 -35.2C-57.8 -35.2 -59.8 -34 -60.2 -31.2C-60.6 -28.4 -63 -28 -62.2 -25.2C-61.4 -22.4 -59.4 -20 -59.4 -24C-59.4 -28 -57.8 -30 -57 -31.2C-56.2 -32.4 -54.6 -36.8 -57.8 -35.2z"} + , + {"fill": "#000000", + "path":"M-66.6 26C-66.6 26 -75 22 -78.2 18.4C-81.4 14.8 -80.948 19.966 -85.8 19.6C-91.647 19.159 -90.6 3.2 -90.6 3.2L-94.6 10.8C-94.6 10.8 -95.8 25.2 -87.8 22.8C-83.893 21.628 -82.6 23.2 -84.2 24C-85.8 24.8 -78.6 25.2 -81.4 26.8C-84.2 28.4 -69.8 23.2 -72.2 33.6L-66.6 26z"} + , + {"fill": "#000000", + "path":"M-79.2 40.4C-79.2 40.4 -94.6 44.8 -98.2 35.2C-98.2 35.2 -103 37.6 -100.8 40.6C-98.6 43.6 -97.4 44 -97.4 44C-97.4 44 -92 45.2 -92.6 46C-93.2 46.8 -95.6 50.2 -95.6 50.2C-95.6 50.2 -85.4 44.2 -79.2 40.4z"} + , + {"fill": "#ffffff", + "path":"M149.201 118.601C148.774 120.735 147.103 121.536 145.201 122.201C143.284 121.243 140.686 118.137 138.801 120.201C138.327 119.721 137.548 119.661 137.204 118.999C136.739 118.101 137.011 117.055 136.669 116.257C136.124 114.985 135.415 113.619 135.601 112.201C137.407 111.489 138.002 109.583 137.528 107.82C137.459 107.563 137.03 107.366 137.23 107.017C137.416 106.694 137.734 106.467 138.001 106.2C137.866 106.335 137.721 106.568 137.61 106.548C137 106.442 137.124 105.805 137.254 105.418C137.839 103.672 139.853 103.408 141.201 104.6C141.457 104.035 141.966 104.229 142.401 104.2C142.351 103.621 142.759 103.094 142.957 102.674C143.475 101.576 145.104 102.682 145.901 102.07C146.977 101.245 148.04 100.546 149.118 101.149C150.927 102.162 152.636 103.374 153.835 105.115C154.41 105.949 154.65 107.23 154.592 108.188C154.554 108.835 153.173 108.483 152.83 109.412C152.185 111.16 154.016 111.679 154.772 113.017C154.97 113.366 154.706 113.67 154.391 113.768C153.98 113.896 153.196 113.707 153.334 114.16C154.306 117.353 151.55 118.031 149.201 118.601z"} + , + {"fill": "#ffffff", + "path":"M139.6 138.201C139.593 136.463 137.992 134.707 139.201 133.001C139.336 133.135 139.467 133.356 139.601 133.356C139.736 133.356 139.867 133.135 140.001 133.001C141.496 135.217 145.148 136.145 145.006 138.991C144.984 139.438 143.897 140.356 144.801 141.001C142.988 142.349 142.933 144.719 142.001 146.601C140.763 146.315 139.551 145.952 138.401 145.401C138.753 143.915 138.636 142.231 139.456 140.911C139.89 140.213 139.603 139.134 139.6 138.201z"} + , + {"fill": "#cccccc", + "path":"M-26.6 129.201C-26.6 129.201 -43.458 139.337 -29.4 124.001C-20.6 114.401 -10.6 108.801 -10.6 108.801C-10.6 108.801 -0.2 104.4 3.4 103.2C7 102 22.2 96.8 25.4 96.4C28.6 96 38.2 92 45 96C51.8 100 59.8 104.4 59.8 104.4C59.8 104.4 43.4 96 39.8 98.4C36.2 100.8 29 100.4 23 103.6C23 103.6 8.2 108.001 5 110.001C1.8 112.001 -8.6 123.601 -10.2 122.801C-11.8 122.001 -9.8 121.601 -8.6 118.801C-7.4 116.001 -9.4 114.401 -17.4 120.801C-25.4 127.201 -26.6 129.201 -26.6 129.201z"} + , + {"fill": "#000000", + "path":"M-19.195 123.234C-19.195 123.234 -17.785 110.194 -9.307 111.859C-9.307 111.859 -1.081 107.689 1.641 105.721C1.641 105.721 9.78 104.019 11.09 103.402C29.569 94.702 44.288 99.221 44.835 98.101C45.381 96.982 65.006 104.099 68.615 108.185C69.006 108.628 58.384 102.588 48.686 100.697C40.413 99.083 18.811 100.944 7.905 106.48C4.932 107.989 -4.013 113.773 -6.544 113.662C-9.075 113.55 -19.195 123.234 -19.195 123.234z"} + , + {"fill": "#cccccc", + "path":"M-23 148.801C-23 148.801 -38.2 146.401 -21.4 144.801C-21.4 144.801 -3.4 142.801 0.6 137.601C0.6 137.601 14.2 128.401 17 128.001C19.8 127.601 49.8 120.401 50.2 118.001C50.6 115.601 56.2 115.601 57.8 116.401C59.4 117.201 58.6 118.401 55.8 119.201C53 120.001 21.8 136.401 15.4 137.601C9 138.801 -2.6 146.401 -7.4 147.601C-12.2 148.801 -23 148.801 -23 148.801z"} + , + {"fill": "#000000", + "path":"M-3.48 141.403C-3.48 141.403 -12.062 140.574 -3.461 139.755C-3.461 139.755 5.355 136.331 7.403 133.668C7.403 133.668 14.367 128.957 15.8 128.753C17.234 128.548 31.194 124.861 31.399 123.633C31.604 122.404 65.67 109.823 70.09 113.013C73.001 115.114 63.1 113.437 53.466 117.847C52.111 118.467 18.258 133.054 14.981 133.668C11.704 134.283 5.765 138.174 3.307 138.788C0.85 139.403 -3.48 141.403 -3.48 141.403z"} + , + {"fill": "#000000", + "path":"M-11.4 143.601C-11.4 143.601 -6.2 143.201 -7.4 144.801C-8.6 146.401 -11 145.601 -11 145.601L-11.4 143.601z"} + , + {"fill": "#000000", + "path":"M-18.6 145.201C-18.6 145.201 -13.4 144.801 -14.6 146.401C-15.8 148.001 -18.2 147.201 -18.2 147.201L-18.6 145.201z"} + , + {"fill": "#000000", + "path":"M-29 146.801C-29 146.801 -23.8 146.401 -25 148.001C-26.2 149.601 -28.6 148.801 -28.6 148.801L-29 146.801z"} + , + {"fill": "#000000", + "path":"M-36.6 147.601C-36.6 147.601 -31.4 147.201 -32.6 148.801C-33.8 150.401 -36.2 149.601 -36.2 149.601L-36.6 147.601z"} + , + {"fill": "#000000", + "path":"M1.8 108.001C1.8 108.001 6.2 108.001 5 109.601C3.8 111.201 0.6 110.801 0.6 110.801L1.8 108.001z"} + , + {"fill": "#000000", + "path":"M-8.2 113.601C-8.2 113.601 -1.694 111.46 -4.2 114.801C-5.4 116.401 -7.8 115.601 -7.8 115.601L-8.2 113.601z"} + , + {"fill": "#000000", + "path":"M-19.4 118.401C-19.4 118.401 -14.2 118.001 -15.4 119.601C-16.6 121.201 -19 120.401 -19 120.401L-19.4 118.401z"} + , + {"fill": "#000000", + "path":"M-27 124.401C-27 124.401 -21.8 124.001 -23 125.601C-24.2 127.201 -26.6 126.401 -26.6 126.401L-27 124.401z"} + , + {"fill": "#000000", + "path":"M-33.8 129.201C-33.8 129.201 -28.6 128.801 -29.8 130.401C-31 132.001 -33.4 131.201 -33.4 131.201L-33.8 129.201z"} + , + {"fill": "#000000", + "path":"M5.282 135.598C5.282 135.598 12.203 135.066 10.606 137.195C9.009 139.325 5.814 138.26 5.814 138.26L5.282 135.598z"} + , + {"fill": "#000000", + "path":"M15.682 130.798C15.682 130.798 22.603 130.266 21.006 132.395C19.409 134.525 16.214 133.46 16.214 133.46L15.682 130.798z"} + , + {"fill": "#000000", + "path":"M26.482 126.398C26.482 126.398 33.403 125.866 31.806 127.995C30.209 130.125 27.014 129.06 27.014 129.06L26.482 126.398z"} + , + {"fill": "#000000", + "path":"M36.882 121.598C36.882 121.598 43.803 121.066 42.206 123.195C40.609 125.325 37.414 124.26 37.414 124.26L36.882 121.598z"} + , + {"fill": "#000000", + "path":"M9.282 103.598C9.282 103.598 16.203 103.066 14.606 105.195C13.009 107.325 9.014 107.06 9.014 107.06L9.282 103.598z"} + , + {"fill": "#000000", + "path":"M19.282 100.398C19.282 100.398 26.203 99.866 24.606 101.995C23.009 104.125 18.614 103.86 18.614 103.86L19.282 100.398z"} + , + {"fill": "#000000", + "path":"M-3.4 140.401C-3.4 140.401 1.8 140.001 0.6 141.601C-0.6 143.201 -3 142.401 -3 142.401L-3.4 140.401z"} + , + {"fill": "#992600", + "path":"M-76.6 41.2C-76.6 41.2 -81 50 -81.4 53.2C-81.4 53.2 -80.6 44.4 -79.4 42.4C-78.2 40.4 -76.6 41.2 -76.6 41.2z"} + , + {"fill": "#992600", + "path":"M-95 55.2C-95 55.2 -98.2 69.6 -97.8 72.4C-97.8 72.4 -99 60.8 -98.6 59.6C-98.2 58.4 -95 55.2 -95 55.2z"} + , + {"fill": "#cccccc", + "path":"M-74.2 -19.4L-74.4 -16.2L-76.6 -16C-76.6 -16 -62.4 -3.4 -61.8 4.2C-61.8 4.2 -61 -4 -74.2 -19.4z"} + , + {"fill": "#000000", + "path":"M-70.216 -18.135C-70.647 -18.551 -70.428 -19.296 -70.836 -19.556C-71.645 -20.072 -69.538 -20.129 -69.766 -20.845C-70.149 -22.051 -69.962 -22.072 -70.084 -23.348C-70.141 -23.946 -69.553 -25.486 -69.168 -25.926C-67.722 -27.578 -69.046 -30.51 -67.406 -32.061C-67.102 -32.35 -66.726 -32.902 -66.441 -33.32C-65.782 -34.283 -64.598 -34.771 -63.648 -35.599C-63.33 -35.875 -63.531 -36.702 -62.962 -36.61C-62.248 -36.495 -61.007 -36.625 -61.052 -35.784C-61.165 -33.664 -62.494 -31.944 -63.774 -30.276C-63.323 -29.572 -63.781 -28.937 -64.065 -28.38C-65.4 -25.76 -65.211 -22.919 -65.385 -20.079C-65.39 -19.994 -65.697 -19.916 -65.689 -19.863C-65.336 -17.528 -64.752 -15.329 -63.873 -13.1C-63.507 -12.17 -63.036 -11.275 -62.886 -10.348C-62.775 -9.662 -62.672 -8.829 -63.08 -8.124C-61.045 -5.234 -62.354 -2.583 -61.185 0.948C-60.978 1.573 -59.286 3.487 -59.749 3.326C-62.262 2.455 -62.374 2.057 -62.551 1.304C-62.697 0.681 -63.027 -0.696 -63.264 -1.298C-63.328 -1.462 -63.499 -3.346 -63.577 -3.468C-65.09 -5.85 -63.732 -5.674 -65.102 -8.032C-66.53 -8.712 -67.496 -9.816 -68.619 -10.978C-68.817 -11.182 -67.674 -11.906 -67.855 -12.119C-68.947 -13.408 -70.1 -14.175 -69.764 -15.668C-69.609 -16.358 -69.472 -17.415 -70.216 -18.135z"} + , + {"fill": "#000000", + "path":"M-73.8 -16.4C-73.8 -16.4 -73.4 -9.6 -71 -8C-68.6 -6.4 -69.8 -7.2 -73 -8.4C-76.2 -9.6 -75 -10.4 -75 -10.4C-75 -10.4 -77.8 -10 -75.4 -8C-73 -6 -69.4 -3.6 -71 -3.6C-72.6 -3.6 -80.2 -7.6 -80.2 -10.4C-80.2 -13.2 -81.2 -17.3 -81.2 -17.3C-81.2 -17.3 -80.1 -18.1 -75.3 -18C-75.3 -18 -73.9 -17.3 -73.8 -16.4z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-74.6 2.2C-74.6 2.2 -83.12 -0.591 -101.6 2.8C-101.6 2.8 -92.569 0.722 -73.8 3C-63.5 4.25 -74.6 2.2 -74.6 2.2z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-72.502 2.129C-72.502 2.129 -80.748 -1.389 -99.453 0.392C-99.453 0.392 -90.275 -0.897 -71.774 2.995C-61.62 5.131 -72.502 2.129 -72.502 2.129z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-70.714 2.222C-70.714 2.222 -78.676 -1.899 -97.461 -1.514C-97.461 -1.514 -88.213 -2.118 -70.052 3.14C-60.086 6.025 -70.714 2.222 -70.714 2.222z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-69.444 2.445C-69.444 2.445 -76.268 -1.862 -93.142 -2.96C-93.142 -2.96 -84.803 -2.79 -68.922 3.319C-60.206 6.672 -69.444 2.445 -69.444 2.445z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M45.84 12.961C45.84 12.961 44.91 13.605 45.124 12.424C45.339 11.243 73.547 -1.927 77.161 -1.677C77.161 -1.677 46.913 11.529 45.84 12.961z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M42.446 13.6C42.446 13.6 41.57 14.315 41.691 13.121C41.812 11.927 68.899 -3.418 72.521 -3.452C72.521 -3.452 43.404 12.089 42.446 13.6z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M39.16 14.975C39.16 14.975 38.332 15.747 38.374 14.547C38.416 13.348 58.233 -2.149 68.045 -4.023C68.045 -4.023 50.015 4.104 39.16 14.975z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M36.284 16.838C36.284 16.838 35.539 17.532 35.577 16.453C35.615 15.373 53.449 1.426 62.28 -0.26C62.28 -0.26 46.054 7.054 36.284 16.838z"} + , + {"fill": "#cccccc", + "path":"M4.6 164.801C4.6 164.801 -10.6 162.401 6.2 160.801C6.2 160.801 24.2 158.801 28.2 153.601C28.2 153.601 41.8 144.401 44.6 144.001C47.4 143.601 63.8 140.001 64.2 137.601C64.6 135.201 70.6 132.801 72.2 133.601C73.8 134.401 73.8 143.601 71 144.401C68.2 145.201 49.4 152.401 43 153.601C36.6 154.801 25 162.401 20.2 163.601C15.4 164.801 4.6 164.801 4.6 164.801z"} + , + {"fill": "#000000", + "path":"M77.6 127.401C77.6 127.401 74.6 129.001 73.4 131.601C73.4 131.601 67 142.201 52.8 145.401C52.8 145.401 29.8 154.401 22 156.401C22 156.401 8.6 161.401 1.2 160.601C1.2 160.601 -5.8 160.801 0.4 162.401C0.4 162.401 20.6 160.401 24 158.601C24 158.601 39.6 153.401 42.6 150.801C45.6 148.201 63.8 143.201 66 141.201C68.2 139.201 78 130.801 77.6 127.401z"} + , + {"fill": "#000000", + "path":"M18.882 158.911C18.882 158.911 24.111 158.685 22.958 160.234C21.805 161.784 19.357 160.91 19.357 160.91L18.882 158.911z"} + , + {"fill": "#000000", + "path":"M11.68 160.263C11.68 160.263 16.908 160.037 15.756 161.586C14.603 163.136 12.155 162.263 12.155 162.263L11.68 160.263z"} + , + {"fill": "#000000", + "path":"M1.251 161.511C1.251 161.511 6.48 161.284 5.327 162.834C4.174 164.383 1.726 163.51 1.726 163.51L1.251 161.511z"} + , + {"fill": "#000000", + "path":"M-6.383 162.055C-6.383 162.055 -1.154 161.829 -2.307 163.378C-3.46 164.928 -5.908 164.054 -5.908 164.054L-6.383 162.055z"} + , + {"fill": "#000000", + "path":"M35.415 151.513C35.415 151.513 42.375 151.212 40.84 153.274C39.306 155.336 36.047 154.174 36.047 154.174L35.415 151.513z"} + , + {"fill": "#000000", + "path":"M45.73 147.088C45.73 147.088 51.689 143.787 51.155 148.849C50.885 151.405 46.362 149.749 46.362 149.749L45.73 147.088z"} + , + {"fill": "#000000", + "path":"M54.862 144.274C54.862 144.274 62.021 140.573 60.287 146.035C59.509 148.485 55.493 146.935 55.493 146.935L54.862 144.274z"} + , + {"fill": "#000000", + "path":"M64.376 139.449C64.376 139.449 68.735 134.548 69.801 141.21C70.207 143.748 65.008 142.11 65.008 142.11L64.376 139.449z"} + , + {"fill": "#000000", + "path":"M26.834 155.997C26.834 155.997 32.062 155.77 30.91 157.32C29.757 158.869 27.308 157.996 27.308 157.996L26.834 155.997z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M62.434 34.603C62.434 34.603 61.708 35.268 61.707 34.197C61.707 33.127 79.191 19.863 88.034 18.479C88.034 18.479 71.935 25.208 62.434 34.603z"} + , + {"fill": "#000000", + "path":"M65.4 98.4C65.4 98.4 87.401 120.801 96.601 124.401C96.601 124.401 105.801 135.601 101.801 161.601C101.801 161.601 98.601 169.201 95.401 148.401C95.401 148.401 98.601 123.201 87.401 139.201C87.401 139.201 79 129.301 85.4 129.601C85.4 129.601 88.601 131.601 89.001 130.001C89.401 128.401 81.4 114.801 64.2 100.4C47 86 65.4 98.4 65.4 98.4z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M7 137.201C7 137.201 6.8 135.401 8.6 136.201C10.4 137.001 104.601 143.201 136.201 167.201C136.201 167.201 91.001 144.001 7 137.201z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M17.4 132.801C17.4 132.801 17.2 131.001 19 131.801C20.8 132.601 157.401 131.601 181.001 164.001C181.001 164.001 159.001 138.801 17.4 132.801z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M29 128.801C29 128.801 28.8 127.001 30.6 127.801C32.4 128.601 205.801 115.601 229.401 148.001C229.401 148.001 219.801 122.401 29 128.801z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M39 124.001C39 124.001 38.8 122.201 40.6 123.001C42.4 123.801 164.601 85.2 188.201 117.601C188.201 117.601 174.801 93 39 124.001z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-19 146.801C-19 146.801 -19.2 145.001 -17.4 145.801C-15.6 146.601 2.2 148.801 4.2 187.601C4.2 187.601 -3 145.601 -19 146.801z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-27.8 148.401C-27.8 148.401 -28 146.601 -26.2 147.401C-24.4 148.201 -10.2 143.601 -13 182.401C-13 182.401 -11.8 147.201 -27.8 148.401z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-35.8 148.801C-35.8 148.801 -36 147.001 -34.2 147.801C-32.4 148.601 -17 149.201 -29.4 171.601C-29.4 171.601 -19.8 147.601 -35.8 148.801z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M11.526 104.465C11.526 104.465 11.082 106.464 12.631 105.247C28.699 92.622 61.141 33.72 116.826 28.086C116.826 28.086 78.518 15.976 11.526 104.465z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M22.726 102.665C22.726 102.665 21.363 101.472 23.231 100.847C25.099 100.222 137.541 27.72 176.826 35.686C176.826 35.686 149.719 28.176 22.726 102.665z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M1.885 108.767C1.885 108.767 1.376 110.366 3.087 109.39C12.062 104.27 15.677 47.059 59.254 45.804C59.254 45.804 26.843 31.09 1.885 108.767z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-18.038 119.793C-18.038 119.793 -19.115 121.079 -17.162 120.825C-6.916 119.493 14.489 78.222 58.928 83.301C58.928 83.301 26.962 68.955 -18.038 119.793z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-6.8 113.667C-6.8 113.667 -7.611 115.136 -5.742 114.511C4.057 111.237 17.141 66.625 61.729 63.078C61.729 63.078 27.603 55.135 -6.8 113.667z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-25.078 124.912C-25.078 124.912 -25.951 125.954 -24.369 125.748C-16.07 124.669 1.268 91.24 37.264 95.354C37.264 95.354 11.371 83.734 -25.078 124.912z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-32.677 130.821C-32.677 130.821 -33.682 131.866 -32.091 131.748C-27.923 131.439 2.715 98.36 21.183 113.862C21.183 113.862 9.168 95.139 -32.677 130.821z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M36.855 98.898C36.855 98.898 35.654 97.543 37.586 97.158C39.518 96.774 160.221 39.061 198.184 51.927C198.184 51.927 172.243 41.053 36.855 98.898z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M3.4 163.201C3.4 163.201 3.2 161.401 5 162.201C6.8 163.001 22.2 163.601 9.8 186.001C9.8 186.001 19.4 162.001 3.4 163.201z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M13.8 161.601C13.8 161.601 13.6 159.801 15.4 160.601C17.2 161.401 35 163.601 37 202.401C37 202.401 29.8 160.401 13.8 161.601z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M20.6 160.001C20.6 160.001 20.4 158.201 22.2 159.001C24 159.801 48.6 163.201 72.2 195.601C72.2 195.601 36.6 158.801 20.6 160.001z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M28.225 157.972C28.225 157.972 27.788 156.214 29.678 156.768C31.568 157.322 52.002 155.423 90.099 189.599C90.099 189.599 43.924 154.656 28.225 157.972z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M38.625 153.572C38.625 153.572 38.188 151.814 40.078 152.368C41.968 152.922 76.802 157.423 128.499 192.399C128.499 192.399 54.324 150.256 38.625 153.572z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-1.8 142.001C-1.8 142.001 -2 140.201 -0.2 141.001C1.6 141.801 55 144.401 85.4 171.201C85.4 171.201 50.499 146.426 -1.8 142.001z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-11.8 146.001C-11.8 146.001 -12 144.201 -10.2 145.001C-8.4 145.801 16.2 149.201 39.8 181.601C39.8 181.601 4.2 144.801 -11.8 146.001z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M49.503 148.962C49.503 148.962 48.938 147.241 50.864 147.655C52.79 148.068 87.86 150.004 141.981 181.098C141.981 181.098 64.317 146.704 49.503 148.962z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M57.903 146.562C57.903 146.562 57.338 144.841 59.264 145.255C61.19 145.668 96.26 147.604 150.381 178.698C150.381 178.698 73.317 143.904 57.903 146.562z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M67.503 141.562C67.503 141.562 66.938 139.841 68.864 140.255C70.79 140.668 113.86 145.004 203.582 179.298C203.582 179.298 82.917 138.904 67.503 141.562z"} + , + {"fill": "#000000", + "path":"M-43.8 148.401C-43.8 148.401 -38.6 148.001 -39.8 149.601C-41 151.201 -43.4 150.401 -43.4 150.401L-43.8 148.401z"} + , + {"fill": "#000000", + "path":"M-13 162.401C-13 162.401 -7.8 162.001 -9 163.601C-10.2 165.201 -12.6 164.401 -12.6 164.401L-13 162.401z"} + , + {"fill": "#000000", + "path":"M-21.8 162.001C-21.8 162.001 -16.6 161.601 -17.8 163.201C-19 164.801 -21.4 164.001 -21.4 164.001L-21.8 162.001z"} + , + {"fill": "#000000", + "path":"M-117.169 150.182C-117.169 150.182 -112.124 151.505 -113.782 152.624C-115.439 153.744 -117.446 152.202 -117.446 152.202L-117.169 150.182z"} + , + {"fill": "#000000", + "path":"M-115.169 140.582C-115.169 140.582 -110.124 141.905 -111.782 143.024C-113.439 144.144 -115.446 142.602 -115.446 142.602L-115.169 140.582z"} + , + {"fill": "#000000", + "path":"M-122.369 136.182C-122.369 136.182 -117.324 137.505 -118.982 138.624C-120.639 139.744 -122.646 138.202 -122.646 138.202L-122.369 136.182z"} + , + {"fill": "#cccccc", + "path":"M-42.6 211.201C-42.6 211.201 -44.2 211.201 -48.2 213.201C-50.2 213.201 -61.4 216.801 -67 226.801C-67 226.801 -54.6 217.201 -42.6 211.201z"} + , + {"fill": "#cccccc", + "path":"M45.116 303.847C45.257 304.105 45.312 304.525 45.604 304.542C46.262 304.582 47.495 304.883 47.37 304.247C46.522 299.941 45.648 295.004 41.515 293.197C40.876 292.918 39.434 293.331 39.36 294.215C39.233 295.739 39.116 297.088 39.425 298.554C39.725 299.975 41.883 299.985 42.8 298.601C43.736 300.273 44.168 302.116 45.116 303.847z"} + , + {"fill": "#cccccc", + "path":"M34.038 308.581C34.786 309.994 34.659 311.853 36.074 312.416C36.814 312.71 38.664 311.735 38.246 310.661C37.444 308.6 37.056 306.361 35.667 304.55C35.467 304.288 35.707 303.755 35.547 303.427C34.953 302.207 33.808 301.472 32.4 301.801C31.285 304.004 32.433 306.133 33.955 307.842C34.091 307.994 33.925 308.37 34.038 308.581z"} + , + {"fill": "#cccccc", + "path":"M-5.564 303.391C-5.672 303.014 -5.71 302.551 -5.545 302.23C-5.014 301.197 -4.221 300.075 -4.558 299.053C-4.906 297.997 -6.022 298.179 -6.672 298.748C-7.807 299.742 -7.856 301.568 -8.547 302.927C-8.743 303.313 -8.692 303.886 -9.133 304.277C-9.607 304.698 -10.047 306.222 -9.951 306.793C-9.898 307.106 -10.081 317.014 -9.859 316.751C-9.24 316.018 -6.19 306.284 -6.121 305.392C-6.064 304.661 -5.332 304.196 -5.564 303.391z"} + , + {"fill": "#cccccc", + "path":"M-31.202 296.599C-28.568 294.1 -25.778 291.139 -26.22 287.427C-26.336 286.451 -28.111 286.978 -28.298 287.824C-29.1 291.449 -31.139 294.11 -33.707 296.502C-35.903 298.549 -37.765 304.893 -38 305.401C-34.303 300.145 -32.046 297.399 -31.202 296.599z"} + , + {"fill": "#cccccc", + "path":"M-44.776 290.635C-44.253 290.265 -44.555 289.774 -44.338 289.442C-43.385 287.984 -42.084 286.738 -42.066 285C-42.063 284.723 -42.441 284.414 -42.776 284.638C-43.053 284.822 -43.395 284.952 -43.503 285.082C-45.533 287.531 -46.933 290.202 -48.376 293.014C-48.559 293.371 -49.703 297.862 -49.39 297.973C-49.151 298.058 -47.431 293.877 -47.221 293.763C-45.958 293.077 -45.946 291.462 -44.776 290.635z"} + , + {"fill": "#cccccc", + "path":"M-28.043 310.179C-27.599 309.31 -26.023 308.108 -26.136 307.219C-26.254 306.291 -25.786 304.848 -26.698 305.536C-27.955 306.484 -31.404 307.833 -31.674 313.641C-31.7 314.212 -28.726 311.519 -28.043 310.179z"} + , + {"fill": "#cccccc", + "path":"M-13.6 293.001C-13.2 292.333 -12.492 292.806 -12.033 292.543C-11.385 292.171 -10.774 291.613 -10.482 290.964C-9.512 288.815 -7.743 286.995 -7.6 284.601C-9.091 283.196 -9.77 285.236 -10.4 286.201C-11.723 284.554 -12.722 286.428 -14.022 286.947C-14.092 286.975 -14.305 286.628 -14.38 286.655C-15.557 287.095 -16.237 288.176 -17.235 288.957C-17.406 289.091 -17.811 288.911 -17.958 289.047C-18.61 289.65 -19.583 289.975 -19.863 290.657C-20.973 293.364 -24.113 295.459 -26 303.001C-25.619 303.91 -21.488 296.359 -21.001 295.661C-20.165 294.465 -20.047 297.322 -18.771 296.656C-18.72 296.629 -18.534 296.867 -18.4 297.001C-18.206 296.721 -17.988 296.492 -17.6 296.601C-17.6 296.201 -17.734 295.645 -17.533 295.486C-16.296 294.509 -16.38 293.441 -15.6 292.201C-15.142 292.99 -14.081 292.271 -13.6 293.001z"} + , + {"fill": "#cccccc", + "path":"M46.2 347.401C46.2 347.401 53.6 327.001 49.2 315.801C49.2 315.801 60.6 337.401 56 348.601C56 348.601 55.6 338.201 51.6 333.201C51.6 333.201 47.6 346.001 46.2 347.401z"} + , + {"fill": "#cccccc", + "path":"M31.4 344.801C31.4 344.801 36.8 336.001 28.8 317.601C28.8 317.601 28 338.001 21.2 349.001C21.2 349.001 35.4 328.801 31.4 344.801z"} + , + {"fill": "#cccccc", + "path":"M21.4 342.801C21.4 342.801 21.2 322.801 21.6 319.801C21.6 319.801 17.8 336.401 7.6 346.001C7.6 346.001 22 334.001 21.4 342.801z"} + , + {"fill": "#cccccc", + "path":"M11.8 310.801C11.8 310.801 17.8 324.401 7.8 342.801C7.8 342.801 14.2 330.601 9.4 323.601C9.4 323.601 12 320.201 11.8 310.801z"} + , + {"fill": "#cccccc", + "path":"M-7.4 342.401C-7.4 342.401 -8.4 326.801 -6.6 324.601C-6.6 324.601 -6.4 318.201 -6.8 317.201C-6.8 317.201 -2.8 311.001 -2.6 318.401C-2.6 318.401 -1.2 326.201 1.6 330.801C1.6 330.801 5.2 336.201 5 342.601C5 342.601 -5 312.401 -7.4 342.401z"} + , + {"fill": "#cccccc", + "path":"M-11 314.801C-11 314.801 -17.6 325.601 -19.4 344.601C-19.4 344.601 -20.8 338.401 -17 324.001C-17 324.001 -12.8 308.601 -11 314.801z"} + , + {"fill": "#cccccc", + "path":"M-32.8 334.601C-32.8 334.601 -27.8 329.201 -26.4 324.201C-26.4 324.201 -22.8 308.401 -29.2 317.001C-29.2 317.001 -29 325.001 -37.2 332.401C-37.2 332.401 -32.4 330.001 -32.8 334.601z"} + , + {"fill": "#cccccc", + "path":"M-38.6 329.601C-38.6 329.601 -35.2 312.201 -34.4 311.401C-34.4 311.401 -32.6 308.001 -35.4 311.201C-35.4 311.201 -44.2 330.401 -48.2 337.001C-48.2 337.001 -40.2 327.801 -38.6 329.601z"} + , + {"fill": "#cccccc", + "path":"M-44.4 313.001C-44.4 313.001 -32.8 290.601 -54.6 316.401C-54.6 316.401 -43.6 306.601 -44.4 313.001z"} + , + {"fill": "#cccccc", + "path":"M-59.8 298.401C-59.8 298.401 -55 279.601 -52.4 279.801C-52.4 279.801 -44.2 270.801 -50.8 281.401C-50.8 281.401 -56.8 291.001 -56.2 300.801C-56.2 300.801 -56.8 291.201 -59.8 298.401z"} + , + {"fill": "#cccccc", + "path":"M270.5 287C270.5 287 258.5 277 256 273.5C256 273.5 269.5 292 269.5 299C269.5 299 272 291.5 270.5 287z"} + , + {"fill": "#cccccc", + "path":"M276 265C276 265 255 250 251.5 242.5C251.5 242.5 278 272 278 276.5C278 276.5 278.5 267.5 276 265z"} + , + {"fill": "#cccccc", + "path":"M293 111C293 111 281 103 279.5 105C279.5 105 290 111.5 292.5 120C292.5 120 291 111 293 111z"} + , + {"fill": "#cccccc", + "path":"M301.5 191.5L284 179.5C284 179.5 303 196.5 303.5 200.5L301.5 191.5z"} + , + {"stroke":"#000000", + "path":"M-89.25 169L-67.25 173.75"} + , + {"stroke":"#000000", + "path":"M-39 331C-39 331 -39.5 327.5 -48.5 338"} + , + {"stroke":"#000000", + "path":"M-33.5 336C-33.5 336 -31.5 329.5 -38 334"} + , + {"stroke":"#000000", + "path":"M20.5 344.5C20.5 344.5 22 333.5 10.5 346.5"} +]; \ No newline at end of file diff --git a/examples/quick/canvas/tiger/tiger.qml b/examples/quick/canvas/tiger/tiger.qml new file mode 100644 index 0000000000..2eb1bb2106 --- /dev/null +++ b/examples/quick/canvas/tiger/tiger.qml @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../contents" +import "tiger.js" as Tiger +Item { + id:container + width:360 + height:600 + + Column { + spacing:5 + anchors.fill:parent + Text { font.pointSize:25; text:"Tiger with SVG path"; anchors.horizontalCenter:parent.horizontalCenter} + + Canvas { + id:canvas + width:360 + height:360 + smooth:true + renderTarget:Canvas.FramebufferObject + renderStrategy: Canvas.Cooperative + property string strokeStyle:"steelblue" + property string fillStyle:"yellow" + property bool fill:true + property bool stroke:true + property real alpha:alphaCtrl.value + property real scaleX : scaleXCtrl.value + property real scaleY : scaleYCtrl.value + property real rotate : rotateCtrl.value + property int frame:0 + + onFillChanged: requestPaint(); + onStrokeChanged: requestPaint(); + onAlphaChanged: requestPaint(); + onScaleXChanged: requestPaint(); + onScaleYChanged: requestPaint(); + onRotateChanged: requestPaint(); + + onPainted : { + canvas.frame++; + if (canvas.frame < Tiger.tiger.length) + requestPaint(); + } + onPaint: { + var ctx = canvas.getContext('2d'); + ctx.save(); + ctx.clearRect(0, 0, canvas.width, canvas.height); + ctx.globalAlpha = canvas.alpha; + ctx.scale(canvas.scaleX, canvas.scaleY); + ctx.rotate(canvas.rotate); + ctx.globalCompositeOperation = "source-over"; + ctx.translate(canvas.width/2, canvas.height/2); + ctx.strokeStyle = Qt.rgba(.3, .3, .3,1); + ctx.lineWidth = 1; + + + for (var i = 0; i < canvas.frame && i < Tiger.tiger.length; i++) { + if (Tiger.tiger[i].width != undefined) + ctx.lineWidth = Tiger.tiger[i].width; + + if (Tiger.tiger[i].path != undefined) + ctx.path = Tiger.tiger[i].path; + + if (Tiger.tiger[i].fill != undefined) { + ctx.fillStyle = Tiger.tiger[i].fill; + ctx.fill(); + } + + if (Tiger.tiger[i].stroke != undefined) { + ctx.strokeStyle = Tiger.tiger[i].stroke; + ctx.stroke(); + } + } + ctx.restore(); + } + } + Rectangle { + id:controls + width:360 + height:160 + Column { + spacing:3 + Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:0.5; name:"ScaleX"} + Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:0.5; name:"ScaleY"} + Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"} + Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} + } + } + } +} diff --git a/examples/quick/canvas/twitterfriends/TwitterUser.qml b/examples/quick/canvas/twitterfriends/TwitterUser.qml new file mode 100644 index 0000000000..8b906216ef --- /dev/null +++ b/examples/quick/canvas/twitterfriends/TwitterUser.qml @@ -0,0 +1,294 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id:twitterUser + property variant friends : []; + property string name : ""; + property string twitterId : ""; + property string image : ""; + property string url : ""; + property string desc : ""; + width : 0; + height : 0; + property int posX:0; + property int posY:0; + property bool hasFocus : false; + property variant canvas; + property variant manager; + property variant linkColor; + property bool selected : false; + + Rectangle { + id:twitterStatus + x:twitterUser.width + y:twitterUser.height + width:250 + height:60 + opacity: 0 + border.color:"steelblue" + border.width:3 + Column { + spacing:2 + Text {color:"steelblue"; font.pointSize:15; width:250; height:30; text:twitterUser.name; wrapMode: Text.WrapAnywhere} + Text {color:"steelblue"; font.pointSize:8; width:250; height:30; text:twitterUser.url; wrapMode: Text.WrapAnywhere} + } + } + + function moved() { + twitterUser.posX = twitterUser.x; + twitterUser.posY = twitterUser.y; + twitterUser.canvas.requestPaint(); + } + + onXChanged: moved(); + onYChanged: moved(); + + MouseArea { + anchors.fill:parent + drag.target : twitterUser + drag.axis : Drag.XandYAxis + + onClicked: { + if (!twitterUser.selected) { + twitterUser.selected = true; + twitterStatus.opacity = 1; + twitterStatus.visible = true; + } else { + twitterUser.selected = false; + twitterStatus.opacity = 0; + } + } + + onDoubleClicked : { + twitterStatus.opacity = 0; + twitterUser.selected = false; + twitterUser.hasFocus = true; + twitterUser.canvas.twitterName = twitterUser.name; + twitterUser.canvas.twitterId = twitterUser.twitterId; + twitterUser.canvas.loading = true; + twitterUser.createFriends(); + } + } + + function show(ctx, layoutChanged) { + var w = canvas.width; + var h = canvas.height; + if (twitterUser.hasFocus) { + twitterUser.width = 60 + twitterUser.height = 60 + twitterUser.posX = w/2; + twitterUser.posY = h/2; + } else { + twitterUser.width = 40 + twitterUser.height = 40 + } + + + if (twitterUser.hasFocus) { + if (layoutChanged) + twitterUser.layoutFriends(); + twitterUser.linkFriends(ctx); + twitterUser.showFriends(ctx); + ctx.shadowOffsetX = 5; + ctx.shadowOffsetY = 5; + ctx.shadowBlur = 7; + ctx.shadowColor = "blue"; + ctx.globalAlpha = 1; + } else { + ctx.shadowOffsetX = 5; + ctx.shadowOffsetY = 5; + ctx.shadowBlur = 7; + ctx.shadowColor = twitterUser.linkColor; + ctx.globalAlpha = 0.6; + } + + if (twitterUser.canvas.isImageLoaded(twitterUser.image)) { + ctx.drawImage(twitterUser.image, twitterUser.posX, twitterUser.posY, twitterUser.width, twitterUser.height); + } +// ctx.font = "15px"; +// var nameSize = ctx.measureText(twitterUser.name).width; +// ctx.fillText(twitterUser.name, twitterUser.posX + nameSize/2 - twitterUser.width/2, twitterUser.posY + twitterUser.height/2 + 10); + } + function dump() { + console.log("name:" + twitterUser.name + + " x:" + twitterUser.posX + + " y:" + twitterUser.posY + + " width:" + twitterUser.width + + " height:" + twitterUser.height + + " id:" + twitterUser.twitterId + + " image:" + twitterUser.image + + " url:" + twitterUser.url + "\n" + twitterUser.desc); + } + + function layoutFriends() { + var w = canvas.width; + var h = canvas.height; + for (var i=0; i < twitterUser.friends.length; i++) { + var friend = manager.getById(twitterUser.friends[i]); + if (friend) { + friend.x = Math.random() *w; + friend.y = Math.random() *h; + } + } + } + + function showFriends(ctx) { + var w = canvas.width; + var h = canvas.height; + for (var i=0; i < twitterUser.friends.length && i < 15; i++) { + var friend = manager.getById(twitterUser.friends[i]); + if (friend && twitterUser.canvas.isImageLoaded(friend.image)) { + friend.hasFocus = false; + friend.show(ctx, false); + } + } + } + + function linkFriends(ctx) { + var w = canvas.width; + var h = canvas.height; + for (var i=0; i < twitterUser.friends.length && i < 15; i++) { + var friend = manager.getById(twitterUser.friends[i]); + if (friend && twitterUser.canvas.isImageLoaded(friend.image)) { + if (!friend.linkColor) + friend.linkColor = Qt.rgba( ((Math.random() * 200) +55)/255 + , ((Math.random() * 200) +55)/255 + , ((Math.random() * 200) +55)/255, 0.8); + ctx.strokeStyle = friend.linkColor; + ctx.lineWidth = 8; + ctx.beginPath(); + ctx.moveTo(twitterUser.posX + twitterUser.width/2, twitterUser.posY + twitterUser.height/2); + ctx.lineTo(friend.x + friend.width/2, friend.y + friend.height/2); + ctx.stroke(); + } + } + } + + + function create(url) { + var x = new XMLHttpRequest; + x.open("GET", url); + + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + var user = eval('(' + x.responseText +')')[0]; + twitterUser.name = user.name; + twitterUser.twitterId = user.id; + twitterUser.image = user.profile_image_url; + twitterUser.canvas.loadImage(twitterUser.image); + twitterUser.url = user.url; + twitterUser.desc = user.description; + twitterUser.createFriends(); + } + } + x.send(); + } + + function createByName(name) { + if (twitterUser.name === "" && twitterUser.twitterId === "") { + twitterUser.name = name; + var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&screen_name=" + name; + twitterUser.create(userUrl); + } + } + + function createById(id) { + if (twitterUser.name === "" && twitterUser.twitterId === "") { + twitterUser.twitterId = id; + var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&user_id=" + id; + twitterUser.create(userUrl); + } + } + + function createFriends() { + if (twitterUser.friends.length === 0) { + var x = new XMLHttpRequest; + var friendsUrl = "https://api.twitter.com/1/friends/ids.json?cursor=-1&stringify_ids=true&user_id=" + twitterUser.twitterId; + x.open("GET", friendsUrl); + + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + twitterUser.friends = eval('(' + x.responseText +')').ids; + var doRequest = false; + var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&user_id="; + + for (var i=0; i + + view.qml + + + diff --git a/examples/quick/modelviews/abstractitemmodel/main.cpp b/examples/quick/modelviews/abstractitemmodel/main.cpp new file mode 100644 index 0000000000..f5930ce840 --- /dev/null +++ b/examples/quick/modelviews/abstractitemmodel/main.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "model.h" + +#include +#include +#include +#include +#include +#include + +//![0] +int main(int argc, char ** argv) +{ + QGuiApplication app(argc, argv); + + AnimalModel model; + model.addAnimal(Animal("Wolf", "Medium")); + model.addAnimal(Animal("Polar bear", "Large")); + model.addAnimal(Animal("Quoll", "Small")); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + QQmlContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", &model); +//![0] + + view.setSource(QUrl("qrc:view.qml")); + view.show(); + + return app.exec(); +} + diff --git a/examples/quick/modelviews/abstractitemmodel/model.cpp b/examples/quick/modelviews/abstractitemmodel/model.cpp new file mode 100644 index 0000000000..8f7649c0d4 --- /dev/null +++ b/examples/quick/modelviews/abstractitemmodel/model.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "model.h" + +Animal::Animal(const QString &type, const QString &size) + : m_type(type), m_size(size) +{ +} + +QString Animal::type() const +{ + return m_type; +} + +QString Animal::size() const +{ + return m_size; +} + +//![0] +AnimalModel::AnimalModel(QObject *parent) + : QAbstractListModel(parent) +{ + QHash roles; + roles[TypeRole] = "type"; + roles[SizeRole] = "size"; + setRoleNames(roles); +} +//![0] + +void AnimalModel::addAnimal(const Animal &animal) +{ + beginInsertRows(QModelIndex(), rowCount(), rowCount()); + m_animals << animal; + endInsertRows(); +} + +int AnimalModel::rowCount(const QModelIndex & parent) const { + return m_animals.count(); +} + +QVariant AnimalModel::data(const QModelIndex & index, int role) const { + if (index.row() < 0 || index.row() >= m_animals.count()) + return QVariant(); + + const Animal &animal = m_animals[index.row()]; + if (role == TypeRole) + return animal.type(); + else if (role == SizeRole) + return animal.size(); + return QVariant(); +} + diff --git a/examples/quick/modelviews/abstractitemmodel/model.h b/examples/quick/modelviews/abstractitemmodel/model.h new file mode 100644 index 0000000000..1378c4487e --- /dev/null +++ b/examples/quick/modelviews/abstractitemmodel/model.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +//![0] +class Animal +{ +public: + Animal(const QString &type, const QString &size); +//![0] + + QString type() const; + QString size() const; + +private: + QString m_type; + QString m_size; +//![1] +}; + +class AnimalModel : public QAbstractListModel +{ + Q_OBJECT +public: + enum AnimalRoles { + TypeRole = Qt::UserRole + 1, + SizeRole + }; + + AnimalModel(QObject *parent = 0); +//![1] + + void addAnimal(const Animal &animal); + + int rowCount(const QModelIndex & parent = QModelIndex()) const; + + QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; + +private: + QList m_animals; +//![2] +}; +//![2] + + diff --git a/examples/quick/modelviews/abstractitemmodel/view.qml b/examples/quick/modelviews/abstractitemmodel/view.qml new file mode 100644 index 0000000000..64f5871d4b --- /dev/null +++ b/examples/quick/modelviews/abstractitemmodel/view.qml @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +//![0] +ListView { + width: 200; height: 250 + + model: myModel + delegate: Text { text: "Animal: " + type + ", " + size } +} +//![0] + diff --git a/examples/quick/modelviews/gridview/gridview-example.qml b/examples/quick/modelviews/gridview/gridview-example.qml new file mode 100644 index 0000000000..ea3bb5cec9 --- /dev/null +++ b/examples/quick/modelviews/gridview/gridview-example.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 300; height: 400 + color: "white" + + ListModel { + id: appModel + ListElement { name: "Music"; icon: "pics/AudioPlayer_48.png" } + ListElement { name: "Movies"; icon: "pics/VideoPlayer_48.png" } + ListElement { name: "Camera"; icon: "pics/Camera_48.png" } + ListElement { name: "Calendar"; icon: "pics/DateBook_48.png" } + ListElement { name: "Messaging"; icon: "pics/EMail_48.png" } + ListElement { name: "Todo List"; icon: "pics/TodoList_48.png" } + ListElement { name: "Contacts"; icon: "pics/AddressBook_48.png" } + } + + Component { + id: appDelegate + + Item { + width: 100; height: 100 + + Image { + id: myIcon + y: 20; anchors.horizontalCenter: parent.horizontalCenter + source: icon + } + Text { + anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter } + text: name + } + MouseArea { + anchors.fill: parent + onClicked: parent.GridView.view.currentIndex = index + } + } + } + + Component { + id: appHighlight + Rectangle { width: 80; height: 80; color: "lightsteelblue" } + } + + GridView { + anchors.fill: parent + cellWidth: 100; cellHeight: 100 + highlight: appHighlight + focus: true + model: appModel + delegate: appDelegate + } +} diff --git a/examples/quick/modelviews/gridview/pics/AddressBook_48.png b/examples/quick/modelviews/gridview/pics/AddressBook_48.png new file mode 100644 index 0000000000..1ab7c8eec1 Binary files /dev/null and b/examples/quick/modelviews/gridview/pics/AddressBook_48.png differ diff --git a/examples/quick/modelviews/gridview/pics/AudioPlayer_48.png b/examples/quick/modelviews/gridview/pics/AudioPlayer_48.png new file mode 100644 index 0000000000..f4b8689f87 Binary files /dev/null and b/examples/quick/modelviews/gridview/pics/AudioPlayer_48.png differ diff --git a/examples/quick/modelviews/gridview/pics/Camera_48.png b/examples/quick/modelviews/gridview/pics/Camera_48.png new file mode 100644 index 0000000000..c76b524945 Binary files /dev/null and b/examples/quick/modelviews/gridview/pics/Camera_48.png differ diff --git a/examples/quick/modelviews/gridview/pics/DateBook_48.png b/examples/quick/modelviews/gridview/pics/DateBook_48.png new file mode 100644 index 0000000000..58f5787fb8 Binary files /dev/null and b/examples/quick/modelviews/gridview/pics/DateBook_48.png differ diff --git a/examples/quick/modelviews/gridview/pics/EMail_48.png b/examples/quick/modelviews/gridview/pics/EMail_48.png new file mode 100644 index 0000000000..d6d84a61be Binary files /dev/null and b/examples/quick/modelviews/gridview/pics/EMail_48.png differ diff --git a/examples/quick/modelviews/gridview/pics/TodoList_48.png b/examples/quick/modelviews/gridview/pics/TodoList_48.png new file mode 100644 index 0000000000..0988448d9b Binary files /dev/null and b/examples/quick/modelviews/gridview/pics/TodoList_48.png differ diff --git a/examples/quick/modelviews/gridview/pics/VideoPlayer_48.png b/examples/quick/modelviews/gridview/pics/VideoPlayer_48.png new file mode 100644 index 0000000000..52638c50a7 Binary files /dev/null and b/examples/quick/modelviews/gridview/pics/VideoPlayer_48.png differ diff --git a/examples/quick/modelviews/listview/content/PetsModel.qml b/examples/quick/modelviews/listview/content/PetsModel.qml new file mode 100644 index 0000000000..4f2087d95e --- /dev/null +++ b/examples/quick/modelviews/listview/content/PetsModel.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListModel { + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Schrödinger" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" + } +} diff --git a/examples/quick/modelviews/listview/content/PressAndHoldButton.qml b/examples/quick/modelviews/listview/content/PressAndHoldButton.qml new file mode 100644 index 0000000000..b20d8f64f1 --- /dev/null +++ b/examples/quick/modelviews/listview/content/PressAndHoldButton.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + id: container + + property int repeatDelay: 300 + property int repeatDuration: 75 + property bool pressed: false + + signal clicked + + scale: pressed ? 0.9 : 1 + + function release() { + autoRepeatClicks.stop() + container.pressed = false + } + + SequentialAnimation on pressed { + id: autoRepeatClicks + running: false + + PropertyAction { target: container; property: "pressed"; value: true } + ScriptAction { script: container.clicked() } + PauseAnimation { duration: repeatDelay } + + SequentialAnimation { + loops: Animation.Infinite + ScriptAction { script: container.clicked() } + PauseAnimation { duration: repeatDuration } + } + } + + MouseArea { + anchors.fill: parent + + onPressed: autoRepeatClicks.start() + onReleased: container.release() + onCanceled: container.release() + } +} + diff --git a/examples/quick/modelviews/listview/content/RecipesModel.qml b/examples/quick/modelviews/listview/content/RecipesModel.qml new file mode 100644 index 0000000000..86210ba436 --- /dev/null +++ b/examples/quick/modelviews/listview/content/RecipesModel.qml @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListModel { + ListElement { + title: "Pancakes" + picture: "content/pics/pancakes.jpg" + ingredients: " +
    +
  • 1 cup (150g) self-raising flour +
  • 1 tbs caster sugar +
  • 3/4 cup (185ml) milk +
  • 1 egg +
+ " + method: " +
    +
  1. Sift flour and sugar together into a bowl. Add a pinch of salt. +
  2. Beat milk and egg together, then add to dry ingredients. Beat until smooth. +
  3. Pour mixture into a pan on medium heat and cook until bubbles appear on the surface. +
  4. Turn over and cook other side until golden. +
+ " + } + ListElement { + title: "Fruit Salad" + picture: "content/pics/fruit-salad.jpg" + ingredients: "* Seasonal Fruit" + method: "* Chop fruit and place in a bowl." + } + ListElement { + title: "Vegetable Soup" + picture: "content/pics/vegetable-soup.jpg" + ingredients: " +
    +
  • 1 onion +
  • 1 turnip +
  • 1 potato +
  • 1 carrot +
  • 1 head of celery +
  • 1 1/2 litres of water +
+ " + method: " +
    +
  1. Chop vegetables. +
  2. Boil in water until vegetables soften. +
  3. Season with salt and pepper to taste. +
+ " + } + ListElement { + title: "Hamburger" + picture: "content/pics/hamburger.jpg" + ingredients: " +
    +
  • 500g minced beef +
  • Seasoning +
  • lettuce, tomato, onion, cheese +
  • 1 hamburger bun for each burger +
+ " + method: " +
    +
  1. Mix the beef, together with seasoning, in a food processor. +
  2. Shape the beef into burgers. +
  3. Grill the burgers for about 5 mins on each side (until cooked through) +
  4. Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion. +
+ " + } + ListElement { + title: "Lemonade" + picture: "content/pics/lemonade.jpg" + ingredients: " +
    +
  • 1 cup Lemon Juice +
  • 1 cup Sugar +
  • 6 Cups of Water (2 cups warm water, 4 cups cold water) +
+ " + method: " +
    +
  1. Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves. +
  2. Pour in lemon juice, stir again, and add 4 cups of cold water. +
  3. Chill or serve over ice cubes. +
+ " + } +} diff --git a/examples/quick/modelviews/listview/content/TextButton.qml b/examples/quick/modelviews/listview/content/TextButton.qml new file mode 100644 index 0000000000..980ee21553 --- /dev/null +++ b/examples/quick/modelviews/listview/content/TextButton.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property alias text: label.text + + signal clicked + + width: label.width + 20; height: label.height + 6 + smooth: true + radius: 10 + + gradient: Gradient { + GradientStop { id: gradientStop; position: 0.0; color: palette.light } + GradientStop { position: 1.0; color: palette.button } + } + + SystemPalette { id: palette } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { container.clicked() } + } + + Text { + id: label + anchors.centerIn: parent + } + + states: State { + name: "pressed" + when: mouseArea.pressed + PropertyChanges { target: gradientStop; color: palette.dark } + } +} + diff --git a/examples/quick/modelviews/listview/content/ToggleButton.qml b/examples/quick/modelviews/listview/content/ToggleButton.qml new file mode 100644 index 0000000000..52f4988f03 --- /dev/null +++ b/examples/quick/modelviews/listview/content/ToggleButton.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: root + property alias label: text.text + property bool active: false + signal toggled + width: 149 + height: 30 + radius: 3 + color: active ? "green" : "lightgray" + border.width: 1 + Text { id: text; anchors.centerIn: parent; font.pixelSize: 14 } + MouseArea { + anchors.fill: parent + onClicked: { active = !active; root.toggled() } + } +} diff --git a/examples/quick/modelviews/listview/content/pics/arrow-down.png b/examples/quick/modelviews/listview/content/pics/arrow-down.png new file mode 100644 index 0000000000..29d1d4439a Binary files /dev/null and b/examples/quick/modelviews/listview/content/pics/arrow-down.png differ diff --git a/examples/quick/modelviews/listview/content/pics/arrow-up.png b/examples/quick/modelviews/listview/content/pics/arrow-up.png new file mode 100644 index 0000000000..e437312217 Binary files /dev/null and b/examples/quick/modelviews/listview/content/pics/arrow-up.png differ diff --git a/examples/quick/modelviews/listview/content/pics/fruit-salad.jpg b/examples/quick/modelviews/listview/content/pics/fruit-salad.jpg new file mode 100644 index 0000000000..da5a6b10a2 Binary files /dev/null and b/examples/quick/modelviews/listview/content/pics/fruit-salad.jpg differ diff --git a/examples/quick/modelviews/listview/content/pics/hamburger.jpg b/examples/quick/modelviews/listview/content/pics/hamburger.jpg new file mode 100644 index 0000000000..d0a15be1bf Binary files /dev/null and b/examples/quick/modelviews/listview/content/pics/hamburger.jpg differ diff --git a/examples/quick/modelviews/listview/content/pics/lemonade.jpg b/examples/quick/modelviews/listview/content/pics/lemonade.jpg new file mode 100644 index 0000000000..db445c9ac8 Binary files /dev/null and b/examples/quick/modelviews/listview/content/pics/lemonade.jpg differ diff --git a/examples/quick/modelviews/listview/content/pics/list-delete.png b/examples/quick/modelviews/listview/content/pics/list-delete.png new file mode 100644 index 0000000000..df2a147d24 Binary files /dev/null and b/examples/quick/modelviews/listview/content/pics/list-delete.png differ diff --git a/examples/quick/modelviews/listview/content/pics/minus-sign.png b/examples/quick/modelviews/listview/content/pics/minus-sign.png new file mode 100644 index 0000000000..d6f233d739 Binary files /dev/null and b/examples/quick/modelviews/listview/content/pics/minus-sign.png differ diff --git a/examples/quick/modelviews/listview/content/pics/moreDown.png b/examples/quick/modelviews/listview/content/pics/moreDown.png new file mode 100644 index 0000000000..31a35d5c20 Binary files /dev/null and b/examples/quick/modelviews/listview/content/pics/moreDown.png differ diff --git a/examples/quick/modelviews/listview/content/pics/moreUp.png b/examples/quick/modelviews/listview/content/pics/moreUp.png new file mode 100644 index 0000000000..fefb9c9098 Binary files /dev/null and b/examples/quick/modelviews/listview/content/pics/moreUp.png differ diff --git a/examples/quick/modelviews/listview/content/pics/pancakes.jpg b/examples/quick/modelviews/listview/content/pics/pancakes.jpg new file mode 100644 index 0000000000..60c439638e Binary files /dev/null and b/examples/quick/modelviews/listview/content/pics/pancakes.jpg differ diff --git a/examples/quick/modelviews/listview/content/pics/plus-sign.png b/examples/quick/modelviews/listview/content/pics/plus-sign.png new file mode 100644 index 0000000000..40df1134f8 Binary files /dev/null and b/examples/quick/modelviews/listview/content/pics/plus-sign.png differ diff --git a/examples/quick/modelviews/listview/content/pics/vegetable-soup.jpg b/examples/quick/modelviews/listview/content/pics/vegetable-soup.jpg new file mode 100644 index 0000000000..9dce332041 Binary files /dev/null and b/examples/quick/modelviews/listview/content/pics/vegetable-soup.jpg differ diff --git a/examples/quick/modelviews/listview/dynamiclist.qml b/examples/quick/modelviews/listview/dynamiclist.qml new file mode 100644 index 0000000000..ee7c6329bc --- /dev/null +++ b/examples/quick/modelviews/listview/dynamiclist.qml @@ -0,0 +1,203 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import "content" + +// This example shows how items can be dynamically added to and removed from +// a ListModel, and how these list modifications can be animated. + +Rectangle { + id: container + width: 500; height: 400 + color: "#343434" + + // The model: + ListModel { + id: fruitModel + + ListElement { + name: "Apple"; cost: 2.45 + attributes: [ + ListElement { description: "Core" }, + ListElement { description: "Deciduous" } + ] + } + ListElement { + name: "Banana"; cost: 1.95 + attributes: [ + ListElement { description: "Tropical" }, + ListElement { description: "Seedless" } + ] + } + ListElement { + name: "Cumquat"; cost: 3.25 + attributes: [ + ListElement { description: "Citrus" } + ] + } + ListElement { + name: "Durian"; cost: 9.95 + attributes: [ + ListElement { description: "Tropical" }, + ListElement { description: "Smelly" } + ] + } + } + + // The delegate for each fruit in the model: + Component { + id: listDelegate + + Item { + id: delegateItem + width: listView.width; height: 55 + clip: true + + Row { + anchors.verticalCenter: parent.verticalCenter + spacing: 10 + + Column { + Image { + source: "content/pics/arrow-up.png" + MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index-1, 1) } + } + Image { source: "content/pics/arrow-down.png" + MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index+1, 1) } + } + } + + Column { + anchors.verticalCenter: parent.verticalCenter + + Text { + text: name + font.pixelSize: 15 + color: "white" + } + Row { + spacing: 5 + Repeater { + model: attributes + Text { text: description; color: "White" } + } + } + } + } + + Row { + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + spacing: 10 + + PressAndHoldButton { + anchors.verticalCenter: parent.verticalCenter + source: "content/pics/plus-sign.png" + onClicked: fruitModel.setProperty(index, "cost", cost + 0.25) + } + + Text { + id: costText + anchors.verticalCenter: parent.verticalCenter + text: '$' + Number(cost).toFixed(2) + font.pixelSize: 15 + color: "white" + font.bold: true + } + + PressAndHoldButton { + anchors.verticalCenter: parent.verticalCenter + source: "content/pics/minus-sign.png" + onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost-0.25)) + } + + Image { + source: "content/pics/list-delete.png" + MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) } + } + } + + // Animate adding and removing of items: + + ListView.onAdd: SequentialAnimation { + PropertyAction { target: delegateItem; property: "height"; value: 0 } + NumberAnimation { target: delegateItem; property: "height"; to: 55; duration: 250; easing.type: Easing.InOutQuad } + } + + ListView.onRemove: SequentialAnimation { + PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: true } + NumberAnimation { target: delegateItem; property: "height"; to: 0; duration: 250; easing.type: Easing.InOutQuad } + + // Make sure delayRemove is set back to false so that the item can be destroyed + PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: false } + } + } + } + + // The view: + ListView { + id: listView + anchors.fill: parent; anchors.margins: 20 + model: fruitModel + delegate: listDelegate + } + + Row { + anchors { left: parent.left; bottom: parent.bottom; margins: 20 } + spacing: 10 + + TextButton { + text: "Add an item" + onClicked: { + fruitModel.append({ + "name": "Pizza Margarita", + "cost": 5.95, + "attributes": [{"description": "Cheese"}, {"description": "Tomato"}] + }) + } + } + + TextButton { + text: "Remove all items" + onClicked: fruitModel.clear() + } + } +} + diff --git a/examples/quick/modelviews/listview/expandingdelegates.qml b/examples/quick/modelviews/listview/expandingdelegates.qml new file mode 100644 index 0000000000..43a9662422 --- /dev/null +++ b/examples/quick/modelviews/listview/expandingdelegates.qml @@ -0,0 +1,202 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +// This example illustrates expanding a list item to show a more detailed view. + +Rectangle { + id: page + width: 400; height: 240 + color: "black" + + // Delegate for the recipes. This delegate has two modes: + // 1. List mode (default), which just shows the picture and title of the recipe. + // 2. Details mode, which also shows the ingredients and method. + Component { + id: recipeDelegate + + Item { + id: recipe + + // Create a property to contain the visibility of the details. + // We can bind multiple element's opacity to this one property, + // rather than having a "PropertyChanges" line for each element we + // want to fade. + property real detailsOpacity : 0 + + width: listView.width + height: 70 + + // A simple rounded rectangle for the background + Rectangle { + id: background + x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2 + color: "ivory" + border.color: "orange" + radius: 5 + } + + // This mouse region covers the entire delegate. + // When clicked it changes mode to 'Details'. If we are already + // in Details mode, then no change will happen. + MouseArea { + anchors.fill: parent + onClicked: recipe.state = 'Details'; + } + + // Lay out the page: picture, title and ingredients at the top, and method at the + // bottom. Note that elements that should not be visible in the list + // mode have their opacity set to recipe.detailsOpacity. + Row { + id: topLayout + x: 10; y: 10; height: recipeImage.height; width: parent.width + spacing: 10 + + Image { + id: recipeImage + width: 50; height: 50 + source: picture + } + + Column { + width: background.width - recipeImage.width - 20; height: recipeImage.height + spacing: 5 + + Text { + text: title + font.bold: true; font.pointSize: 16 + } + + Text { + text: "Ingredients" + font.pointSize: 12; font.bold: true + opacity: recipe.detailsOpacity + } + + Text { + text: ingredients + wrapMode: Text.WordWrap + width: parent.width + opacity: recipe.detailsOpacity + } + } + } + + Item { + id: details + x: 10; width: parent.width - 20 + anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 } + opacity: recipe.detailsOpacity + + Text { + id: methodTitle + anchors.top: parent.top + text: "Method" + font.pointSize: 12; font.bold: true + } + + Flickable { + id: flick + width: parent.width + anchors { top: methodTitle.bottom; bottom: parent.bottom } + contentHeight: methodText.height + clip: true + + Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width } + } + + Image { + anchors { right: flick.right; top: flick.top } + source: "content/pics/moreUp.png" + opacity: flick.atYBeginning ? 0 : 1 + } + + Image { + anchors { right: flick.right; bottom: flick.bottom } + source: "content/pics/moreDown.png" + opacity: flick.atYEnd ? 0 : 1 + } + } + + // A button to close the detailed view, i.e. set the state back to default (''). + TextButton { + y: 10 + anchors { right: background.right; rightMargin: 10 } + opacity: recipe.detailsOpacity + text: "Close" + + onClicked: recipe.state = ''; + } + + states: State { + name: "Details" + + PropertyChanges { target: background; color: "white" } + PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger + PropertyChanges { target: recipe; detailsOpacity: 1; x: 0 } // Make details visible + PropertyChanges { target: recipe; height: listView.height } // Fill the entire list area with the detailed view + + // Move the list so that this item is at the top. + PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y } + + // Disallow flicking while we're in detailed view + PropertyChanges { target: recipe.ListView.view; interactive: false } + } + + transitions: Transition { + // Make the state changes smooth + ParallelAnimation { + ColorAnimation { property: "color"; duration: 500 } + NumberAnimation { duration: 300; properties: "detailsOpacity,x,contentY,height,width" } + } + } + } + } + + // The actual list + ListView { + id: listView + anchors.fill: parent + model: RecipesModel {} + delegate: recipeDelegate + } +} diff --git a/examples/quick/modelviews/listview/highlight.qml b/examples/quick/modelviews/listview/highlight.qml new file mode 100644 index 0000000000..d8f76080e6 --- /dev/null +++ b/examples/quick/modelviews/listview/highlight.qml @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This example shows how to create your own highlight delegate for a ListView +// that uses a SpringAnimation to provide custom movement when the +// highlight bar is moved between items. + +import QtQuick 2.0 +import "content" + +Rectangle { + width: 200; height: 300 + + // Define a delegate component. A component will be + // instantiated for each visible item in the list. + Component { + id: petDelegate + Item { + id: wrapper + width: 200; height: 55 + Column { + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + } + // indent the item if it is the current item + states: State { + name: "Current" + when: wrapper.ListView.isCurrentItem + PropertyChanges { target: wrapper; x: 20 } + } + transitions: Transition { + NumberAnimation { properties: "x"; duration: 200 } + } + } + } + + // Define a highlight with customised movement between items. + Component { + id: highlightBar + Rectangle { + width: 200; height: 50 + color: "#FFFF88" + y: listView.currentItem.y; + Behavior on y { SpringAnimation { spring: 2; damping: 0.1 } } + } + } + + ListView { + id: listView + width: 200; height: parent.height + + model: PetsModel {} + delegate: petDelegate + focus: true + + // Set the highlight delegate. Note we must also set highlightFollowsCurrentItem + // to false so the highlight delegate can control how the highlight is moved. + highlight: highlightBar + highlightFollowsCurrentItem: false + } +} diff --git a/examples/quick/modelviews/listview/highlightranges.qml b/examples/quick/modelviews/listview/highlightranges.qml new file mode 100644 index 0000000000..a536ddcbb2 --- /dev/null +++ b/examples/quick/modelviews/listview/highlightranges.qml @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + id: root + property int current: 0 + width: 600; height: 300 + + // This example shows the same model in three different ListView items, + // with different highlight ranges. The highlight ranges are set by the + // preferredHighlightBegin and preferredHighlightEnd properties in ListView. + // + // The first ListView does not set a highlight range, so its currentItem + // can move freely within the visible area. If it moves outside the + // visible area, the view is automatically scrolled to keep the current + // item visible. + // + // The second ListView sets a highlight range which attempts to keep the + // current item within the the bounds of the range. However, + // items will not scroll beyond the beginning or end of the view, + // forcing the highlight to move outside the range at the ends. + // + // The third ListView sets the highlightRangeMode to StrictlyEnforceRange + // and sets a range smaller than the height of an item. This + // forces the current item to change when the view is flicked, + // since the highlight is unable to move. + // + // All ListViews bind their currentIndex to the root.current property. + // The first ListView sets root.current whenever its currentIndex changes + // due to keyboard interaction. + // Flicking the third ListView with the mouse also changes root.current. + + ListView { + id: list1 + width: 200; height: parent.height + model: PetsModel {} + delegate: petDelegate + + highlight: Rectangle { color: "lightsteelblue" } + currentIndex: root.current + onCurrentIndexChanged: root.current = currentIndex + focus: true + } + + ListView { + id: list2 + x: list1.width + width: 200; height: parent.height + model: PetsModel {} + delegate: petDelegate + + highlight: Rectangle { color: "yellow" } + currentIndex: root.current + preferredHighlightBegin: 80; preferredHighlightEnd: 220 + highlightRangeMode: ListView.ApplyRange + } + + ListView { + id: list3 + x: list1.width + list2.width + width: 200; height: parent.height + model: PetsModel {} + delegate: petDelegate + + highlight: Rectangle { color: "yellow" } + currentIndex: root.current + onCurrentIndexChanged: root.current = currentIndex + preferredHighlightBegin: 125; preferredHighlightEnd: 125 + highlightRangeMode: ListView.StrictlyEnforceRange + } + + // The delegate for each list + Component { + id: petDelegate + Column { + width: 200 + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + } + } +} diff --git a/examples/quick/modelviews/listview/sections.qml b/examples/quick/modelviews/listview/sections.qml new file mode 100644 index 0000000000..2e63a86bb6 --- /dev/null +++ b/examples/quick/modelviews/listview/sections.qml @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This example shows how a ListView can be separated into sections using +// the ListView.section attached property. + +import QtQuick 2.0 +import "content" + +Rectangle { + id: container + width: 300 + height: 360 + + ListModel { + id: animalsModel + ListElement { name: "Ant"; size: "Tiny" } + ListElement { name: "Flea"; size: "Tiny" } + ListElement { name: "Parrot"; size: "Small" } + ListElement { name: "Guinea pig"; size: "Small" } + ListElement { name: "Rat"; size: "Small" } + ListElement { name: "Butterfly"; size: "Small" } + ListElement { name: "Dog"; size: "Medium" } + ListElement { name: "Cat"; size: "Medium" } + ListElement { name: "Pony"; size: "Medium" } + ListElement { name: "Koala"; size: "Medium" } + ListElement { name: "Horse"; size: "Large" } + ListElement { name: "Tiger"; size: "Large" } + ListElement { name: "Giraffe"; size: "Large" } + ListElement { name: "Elephant"; size: "Huge" } + ListElement { name: "Whale"; size: "Huge" } + } + +//! [0] + // The delegate for each section header + Component { + id: sectionHeading + Rectangle { + width: container.width + height: childrenRect.height + color: "lightsteelblue" + + Text { + text: section + font.bold: true + font.pixelSize: 20 + } + } + } + + ListView { + id: view + anchors.top: parent.top + anchors.bottom: buttonBar.top + width: parent.width + model: animalsModel + delegate: Text { text: name; font.pixelSize: 18 } + + section.property: "size" + section.criteria: ViewSection.FullString + section.delegate: sectionHeading + } +//! [0] + + Row { + id: buttonBar + anchors.bottom: parent.bottom + anchors.bottomMargin: 1 + spacing: 1 + ToggleButton { + label: "CurrentLabelAtStart" + onToggled: { + if (active) + view.section.labelPositioning |= ViewSection.CurrentLabelAtStart + else + view.section.labelPositioning &= ~ViewSection.CurrentLabelAtStart + } + } + ToggleButton { + label: "NextLabelAtEnd" + onToggled: { + if (active) + view.section.labelPositioning |= ViewSection.NextLabelAtEnd + else + view.section.labelPositioning &= ~ViewSection.NextLabelAtEnd + } + } + } +} + diff --git a/examples/quick/modelviews/modelviews.pro b/examples/quick/modelviews/modelviews.pro new file mode 100644 index 0000000000..7748da0471 --- /dev/null +++ b/examples/quick/modelviews/modelviews.pro @@ -0,0 +1,8 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + abstractitemmodel \ + objectlistmodel \ + stringlistmodel + + diff --git a/examples/qtquick/modelviews/modelviews.qml b/examples/quick/modelviews/modelviews.qml similarity index 100% rename from examples/qtquick/modelviews/modelviews.qml rename to examples/quick/modelviews/modelviews.qml diff --git a/examples/quick/modelviews/modelviews.qmlproject b/examples/quick/modelviews/modelviews.qmlproject new file mode 100644 index 0000000000..40f9e568fd --- /dev/null +++ b/examples/quick/modelviews/modelviews.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "modelviews.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/quick/modelviews/objectlistmodel/dataobject.cpp b/examples/quick/modelviews/objectlistmodel/dataobject.cpp new file mode 100644 index 0000000000..7216283616 --- /dev/null +++ b/examples/quick/modelviews/objectlistmodel/dataobject.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "dataobject.h" + +DataObject::DataObject(QObject *parent) + : QObject(parent) +{ +} + +DataObject::DataObject(const QString &name, const QString &color, QObject *parent) + : QObject(parent), m_name(name), m_color(color) +{ +} + +QString DataObject::name() const +{ + return m_name; +} + +void DataObject::setName(const QString &name) +{ + if (name != m_name) { + m_name = name; + emit nameChanged(); + } +} + +QString DataObject::color() const +{ + return m_color; +} + +void DataObject::setColor(const QString &color) +{ + if (color != m_color) { + m_color = color; + emit colorChanged(); + } +} diff --git a/examples/quick/modelviews/objectlistmodel/dataobject.h b/examples/quick/modelviews/objectlistmodel/dataobject.h new file mode 100644 index 0000000000..bea92a273c --- /dev/null +++ b/examples/quick/modelviews/objectlistmodel/dataobject.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef DATAOBJECT_H +#define DATAOBJECT_H + +#include + +//![0] +class DataObject : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged) +//![0] + +public: + DataObject(QObject *parent=0); + DataObject(const QString &name, const QString &color, QObject *parent=0); + + QString name() const; + void setName(const QString &name); + + QString color() const; + void setColor(const QString &color); + +signals: + void nameChanged(); + void colorChanged(); + +private: + QString m_name; + QString m_color; +//![1] +}; +//![1] + +#endif // DATAOBJECT_H diff --git a/examples/quick/modelviews/objectlistmodel/main.cpp b/examples/quick/modelviews/objectlistmodel/main.cpp new file mode 100644 index 0000000000..bb3895f7c0 --- /dev/null +++ b/examples/quick/modelviews/objectlistmodel/main.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include +#include +#include +#include + +#include "dataobject.h" + +/* + This example illustrates exposing a QList as a + model in QML +*/ + +//![0] +int main(int argc, char ** argv) +{ + QGuiApplication app(argc, argv); + + QList dataList; + dataList.append(new DataObject("Item 1", "red")); + dataList.append(new DataObject("Item 2", "green")); + dataList.append(new DataObject("Item 3", "blue")); + dataList.append(new DataObject("Item 4", "yellow")); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + QQmlContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); +//![0] + + view.setSource(QUrl("qrc:view.qml")); + view.show(); + + return app.exec(); +} + diff --git a/examples/quick/modelviews/objectlistmodel/objectlistmodel.pro b/examples/quick/modelviews/objectlistmodel/objectlistmodel.pro new file mode 100644 index 0000000000..7f323c3999 --- /dev/null +++ b/examples/quick/modelviews/objectlistmodel/objectlistmodel.pro @@ -0,0 +1,6 @@ +QT += qml quick + +SOURCES += main.cpp \ + dataobject.cpp +HEADERS += dataobject.h +RESOURCES += objectlistmodel.qrc diff --git a/examples/quick/modelviews/objectlistmodel/objectlistmodel.qmlproject b/examples/quick/modelviews/objectlistmodel/objectlistmodel.qmlproject new file mode 100644 index 0000000000..2bb4016996 --- /dev/null +++ b/examples/quick/modelviews/objectlistmodel/objectlistmodel.qmlproject @@ -0,0 +1,14 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/quick/modelviews/objectlistmodel/objectlistmodel.qrc b/examples/quick/modelviews/objectlistmodel/objectlistmodel.qrc new file mode 100644 index 0000000000..17e9301471 --- /dev/null +++ b/examples/quick/modelviews/objectlistmodel/objectlistmodel.qrc @@ -0,0 +1,5 @@ + + + view.qml + + diff --git a/examples/quick/modelviews/objectlistmodel/view.qml b/examples/quick/modelviews/objectlistmodel/view.qml new file mode 100644 index 0000000000..3954e79829 --- /dev/null +++ b/examples/quick/modelviews/objectlistmodel/view.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//![0] +ListView { + width: 100; height: 100 + + model: myModel + delegate: Rectangle { + height: 25 + width: 100 + color: model.modelData.color + Text { text: name } + } +} +//![0] diff --git a/examples/quick/modelviews/package/Delegate.qml b/examples/quick/modelviews/package/Delegate.qml new file mode 100644 index 0000000000..97c7840cb4 --- /dev/null +++ b/examples/quick/modelviews/package/Delegate.qml @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//![0] +Package { + Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' } + Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' } + + Rectangle { + id: wrapper + width: 200; height: 25 + color: 'lightsteelblue' + + Text { text: display; anchors.centerIn: parent } + MouseArea { + anchors.fill: parent + onClicked: { + if (wrapper.state == 'inList') + wrapper.state = 'inGrid'; + else + wrapper.state = 'inList'; + } + } + + state: 'inList' + states: [ + State { + name: 'inList' + ParentChange { target: wrapper; parent: listDelegate } + }, + State { + name: 'inGrid' + ParentChange { + target: wrapper; parent: gridDelegate + x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height + } + } + ] + + transitions: [ + Transition { + ParentAnimation { + NumberAnimation { properties: 'x,y,width,height'; duration: 300 } + } + } + ] + } +} +//![0] diff --git a/examples/qtquick/modelviews/package/view.qml b/examples/quick/modelviews/package/view.qml similarity index 100% rename from examples/qtquick/modelviews/package/view.qml rename to examples/quick/modelviews/package/view.qml diff --git a/examples/quick/modelviews/parallax/content/Clock.qml b/examples/quick/modelviews/parallax/content/Clock.qml new file mode 100644 index 0000000000..7f0e8cba83 --- /dev/null +++ b/examples/quick/modelviews/parallax/content/Clock.qml @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id : clock + width: { + if (ListView.view && ListView.view.width >= 200) + return ListView.view.width / Math.floor(ListView.view.width / 200.0); + else + return 200; + } + + height: { + if (ListView.view && ListView.view.height >= 240) + return ListView.view.height; + else + return 240; + } + + property alias city: cityLabel.text + property int hours + property int minutes + property int seconds + property real shift + property bool night: false + property bool internationalTime: true //Unset for local time + + function timeChanged() { + var date = new Date; + hours = internationalTime ? date.getUTCHours() + Math.floor(clock.shift) : date.getHours() + night = ( hours < 7 || hours > 19 ) + minutes = internationalTime ? date.getUTCMinutes() + ((clock.shift % 1) * 60) : date.getMinutes() + seconds = date.getUTCSeconds(); + } + + Timer { + interval: 100; running: true; repeat: true; + onTriggered: clock.timeChanged() + } + + Item { + anchors.centerIn: parent + width: 200; height: 240 + + Image { id: background; source: "clock.png"; visible: clock.night == false } + Image { source: "clock-night.png"; visible: clock.night == true } + + + Image { + x: 92.5; y: 27 + source: "hour.png" + smooth: true + transform: Rotation { + id: hourRotation + origin.x: 7.5; origin.y: 73; + angle: (clock.hours * 30) + (clock.minutes * 0.5) + Behavior on angle { + SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } + } + } + } + + Image { + x: 93.5; y: 17 + source: "minute.png" + smooth: true + transform: Rotation { + id: minuteRotation + origin.x: 6.5; origin.y: 83; + angle: clock.minutes * 6 + Behavior on angle { + SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } + } + } + } + + Image { + x: 97.5; y: 20 + source: "second.png" + smooth: true + transform: Rotation { + id: secondRotation + origin.x: 2.5; origin.y: 80; + angle: clock.seconds * 6 + Behavior on angle { + SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } + } + } + } + + Image { + anchors.centerIn: background; source: "center.png" + } + + Text { + id: cityLabel + y: 210; anchors.horizontalCenter: parent.horizontalCenter + color: "white" + font.family: "Helvetica" + font.bold: true; font.pixelSize: 16 + style: Text.Raised; styleColor: "black" + } + } +} diff --git a/examples/quick/modelviews/parallax/content/ParallaxView.qml b/examples/quick/modelviews/parallax/content/ParallaxView.qml new file mode 100644 index 0000000000..2acf50dcef --- /dev/null +++ b/examples/quick/modelviews/parallax/content/ParallaxView.qml @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root + + property alias background: background.source + property int currentIndex: 0 + default property alias content: visualModel.children + + Image { + id: background + fillMode: Image.TileHorizontally + x: -list.contentX / 2 + width: Math.max(list.contentWidth, parent.width) + } + + ListView { + id: list + anchors.fill: parent + + currentIndex: root.currentIndex + onCurrentIndexChanged: root.currentIndex = currentIndex + + orientation: Qt.Horizontal + boundsBehavior: Flickable.DragOverBounds + model: VisualItemModel { id: visualModel } + + highlightRangeMode: ListView.StrictlyEnforceRange + snapMode: ListView.SnapOneItem + } + + ListView { + id: selector + + height: 50 + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + width: Math.min(count * 50, parent.width - 20) + interactive: width == parent.width - 20 + orientation: Qt.Horizontal + + currentIndex: root.currentIndex + onCurrentIndexChanged: root.currentIndex = currentIndex + + model: visualModel.children + delegate: Item { + width: 50; height: 50 + id: delegateRoot + + Image { + id: image + source: modelData.icon + smooth: true + scale: 0.8 + } + + MouseArea { + anchors.fill: parent + onClicked: { root.currentIndex = index } + } + + states: State { + name: "Selected" + when: delegateRoot.ListView.isCurrentItem == true + PropertyChanges { + target: image + scale: 1 + y: -5 + } + } + transitions: Transition { + NumberAnimation { properties: "scale,y" } + } + } + + Rectangle { + color: "#60FFFFFF" + x: -10; y: -10; z: -1 + width: parent.width + 20; height: parent.height + 20 + radius: 10 + } + } +} diff --git a/examples/quick/modelviews/parallax/content/QuitButton.qml b/examples/quick/modelviews/parallax/content/QuitButton.qml new file mode 100644 index 0000000000..702b892d23 --- /dev/null +++ b/examples/quick/modelviews/parallax/content/QuitButton.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +Image { + source: "quit.png" + scale: quitMouse.pressed ? 0.8 : 1.0 + smooth: quitMouse.pressed + MouseArea { + id: quitMouse + anchors.fill: parent + anchors.margins: -10 + onClicked: Qt.quit() + } +} diff --git a/examples/quick/modelviews/parallax/content/Smiley.qml b/examples/quick/modelviews/parallax/content/Smiley.qml new file mode 100644 index 0000000000..982b6c5d2b --- /dev/null +++ b/examples/quick/modelviews/parallax/content/Smiley.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +// This is taken from the declarative animation/basics/property-animation.qml +// example + +Item { + id: window + width: 320; height: 480 + + Image { + anchors.horizontalCenter: parent.horizontalCenter + y: smiley.minHeight + 58 + source: "pics/shadow.png" + + scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight) + } + + Image { + id: smiley + property int maxHeight: window.height / 3 + property int minHeight: 2 * window.height / 3 + + anchors.horizontalCenter: parent.horizontalCenter + y: minHeight + source: "pics/face-smile.png" + + SequentialAnimation on y { + loops: Animation.Infinite + + NumberAnimation { + from: smiley.minHeight; to: smiley.maxHeight + easing.type: Easing.OutExpo; duration: 300 + } + + NumberAnimation { + from: smiley.maxHeight; to: smiley.minHeight + easing.type: Easing.OutBounce; duration: 1000 + } + + PauseAnimation { duration: 500 } + } + } +} + diff --git a/examples/quick/modelviews/parallax/content/background.png b/examples/quick/modelviews/parallax/content/background.png new file mode 100644 index 0000000000..a885950862 Binary files /dev/null and b/examples/quick/modelviews/parallax/content/background.png differ diff --git a/examples/quick/modelviews/parallax/content/center.png b/examples/quick/modelviews/parallax/content/center.png new file mode 100644 index 0000000000..7fbd802a44 Binary files /dev/null and b/examples/quick/modelviews/parallax/content/center.png differ diff --git a/examples/quick/modelviews/parallax/content/clock-night.png b/examples/quick/modelviews/parallax/content/clock-night.png new file mode 100644 index 0000000000..cc7151a397 Binary files /dev/null and b/examples/quick/modelviews/parallax/content/clock-night.png differ diff --git a/examples/quick/modelviews/parallax/content/clock.png b/examples/quick/modelviews/parallax/content/clock.png new file mode 100644 index 0000000000..462edacc0e Binary files /dev/null and b/examples/quick/modelviews/parallax/content/clock.png differ diff --git a/examples/quick/modelviews/parallax/content/hour.png b/examples/quick/modelviews/parallax/content/hour.png new file mode 100644 index 0000000000..f8061a1235 Binary files /dev/null and b/examples/quick/modelviews/parallax/content/hour.png differ diff --git a/examples/quick/modelviews/parallax/content/minute.png b/examples/quick/modelviews/parallax/content/minute.png new file mode 100644 index 0000000000..1297ec7c2b Binary files /dev/null and b/examples/quick/modelviews/parallax/content/minute.png differ diff --git a/examples/quick/modelviews/parallax/content/pics/background.jpg b/examples/quick/modelviews/parallax/content/pics/background.jpg new file mode 100644 index 0000000000..61cca2f138 Binary files /dev/null and b/examples/quick/modelviews/parallax/content/pics/background.jpg differ diff --git a/examples/quick/modelviews/parallax/content/pics/face-smile.png b/examples/quick/modelviews/parallax/content/pics/face-smile.png new file mode 100644 index 0000000000..3d66d72578 Binary files /dev/null and b/examples/quick/modelviews/parallax/content/pics/face-smile.png differ diff --git a/examples/quick/modelviews/parallax/content/pics/home-page.png b/examples/quick/modelviews/parallax/content/pics/home-page.png new file mode 100644 index 0000000000..bd090c3708 Binary files /dev/null and b/examples/quick/modelviews/parallax/content/pics/home-page.png differ diff --git a/examples/quick/modelviews/parallax/content/pics/home-page.svg b/examples/quick/modelviews/parallax/content/pics/home-page.svg new file mode 100644 index 0000000000..4f16958844 --- /dev/null +++ b/examples/quick/modelviews/parallax/content/pics/home-page.svg @@ -0,0 +1,445 @@ + +image/svg+xmlGo HomeJakub Steinerhttp://jimmac.musichall.czhomereturngodefaultuserdirectoryTuomas Kuosmanen + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/quick/modelviews/parallax/content/pics/shadow.png b/examples/quick/modelviews/parallax/content/pics/shadow.png new file mode 100644 index 0000000000..8270565e87 Binary files /dev/null and b/examples/quick/modelviews/parallax/content/pics/shadow.png differ diff --git a/examples/quick/modelviews/parallax/content/pics/yast-joystick.png b/examples/quick/modelviews/parallax/content/pics/yast-joystick.png new file mode 100644 index 0000000000..858cea0301 Binary files /dev/null and b/examples/quick/modelviews/parallax/content/pics/yast-joystick.png differ diff --git a/examples/quick/modelviews/parallax/content/pics/yast-wol.png b/examples/quick/modelviews/parallax/content/pics/yast-wol.png new file mode 100644 index 0000000000..7712180a3b Binary files /dev/null and b/examples/quick/modelviews/parallax/content/pics/yast-wol.png differ diff --git a/examples/quick/modelviews/parallax/content/quit.png b/examples/quick/modelviews/parallax/content/quit.png new file mode 100644 index 0000000000..b822057d4e Binary files /dev/null and b/examples/quick/modelviews/parallax/content/quit.png differ diff --git a/examples/quick/modelviews/parallax/content/second.png b/examples/quick/modelviews/parallax/content/second.png new file mode 100644 index 0000000000..4aa9fb5e8e Binary files /dev/null and b/examples/quick/modelviews/parallax/content/second.png differ diff --git a/examples/qtquick/modelviews/parallax/parallax.qml b/examples/quick/modelviews/parallax/parallax.qml similarity index 100% rename from examples/qtquick/modelviews/parallax/parallax.qml rename to examples/quick/modelviews/parallax/parallax.qml diff --git a/examples/quick/modelviews/pathview/pathview-example.qml b/examples/quick/modelviews/pathview/pathview-example.qml new file mode 100644 index 0000000000..6161343830 --- /dev/null +++ b/examples/quick/modelviews/pathview/pathview-example.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 400; height: 240 + color: "white" + + ListModel { + id: appModel + ListElement { name: "Music"; icon: "pics/AudioPlayer_48.png" } + ListElement { name: "Movies"; icon: "pics/VideoPlayer_48.png" } + ListElement { name: "Camera"; icon: "pics/Camera_48.png" } + ListElement { name: "Calendar"; icon: "pics/DateBook_48.png" } + ListElement { name: "Messaging"; icon: "pics/EMail_48.png" } + ListElement { name: "Todo List"; icon: "pics/TodoList_48.png" } + ListElement { name: "Contacts"; icon: "pics/AddressBook_48.png" } + } + + Component { + id: appDelegate + Item { + width: 100; height: 100 + scale: PathView.iconScale + + Image { + id: myIcon + y: 20; anchors.horizontalCenter: parent.horizontalCenter + source: icon + smooth: true + } + Text { + anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter } + text: name + smooth: true + } + + MouseArea { + anchors.fill: parent + onClicked: view.currentIndex = index + } + } + } + + Component { + id: appHighlight + Rectangle { width: 80; height: 80; color: "lightsteelblue" } + } + + PathView { + id: view + anchors.fill: parent + highlight: appHighlight + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + focus: true + model: appModel + delegate: appDelegate + path: Path { + startX: 10 + startY: 50 + PathAttribute { name: "iconScale"; value: 0.5 } + PathQuad { x: 200; y: 150; controlX: 50; controlY: 200 } + PathAttribute { name: "iconScale"; value: 1.0 } + PathQuad { x: 390; y: 50; controlX: 350; controlY: 200 } + PathAttribute { name: "iconScale"; value: 0.5 } + } + } +} diff --git a/examples/quick/modelviews/pathview/pics/AddressBook_48.png b/examples/quick/modelviews/pathview/pics/AddressBook_48.png new file mode 100644 index 0000000000..1ab7c8eec1 Binary files /dev/null and b/examples/quick/modelviews/pathview/pics/AddressBook_48.png differ diff --git a/examples/quick/modelviews/pathview/pics/AudioPlayer_48.png b/examples/quick/modelviews/pathview/pics/AudioPlayer_48.png new file mode 100644 index 0000000000..f4b8689f87 Binary files /dev/null and b/examples/quick/modelviews/pathview/pics/AudioPlayer_48.png differ diff --git a/examples/quick/modelviews/pathview/pics/Camera_48.png b/examples/quick/modelviews/pathview/pics/Camera_48.png new file mode 100644 index 0000000000..c76b524945 Binary files /dev/null and b/examples/quick/modelviews/pathview/pics/Camera_48.png differ diff --git a/examples/quick/modelviews/pathview/pics/DateBook_48.png b/examples/quick/modelviews/pathview/pics/DateBook_48.png new file mode 100644 index 0000000000..58f5787fb8 Binary files /dev/null and b/examples/quick/modelviews/pathview/pics/DateBook_48.png differ diff --git a/examples/quick/modelviews/pathview/pics/EMail_48.png b/examples/quick/modelviews/pathview/pics/EMail_48.png new file mode 100644 index 0000000000..d6d84a61be Binary files /dev/null and b/examples/quick/modelviews/pathview/pics/EMail_48.png differ diff --git a/examples/quick/modelviews/pathview/pics/TodoList_48.png b/examples/quick/modelviews/pathview/pics/TodoList_48.png new file mode 100644 index 0000000000..0988448d9b Binary files /dev/null and b/examples/quick/modelviews/pathview/pics/TodoList_48.png differ diff --git a/examples/quick/modelviews/pathview/pics/VideoPlayer_48.png b/examples/quick/modelviews/pathview/pics/VideoPlayer_48.png new file mode 100644 index 0000000000..52638c50a7 Binary files /dev/null and b/examples/quick/modelviews/pathview/pics/VideoPlayer_48.png differ diff --git a/examples/quick/modelviews/stringlistmodel/main.cpp b/examples/quick/modelviews/stringlistmodel/main.cpp new file mode 100644 index 0000000000..12859316a3 --- /dev/null +++ b/examples/quick/modelviews/stringlistmodel/main.cpp @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include +#include +#include +#include +#include + + +/* + This example illustrates exposing a QStringList as a + model in QML +*/ + +int main(int argc, char ** argv) +{ + QGuiApplication app(argc, argv); + +//![0] + QStringList dataList; + dataList.append("Item 1"); + dataList.append("Item 2"); + dataList.append("Item 3"); + dataList.append("Item 4"); + + QQuickView view; + QQmlContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); +//![0] + + view.setSource(QUrl("qrc:view.qml")); + view.show(); + + return app.exec(); +} + diff --git a/examples/quick/modelviews/stringlistmodel/stringlistmodel.pro b/examples/quick/modelviews/stringlistmodel/stringlistmodel.pro new file mode 100644 index 0000000000..19e62cd1b7 --- /dev/null +++ b/examples/quick/modelviews/stringlistmodel/stringlistmodel.pro @@ -0,0 +1,4 @@ +QT += qml quick + +SOURCES += main.cpp +RESOURCES += stringlistmodel.qrc diff --git a/examples/quick/modelviews/stringlistmodel/stringlistmodel.qrc b/examples/quick/modelviews/stringlistmodel/stringlistmodel.qrc new file mode 100644 index 0000000000..17e9301471 --- /dev/null +++ b/examples/quick/modelviews/stringlistmodel/stringlistmodel.qrc @@ -0,0 +1,5 @@ + + + view.qml + + diff --git a/examples/quick/modelviews/stringlistmodel/view.qml b/examples/quick/modelviews/stringlistmodel/view.qml new file mode 100644 index 0000000000..945763c295 --- /dev/null +++ b/examples/quick/modelviews/stringlistmodel/view.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +//![0] + +ListView { + width: 100; height: 100 + + model: myModel + delegate: Rectangle { + height: 25 + width: 100 + Text { text: modelData } + } +} +//![0] diff --git a/examples/quick/modelviews/visualdatamodel/dragselection.qml b/examples/quick/modelviews/visualdatamodel/dragselection.qml new file mode 100644 index 0000000000..c3186a5ad8 --- /dev/null +++ b/examples/quick/modelviews/visualdatamodel/dragselection.qml @@ -0,0 +1,200 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root + + width: 320 + height: 480 + + property bool dragging: false + + Component { + id: packageDelegate + Package { + id: packageRoot + + MouseArea { + id: visibleContainer + Package.name: "visible" + + width: 64 + height: 64 + enabled: packageRoot.VisualDataModel.inSelected + + drag.target: draggable + + Item { + id: draggable + + width: 64 + height: 64 + + Drag.active: visibleContainer.drag.active + + anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter } + + states: State { + when: visibleContainer.drag.active + AnchorChanges { target: draggable; anchors { horizontalCenter: undefined; verticalCenter: undefined} } + ParentChange { target: selectionView; parent: draggable; x: 0; y: 0 } + PropertyChanges { target: root; dragging: true } + ParentChange { target: draggable; parent: root } + } + } + DropArea { + anchors.fill: parent + onEntered: selectedItems.move(0, visualModel.items.get(packageRoot.VisualDataModel.itemsIndex), selectedItems.count) + } + } + Item { + id: selectionContainer + Package.name: "selection" + + width: 64 + height: 64 + + visible: PathView.onPath + } + Rectangle { + id: content + parent: visibleContainer + + width: 58 + height: 58 + + radius: 8 + + gradient: Gradient { + GradientStop { id: gradientStart; position: 0.0; color: "#8AC953" } + GradientStop { id: gradientEnd; position: 1.0; color: "#8BC953" } + } + + border.width: 2 + border.color: "#007423" + + state: root.dragging && packageRoot.VisualDataModel.inSelected ? "selected" : "visible" + + Text { + anchors.fill: parent + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + color: "white" + text: modelData + font.pixelSize: 18 + } + + Rectangle { + anchors { right: parent.right; top: parent.top; margins: 3 } + width: 12; height: 12 + color: packageRoot.VisualDataModel.inSelected ? "black" : "white" + radius: 6 + + border.color: "white" + border.width: 2 + + MouseArea { + anchors.fill: parent + onClicked: packageRoot.VisualDataModel.inSelected = !packageRoot.VisualDataModel.inSelected + } + } + + states: [ + State { + name: "selected" + ParentChange { target: content; parent: selectionContainer; x: 3; y: 3 } + PropertyChanges { target: packageRoot; VisualDataModel.inItems: visibleContainer.drag.active } + PropertyChanges { target: gradientStart; color: "#017423" } + PropertyChanges { target: gradientStart; color: "#007423" } + }, State { + name: "visible" + PropertyChanges { target: packageRoot; VisualDataModel.inItems: true } + ParentChange { target: content; parent: visibleContainer; x: 3; y: 3 } + PropertyChanges { target: gradientStart; color: "#8AC953" } + PropertyChanges { target: gradientStart; color: "#8BC953" } + } + ] + transitions: Transition { + PropertyAction { target: packageRoot; properties: "VisualDataModel.inItems" } + ParentAnimation { + target: content + NumberAnimation { target: content; properties: "x,y"; duration: 500 } + } + ColorAnimation { targets: [gradientStart, gradientEnd]; duration: 500 } + } + } + } + } + + VisualDataModel { + id: visualModel + model: 35 + delegate: packageDelegate + + groups: VisualDataGroup { id: selectedItems; name: "selected" } + + Component.onCompleted: parts.selection.filterOnGroup = "selected" + } + + PathView { + id: selectionView + + height: 64 + width: 64 + + model: visualModel.parts.selection + + path: Path { + startX: 0 + startY: 0 + PathLine { x: 64; y: 64 } + } + } + + GridView { + id: itemsView + anchors { fill: parent } + cellWidth: 64 + cellHeight: 64 + model: visualModel.parts.visible + } +} diff --git a/examples/quick/modelviews/visualdatamodel/slideshow.qml b/examples/quick/modelviews/visualdatamodel/slideshow.qml new file mode 100644 index 0000000000..040c6be307 --- /dev/null +++ b/examples/quick/modelviews/visualdatamodel/slideshow.qml @@ -0,0 +1,156 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +Rectangle { + id: root + + property Item displayItem: null + + width: 300; height: 400 + + color: "black" + + VisualDataModel { + id: visualModel + + model: XmlListModel { + source: "http://api.flickr.com/services/feeds/photos_public.gne?format=rss2" + query: "/rss/channel/item" + namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" + + XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" } + XmlRole { name: "url"; query: "media:content/@url/string()" } + } + + delegate: Item { + id: delegateItem + + width: 76; height: 76 + + Rectangle { + id: image + x: 0; y: 0; width: 76; height: 76 + border.width: 1 + border.color: "white" + color: "black" + + Image { + anchors.fill: parent + anchors.leftMargin: 1 + anchors.topMargin: 1 + + source: imagePath + fillMode: Image.PreserveAspectFit + + } + + MouseArea { + id: clickArea + anchors.fill: parent + + onClicked: root.displayItem = root.displayItem !== delegateItem ? delegateItem : null + } + + states: [ + State { + when: root.displayItem === delegateItem + name: "inDisplay"; + ParentChange { target: image; parent: imageContainer; x: 75; y: 75; width: 150; height: 150 } + PropertyChanges { target: image; z: 2 } + PropertyChanges { target: delegateItem; VisualDataModel.inItems: false } + }, + State { + when: root.displayItem !== delegateItem + name: "inList"; + ParentChange { target: image; parent: delegateItem; x: 2; y: 2; width: 75; height: 75 } + PropertyChanges { target: image; z: 1 } + PropertyChanges { target: delegateItem; VisualDataModel.inItems: true } + } + ] + + transitions: [ + Transition { + from: "inList" + SequentialAnimation { + PropertyAction { target: delegateItem; property: "VisualDataModel.inPersistedItems"; value: true } + ParentAnimation { + target: image; + via: root + NumberAnimation { target: image; properties: "x,y,width,height"; duration: 1000 } + } + } + }, Transition { + from: "inDisplay" + SequentialAnimation { + ParentAnimation { + target: image + NumberAnimation { target: image; properties: "x,y,width,height"; duration: 1000 } + } + PropertyAction { target: delegateItem; property: "VisualDataModel.inPersistedItems"; value: false } + } + } + ] + } + } + } + + + PathView { + id: imagePath + + anchors { left: parent.left; top: imageContainer.bottom; right: parent.right; bottom: parent.bottom } + model: visualModel + + pathItemCount: 7 + path: Path { + startX: -50; startY: 0 + PathQuad { x: 150; y: 50; controlX: 0; controlY: 50 } + PathQuad { x: 350; y: 0; controlX: 300; controlY: 50 } + } + } + + Item { + id: imageContainer + anchors { fill: parent; bottomMargin: 100 } + } +} diff --git a/examples/quick/modelviews/visualdatamodel/sortedmodel.qml b/examples/quick/modelviews/visualdatamodel/sortedmodel.qml new file mode 100644 index 0000000000..8d3b0a58e5 --- /dev/null +++ b/examples/quick/modelviews/visualdatamodel/sortedmodel.qml @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 480; height: 640 + + Component { + id: numberDelegate + + Text { + id: numberText + anchors { left: parent.left; right: parent.right } + text: number + + horizontalAlignment: Text.AlignHCenter + font.pixelSize: 18 + + Text { + anchors { left: parent.left; baseline: parent.baseline } + text: index + + horizontalAlignment: Text.AlignLeft + font.pixelSize: 12 + } + Text { + anchors { right: parent.right; baseline: parent.baseline } + text: numberText.VisualDataModel.itemsIndex + + horizontalAlignment: Text.AlignRight + font.pixelSize: 12 + } + } + } + + ListView { + anchors { + left: parent.left; top: parent.top; + right: parent.horizontalCenter; bottom: button.top + leftMargin: 2; topMargin: 2; rightMargin: 1; bottomMargin: 2 + } + + model: ListModel { + id: unsortedModel + } + delegate: numberDelegate + } + ListView { + anchors { + left: parent.horizontalCenter; top: parent.top; + right: parent.right; bottom: button.top + leftMargin: 1; topMargin: 2; rightMargin: 2; bottomMargin: 2 + } + model: VisualDataModel { + model: unsortedModel + delegate: numberDelegate + + items.onChanged: { + for (var i = 0; i < inserted.length; ++i) { + for (var j = inserted[i].index; j < inserted[i].index + inserted[i].count; ++j) { + var number = items.get(j).model.number + for (var l = 0, k = 0; l < unsortedModel.count; ++l) { + if (l == inserted[k].index) { + l += inserted[k].count - 1 + ++k + } else if (number < items.get(l).model.number) { + items.move(j, l, 1) + break + } + } + inserted[i].index += 1; + inserted[i].count -= 1; + } + } + } + } + } + + Rectangle { + id: button + + anchors { left: parent.left; right: parent.right; bottom: parent.bottom; margins: 2 } + height: moreText.implicitHeight + 4 + + color: "black" + + Text { + id: moreText + + anchors.fill: parent + text: "More" + color: "white" + font.pixelSize: 18 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + MouseArea { + anchors.fill: parent + + onClicked: unsortedModel.append({ "number": Math.floor(Math.random() * 100) }) + } + } +} diff --git a/examples/quick/modelviews/visualdatamodel/visualdatamodel.qmlproject b/examples/quick/modelviews/visualdatamodel/visualdatamodel.qmlproject new file mode 100644 index 0000000000..2bb4016996 --- /dev/null +++ b/examples/quick/modelviews/visualdatamodel/visualdatamodel.qmlproject @@ -0,0 +1,14 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qtquick/modelviews/visualitemmodel/visualitemmodel.qml b/examples/quick/modelviews/visualitemmodel/visualitemmodel.qml similarity index 100% rename from examples/qtquick/modelviews/visualitemmodel/visualitemmodel.qml rename to examples/quick/modelviews/visualitemmodel/visualitemmodel.qml diff --git a/examples/quick/mousearea/mousearea-example.qml b/examples/quick/mousearea/mousearea-example.qml new file mode 100644 index 0000000000..30e3e62864 --- /dev/null +++ b/examples/quick/mousearea/mousearea-example.qml @@ -0,0 +1,176 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: box + width: 400; height: 300 + + Rectangle { + id: redSquare + width: 120; height: 120 + anchors.top: parent.top; anchors.left: parent.left; anchors.margins: 10 + color: "red" + + Text { text: "Click"; font.pixelSize: 16; anchors.centerIn: parent } + + MouseArea { + anchors.fill: parent + hoverEnabled: true + property string buttonID + + acceptedButtons: Qt.AllButtons + // Value 'All.Buttons' is eqivalent to: + // 'Qt::LeftButton | Qt::RightButton | Qt::MiddleButton .... | Qt::ExtraButton24' + + onEntered: info.text = 'Entered' + onExited: info.text = 'Exited (pressed=' + pressed + ')' + + onPressed: { + if (mouse.button == Qt.LeftButton) + buttonID = 'LeftButton' + else if (mouse.button == Qt.RightButton) + buttonID = 'RightButton' + else if (mouse.button == Qt.MidButton) + buttonID = 'MiddleButton' + else if (mouse.button == Qt.BackButton) + buttonID = 'BackButton' + else if (mouse.button == Qt.ForwardButton) + buttonID = 'ForwardButton' + else if (mouse.button == Qt.TaskButton) + buttonID = 'TaskButton' + else if (mouse.button == Qt.ExtraButton4) + buttonID = 'ExtraButton4' + else if (mouse.button == Qt.ExtraButton5) + buttonID = 'ExtraButton5' + else if (mouse.button == Qt.ExtraButton6) + buttonID = 'ExtraButton6' + else if (mouse.button == Qt.ExtraButton7) + buttonID = 'ExtraButton7' + else if (mouse.button == Qt.ExtraButton8) + buttonID = 'ExtraButton8' + else if (mouse.button == Qt.ExtraButton9) + buttonID = 'ExtraButton9' + else if (mouse.button == Qt.ExtraButton10) + buttonID = 'ExtraButton10' + else if (mouse.button == Qt.ExtraButton11) + buttonID = 'ExtraButton11' + else if (mouse.button == Qt.ExtraButton12) + buttonID = 'ExtraButton12' + else if (mouse.button == Qt.ExtraButton13) + buttonID = 'ExtraButton13' + else if (mouse.button == Qt.ExtraButton14) + buttonID = 'ExtraButton14' + else if (mouse.button == Qt.ExtraButton15) + buttonID = 'ExtraButton15' + else if (mouse.button == Qt.ExtraButton16) + buttonID = 'ExtraButton16' + else if (mouse.button == Qt.ExtraButton17) + buttonID = 'ExtraButton17' + else if (mouse.button == Qt.ExtraButton18) + buttonID = 'ExtraButton18' + else if (mouse.button == Qt.ExtraButton19) + buttonID = 'ExtraButton19' + else if (mouse.button == Qt.ExtraButton20) + buttonID = 'ExtraButton20' + else if (mouse.button == Qt.ExtraButton21) + buttonID = 'ExtraButton21' + else if (mouse.button == Qt.ExtraButton22) + buttonID = 'ExtraButton22' + else if (mouse.button == Qt.ExtraButton23) + buttonID = 'ExtraButton23' + else if (mouse.button == Qt.ExtraButton24) + buttonID = 'ExtraButton24' + + info.text = 'Pressed (' + buttonID + ' shift=' + + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')' + var posInBox = redSquare.mapToItem(box, mouse.x, mouse.y) + posInfo.text = + mouse.x + ',' + mouse.y + ' in square' + + ' (' + posInBox.x + ',' + posInBox.y + ' in window)' + } + + onReleased: { + btn.text = 'Released (isClick=' + mouse.isClick + ' wasHeld=' + mouse.wasHeld + ')' + posInfo.text = '' + } + + onPressAndHold: btn.text = 'Press and hold' + onClicked: btn.text = 'Clicked (wasHeld=' + mouse.wasHeld + ')' + onDoubleClicked: btn.text = 'Double clicked' + } + } + + Rectangle { + id: blueSquare + width: 120; height: 120 + x: box.width - width - 10; y: 10 // making this item draggable, so don't use anchors + color: "blue" + + Text { text: "Drag"; font.pixelSize: 16; color: "white"; anchors.centerIn: parent } + + MouseArea { + anchors.fill: parent + drag.target: blueSquare + drag.axis: Drag.XandYAxis + drag.minimumX: 0 + drag.maximumX: box.width - parent.width + drag.minimumY: 0 + drag.maximumY: box.height - parent.width + } + } + + Text { + id: info + anchors.bottom: btn.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20 + + onTextChanged: console.log(text) + } + + Text { + id: btn + anchors.bottom: posInfo.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20 + } + + Text { + id: posInfo + anchors.bottom: parent.bottom; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20 + } +} diff --git a/examples/quick/openglunderqml/main.cpp b/examples/quick/openglunderqml/main.cpp new file mode 100644 index 0000000000..3b682deaec --- /dev/null +++ b/examples/quick/openglunderqml/main.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include + +#include "squircle.h" + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("QtQuick", 2, 0, "Squircle"); + + QQuickView view; + view.setSource(QUrl("main.qml")); + view.show(); + + return app.exec(); + +} diff --git a/examples/quick/openglunderqml/main.qml b/examples/quick/openglunderqml/main.qml new file mode 100644 index 0000000000..1485cbbdb8 --- /dev/null +++ b/examples/quick/openglunderqml/main.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + + width: 400 + height: 300 + + Squircle { + SequentialAnimation on t { + NumberAnimation { to: 1; duration: 2500; easing.type: Easing.InQuad } + NumberAnimation { to: 0; duration: 2500; easing.type: Easing.OutQuad } + loops: Animation.Infinite + running: true + } + } + + Rectangle { + color: Qt.rgba(1, 1, 1, 0.8); + radius: 10 + border.width: 1 + border.color: "white" + anchors.fill: label + anchors.margins: -10 + } + + Text { + id: label + color: "black" + wrapMode: Text.WordWrap + text: "The background here is a squircle rendered with raw OpenGL using the 'beforeRender()' signal in QQuickCanvas. This text label and its border is rendered using QML" + anchors.right: parent.right + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.margins: 20 + } + +} diff --git a/examples/quick/openglunderqml/openglunderqml.pro b/examples/quick/openglunderqml/openglunderqml.pro new file mode 100644 index 0000000000..64a58b3729 --- /dev/null +++ b/examples/quick/openglunderqml/openglunderqml.pro @@ -0,0 +1,6 @@ +QT += qml quick + +HEADERS += squircle.h +SOURCES += squircle.cpp main.cpp + +OTHER_FILES += main.qml diff --git a/examples/quick/openglunderqml/squircle.cpp b/examples/quick/openglunderqml/squircle.cpp new file mode 100644 index 0000000000..b56f0baaf6 --- /dev/null +++ b/examples/quick/openglunderqml/squircle.cpp @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "squircle.h" + +#include +#include +#include + +Squircle::Squircle() + : m_program(0) +{ + setFlag(ItemHasContents); +} + +void Squircle::itemChange(ItemChange change, const ItemChangeData &) +{ + // The ItemSceneChange event is sent when we are first attached to a canvas. + if (change == ItemSceneChange) { + QQuickCanvas *c = canvas(); + + // Connect our the beforeRendering signal to our paint function. + // Since this call is executed on the rendering thread it must be + // a Qt::DirectConnection + connect(c, SIGNAL(beforeRendering()), this, SLOT(paint()), Qt::DirectConnection); + + // If we allow QML to do the clearing, they would clear what we paint + // and nothing would show. + c->setClearBeforeRendering(false); + } +} + + +void Squircle::paint() +{ + if (!m_program) { + m_program = new QOpenGLShaderProgram(); + m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, + "attribute highp vec4 vertices;" + "varying highp vec2 coords;" + "void main() {" + " gl_Position = vertices;" + " coords = vertices.xy;" + "}"); + m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, + "uniform lowp float t;" + "varying highp vec2 coords;" + "void main() {" + " lowp float i = 1. - (pow(coords.x, 4.) + pow(coords.y, 4.));" + " i = smoothstep(t - 0.3, t + 0.3, i);" + " gl_FragColor = vec4(coords / 2. + .5, i, i);" + "}"); + + m_program->bindAttributeLocation("vertices", 0); + m_program->link(); + } + + m_program->bind(); + + m_program->enableAttributeArray(0); + + float values[] = { + -1, -1, + 1, -1, + -1, 1, + 1, 1 + }; + m_program->setAttributeArray(0, GL_FLOAT, values, 2); + m_program->setUniformValue("t", (float) m_t); + + glDisable(GL_DEPTH_TEST); + + glClearColor(0, 0, 0, 1); + glClear(GL_COLOR_BUFFER_BIT); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + m_program->disableAttributeArray(0); + m_program->release(); +} + + diff --git a/examples/quick/openglunderqml/squircle.h b/examples/quick/openglunderqml/squircle.h new file mode 100644 index 0000000000..283131a662 --- /dev/null +++ b/examples/quick/openglunderqml/squircle.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SQUIRCLE_H +#define SQUIRCLE_H + +#include +#include + +class Squircle : public QQuickItem +{ + Q_OBJECT + + Q_PROPERTY(qreal t READ t WRITE setT NOTIFY tChanged) + +public: + Squircle(); + + qreal t() const { return m_t; } + void setT(qreal t) { m_t = t; emit tChanged(); } + + void itemChange(ItemChange change, const ItemChangeData &); + +signals: + void tChanged(); + +public slots: + void paint(); + +private: + QOpenGLShaderProgram *m_program; + + qreal m_t; + bool m_render_under; + bool m_render_over; +}; + +#endif // SQUIRCLE_H diff --git a/examples/quick/painteditem/painteditem.pro b/examples/quick/painteditem/painteditem.pro new file mode 100644 index 0000000000..e3afd6b0f0 --- /dev/null +++ b/examples/quick/painteditem/painteditem.pro @@ -0,0 +1,5 @@ +TEMPLATE = subdirs + +SUBDIRS = \ + smile \ + textballoons diff --git a/examples/quick/painteditem/smile/main.cpp b/examples/quick/painteditem/smile/main.cpp new file mode 100644 index 0000000000..1c7888b10b --- /dev/null +++ b/examples/quick/painteditem/smile/main.cpp @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +class MyPaintItem : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(QString face READ face WRITE setFace NOTIFY faceChanged) +public: + MyPaintItem() + : QQuickPaintedItem() + , m_face(QLatin1String(":-)")) + { + setAntialiasing(true); + } + QString face() const {return m_face;} + void setFace(const QString &face) { + if (m_face != face) { + m_face = face; + emit faceChanged(); + } + } + virtual void paint(QPainter *p) + { + QRectF rect(0, 0, width(), height()); + rect.adjust(10, 10, -10, -10); + p->setPen(QPen(Qt::black, 20)); + p->setBrush(Qt::yellow); + p->drawEllipse(rect); + p->setPen(Qt::black); + p->setFont(QFont(QLatin1String("Times"), qRound(rect.height() / 2))); + p->drawText(rect, Qt::AlignCenter, m_face); + } +signals: + void faceChanged(); +private: + QString m_face; +}; + +int main(int argc, char ** argv) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("MyModule", 1, 0, "MyPaintItem"); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("smile.qml")); + view.show(); + view.raise(); + + return app.exec(); +} + +#include "main.moc" diff --git a/examples/quick/painteditem/smile/smile.pro b/examples/quick/painteditem/smile/smile.pro new file mode 100644 index 0000000000..b1af4ee0ad --- /dev/null +++ b/examples/quick/painteditem/smile/smile.pro @@ -0,0 +1,11 @@ +TEMPLATE = app +TARGET = painteditem + +QT += qml quick + +macx: CONFIG -= app_bundle + +SOURCES += main.cpp + +CONFIG += console + diff --git a/examples/quick/painteditem/smile/smile.qml b/examples/quick/painteditem/smile/smile.qml new file mode 100644 index 0000000000..33919bc04f --- /dev/null +++ b/examples/quick/painteditem/smile/smile.qml @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import MyModule 1.0 + +Rectangle { + width: 500 + height: 500 + gradient: Gradient { + GradientStop { position: 0.0; color: "#00249a" } + GradientStop { position: 0.7; color: "#ffd94f" } + GradientStop { position: 1.0; color: "#ffa322" } + } + MyPaintItem { + renderTarget:PaintedItem.Image + clip:true + width:240 + height:240 + anchors.left : parent.left + anchors.top :parent.top + anchors.margins: 10 + smooth: true + MouseArea { + anchors.fill:parent + onClicked: { + if (parent.face == ":-)") + parent.face = ":-("; + else + parent.face = ":-)"; + parent.update() + } + } + } + MyPaintItem { + clip:true + renderTarget:PaintedItem.Image + width:240 + height:240 + anchors.right : parent.right + anchors.top :parent.top + anchors.margins: 10 + smooth: true + MouseArea { + anchors.fill:parent + onClicked: { + if (parent.face == ":-)") + parent.face = ":-("; + else + parent.face = ":-)"; + parent.update() + } + } + } + MyPaintItem { + clip:true + renderTarget:PaintedItem.Image + width:240 + height:240 + anchors.left : parent.left + anchors.bottom :parent.bottom + anchors.margins: 10 + smooth: true + MouseArea { + anchors.fill:parent + onClicked: { + if (parent.face == ":-)") + parent.face = ":-("; + else + parent.face = ":-)"; + parent.update() + } + } + } + MyPaintItem { + clip:true + renderTarget:PaintedItem.Image + width:240 + height:240 + anchors.right : parent.right + anchors.bottom :parent.bottom + anchors.margins: 10 + smooth: true + MouseArea { + anchors.fill:parent + onClicked: { + if (parent.face == ":-)") + parent.face = ":-("; + else + parent.face = ":-)"; + parent.update() + } + } + } +} \ No newline at end of file diff --git a/examples/quick/painteditem/textballoons/TextBalloonPlugin/plugin.h b/examples/quick/painteditem/textballoons/TextBalloonPlugin/plugin.h new file mode 100644 index 0000000000..c500c1c525 --- /dev/null +++ b/examples/quick/painteditem/textballoons/TextBalloonPlugin/plugin.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "../textballoon.h" + +class TextBalloonPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "textballoon.json") +public: + void registerTypes(const char *uri) + { + qmlRegisterType(uri, 1, 0, "TextBalloon"); + } +}; diff --git a/examples/quick/painteditem/textballoons/TextBalloonPlugin/qmldir b/examples/quick/painteditem/textballoons/TextBalloonPlugin/qmldir new file mode 100644 index 0000000000..e8a08ae9d3 --- /dev/null +++ b/examples/quick/painteditem/textballoons/TextBalloonPlugin/qmldir @@ -0,0 +1 @@ +plugin qmltextballoonplugin diff --git a/examples/quick/painteditem/textballoons/textballoon.cpp b/examples/quick/painteditem/textballoons/textballoon.cpp new file mode 100644 index 0000000000..d097adfe1b --- /dev/null +++ b/examples/quick/painteditem/textballoons/textballoon.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "textballoon.h" + +//! [0] +TextBalloon::TextBalloon(QQuickItem *parent) + : QQuickPaintedItem(parent) + , rightAligned(false) +{ +} +//! [0] + +//! [1] +void TextBalloon::paint(QPainter *painter) +{ + QBrush brush(QColor("#007430")); + + painter->setBrush(brush); + painter->setPen(Qt::NoPen); + painter->setRenderHint(QPainter::Antialiasing); + + painter->drawRoundedRect(0, 0, boundingRect().width(), boundingRect().height() - 10, 10, 10); + + if (rightAligned) + { + const QPointF points[3] = { + QPointF(boundingRect().width() - 10.0, boundingRect().height() - 10.0), + QPointF(boundingRect().width() - 20.0, boundingRect().height()), + QPointF(boundingRect().width() - 30.0, boundingRect().height() - 10.0), + }; + painter->drawConvexPolygon(points, 3); + } + else + { + const QPointF points[3] = { + QPointF(10.0, boundingRect().height() - 10.0), + QPointF(20.0, boundingRect().height()), + QPointF(30.0, boundingRect().height() - 10.0), + }; + painter->drawConvexPolygon(points, 3); + } +} +//! [1] + +bool TextBalloon::isRightAligned() +{ + return this->rightAligned; +} + +void TextBalloon::setRightAligned(bool rightAligned) +{ + this->rightAligned = rightAligned; +} diff --git a/examples/quick/painteditem/textballoons/textballoon.h b/examples/quick/painteditem/textballoons/textballoon.h new file mode 100644 index 0000000000..93ed0a7105 --- /dev/null +++ b/examples/quick/painteditem/textballoons/textballoon.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TEXTBALLOON_H +#define TEXTBALLOON_H + +#include + +//! [0] +class TextBalloon : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(bool rightAligned READ isRightAligned WRITE setRightAligned NOTIFY rightAlignedChanged) + + public: + TextBalloon(QQuickItem *parent = 0); + void paint(QPainter *painter); + + bool isRightAligned(); + void setRightAligned(bool rightAligned); + + private: + bool rightAligned; + + signals: + void rightAlignedChanged(); +}; +//! [0] + +#endif diff --git a/examples/qtquick/painteditem/textballoons/textballoon.json b/examples/quick/painteditem/textballoons/textballoon.json similarity index 100% rename from examples/qtquick/painteditem/textballoons/textballoon.json rename to examples/quick/painteditem/textballoons/textballoon.json diff --git a/examples/quick/painteditem/textballoons/textballoons.pro b/examples/quick/painteditem/textballoons/textballoons.pro new file mode 100644 index 0000000000..d612048ee8 --- /dev/null +++ b/examples/quick/painteditem/textballoons/textballoons.pro @@ -0,0 +1,25 @@ +TEMPLATE = lib +CONFIG += qt plugin +QT += qml quick + +TARGET = qmltextballoonplugin + +HEADERS += TextBalloonPlugin/plugin.h \ + textballoon.h + +SOURCES += textballoon.cpp + +OTHER_FILES += textballoon.json + +DESTDIR = TextBalloonPlugin + +qdeclarativesources.files += \ + TextBalloonPlugin/qmldir + +qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem/textballoons/TextBalloonPlugin + +sources.files = textballoons.qml +sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem/textballoons +target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem/textballoons/TextBalloonPlugin + +INSTALLS = qdeclarativesources sources target diff --git a/examples/quick/painteditem/textballoons/textballoons.qml b/examples/quick/painteditem/textballoons/textballoons.qml new file mode 100644 index 0000000000..b00ce2bfed --- /dev/null +++ b/examples/quick/painteditem/textballoons/textballoons.qml @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import TextBalloonPlugin 1.0 + +Item { + height: 480 + width: 640 + + //! [0] + ListModel { + id: balloonModel + ListElement { + balloonWidth: 200 + } + ListElement { + balloonWidth: 350 + } + } + + ListView { + anchors.bottom: controls.top + anchors.bottomMargin: 2 + anchors.top: parent.top + id: balloonView + delegate: TextBalloon { + anchors.right: index % 2 == 0 ? undefined : parent.right + height: 60 + rightAligned: index % 2 == 0 ? false : true + width: balloonWidth + } + model: balloonModel + spacing: 5 + width: parent.width + } + //! [0] + + //! [1] + Rectangle { + id: controls + + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.margins: 1 + anchors.right: parent.right + border.width: 2 + color: "white" + height: parent.height * 0.15 + + Text { + anchors.centerIn: parent + text: "Add another balloon" + } + + MouseArea { + anchors.fill: parent + hoverEnabled: true + onClicked: { + balloonModel.append({"balloonWidth": Math.floor(Math.random() * 300 + 100)}) + balloonView.positionViewAtIndex(balloonView.count -1, ListView.End) + } + onEntered: { + parent.color = "#8ac953" + } + onExited: { + parent.color = "white" + } + } + } + //! [1] +} diff --git a/examples/quick/positioners/content/Button.qml b/examples/quick/positioners/content/Button.qml new file mode 100644 index 0000000000..ee3aa9057e --- /dev/null +++ b/examples/quick/positioners/content/Button.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: page + + property string text + property string icon + signal clicked + + border.color: "black"; color: "steelblue"; radius: 5 + width: pix.width + textelement.width + 13 + height: pix.height + 10 + + Image { id: pix; x: 5; y:5; source: parent.icon } + + Text { + id: textelement + text: page.text; color: "white" + x: pix.width + pix.x + 3 + anchors.verticalCenter: pix.verticalCenter + } + + MouseArea { + id: mr + anchors.fill: parent + onClicked: { parent.focus = true; page.clicked() } + } + + states: State { + name: "pressed"; when: mr.pressed + PropertyChanges { target: textelement; x: 5 } + PropertyChanges { target: pix; x: textelement.x + textelement.width + 3 } + } + + transitions: Transition { + NumberAnimation { properties: "x,left"; easing.type: Easing.InOutQuad; duration: 200 } + } +} diff --git a/examples/quick/positioners/content/add.png b/examples/quick/positioners/content/add.png new file mode 100644 index 0000000000..1ee45423e3 Binary files /dev/null and b/examples/quick/positioners/content/add.png differ diff --git a/examples/quick/positioners/content/del.png b/examples/quick/positioners/content/del.png new file mode 100644 index 0000000000..8d2eaed523 Binary files /dev/null and b/examples/quick/positioners/content/del.png differ diff --git a/examples/quick/positioners/positioners-attachedproperties.qml b/examples/quick/positioners/positioners-attachedproperties.qml new file mode 100644 index 0000000000..a05927f5ea --- /dev/null +++ b/examples/quick/positioners/positioners-attachedproperties.qml @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 100 + + // Create row with four rectangles, the fourth one is hidden + Row { + id: row + + Rectangle { + id: red + color: "red" + width: 100 + height: 100 + + // When mouse is clicked, display the values of the positioner + MouseArea { + anchors.fill: parent + onClicked: row.showInfo(red.Positioner) + } + } + + Rectangle { + id: green + color: "green" + width: 100 + height: 100 + + // When mouse is clicked, display the values of the positioner + MouseArea { + anchors.fill: parent + onClicked: row.showInfo(green.Positioner) + } + } + + Rectangle { + id: blue + color: "blue" + width: 100 + height: 100 + + // When mouse is clicked, display the values of the positioner + MouseArea { + anchors.fill: parent + onClicked: row.showInfo(blue.Positioner) + } + } + + // This rectangle is not visible, so it doesn't have a positioner value + Rectangle { + color: "black" + width: 100 + height: 100 + visible: false + } + + // Print the index of the child item in the positioner and convenience + // properties showing if it's the first or last item. + function showInfo(positioner) { + console.log("Item Index = " + positioner.index) + console.log(" isFirstItem = " + positioner.isFirstItem) + console.log(" isLastItem = " + positioner.isLastItem) + } + } +} diff --git a/examples/qtquick/positioners/positioners.qml b/examples/quick/positioners/positioners.qml similarity index 100% rename from examples/qtquick/positioners/positioners.qml rename to examples/quick/positioners/positioners.qml diff --git a/examples/qtquick/qtquick.pro b/examples/quick/quick.pro similarity index 100% rename from examples/qtquick/qtquick.pro rename to examples/quick/quick.pro diff --git a/examples/quick/righttoleft/layoutdirection/layoutdirection.qml b/examples/quick/righttoleft/layoutdirection/layoutdirection.qml new file mode 100644 index 0000000000..0c65647d5b --- /dev/null +++ b/examples/quick/righttoleft/layoutdirection/layoutdirection.qml @@ -0,0 +1,246 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: root + property bool mirror + property int direction: Qt.application.layoutDirection + LayoutMirroring.enabled: mirror + LayoutMirroring.childrenInherit: true + width: column.width + 80 + height: column.height + 40 + Column { + id: column + width: 190 + spacing: 10 + anchors.centerIn: parent + + Text { + text: "Row" + anchors.horizontalCenter: parent.horizontalCenter + } + + Row { + layoutDirection: root.direction + spacing: 10 + move: Transition { + NumberAnimation { + properties: "x" + } + } + Repeater { + model: 4 + Loader { + property int value: index + sourceComponent: positionerDelegate + } + } + } + + Text { + text: "Grid" + anchors.horizontalCenter: parent.horizontalCenter + } + + Grid { + layoutDirection: root.direction + spacing: 10; columns: 4 + move: Transition { + NumberAnimation { + properties: "x" + } + } + Repeater { + model: 11 + Loader { + property int value: index + sourceComponent: positionerDelegate + } + } + } + + Text { + text: "Flow" + anchors.horizontalCenter: parent.horizontalCenter + } + + Flow { + layoutDirection: root.direction + spacing: 10; width: parent.width + move: Transition { + NumberAnimation { + properties: "x" + } + } + Repeater { + model: 10 + Loader { + property int value: index + sourceComponent: positionerDelegate + } + } + } + + Text { + text: "ListView" + anchors.horizontalCenter: parent.horizontalCenter + } + + ListView { + id: listView + clip: true + width: parent.width; height: 40 + layoutDirection: root.direction + orientation: Qt.Horizontal + model: 48 + delegate: viewDelegate + } + + Text { + text: "GridView" + anchors.horizontalCenter: parent.horizontalCenter + } + + GridView { + clip: true + width: 200; height: 160 + cellWidth: 50; cellHeight: 50 + layoutDirection: root.direction + model: 48 + delegate: viewDelegate + } + + Rectangle { + height: 50; width: parent.width + color: mouseArea.pressed ? "black" : "gray" + Column { + anchors.centerIn: parent + Text { + text: root.direction ? "Right to left" : "Left to right" + color: "white" + font.pixelSize: 16 + anchors.horizontalCenter: parent.horizontalCenter + } + Text { + text: "(click here to toggle)" + color: "white" + font.pixelSize: 10 + font.italic: true + anchors.horizontalCenter: parent.horizontalCenter + } + } + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { + if (root.direction == Qt.LeftToRight) { + root.direction = Qt.RightToLeft; + } else { + root.direction = Qt.LeftToRight; + } + } + } + } + + Rectangle { + height: 50; width: parent.width + color: mouseArea2.pressed ? "black" : "gray" + Column { + anchors.centerIn: parent + Text { + text: root.mirror ? "Mirrored" : "Not mirrored" + color: "white" + font.pixelSize: 16 + anchors.horizontalCenter: parent.horizontalCenter + } + Text { + text: "(click here to toggle)" + color: "white" + font.pixelSize: 10 + font.italic: true + anchors.horizontalCenter: parent.horizontalCenter + } + } + MouseArea { + id: mouseArea2 + anchors.fill: parent + onClicked: { + root.mirror = !root.mirror; + } + } + } + } + + Component { + id: positionerDelegate + Rectangle { + width: 40; height: 40 + color: Qt.rgba(0.8/(parent.value+1),0.8/(parent.value+1),0.8/(parent.value+1),1.0) + Text { + text: parent.parent.value+1 + color: "white" + font.pixelSize: 18 + anchors.centerIn: parent + } + } + } + Component { + id: viewDelegate + Item { + width: (listView.effectiveLayoutDirection == Qt.LeftToRight ? (index == 48 - 1) : (index == 0)) ? 40 : 50 + Rectangle { + width: 40; height: 40 + color: Qt.rgba(0.5+(48 - index)*Math.random()/48, + 0.3+index*Math.random()/48, + 0.3*Math.random(), + 1.0) + Text { + text: index+1 + color: "white" + font.pixelSize: 18 + anchors.centerIn: parent + } + } + } + } +} + diff --git a/examples/quick/righttoleft/layoutdirection/layoutdirection.qmlproject b/examples/quick/righttoleft/layoutdirection/layoutdirection.qmlproject new file mode 100644 index 0000000000..33cbb3c9e2 --- /dev/null +++ b/examples/quick/righttoleft/layoutdirection/layoutdirection.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "layoutdirection.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/quick/righttoleft/layoutmirroring/layoutmirroring.qml b/examples/quick/righttoleft/layoutmirroring/layoutmirroring.qml new file mode 100644 index 0000000000..5c4739bd57 --- /dev/null +++ b/examples/quick/righttoleft/layoutmirroring/layoutmirroring.qml @@ -0,0 +1,313 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: root + property bool mirror: Qt.application.layoutDirection == Qt.RightToLeft + LayoutMirroring.enabled: mirror + LayoutMirroring.childrenInherit: true + width: 400 + height: 875 + color: "lightsteelblue" + + Column { + spacing: 10 + anchors { left: parent.left; right: parent.right; top: parent.top; margins: 10 } + + Text { + text: "Positioners" + anchors.left: parent.left + } + + Column { + id: positioners + spacing: 5 + anchors.left: parent.left + Row { + id: row + spacing: 4 + property string text: "THISISROW" + anchors.left: parent.left + Repeater { + model: parent.text.length + delegate: positionerDelegate + } + } + Flow { + id: flow + spacing: 4 + width: 90 + property string text: "THISISFLOW" + anchors.left: parent.left + Repeater { + model: parent.text.length + delegate: positionerDelegate + } + } + Grid { + id: grid + spacing: 4 + columns: 6 + property string text: "THISISGRID" + anchors.left: parent.left + Repeater { + model: parent.text.length + delegate: positionerDelegate + } + } + Component { + id: positionerDelegate + Text { + color: "white" + font.pixelSize: 20 + text: parent.text[index] + Rectangle { + z: -1 + opacity: 0.7 + color: "black" + anchors.fill: parent + } + } + } + } + + Text { + text: "Text alignment" + anchors.left: parent.left + } + + Rectangle { + id: textStrings + width: 148 + height: 85 + color: "white" + anchors.left: parent.left + Column { + spacing: 5 + width: parent.width + anchors { fill: parent; margins: 5 } + Text { + id: englishText + width: parent.width + text: "English text" + } + Text { + id: arabicText + width: parent.width + text: "النص العربي" + } + Text { + id: leftAlignedText + width: parent.width + text: "Text aligned to left" + horizontalAlignment: Text.AlignLeft + } + Text { + id: rightAlignedText + width: parent.width + text: "Text aligned to right" + horizontalAlignment: Text.AlignRight + } + } + } + + Text { + text: "Model views" + anchors.left: parent.left + } + + Column { + id: views + spacing: 10 + anchors.left: parent.left + ListView { + id: listView + z: -1 + clip: true + model: text.length + width: 360; height: 45 + orientation: Qt.Horizontal + property string text: "LISTVIEWLISTVIEWLISTVIEWLISTVIEWLISTVIEWLISTVIEW" + delegate: Rectangle { + color: "black" + width: 45; height: 45 + Rectangle { + anchors { fill: parent; margins: 1 } + color: "red" + } + Text { + text: listView.text[index] + font.pixelSize: 30 + anchors.centerIn: parent + } + } + } + GridView { + id: gridView + z: -1 + clip: true + model: text.length + width: 180; height: 90 + cellWidth: 45; cellHeight: 45 + property string text: "GRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEW" + anchors.left: parent.left + delegate: Rectangle { + color: "black" + width: 45; height: 45 + Rectangle { + anchors { fill: parent; margins: 1 } + color: "red" + } + Text { + anchors.centerIn: parent + font.pixelSize: 30 + text: gridView.text[index] + } + } + } + } + + Text { + text: "Item x" + anchors.left: parent.left + } + Rectangle { + id: items + color: Qt.rgba(0.2, 0.2, 0.2, 0.6) + width: 275; height: 95 + anchors.left: parent.left + Rectangle { + y: 5; x: 5 + width: 130; height: 40 + Text { + text: "Item with x: 5\n(not mirrored)" + anchors.centerIn: parent + } + } + Rectangle { + color: Qt.rgba(0.7, 0.7, 0.7) + y: 50; x: mirror(5) + width: 130; height: 40 + function mirror(value) { + return LayoutMirroring.enabled ? (parent.width - width - value) : value; + } + Text { + text: "Item with x: " + parent.x + "\n(manually mirrored)" + anchors.centerIn: parent + } + } + } + Text { + text: "Item anchors" + anchors.left: parent.left + } + + Rectangle { + id: anchoredItems + color: Qt.rgba(0.2, 0.2, 0.2, 0.6) + width: 270; height: 170 + anchors.left: parent.left + Rectangle { + id: blackRectangle + color: "black" + width: 180; height: 90 + anchors { horizontalCenter: parent.horizontalCenter; horizontalCenterOffset: 30 } + Text { + text: "Horizontal center anchored\nwith offset 30\nto the horizontal center\nof the parent." + color: "white" + anchors.centerIn: parent + } + } + Rectangle { + id: whiteRectangle + color: "white" + width: 120; height: 70 + anchors { left: parent.left; bottom: parent.bottom } + Text { + text: "Left side anchored\nto the left side\nof the parent." + color: "black" + anchors.centerIn: parent + } + } + Rectangle { + id: grayRectangle + color: Qt.rgba(0.7, 0.7, 0.7) + width: 140; height: 90 + anchors { right: parent.right; bottom: parent.bottom } + Text { + text: "Right side anchored\nto the right side\nof the parent." + anchors.centerIn: parent + } + } + } + Rectangle { + id: mirrorButton + color: mouseArea2.pressed ? "black" : "gray" + height: 50; width: parent.width + anchors.left: parent.left + Column { + anchors.centerIn: parent + Text { + text: root.mirror ? "Mirrored" : "Not mirrored" + color: "white" + font.pixelSize: 16 + anchors.horizontalCenter: parent.horizontalCenter + } + Text { + text: "(click here to toggle)" + color: "white" + font.pixelSize: 10 + font.italic: true + anchors.horizontalCenter: parent.horizontalCenter + } + } + MouseArea { + id: mouseArea2 + anchors.fill: parent + onClicked: { + root.mirror = !root.mirror; + } + } + } + } +} + diff --git a/examples/quick/righttoleft/layoutmirroring/layoutmirroring.qmlproject b/examples/quick/righttoleft/layoutmirroring/layoutmirroring.qmlproject new file mode 100644 index 0000000000..72bc04a8a9 --- /dev/null +++ b/examples/quick/righttoleft/layoutmirroring/layoutmirroring.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "layoutmirroring.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/quick/righttoleft/textalignment/textalignment.qml b/examples/quick/righttoleft/textalignment/textalignment.qml new file mode 100644 index 0000000000..ef5b97bb1a --- /dev/null +++ b/examples/quick/righttoleft/textalignment/textalignment.qml @@ -0,0 +1,427 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: root + color: "white" + width: containerColumn.width + height: containerColumn.height + containerColumn.anchors.topMargin + + property bool mirror: false + property variant horizontalAlignment: undefined + + property variant editorType: ["Plain Text", "Styled Text", "Plain Rich Text", "Italic Rich Text", "Plain TextEdit", "Italic TextEdit", "TextInput"] + property variant text: ["", " ", "Hello world!", "مرحبا العالم!", "Hello world! Hello!\nHello world! Hello!", "مرحبا العالم! مرحبا! مرحبا العالم! مرحبا!" ,"مرحبا العالم! مرحبا! مرحبا Hello world!\nالعالم! مرحبا!"] + property variant description: ["empty text", "white-space-only text", "left-to-right text", "right-to-left text", "multi-line left-to-right text", "multi-line right-to-left text", "multi-line bidi text"] + property variant textComponents: [plainTextComponent, styledTextComponent, richTextComponent, italicRichTextComponent, plainTextEdit, italicTextEdit, textInput] + + function shortText(horizontalAlignment) { + + // all the different QML editors have + // the same alignment values + switch (horizontalAlignment) { + case Text.AlignLeft: + return "L"; + case Text.AlignRight: + return "R"; + case Text.AlignHCenter: + return "C"; + case Text.AlignJustify: + return "J"; + default: + return "Error"; + } + } + Column { + id: containerColumn + spacing: 10 + width: editorTypeRow.width + anchors { top: parent.top; topMargin: 5 } + Row { + id: editorTypeRow + Repeater { + model: editorType.length + Item { + width: editorColumn.width + height: editorColumn.height + Column { + id: editorColumn + spacing: 5 + width: textColumn.width+10 + Text { + text: root.editorType[index] + font.pixelSize: 16 + anchors.horizontalCenter: parent.horizontalCenter + } + Column { + id: textColumn + spacing: 5 + anchors.horizontalCenter: parent.horizontalCenter + Repeater { + model: textComponents.length + delegate: textComponents[index] + } + } + } + } + } + } + Column { + spacing: 2 + width: parent.width + Rectangle { + // button + height: 50; width: parent.width + color: mouseArea.pressed ? "black" : "lightgray" + Column { + anchors.centerIn: parent + Text { + text: root.mirror ? "Mirrored" : "Not mirrored" + color: "white" + font.pixelSize: 16 + anchors.horizontalCenter: parent.horizontalCenter + } + Text { + text: "(click here to toggle)" + color: "white" + font.pixelSize: 10 + font.italic: true + anchors.horizontalCenter: parent.horizontalCenter + } + } + MouseArea { + id: mouseArea + property int index: 0 + anchors.fill: parent + onClicked: root.mirror = !root.mirror + } + } + Rectangle { + // button + height: 50; width: parent.width + color: mouseArea2.pressed ? "black" : "gray" + Column { + anchors.centerIn: parent + Text { + text: { + if (root.horizontalAlignment == undefined) + return "Implict alignment"; + switch (root.horizontalAlignment) { + case Text.AlignLeft: + return "Left alignment"; + case Text.AlignRight: + return "Right alignment"; + case Text.AlignHCenter: + return "Center alignment"; + case Text.AlignJustify: + return "Justify alignment"; + } + } + color: "white" + font.pixelSize: 16 + anchors.horizontalCenter: parent.horizontalCenter + } + Text { + text: "(click here to toggle)" + color: "white" + font.pixelSize: 10 + font.italic: true + anchors.horizontalCenter: parent.horizontalCenter + } + } + MouseArea { + id: mouseArea2 + property int index: 0 + anchors.fill: parent + onClicked: { + if (index < 0) { + root.horizontalAlignment = undefined; + } else { + root.horizontalAlignment = Math.pow(2, index); + } + index = (index + 2) % 5 - 1; + } + } + } + } + } + + Component { + id: plainTextComponent + Text { + width: 180 + text: root.text[index] + font.pixelSize: 24 + wrapMode: Text.WordWrap + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + textFormat: Text.RichText + Rectangle { + z: -1 + color: Qt.rgba(0.8, 0.2, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: styledTextComponent + Text { + width: 180 + text: root.text[index] + font.pixelSize: 24 + wrapMode: Text.WordWrap + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + textFormat: Text.RichText + style: Text.Sunken + styleColor: "white" + Rectangle { + z: -1 + color: Qt.rgba(0.8, 0.2, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: richTextComponent + Text { + width: 180 + text: root.text[index] + font.pixelSize: 24 + wrapMode: Text.WordWrap + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + textFormat: Text.RichText + Rectangle { + z: -1 + color: Qt.rgba(0.8, 0.2, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: italicRichTextComponent + Text { + width: 180 + text: "" + root.text[index] + "" + font.pixelSize: 24 + wrapMode: Text.WordWrap + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + textFormat: Text.RichText + property variant backgroundColor: Qt.rgba(0.8, 0.2, 0.2, 0.3) + Rectangle { + z: -1 + color: parent.backgroundColor + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: plainTextEdit + TextEdit { + width: 180 + text: root.text[index] + font.pixelSize: 24 + cursorVisible: true + wrapMode: TextEdit.WordWrap + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + Rectangle { + z: -1 + color: Qt.rgba(0.5, 0.5, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: italicTextEdit + TextEdit { + width: 180 + text: "" + root.text[index] + "" + font.pixelSize: 24 + cursorVisible: true + wrapMode: TextEdit.WordWrap + textFormat: TextEdit.RichText + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + Rectangle { + z: -1 + color: Qt.rgba(0.5, 0.5, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: textInput + Item { + width: 180 + height: textInput.text.length > 20 ? 3*textInput.height : textInput.height + TextInput { + id: textInput + width: 180 + text: root.text[index] + font.pixelSize: 24 + cursorVisible: true + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + Rectangle { + z: -1 + color: Qt.rgba(0.6, 0.4, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + } +} + diff --git a/examples/quick/righttoleft/textalignment/textalignment.qmlproject b/examples/quick/righttoleft/textalignment/textalignment.qmlproject new file mode 100644 index 0000000000..e4b5061364 --- /dev/null +++ b/examples/quick/righttoleft/textalignment/textalignment.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "textalignment.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/quick/shadereffects/content/Slider.qml b/examples/quick/shadereffects/content/Slider.qml new file mode 100644 index 0000000000..ff5f628b14 --- /dev/null +++ b/examples/quick/shadereffects/content/Slider.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + property real value: bar.x / (foo.width - bar.width) + Item { + id: foo + width: parent.width - 4 + height: 6 + anchors.centerIn: parent + + Rectangle { + height: parent.height + anchors.left: parent.left + anchors.right: bar.horizontalCenter + color: "blue" + radius: 3 + } + Rectangle { + height: parent.height + anchors.left: bar.horizontalCenter + anchors.right: parent.right + color: "gray" + radius: 3 + } + Rectangle { + anchors.fill: parent + color: "transparent" + radius: 3 + border.width: 2 + border.color: "black" + } + + Rectangle { + id: bar + y: -7 + width: 20 + height: 20 + radius: 15 + color: "white" + border.width: 2 + border.color: "black" + MouseArea { + anchors.fill: parent + drag.target: parent + drag.axis: Drag.XAxis + drag.minimumX: 0 + drag.maximumX: foo.width - parent.width + } + } + } +} + diff --git a/examples/quick/shadereffects/content/face-smile.png b/examples/quick/shadereffects/content/face-smile.png new file mode 100644 index 0000000000..3d66d72578 Binary files /dev/null and b/examples/quick/shadereffects/content/face-smile.png differ diff --git a/examples/quick/shadereffects/content/qt-logo.png b/examples/quick/shadereffects/content/qt-logo.png new file mode 100644 index 0000000000..7d3e97eb36 Binary files /dev/null and b/examples/quick/shadereffects/content/qt-logo.png differ diff --git a/examples/quick/shadereffects/shadereffects.qml b/examples/quick/shadereffects/shadereffects.qml new file mode 100644 index 0000000000..b820c8131e --- /dev/null +++ b/examples/quick/shadereffects/shadereffects.qml @@ -0,0 +1,315 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Image { + width: 320 + height: 480 +/*! + \title QML Examples - Shader Effects + \example declarative/shadereffects + \image qml-shadereffects-example.png + \brief This is a shader effects example + + This example demonstrates a couple of visual effects that you can perform + with shaders in QtQuick 2.0 +*/ + source: "../snake/content/pics/background.png" + + Flickable { + anchors.fill: parent + contentWidth: 640 + contentHeight: 360 + + ShaderEffectSource { + id: theSource + sourceItem: theItem + smooth: true + } + + function saturate(x) { + return Math.min(Math.max(x, 0), 1) + } + + function sliderToColor(x) { + return Qt.rgba(saturate(Math.max(2 - 6 * x, 6 * x - 4)), + saturate(Math.min(6 * x, 4 - 6 * x)), + saturate(Math.min(6 * x - 2, 6 - 6 * x))) + } + + Grid { + anchors.centerIn: parent + columns: 3 + + Item { + id: theItem + width: 180 + height: 180 + ListView { + anchors.centerIn: parent + width: 160 + height: 140 + clip: true + snapMode: ListView.SnapOneItem + model: VisualItemModel { + Text { + width: 160 + height: 140 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + font.pixelSize: 120 + font.family: "Times" + color: "blue" + text: "Qt" + } + Image { + width: 160 + height: 140 + source: "content/qt-logo.png" + smooth: true + } + Image { + width: 160 + height: 140 + source: "content/face-smile.png" + smooth: true + } + } + } + } + ShaderEffect { + width: 180 + height: 180 + property variant source: theSource + property real amplitude: 0.04 * wobbleSlider.value + property real frequency: 20 + property real time: 0 + NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 } + fragmentShader: + "uniform lowp float qt_Opacity;" + + "uniform highp float amplitude;" + + "uniform highp float frequency;" + + "uniform highp float time;" + + "uniform sampler2D source;" + + "varying highp vec2 qt_TexCoord0;" + + "void main() {" + + " highp vec2 p = sin(time + frequency * qt_TexCoord0);" + + " gl_FragColor = texture2D(source, qt_TexCoord0 + amplitude * vec2(p.y, -p.x)) * qt_Opacity;" + + "}" + Slider { + id: wobbleSlider + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + height: 40 + } + } + ShaderEffect { + width: 180 + height: 180 + property variant source: theSource + property variant shadow: ShaderEffectSource { + smooth: true + sourceItem: ShaderEffect { + width: theItem.width + height: theItem.height + property variant delta: Qt.size(0.0, 1.0 / height) + property variant source: ShaderEffectSource { + smooth: true + sourceItem: ShaderEffect { + width: theItem.width + height: theItem.height + property variant delta: Qt.size(1.0 / width, 0.0) + property variant source: theSource + fragmentShader: " + uniform lowp float qt_Opacity; + uniform sampler2D source; + uniform highp vec2 delta; + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta) + + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta) + + 0.2466 * texture2D(source, qt_TexCoord0) + + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta) + + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity; + }" + } + } + fragmentShader: " + uniform lowp float qt_Opacity; + uniform sampler2D source; + uniform highp vec2 delta; + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta) + + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta) + + 0.2466 * texture2D(source, qt_TexCoord0) + + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta) + + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity; + }" + } + } + property real angle: 0 + property variant offset: Qt.point(15.0 * Math.cos(angle), 15.0 * Math.sin(angle)) + NumberAnimation on angle { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 6000 } + property variant delta: Qt.size(offset.x / width, offset.y / height) + property real darkness: shadowSlider.value + fragmentShader: " + uniform lowp float qt_Opacity; + uniform highp vec2 offset; + uniform sampler2D source; + uniform sampler2D shadow; + uniform highp float darkness; + uniform highp vec2 delta; + varying highp vec2 qt_TexCoord0; + void main() { + lowp vec4 fg = texture2D(source, qt_TexCoord0); + lowp vec4 bg = texture2D(shadow, qt_TexCoord0 + delta); + gl_FragColor = (fg + vec4(0., 0., 0., darkness * bg.a) * (1. - fg.a)) * qt_Opacity; + }" + Slider { + id: shadowSlider + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + height: 40 + } + } + ShaderEffect { + width: 180 + height: 180 + property variant source: theSource + property variant delta: Qt.size(0.5 / width, 0.5 / height) + fragmentShader: " + uniform sampler2D source; + uniform highp vec2 delta; + uniform highp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + void main() { + lowp vec4 tl = texture2D(source, qt_TexCoord0 - delta); + lowp vec4 tr = texture2D(source, qt_TexCoord0 + vec2(delta.x, -delta.y)); + lowp vec4 bl = texture2D(source, qt_TexCoord0 - vec2(delta.x, -delta.y)); + lowp vec4 br = texture2D(source, qt_TexCoord0 + delta); + lowp vec4 gx = (tl + bl) - (tr + br); + lowp vec4 gy = (tl + tr) - (bl + br); + gl_FragColor.xyz = vec3(0.); + gl_FragColor.w = clamp(dot(sqrt(gx * gx + gy * gy), vec4(1.)), 0., 1.) * qt_Opacity; + }" + } + ShaderEffect { + width: 180 + height: 180 + property variant source: theSource + property color tint: sliderToColor(colorizeSlider.value) + fragmentShader: " + uniform sampler2D source; + uniform lowp vec4 tint; + uniform lowp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + void main() { + lowp vec4 c = texture2D(source, qt_TexCoord0); + lowp float lo = min(min(c.x, c.y), c.z); + lowp float hi = max(max(c.x, c.y), c.z); + gl_FragColor = qt_Opacity * vec4(mix(vec3(lo), vec3(hi), tint.xyz), c.w); + }" + Slider { + id: colorizeSlider + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + height: 40 + } + } + ShaderEffect { + width: 180 + height: 180 + mesh: Qt.size(10, 10) + property variant source: theSource + property real bend: 0 + property real minimize: 0 + property real side: genieSlider.value + SequentialAnimation on bend { + loops: Animation.Infinite + NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine } + PauseAnimation { duration: 1600 } + NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine } + PauseAnimation { duration: 1000 } + } + SequentialAnimation on minimize { + loops: Animation.Infinite + PauseAnimation { duration: 300 } + NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine } + PauseAnimation { duration: 1000 } + NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine } + PauseAnimation { duration: 1300 } + } + vertexShader: " + uniform highp mat4 qt_Matrix; + uniform highp float bend; + uniform highp float minimize; + uniform highp float side; + uniform highp float width; + uniform highp float height; + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + varying highp vec2 qt_TexCoord0; + void main() { + qt_TexCoord0 = qt_MultiTexCoord0; + highp vec4 pos = qt_Vertex; + pos.y = mix(qt_Vertex.y, height, minimize); + highp float t = pos.y / height; + t = (3. - 2. * t) * t * t; + pos.x = mix(qt_Vertex.x, side * width, t * bend); + gl_Position = qt_Matrix * pos; + }" + Slider { + id: genieSlider + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + height: 40 + } + } + } + } +} diff --git a/examples/quick/text/fonts/availableFonts.qml b/examples/quick/text/fonts/availableFonts.qml new file mode 100644 index 0000000000..0b87259556 --- /dev/null +++ b/examples/quick/text/fonts/availableFonts.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 480; height: 640; color: "steelblue" + + ListView { + anchors.fill: parent; model: Qt.fontFamilies() + + delegate: Item { + height: 40; width: ListView.view.width + Text { + anchors.centerIn: parent + text: modelData; font.family: modelData; font.pixelSize: 24; color: "white" + } + } + } +} diff --git a/examples/quick/text/fonts/banner.qml b/examples/quick/text/fonts/banner.qml new file mode 100644 index 0000000000..6c9aa25fa1 --- /dev/null +++ b/examples/quick/text/fonts/banner.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: screen + + property int pixelSize: screen.height * 1.25 + property color textColor: "lightsteelblue" + property string text: "Hello world! " + + width: 640; height: 320 + color: "steelblue" + + Row { + y: -screen.height / 4.5 + + NumberAnimation on x { from: 0; to: -text.width; duration: 6000; loops: Animation.Infinite } + Text { id: text; font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } + Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } + Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } + } +} diff --git a/tests/auto/qtquick2/qdeclarativefontloader/data/tarzeau_ocr_a.ttf b/examples/quick/text/fonts/content/fonts/tarzeau_ocr_a.ttf similarity index 100% rename from tests/auto/qtquick2/qdeclarativefontloader/data/tarzeau_ocr_a.ttf rename to examples/quick/text/fonts/content/fonts/tarzeau_ocr_a.ttf diff --git a/examples/quick/text/fonts/fonts.qml b/examples/quick/text/fonts/fonts.qml new file mode 100644 index 0000000000..78cef25eae --- /dev/null +++ b/examples/quick/text/fonts/fonts.qml @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + property string myText: "The quick brown fox jumps over the lazy dog." + + width: 800; height: 480 + color: "steelblue" + + FontLoader { id: fixedFont; name: "Courier" } + FontLoader { id: localFont; source: "content/fonts/tarzeau_ocr_a.ttf" } + FontLoader { id: webFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" } + + Column { + anchors { fill: parent; leftMargin: 10; rightMargin: 10 } + spacing: 15 + + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideRight + font.family: "Times"; font.pointSize: 42 + } + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideLeft + font { family: "Times"; pointSize: 42; capitalization: Font.AllUppercase } + } + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideMiddle + font { family: fixedFont.name; pointSize: 42; weight: Font.Bold; capitalization: Font.AllLowercase } + } + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideRight + font { family: fixedFont.name; pointSize: 42; italic: true; capitalization: Font.SmallCaps } + } + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideLeft + font { family: localFont.name; pointSize: 42; capitalization: Font.Capitalize } + } + Text { + text: { + if (webFont.status == FontLoader.Ready) myText + else if (webFont.status == FontLoader.Loading) "Loading..." + else if (webFont.status == FontLoader.Error) "Error loading font" + } + color: "lightsteelblue" + width: parent.width + elide: Text.ElideMiddle + font.family: webFont.name; font.pointSize: 42 + } + } +} diff --git a/examples/quick/text/fonts/hello.qml b/examples/quick/text/fonts/hello.qml new file mode 100644 index 0000000000..d9479fb208 --- /dev/null +++ b/examples/quick/text/fonts/hello.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: screen + + width: 800; height: 480 + color: "black" + + Item { + id: container + x: screen.width / 2; y: screen.height / 2 + + Text { + id: text + anchors.centerIn: parent + color: "white" + text: "Hello world!" + font.pixelSize: 60 + smooth: true + + SequentialAnimation on font.letterSpacing { + loops: Animation.Infinite; + NumberAnimation { from: 0; to: 150; easing.type: Easing.InQuad; duration: 3000 } + ScriptAction { + script: { + container.y = (screen.height / 4) + (Math.random() * screen.height / 2) + container.x = (screen.width / 4) + (Math.random() * screen.width / 2) + } + } + } + + SequentialAnimation on opacity { + loops: Animation.Infinite; + NumberAnimation { from: 1; to: 0; duration: 2600 } + PauseAnimation { duration: 400 } + } + } + } +} diff --git a/examples/quick/text/imgtag/TextWithImage.qml b/examples/quick/text/imgtag/TextWithImage.qml new file mode 100644 index 0000000000..bc09aa2a52 --- /dev/null +++ b/examples/quick/text/imgtag/TextWithImage.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Text { + width: parent.width + font.pointSize: 14 + wrapMode: Text.WordWrap + textFormat: Text.StyledText + horizontalAlignment: main.hAlign + + Rectangle { + border.color: "#efefef" + color: "transparent" + anchors.fill: parent + } +} diff --git a/tests/auto/qtquick2/qquicktext/data/images/face-sad.png b/examples/quick/text/imgtag/images/face-sad.png similarity index 100% rename from tests/auto/qtquick2/qquicktext/data/images/face-sad.png rename to examples/quick/text/imgtag/images/face-sad.png diff --git a/examples/quick/text/imgtag/images/face-smile-big.png b/examples/quick/text/imgtag/images/face-smile-big.png new file mode 100644 index 0000000000..d05e0bf21e Binary files /dev/null and b/examples/quick/text/imgtag/images/face-smile-big.png differ diff --git a/examples/quick/text/imgtag/images/face-smile.png b/examples/quick/text/imgtag/images/face-smile.png new file mode 100644 index 0000000000..e5e1d1353c Binary files /dev/null and b/examples/quick/text/imgtag/images/face-smile.png differ diff --git a/tests/auto/qtquick2/qquicktext/data/images/heart200.png b/examples/quick/text/imgtag/images/heart200.png similarity index 100% rename from tests/auto/qtquick2/qquicktext/data/images/heart200.png rename to examples/quick/text/imgtag/images/heart200.png diff --git a/examples/quick/text/imgtag/images/qtlogo.png b/examples/quick/text/imgtag/images/qtlogo.png new file mode 100644 index 0000000000..996719a4c6 Binary files /dev/null and b/examples/quick/text/imgtag/images/qtlogo.png differ diff --git a/tests/auto/qtquick2/qquicktext/data/images/starfish_2.png b/examples/quick/text/imgtag/images/starfish_2.png similarity index 100% rename from tests/auto/qtquick2/qquicktext/data/images/starfish_2.png rename to examples/quick/text/imgtag/images/starfish_2.png diff --git a/examples/quick/text/imgtag/imgtag.qml b/examples/quick/text/imgtag/imgtag.qml new file mode 100644 index 0000000000..9d181af2cb --- /dev/null +++ b/examples/quick/text/imgtag/imgtag.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: main + width: 320; height: 480 + focus: true + + property var hAlign: Text.AlignLeft + + Flickable { + anchors.fill: parent + contentWidth: parent.width + contentHeight: col.height + 20 + + Column { + id: col + x: 10; y: 10 + spacing: 20 + width: parent.width - 20 + + TextWithImage { + text: "This is a happy face" + } + TextWithImage { + text: "This is a veryhappy face aligned in the middle." + } + TextWithImage { + elide: Text.ElideRight + maximumLineCount: 2 + text: "This is a sad face aligned to the top. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc rutrum dui pretium ipsum malesuada venenatis. Nulla sed turpis risus. Integer sit amet odio quis mauris varius venenatisLorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc rutrum dui pretium ipsum malesuada venenatis. Nulla sed turpis risus. Integer sit amet odio quis mauris varius venenatis." + } + TextWithImage { + text: "This is a tinyhappy face." + } + TextWithImage { + text: "This is a starfishaligned to the top and another onealigned to the bottom." + } + TextWithImage { + text: "Qt logosaligned in the middle with different sizes." + } + TextWithImage { + text: "Some hearts with different sizes." + } + TextWithImage { + text: "Resized imagefrom the internet." + } + TextWithImage { + text: "Imagefrom the internet." + } + TextWithImage { + height: 120 + verticalAlignment: Text.AlignVCenter + text: "This is a happy face with an explicit height." + } + } + } + + Keys.onUpPressed: main.hAlign = Text.AlignHCenter + Keys.onLeftPressed: main.hAlign = Text.AlignLeft + Keys.onRightPressed: main.hAlign = Text.AlignRight +} diff --git a/examples/quick/text/styledtext-layout.qml b/examples/quick/text/styledtext-layout.qml new file mode 100644 index 0000000000..4571330568 --- /dev/null +++ b/examples/quick/text/styledtext-layout.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: main + width: 320; height: 480 + focus: true + + property real offset: 0 + property real margin: 10 + + Keys.onLeftPressed: myText.horizontalAlignment = Text.AlignLeft + Keys.onUpPressed: myText.horizontalAlignment = Text.AlignHCenter + Keys.onRightPressed: myText.horizontalAlignment = Text.AlignRight + Keys.onDownPressed: myText.horizontalAlignment = Text.AlignJustify + + Text { + id: myText + anchors.fill: parent + anchors.margins: 10 + wrapMode: Text.WordWrap + font.family: "Times New Roman" + font.pixelSize: 13 + textFormat: Text.StyledText + horizontalAlignment: Text.AlignJustify + + text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer at ante dui sed eu egestas est facilis www.nokia.com.
Curabitur ante est, pulvinar quis adipiscing a, iaculis id ipsum. Phasellus id neque id velit facilisis cursus ac sit amet nibh. Donec enim arcu, pharetra non semper nec, iaculis eget elit. Nunc blandit condimentum odio vel egestas.
  • Coffee
    1. Espresso
    2. Cappuccino
    3. Flat White
    4. Latte
  • Juice
    1. Orange
    2. Apple
    3. Pineapple
    4. Tomato

Proin consectetur sapien in ipsum lacinia sit amet mattis orci interdum. Quisque vitae accumsan lectus. Ut nisi turpis, sollicitudin ut dignissim id, fermentum ac est. Maecenas nec libero leo. Sed ac leo eget ipsum ultricies viverra sit amet eu orci. Praesent et tortor risus, viverra accumsan sapien. Sed faucibus eleifend lectus, sed euismod urna porta eu. Aenean ultricies lectus ut orci dictum quis convallis nisi ultrices. Nunc elit mi, iaculis a porttitor rutrum, venenatis malesuada nisi. Suspendisse turpis quam, euismod non imperdiet et, rutrum nec ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit." + + onLineLaidOut: { + line.width = width / 2 - (2 * margin) + if (line.number === 30) { + main.offset = line.y + } + if (line.number >= 30) { + line.x = width / 2 + margin + line.y -= main.offset + } + if ((line.y + line.height) > rect.y && line.y < (rect.y + rect.height)) { + if (line.number < 30) + line.width = Math.min((rect.x - line.x), line.width) + else { + line.x = Math.max((rect.x + rect.width), width / 2 + margin) + line.width = Math.min((width - margin - line.x), line.width) + } + } + } + + Item { + id: rect + x: 28; y: 20 + width: 60; height: 60 + + Rectangle { + anchors { fill: parent; leftMargin: 2; rightMargin: 2 } + color: "lightsteelblue"; opacity: 0.3 + } + + MouseArea { + anchors.fill: parent + drag.target: rect + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: mouse.button == Qt.RightButton ? myText.font.pixelSize -= 1 : myText.font.pixelSize += 1 + onPositionChanged: myText.doLayout() + } + } + } + +} diff --git a/examples/qtquick/text/text.qml b/examples/quick/text/text.qml similarity index 100% rename from examples/qtquick/text/text.qml rename to examples/quick/text/text.qml diff --git a/examples/quick/text/text.qmlproject b/examples/quick/text/text.qmlproject new file mode 100644 index 0000000000..c08d9b9a89 --- /dev/null +++ b/examples/quick/text/text.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "text.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/quick/text/textselection/pics/endHandle.png b/examples/quick/text/textselection/pics/endHandle.png new file mode 100644 index 0000000000..1a4bc5d7a0 Binary files /dev/null and b/examples/quick/text/textselection/pics/endHandle.png differ diff --git a/examples/quick/text/textselection/pics/endHandle.sci b/examples/quick/text/textselection/pics/endHandle.sci new file mode 100644 index 0000000000..4f51f24278 --- /dev/null +++ b/examples/quick/text/textselection/pics/endHandle.sci @@ -0,0 +1,5 @@ +border.left: 0 +border.top: 6 +border.bottom: 6 +border.right: 6 +source: endHandle.png diff --git a/examples/quick/text/textselection/pics/startHandle.png b/examples/quick/text/textselection/pics/startHandle.png new file mode 100644 index 0000000000..deedcd5c91 Binary files /dev/null and b/examples/quick/text/textselection/pics/startHandle.png differ diff --git a/examples/quick/text/textselection/pics/startHandle.sci b/examples/quick/text/textselection/pics/startHandle.sci new file mode 100644 index 0000000000..f9eae204c1 --- /dev/null +++ b/examples/quick/text/textselection/pics/startHandle.sci @@ -0,0 +1,5 @@ +border.left: 6 +border.top: 6 +border.bottom: 6 +border.right: 0 +source: startHandle.png diff --git a/examples/quick/text/textselection/textselection.qml b/examples/quick/text/textselection/textselection.qml new file mode 100644 index 0000000000..7938ce5bf7 --- /dev/null +++ b/examples/quick/text/textselection/textselection.qml @@ -0,0 +1,211 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Rectangle { + id: editor + color: "lightGrey" + width: 640; height: 480 + + Rectangle { + color: "white" + anchors.fill: parent + anchors.margins: 20 + + BorderImage { + id: startHandle + source: "pics/startHandle.sci" + opacity: 0.0 + width: 10 + x: edit.positionToRectangle(edit.selectionStart).x - flick.contentX-width + y: edit.positionToRectangle(edit.selectionStart).y - flick.contentY + height: edit.positionToRectangle(edit.selectionStart).height + } + + BorderImage { + id: endHandle + source: "pics/endHandle.sci" + opacity: 0.0 + width: 10 + x: edit.positionToRectangle(edit.selectionEnd).x - flick.contentX + y: edit.positionToRectangle(edit.selectionEnd).y - flick.contentY + height: edit.positionToRectangle(edit.selectionEnd).height + } + + Flickable { + id: flick + + anchors.fill: parent + contentWidth: edit.paintedWidth + contentHeight: edit.paintedHeight + interactive: true + clip: true + + function ensureVisible(r) { + if (contentX >= r.x) + contentX = r.x; + else if (contentX+width <= r.x+r.width) + contentX = r.x+r.width-width; + if (contentY >= r.y) + contentY = r.y; + else if (contentY+height <= r.y+r.height) + contentY = r.y+r.height-height; + } + + TextEdit { + id: edit + width: flick.width + height: flick.height + focus: true + wrapMode: TextEdit.Wrap + textFormat: TextEdit.RichText + + onCursorRectangleChanged: flick.ensureVisible(cursorRectangle) + + text: "

Text Selection

" + +"

This example is a whacky text selection mechanisms, showing how these can be implemented in the TextEdit element, to cater for whatever style is appropriate for the target platform." + +"

Press-and-hold to select a word, then drag the selection handles." + +"

Drag outside the selection to scroll the text." + +"

Click inside the selection to cut/copy/paste/cancel selection." + +"

It's too whacky to let you paste if there is no current selection." + + } + } + + Item { + id: menu + opacity: 0.0 + width: 100 + height: 120 + anchors.centerIn: parent + + Rectangle { + border.width: 1 + border.color: "darkBlue" + radius: 15 + color: "#806080FF" + anchors.fill: parent + } + + Column { + anchors.centerIn: parent + spacing: 8 + + Rectangle { + border.width: 1 + border.color: "darkBlue" + color: "#ff7090FF" + width: 60 + height: 16 + + Text { anchors.centerIn: parent; text: "Cut" } + + MouseArea { + anchors.fill: parent + onClicked: { edit.cut(); editor.state = "" } + } + } + + Rectangle { + border.width: 1 + border.color: "darkBlue" + color: "#ff7090FF" + width: 60 + height: 16 + + Text { anchors.centerIn: parent; text: "Copy" } + + MouseArea { + anchors.fill: parent + onClicked: { edit.copy(); editor.state = "selection" } + } + } + + Rectangle { + border.width: 1 + border.color: "darkBlue" + color: "#ff7090FF" + width: 60 + height: 16 + + Text { anchors.centerIn: parent; text: "Paste" } + + MouseArea { + anchors.fill: parent + onClicked: { edit.paste(); edit.cursorPosition = edit.selectionEnd; editor.state = "" } + } + } + + Rectangle { + border.width: 1 + border.color: "darkBlue" + color: "#ff7090FF" + width: 60 + height: 16 + + Text { anchors.centerIn: parent; text: "Deselect" } + + MouseArea { + anchors.fill: parent + onClicked: { + edit.cursorPosition = edit.selectionEnd; + edit.deselect(); + editor.state = "" + } + } + } + } + } + } + + states: [ + State { + name: "selection" + PropertyChanges { target: startHandle; opacity: 1.0 } + PropertyChanges { target: endHandle; opacity: 1.0 } + }, + State { + name: "menu" + PropertyChanges { target: startHandle; opacity: 0.5 } + PropertyChanges { target: endHandle; opacity: 0.5 } + PropertyChanges { target: menu; opacity: 1.0 } + } + ] +} diff --git a/examples/quick/threading/threadedlistmodel/dataloader.js b/examples/quick/threading/threadedlistmodel/dataloader.js new file mode 100644 index 0000000000..4d2aab323d --- /dev/null +++ b/examples/quick/threading/threadedlistmodel/dataloader.js @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// ![0] +WorkerScript.onMessage = function(msg) { + if (msg.action == 'appendCurrentTime') { + var data = {'time': new Date().toTimeString()}; + msg.model.append(data); + msg.model.sync(); // updates the changes to the list + } +} +// ![0] diff --git a/examples/quick/threading/threadedlistmodel/threadedlistmodel.qmlproject b/examples/quick/threading/threadedlistmodel/threadedlistmodel.qmlproject new file mode 100644 index 0000000000..e7c8e69f14 --- /dev/null +++ b/examples/quick/threading/threadedlistmodel/threadedlistmodel.qmlproject @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QmlProject 1.1 + +Project { + mainFile: "timedisplay.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/quick/threading/threadedlistmodel/timedisplay.qml b/examples/quick/threading/threadedlistmodel/timedisplay.qml new file mode 100644 index 0000000000..48d0f659e5 --- /dev/null +++ b/examples/quick/threading/threadedlistmodel/timedisplay.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// ![0] +import QtQuick 2.0 + +Rectangle { + color: "white" + width: 200 + height: 300 + + ListView { + anchors.fill: parent + model: listModel + delegate: Component { + Text { text: time } + } + + ListModel { id: listModel } + + WorkerScript { + id: worker + source: "dataloader.js" + } + + Timer { + id: timer + interval: 2000; repeat: true + running: true + triggeredOnStart: true + + onTriggered: { + var msg = {'action': 'appendCurrentTime', 'model': listModel}; + worker.sendMessage(msg); + } + } + } +} +// ![0] diff --git a/examples/quick/threading/workerscript/workerscript.js b/examples/quick/threading/workerscript/workerscript.js new file mode 100644 index 0000000000..f76471f920 --- /dev/null +++ b/examples/quick/threading/workerscript/workerscript.js @@ -0,0 +1,15 @@ +var lastx = 0; +var lasty = 0; + +WorkerScript.onMessage = function(message) { + var ydiff = message.y - lasty; + var xdiff = message.x - lastx; + + var total = Math.sqrt(ydiff * ydiff + xdiff * xdiff); + + lastx = message.x; + lasty = message.y; + + WorkerScript.sendMessage( {xmove: xdiff, ymove: ydiff, move: total} ); +} + diff --git a/examples/quick/threading/workerscript/workerscript.qml b/examples/quick/threading/workerscript/workerscript.qml new file mode 100644 index 0000000000..7fced8166c --- /dev/null +++ b/examples/quick/threading/workerscript/workerscript.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 480; height: 320 + + WorkerScript { + id: myWorker + source: "workerscript.js" + + onMessage: { + console.log("Moved " + messageObject.xmove + " along the X axis."); + console.log("Moved " + messageObject.ymove + " along the Y axis."); + console.log("Moved " + messageObject.move + " pixels."); + } + } + + Rectangle { + width: 200; height: 200 + anchors.left: parent.left; anchors.leftMargin: 20 + color: "red" + + MouseArea { + anchors.fill: parent + onClicked: myWorker.sendMessage( { rectangle: "red", x: mouse.x, y: mouse.y } ); + } + } + + Rectangle { + width: 200; height: 200 + anchors.right: parent.right; anchors.rightMargin: 20 + color: "blue" + + MouseArea { + anchors.fill: parent + onClicked: myWorker.sendMessage( { rectangle: "blue", x: mouse.x, y: mouse.y } ); + } + } + + Text { + text: "Click a Rectangle!" + anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 50 } + } +} diff --git a/examples/quick/threading/workerscript/workerscript.qmlproject b/examples/quick/threading/workerscript/workerscript.qmlproject new file mode 100644 index 0000000000..6d7a91feeb --- /dev/null +++ b/examples/quick/threading/workerscript/workerscript.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "workerscript.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/quick/touchinteraction/flickable/content/Day.qml b/examples/quick/touchinteraction/flickable/content/Day.qml new file mode 100644 index 0000000000..7fe625c305 --- /dev/null +++ b/examples/quick/touchinteraction/flickable/content/Day.qml @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Component { + Item { + property variant stickies + + id: page + width: ListView.view.width+40; height: ListView.view.height + + + Image { + source: "cork.jpg" + width: page.ListView.view.width + height: page.ListView.view.height + fillMode: Image.PreserveAspectCrop + clip: true + } + + MouseArea { + anchors.fill: parent + onClicked: page.focus = false; + } + + Text { + text: name; x: 15; y: 8; height: 40; width: 370 + font.pixelSize: 18; font.bold: true; color: "white" + style: Text.Outline; styleColor: "black" + } + + Repeater { + model: notes + Item { + id: stickyPage + + property int randomX: Math.random() * (page.ListView.view.width-0.5*stickyImage.width) +100 + property int randomY: Math.random() * (page.ListView.view.height-0.5*stickyImage.height) +50 + + x: randomX; y: randomY + + rotation: -flickable.horizontalVelocity / 100; + Behavior on rotation { + SpringAnimation { spring: 2.0; damping: 0.15 } + } + + Item { + id: sticky + scale: 0.7 + + Image { + id: stickyImage + x: 8 + -width * 0.6 / 2; y: -20 + source: "note-yellow.png" + scale: 0.6; transformOrigin: Item.TopLeft + smooth: true + } + + TextEdit { + id: myText + x: -104; y: 36; width: 215; height: 200 + smooth: true + font.pixelSize: 24 + readOnly: false + rotation: -8 + text: noteText + } + + Item { + x: stickyImage.x; y: -20 + width: stickyImage.width * stickyImage.scale + height: stickyImage.height * stickyImage.scale + + MouseArea { + id: mouse + anchors.fill: parent + drag.target: stickyPage + drag.axis: Drag.XandYAxis + drag.minimumY: 0 + drag.maximumY: page.height - 80 + drag.minimumX: 100 + drag.maximumX: page.width - 140 + onClicked: { myText.focus = true; myText.openSoftwareInputPanel(); } + } + } + } + + Image { + x: -width / 2; y: -height * 0.5 / 2 + source: "tack.png" + scale: 0.7; transformOrigin: Item.TopLeft + } + + states: State { + name: "pressed" + when: mouse.pressed + PropertyChanges { target: sticky; rotation: 8; scale: 1 } + PropertyChanges { target: page; z: 8 } + } + + transitions: Transition { + NumberAnimation { properties: "rotation,scale"; duration: 200 } + } + } + } + } +} + + + + + + + + diff --git a/examples/quick/touchinteraction/flickable/content/cork.jpg b/examples/quick/touchinteraction/flickable/content/cork.jpg new file mode 100644 index 0000000000..160bc002bf Binary files /dev/null and b/examples/quick/touchinteraction/flickable/content/cork.jpg differ diff --git a/examples/quick/touchinteraction/flickable/content/note-yellow.png b/examples/quick/touchinteraction/flickable/content/note-yellow.png new file mode 100644 index 0000000000..8ddecc8b03 Binary files /dev/null and b/examples/quick/touchinteraction/flickable/content/note-yellow.png differ diff --git a/examples/quick/touchinteraction/flickable/content/tack.png b/examples/quick/touchinteraction/flickable/content/tack.png new file mode 100644 index 0000000000..cef2d1cd23 Binary files /dev/null and b/examples/quick/touchinteraction/flickable/content/tack.png differ diff --git a/examples/quick/touchinteraction/flickable/corkboards.qml b/examples/quick/touchinteraction/flickable/corkboards.qml new file mode 100644 index 0000000000..dc3aa6b378 --- /dev/null +++ b/examples/quick/touchinteraction/flickable/corkboards.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + width: 800; height: 480 + color: "#464646" + + ListModel { + id: list + + ListElement { + name: "Sunday" + notes: [ + ListElement { noteText: "Lunch" }, + ListElement { noteText: "Birthday Party" } + ] + } + + ListElement { + name: "Monday" + notes: [ + ListElement { noteText: "Pickup kids from\nschool\n4.30pm" }, + ListElement { noteText: "Checkout Qt" }, ListElement { noteText: "Read email" } + ] + } + + ListElement { + name: "Tuesday" + notes: [ + ListElement { noteText: "Walk dog" }, + ListElement { noteText: "Buy newspaper" } + ] + } + + ListElement { + name: "Wednesday" + notes: [ ListElement { noteText: "Cook dinner" } ] + } + + ListElement { + name: "Thursday" + notes: [ + ListElement { noteText: "Meeting\n5.30pm" }, + ListElement { noteText: "Weed garden" } + ] + } + + ListElement { + name: "Friday" + notes: [ + ListElement { noteText: "More work" }, + ListElement { noteText: "Grocery shopping" } + ] + } + + ListElement { + name: "Saturday" + notes: [ + ListElement { noteText: "Drink" }, + ListElement { noteText: "Download Qt\nPlay with QML" } + ] + } + } + + ListView { + id: flickable + + anchors.fill: parent + focus: true + highlightRangeMode: ListView.StrictlyEnforceRange + orientation: ListView.Horizontal + snapMode: ListView.SnapOneItem + model: list + delegate: Day { } + } +} diff --git a/examples/quick/touchinteraction/multipointtouch/bearwhack.qml b/examples/quick/touchinteraction/multipointtouch/bearwhack.qml new file mode 100644 index 0000000000..db46473c05 --- /dev/null +++ b/examples/quick/touchinteraction/multipointtouch/bearwhack.qml @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "content" + +Item { + id: root + height: 640 + width: 320 + Item { + id: startScreen + anchors.fill: parent + z: 1000 + Image { + source: "content/title.png" + anchors.centerIn: parent + } + MouseArea{ + anchors.fill: parent + onClicked: {//Game Start + parent.visible = false; + } + } + } + Rectangle { + id: bg + anchors.fill: parent + gradient: Gradient { + GradientStop { position: 0.0; color: "DarkBlue" } + GradientStop { position: 0.8; color: "SkyBlue" } + GradientStop { position: 0.81; color: "ForestGreen" } + GradientStop { position: 1.0; color: "DarkGreen" } + } + } + + BearWhackParticleSystem { + id: particleSystem + anchors.fill: parent + running: !startScreen.visible + } + + property int score: 0 + + Text { + anchors.right: parent.right + anchors.margins: 4 + anchors.top: parent.top + color: "white" + function padded(num) { + var ret = num.toString(); + while (ret.length < 6) + ret = "0" + ret; + return ret; + } + text: "Score: " + padded(score) + } + MultiPointTouchArea { + anchors.fill: parent + touchPoints: [//Support up to 4 touches at once? + AugmentedTouchPoint{ system: particleSystem }, + AugmentedTouchPoint{ system: particleSystem }, + AugmentedTouchPoint{ system: particleSystem }, + AugmentedTouchPoint{ system: particleSystem } + ] + } + MouseArea{ + anchors.fill: parent + id: ma + onPressedChanged: { + if (pressed) { + timer.restart(); + sgoal.enabled = true; + particleSystem.explode(mouseX,mouseY); + } + } + Timer { + id: timer + interval: 100 + running: false + repeat: false + onTriggered: sgoal.enabled = false + } + SpriteGoal { + id: sgoal + x: ma.mouseX - 16 + y: ma.mouseY - 16 + width: 32 + height: 32 + system: particleSystem + parent: particleSystem + goalState: "falling" + enabled: false + } + } +} diff --git a/examples/quick/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml b/examples/quick/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml new file mode 100644 index 0000000000..aede1a8f4e --- /dev/null +++ b/examples/quick/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +TouchPoint { + id: container + property ParticleSystem system + onPressedChanged: { + if (pressed) { + timer.restart(); + child.enabled = true; + system.explode(x,y); + } + } + property QtObject obj: Timer { + id: timer + interval: 100 + running: false + repeat: false + onTriggered: child.enabled = false + } + property Item child: SpriteGoal { + enabled: false + x: container.area.x - 16 + y: container.area.y - 16 + width: container.area.width + 32 + height: container.area.height + 32 //+32 so it doesn't have to hit the exact center + system: container.system + parent: container.system + goalState: "falling" + } +} diff --git a/examples/quick/touchinteraction/multipointtouch/content/Bear0.png b/examples/quick/touchinteraction/multipointtouch/content/Bear0.png new file mode 100644 index 0000000000..64a02cec8e Binary files /dev/null and b/examples/quick/touchinteraction/multipointtouch/content/Bear0.png differ diff --git a/examples/quick/touchinteraction/multipointtouch/content/Bear1.png b/examples/quick/touchinteraction/multipointtouch/content/Bear1.png new file mode 100644 index 0000000000..3b88f3b32e Binary files /dev/null and b/examples/quick/touchinteraction/multipointtouch/content/Bear1.png differ diff --git a/examples/quick/touchinteraction/multipointtouch/content/Bear2.png b/examples/quick/touchinteraction/multipointtouch/content/Bear2.png new file mode 100644 index 0000000000..337b636070 Binary files /dev/null and b/examples/quick/touchinteraction/multipointtouch/content/Bear2.png differ diff --git a/examples/quick/touchinteraction/multipointtouch/content/Bear3.png b/examples/quick/touchinteraction/multipointtouch/content/Bear3.png new file mode 100644 index 0000000000..f0e68590f4 Binary files /dev/null and b/examples/quick/touchinteraction/multipointtouch/content/Bear3.png differ diff --git a/examples/quick/touchinteraction/multipointtouch/content/BearB.png b/examples/quick/touchinteraction/multipointtouch/content/BearB.png new file mode 100644 index 0000000000..c9a84ae1d4 Binary files /dev/null and b/examples/quick/touchinteraction/multipointtouch/content/BearB.png differ diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml b/examples/quick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml similarity index 100% rename from examples/qtquick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml rename to examples/quick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml diff --git a/examples/quick/touchinteraction/multipointtouch/content/ParticleFlame.qml b/examples/quick/touchinteraction/multipointtouch/content/ParticleFlame.qml new file mode 100644 index 0000000000..9788c5c665 --- /dev/null +++ b/examples/quick/touchinteraction/multipointtouch/content/ParticleFlame.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +ParticleSystem { + property alias color: img.color + property alias emitting: emitter.enabled + ImageParticle { + id: img + source: "blur-circle.png" + colorVariation: 0.1 + color: "#ff521d" + alpha: 0 + } + Emitter { + id: emitter + speedFromMovement: 20 + emitRate: 80 + lifeSpan: 1500 + speed: PointDirection{ y: -90; yVariation: 50; } + acceleration: PointDirection{ xVariation: 100; yVariation: 90; } + size: 51 + sizeVariation: 53 + endSize: 64 + } +} diff --git a/examples/quick/touchinteraction/multipointtouch/content/blur-circle.png b/examples/quick/touchinteraction/multipointtouch/content/blur-circle.png new file mode 100644 index 0000000000..1b03cd0b2c Binary files /dev/null and b/examples/quick/touchinteraction/multipointtouch/content/blur-circle.png differ diff --git a/examples/quick/touchinteraction/multipointtouch/content/blur-circle3.png b/examples/quick/touchinteraction/multipointtouch/content/blur-circle3.png new file mode 100644 index 0000000000..dbc39cb16e Binary files /dev/null and b/examples/quick/touchinteraction/multipointtouch/content/blur-circle3.png differ diff --git a/examples/quick/touchinteraction/multipointtouch/content/heart-blur.png b/examples/quick/touchinteraction/multipointtouch/content/heart-blur.png new file mode 100644 index 0000000000..dbc38804ee Binary files /dev/null and b/examples/quick/touchinteraction/multipointtouch/content/heart-blur.png differ diff --git a/examples/quick/touchinteraction/multipointtouch/content/title.png b/examples/quick/touchinteraction/multipointtouch/content/title.png new file mode 100644 index 0000000000..d630ea2643 Binary files /dev/null and b/examples/quick/touchinteraction/multipointtouch/content/title.png differ diff --git a/examples/quick/touchinteraction/multipointtouch/multiflame.qml b/examples/quick/touchinteraction/multipointtouch/multiflame.qml new file mode 100644 index 0000000000..72a0ce21f8 --- /dev/null +++ b/examples/quick/touchinteraction/multipointtouch/multiflame.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import "content" + +Rectangle { + width: 360 + height: 480 + color: "black" + + MultiPointTouchArea { + anchors.fill: parent + minimumTouchPoints: 1 + maximumTouchPoints: 5 + touchPoints: [ + TouchPoint { id: touch1 }, + TouchPoint { id: touch2 }, + TouchPoint { id: touch11 }, + TouchPoint { id: touch21 }, + TouchPoint { id: touch31 } + ] + } + + ParticleFlame { + color: "red" + x: touch1.x + y: touch1.y + emitting: touch1.pressed + } + ParticleFlame { + color: "green" + x: touch2.x + y: touch2.y + emitting: touch2.pressed + } + ParticleFlame { + color: "yellow" + x: touch11.x + y: touch11.y + emitting: touch11.pressed + } + ParticleFlame { + color: "blue" + x: touch21.x + y: touch21.y + emitting: touch21.pressed + } + ParticleFlame { + color: "violet" + x: touch31.x + y: touch31.y + emitting: touch31.pressed + } +} diff --git a/examples/quick/touchinteraction/pincharea/flickresize.qml b/examples/quick/touchinteraction/pincharea/flickresize.qml new file mode 100644 index 0000000000..037766e4a0 --- /dev/null +++ b/examples/quick/touchinteraction/pincharea/flickresize.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 640 + height: 360 + color: "gray" + + Flickable { + id: flick + anchors.fill: parent + contentWidth: 500 + contentHeight: 500 + + PinchArea { + width: Math.max(flick.contentWidth, flick.width) + height: Math.max(flick.contentHeight, flick.height) + + property real initialWidth + property real initialHeight + onPinchStarted: { + initialWidth = flick.contentWidth + initialHeight = flick.contentHeight + } + + onPinchUpdated: { + // adjust content pos due to drag + flick.contentX += pinch.previousCenter.x - pinch.center.x + flick.contentY += pinch.previousCenter.y - pinch.center.y + + // resize content + flick.resizeContent(initialWidth * pinch.scale, initialHeight * pinch.scale, pinch.center) + } + + onPinchFinished: { + // Move its content within bounds. + flick.returnToBounds() + } + + Rectangle { + width: flick.contentWidth + height: flick.contentHeight + color: "white" + Image { + anchors.fill: parent + source: "qt-logo.jpg" + MouseArea { + anchors.fill: parent + onDoubleClicked: { + flick.contentWidth = 500 + flick.contentHeight = 500 + } + } + } + } + } + } +} diff --git a/examples/quick/touchinteraction/pincharea/qt-logo.jpg b/examples/quick/touchinteraction/pincharea/qt-logo.jpg new file mode 100644 index 0000000000..4014b4659c Binary files /dev/null and b/examples/quick/touchinteraction/pincharea/qt-logo.jpg differ diff --git a/examples/qtquick/touchinteraction/touchinteraction.qml b/examples/quick/touchinteraction/touchinteraction.qml similarity index 100% rename from examples/qtquick/touchinteraction/touchinteraction.qml rename to examples/quick/touchinteraction/touchinteraction.qml diff --git a/examples/quick/touchinteraction/touchinteraction.qmlproject b/examples/quick/touchinteraction/touchinteraction.qmlproject new file mode 100644 index 0000000000..a9aa9d2e81 --- /dev/null +++ b/examples/quick/touchinteraction/touchinteraction.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "touchinteraction.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/tutorials/extending/chapter1-basics/chapter1-basics.pro b/examples/tutorials/extending/chapter1-basics/chapter1-basics.pro index affc57ce1f..8ed66f8b66 100644 --- a/examples/tutorials/extending/chapter1-basics/chapter1-basics.pro +++ b/examples/tutorials/extending/chapter1-basics/chapter1-basics.pro @@ -1,4 +1,4 @@ -QT += declarative quick +QT += qml quick HEADERS += piechart.h SOURCES += piechart.cpp \ diff --git a/examples/tutorials/extending/chapter2-methods/chapter2-methods.pro b/examples/tutorials/extending/chapter2-methods/chapter2-methods.pro index affc57ce1f..8ed66f8b66 100644 --- a/examples/tutorials/extending/chapter2-methods/chapter2-methods.pro +++ b/examples/tutorials/extending/chapter2-methods/chapter2-methods.pro @@ -1,4 +1,4 @@ -QT += declarative quick +QT += qml quick HEADERS += piechart.h SOURCES += piechart.cpp \ diff --git a/examples/tutorials/extending/chapter3-bindings/chapter3-bindings.pro b/examples/tutorials/extending/chapter3-bindings/chapter3-bindings.pro index affc57ce1f..8ed66f8b66 100644 --- a/examples/tutorials/extending/chapter3-bindings/chapter3-bindings.pro +++ b/examples/tutorials/extending/chapter3-bindings/chapter3-bindings.pro @@ -1,4 +1,4 @@ -QT += declarative quick +QT += qml quick HEADERS += piechart.h SOURCES += piechart.cpp \ diff --git a/examples/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro b/examples/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro index 6724fa0375..23eb222ea3 100644 --- a/examples/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro +++ b/examples/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro @@ -1,4 +1,4 @@ -QT += declarative quick +QT += qml quick HEADERS += piechart.h \ pieslice.h diff --git a/examples/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro b/examples/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro index 6724fa0375..23eb222ea3 100644 --- a/examples/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro +++ b/examples/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro @@ -1,4 +1,4 @@ -QT += declarative quick +QT += qml quick HEADERS += piechart.h \ pieslice.h diff --git a/examples/tutorials/extending/chapter5-listproperties/piechart.cpp b/examples/tutorials/extending/chapter5-listproperties/piechart.cpp index bfcb607e60..910916508e 100644 --- a/examples/tutorials/extending/chapter5-listproperties/piechart.cpp +++ b/examples/tutorials/extending/chapter5-listproperties/piechart.cpp @@ -56,12 +56,12 @@ void PieChart::setName(const QString &name) } //![0] -QDeclarativeListProperty PieChart::slices() +QQmlListProperty PieChart::slices() { - return QDeclarativeListProperty(this, 0, &PieChart::append_slice); + return QQmlListProperty(this, 0, &PieChart::append_slice); } -void PieChart::append_slice(QDeclarativeListProperty *list, PieSlice *slice) +void PieChart::append_slice(QQmlListProperty *list, PieSlice *slice) { PieChart *chart = qobject_cast(list->object); if (chart) { diff --git a/examples/tutorials/extending/chapter5-listproperties/piechart.h b/examples/tutorials/extending/chapter5-listproperties/piechart.h index 9beabda5f3..6c17bc1258 100644 --- a/examples/tutorials/extending/chapter5-listproperties/piechart.h +++ b/examples/tutorials/extending/chapter5-listproperties/piechart.h @@ -48,7 +48,7 @@ class PieSlice; class PieChart : public QQuickItem { Q_OBJECT - Q_PROPERTY(QDeclarativeListProperty slices READ slices) + Q_PROPERTY(QQmlListProperty slices READ slices) //![0] Q_PROPERTY(QString name READ name WRITE setName) @@ -61,10 +61,10 @@ class PieChart : public QQuickItem void setName(const QString &name); //![2] - QDeclarativeListProperty slices(); + QQmlListProperty slices(); private: - static void append_slice(QDeclarativeListProperty *list, PieSlice *slice); + static void append_slice(QQmlListProperty *list, PieSlice *slice); QString m_name; QList m_slices; diff --git a/examples/tutorials/extending/chapter6-plugins/chapter6-plugins.pro b/examples/tutorials/extending/chapter6-plugins/chapter6-plugins.pro index c243ec4572..75f88b2eaa 100644 --- a/examples/tutorials/extending/chapter6-plugins/chapter6-plugins.pro +++ b/examples/tutorials/extending/chapter6-plugins/chapter6-plugins.pro @@ -1,6 +1,6 @@ TEMPLATE = lib CONFIG += qt plugin -QT += declarative quick +QT += qml quick DESTDIR = ChartsPlugin TARGET = chartsplugin diff --git a/examples/tutorials/extending/chapter6-plugins/chartsplugin.cpp b/examples/tutorials/extending/chapter6-plugins/chartsplugin.cpp index d75f810964..0cead527b8 100644 --- a/examples/tutorials/extending/chapter6-plugins/chartsplugin.cpp +++ b/examples/tutorials/extending/chapter6-plugins/chartsplugin.cpp @@ -41,7 +41,7 @@ //![0] #include "piechart.h" #include "pieslice.h" -#include +#include void ChartsPlugin::registerTypes(const char *uri) { diff --git a/examples/tutorials/extending/chapter6-plugins/chartsplugin.h b/examples/tutorials/extending/chapter6-plugins/chartsplugin.h index 863564b09c..4db1b01987 100644 --- a/examples/tutorials/extending/chapter6-plugins/chartsplugin.h +++ b/examples/tutorials/extending/chapter6-plugins/chartsplugin.h @@ -41,12 +41,12 @@ #define CHARTSPLUGIN_H //![0] -#include +#include -class ChartsPlugin : public QDeclarativeExtensionPlugin +class ChartsPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "chartsplugin.json") + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "chartsplugin.json") public: void registerTypes(const char *uri); diff --git a/examples/tutorials/extending/chapter6-plugins/piechart.cpp b/examples/tutorials/extending/chapter6-plugins/piechart.cpp index 2a8f40289e..b188e39d81 100644 --- a/examples/tutorials/extending/chapter6-plugins/piechart.cpp +++ b/examples/tutorials/extending/chapter6-plugins/piechart.cpp @@ -55,12 +55,12 @@ void PieChart::setName(const QString &name) m_name = name; } -QDeclarativeListProperty PieChart::slices() +QQmlListProperty PieChart::slices() { - return QDeclarativeListProperty(this, 0, &PieChart::append_slice); + return QQmlListProperty(this, 0, &PieChart::append_slice); } -void PieChart::append_slice(QDeclarativeListProperty *list, PieSlice *slice) +void PieChart::append_slice(QQmlListProperty *list, PieSlice *slice) { PieChart *chart = qobject_cast(list->object); if (chart) { diff --git a/examples/tutorials/extending/chapter6-plugins/piechart.h b/examples/tutorials/extending/chapter6-plugins/piechart.h index fe6b96afdc..2ee8108784 100644 --- a/examples/tutorials/extending/chapter6-plugins/piechart.h +++ b/examples/tutorials/extending/chapter6-plugins/piechart.h @@ -47,7 +47,7 @@ class PieSlice; class PieChart : public QQuickItem { Q_OBJECT - Q_PROPERTY(QDeclarativeListProperty slices READ slices) + Q_PROPERTY(QQmlListProperty slices READ slices) Q_PROPERTY(QString name READ name WRITE setName) public: @@ -56,10 +56,10 @@ class PieChart : public QQuickItem QString name() const; void setName(const QString &name); - QDeclarativeListProperty slices(); + QQmlListProperty slices(); private: - static void append_slice(QDeclarativeListProperty *list, PieSlice *slice); + static void append_slice(QQmlListProperty *list, PieSlice *slice); QString m_name; QList m_slices; diff --git a/examples/tutorials/gettingStartedQml/core/Button.qml b/examples/tutorials/gettingStartedQml/core/Button.qml index 41be4134bd..9ea8c6dfff 100644 --- a/examples/tutorials/gettingStartedQml/core/Button.qml +++ b/examples/tutorials/gettingStartedQml/core/Button.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/core/EditMenu.qml b/examples/tutorials/gettingStartedQml/core/EditMenu.qml index 7471669a37..dcac7bd29a 100644 --- a/examples/tutorials/gettingStartedQml/core/EditMenu.qml +++ b/examples/tutorials/gettingStartedQml/core/EditMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/core/FileDialog.qml b/examples/tutorials/gettingStartedQml/core/FileDialog.qml index 2d08e19bcf..0a4341b868 100644 --- a/examples/tutorials/gettingStartedQml/core/FileDialog.qml +++ b/examples/tutorials/gettingStartedQml/core/FileDialog.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/core/FileMenu.qml b/examples/tutorials/gettingStartedQml/core/FileMenu.qml index 67d747d8fb..a4be5eff15 100644 --- a/examples/tutorials/gettingStartedQml/core/FileMenu.qml +++ b/examples/tutorials/gettingStartedQml/core/FileMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/core/MenuBar.qml b/examples/tutorials/gettingStartedQml/core/MenuBar.qml index 68e25899e3..8d7be29fdd 100644 --- a/examples/tutorials/gettingStartedQml/core/MenuBar.qml +++ b/examples/tutorials/gettingStartedQml/core/MenuBar.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/core/TextArea.qml b/examples/tutorials/gettingStartedQml/core/TextArea.qml index 2ca145260c..99fb5ca60c 100644 --- a/examples/tutorials/gettingStartedQml/core/TextArea.qml +++ b/examples/tutorials/gettingStartedQml/core/TextArea.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp b/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp index 626ef93adc..776af5629b 100644 --- a/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp +++ b/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: @@ -41,7 +41,7 @@ #include "dialogPlugin.h" #include "directory.h" #include "file.h" -#include +#include void DialogPlugin::registerTypes(const char *uri) { diff --git a/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.h b/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.h index 7ad707f6d9..fcaa210457 100644 --- a/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.h +++ b/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.h @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: @@ -41,15 +41,15 @@ #ifndef DIALOGPLUGIN_H #define DIALOGPLUGIN_H -#include +#include -class DialogPlugin : public QDeclarativeExtensionPlugin +class DialogPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "dialogplugin.json") + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "dialogplugin.json") public: - //registerTypes is inherited from QDeclarativeExtensionPlugin + //registerTypes is inherited from QQmlExtensionPlugin void registerTypes(const char *uri); }; diff --git a/examples/tutorials/gettingStartedQml/filedialog/directory.cpp b/examples/tutorials/gettingStartedQml/filedialog/directory.cpp index 3253327cb4..eadc11e52f 100644 --- a/examples/tutorials/gettingStartedQml/filedialog/directory.cpp +++ b/examples/tutorials/gettingStartedQml/filedialog/directory.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: @@ -72,7 +72,7 @@ int Directory::filesCount() const /* Function called to append data onto list property */ -void appendFiles(QDeclarativeListProperty * property, File * file) +void appendFiles(QQmlListProperty * property, File * file) { Q_UNUSED(property); Q_UNUSED(file); @@ -82,7 +82,7 @@ void appendFiles(QDeclarativeListProperty * property, File * file) /* Function called to retrieve file in the list using an index */ -File* fileAt(QDeclarativeListProperty * property, int index) +File* fileAt(QQmlListProperty * property, int index) { return static_cast< QList *>(property->data)->at(index); } @@ -90,7 +90,7 @@ File* fileAt(QDeclarativeListProperty * property, int index) /* Returns the number of files in the list */ -int filesSize(QDeclarativeListProperty * property) +int filesSize(QQmlListProperty * property) { return static_cast< QList *>(property->data)->size(); } @@ -98,18 +98,18 @@ int filesSize(QDeclarativeListProperty * property) /* Function called to empty the list property contents */ -void clearFilesPtr(QDeclarativeListProperty *property) +void clearFilesPtr(QQmlListProperty *property) { return static_cast< QList *>(property->data)->clear(); } /* -Returns the list of files as a QDeclarativeListProperty. +Returns the list of files as a QQmlListProperty. */ -QDeclarativeListProperty Directory::files() +QQmlListProperty Directory::files() { refresh(); - return QDeclarativeListProperty( this, &m_fileList, &appendFiles, &filesSize, &fileAt, &clearFilesPtr ); + return QQmlListProperty( this, &m_fileList, &appendFiles, &filesSize, &fileAt, &clearFilesPtr ); } /* diff --git a/examples/tutorials/gettingStartedQml/filedialog/directory.h b/examples/tutorials/gettingStartedQml/filedialog/directory.h index 04317707c3..30d6751bd2 100644 --- a/examples/tutorials/gettingStartedQml/filedialog/directory.h +++ b/examples/tutorials/gettingStartedQml/filedialog/directory.h @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include class Directory : public QObject { @@ -57,7 +57,7 @@ class Directory : public QObject { Q_PROPERTY(int filesCount READ filesCount) //list property containing file names as QString - Q_PROPERTY(QDeclarativeListProperty files READ files CONSTANT ) + Q_PROPERTY(QQmlListProperty files READ files CONSTANT ) //file name of the text file to read/write Q_PROPERTY(QString filename READ filename WRITE setFilename NOTIFY filenameChanged) @@ -72,7 +72,7 @@ class Directory : public QObject { int filesCount() const; QString filename() const; QString fileContent() const; - QDeclarativeListProperty files(); + QQmlListProperty files(); //properties' write functions void setFilename(const QString &str); diff --git a/examples/tutorials/gettingStartedQml/filedialog/file.cpp b/examples/tutorials/gettingStartedQml/filedialog/file.cpp index 120486315b..e3b22027f5 100644 --- a/examples/tutorials/gettingStartedQml/filedialog/file.cpp +++ b/examples/tutorials/gettingStartedQml/filedialog/file.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/filedialog/file.h b/examples/tutorials/gettingStartedQml/filedialog/file.h index 6b8806ee32..d13638b414 100644 --- a/examples/tutorials/gettingStartedQml/filedialog/file.h +++ b/examples/tutorials/gettingStartedQml/filedialog/file.h @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/filedialog/filedialog.pro b/examples/tutorials/gettingStartedQml/filedialog/filedialog.pro index d85787d00c..85edb40257 100644 --- a/examples/tutorials/gettingStartedQml/filedialog/filedialog.pro +++ b/examples/tutorials/gettingStartedQml/filedialog/filedialog.pro @@ -1,6 +1,6 @@ TEMPLATE = lib CONFIG += qt plugin -QT += declarative +QT += qml DESTDIR += ../plugins OBJECTS_DIR = tmp diff --git a/examples/tutorials/gettingStartedQml/parts/part0/Button.qml b/examples/tutorials/gettingStartedQml/parts/part0/Button.qml index 3097a7615c..6cae3f3ab3 100644 --- a/examples/tutorials/gettingStartedQml/parts/part0/Button.qml +++ b/examples/tutorials/gettingStartedQml/parts/part0/Button.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part1/Button.qml b/examples/tutorials/gettingStartedQml/parts/part1/Button.qml index 70f7508de3..118e6fc4d3 100644 --- a/examples/tutorials/gettingStartedQml/parts/part1/Button.qml +++ b/examples/tutorials/gettingStartedQml/parts/part1/Button.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part1/EditMenu.qml b/examples/tutorials/gettingStartedQml/parts/part1/EditMenu.qml index 5d14fc4f69..231a20a3a2 100644 --- a/examples/tutorials/gettingStartedQml/parts/part1/EditMenu.qml +++ b/examples/tutorials/gettingStartedQml/parts/part1/EditMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part1/FileMenu.qml b/examples/tutorials/gettingStartedQml/parts/part1/FileMenu.qml index ddb6df438c..c36f6d4734 100644 --- a/examples/tutorials/gettingStartedQml/parts/part1/FileMenu.qml +++ b/examples/tutorials/gettingStartedQml/parts/part1/FileMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part1/SimpleButton.qml b/examples/tutorials/gettingStartedQml/parts/part1/SimpleButton.qml index e0f377cfe5..f43a56ea7a 100644 --- a/examples/tutorials/gettingStartedQml/parts/part1/SimpleButton.qml +++ b/examples/tutorials/gettingStartedQml/parts/part1/SimpleButton.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part2/Button.qml b/examples/tutorials/gettingStartedQml/parts/part2/Button.qml index 65660b0cc1..aa178f8bf9 100644 --- a/examples/tutorials/gettingStartedQml/parts/part2/Button.qml +++ b/examples/tutorials/gettingStartedQml/parts/part2/Button.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part2/EditMenu.qml b/examples/tutorials/gettingStartedQml/parts/part2/EditMenu.qml index 2a4c0a2834..fb2db7ade3 100644 --- a/examples/tutorials/gettingStartedQml/parts/part2/EditMenu.qml +++ b/examples/tutorials/gettingStartedQml/parts/part2/EditMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part2/FileMenu.qml b/examples/tutorials/gettingStartedQml/parts/part2/FileMenu.qml index 3f60bc6c2a..b715298147 100644 --- a/examples/tutorials/gettingStartedQml/parts/part2/FileMenu.qml +++ b/examples/tutorials/gettingStartedQml/parts/part2/FileMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part2/MenuBar.qml b/examples/tutorials/gettingStartedQml/parts/part2/MenuBar.qml index 99151ff9b0..408b561022 100644 --- a/examples/tutorials/gettingStartedQml/parts/part2/MenuBar.qml +++ b/examples/tutorials/gettingStartedQml/parts/part2/MenuBar.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part3/Button.qml b/examples/tutorials/gettingStartedQml/parts/part3/Button.qml index 65660b0cc1..aa178f8bf9 100644 --- a/examples/tutorials/gettingStartedQml/parts/part3/Button.qml +++ b/examples/tutorials/gettingStartedQml/parts/part3/Button.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part3/EditMenu.qml b/examples/tutorials/gettingStartedQml/parts/part3/EditMenu.qml index 2a4c0a2834..fb2db7ade3 100644 --- a/examples/tutorials/gettingStartedQml/parts/part3/EditMenu.qml +++ b/examples/tutorials/gettingStartedQml/parts/part3/EditMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part3/FileMenu.qml b/examples/tutorials/gettingStartedQml/parts/part3/FileMenu.qml index 3f60bc6c2a..b715298147 100644 --- a/examples/tutorials/gettingStartedQml/parts/part3/FileMenu.qml +++ b/examples/tutorials/gettingStartedQml/parts/part3/FileMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part3/MenuBar.qml b/examples/tutorials/gettingStartedQml/parts/part3/MenuBar.qml index 99151ff9b0..408b561022 100644 --- a/examples/tutorials/gettingStartedQml/parts/part3/MenuBar.qml +++ b/examples/tutorials/gettingStartedQml/parts/part3/MenuBar.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part3/TextArea.qml b/examples/tutorials/gettingStartedQml/parts/part3/TextArea.qml index faee31e97c..279ae045c3 100644 --- a/examples/tutorials/gettingStartedQml/parts/part3/TextArea.qml +++ b/examples/tutorials/gettingStartedQml/parts/part3/TextArea.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part3/TextEditor.qml b/examples/tutorials/gettingStartedQml/parts/part3/TextEditor.qml index c14437dcd0..54fa115aec 100644 --- a/examples/tutorials/gettingStartedQml/parts/part3/TextEditor.qml +++ b/examples/tutorials/gettingStartedQml/parts/part3/TextEditor.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part4/Button.qml b/examples/tutorials/gettingStartedQml/parts/part4/Button.qml index 5572989f5d..7fb4f1e536 100644 --- a/examples/tutorials/gettingStartedQml/parts/part4/Button.qml +++ b/examples/tutorials/gettingStartedQml/parts/part4/Button.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part4/EditMenu.qml b/examples/tutorials/gettingStartedQml/parts/part4/EditMenu.qml index 07282733f7..cdfbd30a06 100644 --- a/examples/tutorials/gettingStartedQml/parts/part4/EditMenu.qml +++ b/examples/tutorials/gettingStartedQml/parts/part4/EditMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part4/FileMenu.qml b/examples/tutorials/gettingStartedQml/parts/part4/FileMenu.qml index 1aa98a9498..a1d95bf87a 100644 --- a/examples/tutorials/gettingStartedQml/parts/part4/FileMenu.qml +++ b/examples/tutorials/gettingStartedQml/parts/part4/FileMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part4/MenuBar.qml b/examples/tutorials/gettingStartedQml/parts/part4/MenuBar.qml index ba1697f6f8..024c60f87c 100644 --- a/examples/tutorials/gettingStartedQml/parts/part4/MenuBar.qml +++ b/examples/tutorials/gettingStartedQml/parts/part4/MenuBar.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part4/SimpleButton.qml b/examples/tutorials/gettingStartedQml/parts/part4/SimpleButton.qml index 11864d337e..0216131819 100644 --- a/examples/tutorials/gettingStartedQml/parts/part4/SimpleButton.qml +++ b/examples/tutorials/gettingStartedQml/parts/part4/SimpleButton.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part4/TextArea.qml b/examples/tutorials/gettingStartedQml/parts/part4/TextArea.qml index b3b1e07294..de664a15fd 100644 --- a/examples/tutorials/gettingStartedQml/parts/part4/TextArea.qml +++ b/examples/tutorials/gettingStartedQml/parts/part4/TextArea.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part4/TextEditor.qml b/examples/tutorials/gettingStartedQml/parts/part4/TextEditor.qml index 13735b35c9..43a6bc0eea 100644 --- a/examples/tutorials/gettingStartedQml/parts/part4/TextEditor.qml +++ b/examples/tutorials/gettingStartedQml/parts/part4/TextEditor.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part5/TextEditor.qml b/examples/tutorials/gettingStartedQml/parts/part5/TextEditor.qml index b517971c55..50501ddadc 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/TextEditor.qml +++ b/examples/tutorials/gettingStartedQml/parts/part5/TextEditor.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part5/core/Button.qml b/examples/tutorials/gettingStartedQml/parts/part5/core/Button.qml index 628af3a835..f6dd54ac9a 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/core/Button.qml +++ b/examples/tutorials/gettingStartedQml/parts/part5/core/Button.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part5/core/EditMenu.qml b/examples/tutorials/gettingStartedQml/parts/part5/core/EditMenu.qml index a92e51eb94..fe4bbf4cb2 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/core/EditMenu.qml +++ b/examples/tutorials/gettingStartedQml/parts/part5/core/EditMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part5/core/FileDialog.qml b/examples/tutorials/gettingStartedQml/parts/part5/core/FileDialog.qml index eeea0d2304..af83ef5e63 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/core/FileDialog.qml +++ b/examples/tutorials/gettingStartedQml/parts/part5/core/FileDialog.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part5/core/FileMenu.qml b/examples/tutorials/gettingStartedQml/parts/part5/core/FileMenu.qml index 2a33a30d43..57555010b6 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/core/FileMenu.qml +++ b/examples/tutorials/gettingStartedQml/parts/part5/core/FileMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part5/core/MenuBar.qml b/examples/tutorials/gettingStartedQml/parts/part5/core/MenuBar.qml index 81898ea86b..4a13f59dac 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/core/MenuBar.qml +++ b/examples/tutorials/gettingStartedQml/parts/part5/core/MenuBar.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part5/core/TextArea.qml b/examples/tutorials/gettingStartedQml/parts/part5/core/TextArea.qml index 0d77c30317..0882633c59 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/core/TextArea.qml +++ b/examples/tutorials/gettingStartedQml/parts/part5/core/TextArea.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.cpp b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.cpp index e4692b0a47..bd5c3f7428 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.cpp +++ b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: @@ -41,7 +41,7 @@ #include "dialogPlugin.h" #include "directory.h" #include "file.h" -#include +#include void DialogPlugin::registerTypes(const char *uri){ @@ -49,7 +49,7 @@ void DialogPlugin::registerTypes(const char *uri){ qmlRegisterType(uri, 1, 0, "Directory"); qmlRegisterType(uri,1,0,"File"); - //qRegisterMetaType > ("QDeclarativeListProperty"); + //qRegisterMetaType > ("QQmlListProperty"); } diff --git a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.h b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.h index b46d252616..8d5459a543 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.h +++ b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.h @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: @@ -41,14 +41,14 @@ #ifndef DIALOGPLUGIN_H #define DIALOGPLUGIN_H -#include +#include -class DialogPlugin : public QDeclarativeExtensionPlugin +class DialogPlugin : public QQmlExtensionPlugin { Q_OBJECT public: - //registerTypes is inherited from QDeclarativeExtensionPlugin + //registerTypes is inherited from QQmlExtensionPlugin void registerTypes(const char *uri); }; diff --git a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.cpp b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.cpp index b2984d3c2d..2247360017 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.cpp +++ b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: @@ -74,39 +74,39 @@ int Directory:: filesCount() const{ /* Function called to append data onto list property */ -void appendFiles(QDeclarativeListProperty * property, File * file){ +void appendFiles(QQmlListProperty * property, File * file){ //Do nothing. can't add to a directory using this method } /* Function called to retrieve file in the list using an index */ -File* fileAt(QDeclarativeListProperty * property, int index){ +File* fileAt(QQmlListProperty * property, int index){ return static_cast< QList *>(property->data)->at(index); } /* Returns the number of files in the list */ -int filesSize(QDeclarativeListProperty * property){ +int filesSize(QQmlListProperty * property){ return static_cast< QList *>(property->data)->size(); } /* Function called to empty the list property contents */ -void clearFilesPtr(QDeclarativeListProperty *property){ +void clearFilesPtr(QQmlListProperty *property){ return static_cast< QList *>(property->data)->clear(); } /* -Returns the list of files as a QDeclarativeListProperty. +Returns the list of files as a QQmlListProperty. */ -QDeclarativeListProperty Directory::files(){ +QQmlListProperty Directory::files(){ refresh(); -// return QDeclarativeListProperty(this,m_filePtrList); //not recommended in the docs - return QDeclarativeListProperty( this, &m_fileList, &appendFiles, &filesSize, &fileAt, &clearFilesPtr ); +// return QQmlListProperty(this,m_filePtrList); //not recommended in the docs + return QQmlListProperty( this, &m_fileList, &appendFiles, &filesSize, &fileAt, &clearFilesPtr ); } /* diff --git a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.h b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.h index 53872f257b..a47e9e112f 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.h +++ b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.h @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include class Directory : public QObject{ @@ -57,7 +57,7 @@ class Directory : public QObject{ Q_PROPERTY(int filesCount READ filesCount) //list property containing file names as QString - Q_PROPERTY(QDeclarativeListProperty files READ files CONSTANT ) + Q_PROPERTY(QQmlListProperty files READ files CONSTANT ) //file name of the text file to read/write Q_PROPERTY(QString filename READ filename WRITE setFilename NOTIFY filenameChanged) @@ -72,7 +72,7 @@ class Directory : public QObject{ int filesCount() const; QString filename() const; QString fileContent() const; - QDeclarativeListProperty files(); + QQmlListProperty files(); //properties' write functions void setFilename(const QString &str); diff --git a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.cpp b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.cpp index c1b57297cf..2385ed3240 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.cpp +++ b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.h b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.h index d57595607c..251b45282d 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.h +++ b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.h @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/filedialog.pro b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/filedialog.pro index 6247747003..71abddc7e3 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/filedialog.pro +++ b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/filedialog.pro @@ -1,6 +1,6 @@ TEMPLATE = lib CONFIG += qt plugin -QT += declarative +QT += qml DESTDIR += ../plugins OBJECTS_DIR = tmp diff --git a/examples/tutorials/gettingStartedQml/texteditor.qml b/examples/tutorials/gettingStartedQml/texteditor.qml index 76d79b6b90..05358294f5 100644 --- a/examples/tutorials/gettingStartedQml/texteditor.qml +++ b/examples/tutorials/gettingStartedQml/texteditor.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/window/window.cpp b/examples/window/window.cpp index 4854256190..2112ab8f45 100644 --- a/examples/window/window.cpp +++ b/examples/window/window.cpp @@ -39,16 +39,16 @@ ****************************************************************************/ #include -#include -#include +#include +#include #include #include int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); + QQmlEngine engine; + QQmlComponent component(&engine); component.loadUrl(QUrl::fromLocalFile("Window.qml")); if ( component.isReady() ) component.create(); diff --git a/examples/window/window.pro b/examples/window/window.pro index 74804bd776..c4518418f6 100644 --- a/examples/window/window.pro +++ b/examples/window/window.pro @@ -1,5 +1,5 @@ TEMPLATE = app CONFIG += qt -QT += declarative +QT += qml SOURCES += window.cpp diff --git a/modules/qt_declarative.pri b/modules/qt_declarative.pri index 54727d462a..619f562f49 100644 --- a/modules/qt_declarative.pri +++ b/modules/qt_declarative.pri @@ -4,14 +4,189 @@ QT.declarative.MINOR_VERSION = 0 QT.declarative.PATCH_VERSION = 0 QT.declarative.name = QtDeclarative -QT.declarative.bins = $$QT_MODULE_BIN_BASE QT.declarative.includes = $$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/QtDeclarative QT.declarative.private_includes = $$QT_MODULE_INCLUDE_BASE/QtDeclarative/$$QT.declarative.VERSION QT.declarative.sources = $$QT_MODULE_BASE/src/declarative -QT.declarative.libs = $$QT_MODULE_LIB_BASE QT.declarative.plugins = $$QT_MODULE_PLUGIN_BASE QT.declarative.imports = $$QT_MODULE_IMPORT_BASE QT.declarative.depends = gui network xmlpatterns -QT.declarative.DEFINES = QT_DECLARATIVE_LIB +QT.declarative.DEFINES = \ + QDeclarativeAbstractAnimation=QQuickAbstractAnimation\ + QDeclarativeAbstractBinding=QQmlAbstractBinding\ + QDeclarativeAbstractBoundSignal=QQmlAbstractBoundSignal\ + QDeclarativeAccessible=QQmlAccessible\ + QDeclarativeAccessibleAttached=QQmlAccessibleAttached\ + QDeclarativeAccessorProperties=QQmlAccessorProperties\ + QDeclarativeAction=QQuickAction\ + QDeclarativeActionEvent=QQuickActionEvent\ + QDeclarativeAnimationGroup=QQuickAnimationGroup\ + QDeclarativeAnimationPropertyUpdater=QQuickAnimationPropertyUpdater\ + QDeclarativeApplication=QQuickApplication\ + QDeclarativeBehavior=QQuickBehavior\ + QDeclarativeBind=QQuickBind\ + QDeclarativeBinding=QQmlBinding\ + QDeclarativeBindingProfiler=QQmlBindingProfiler\ + QDeclarativeBoundSignal=QQmlBoundSignal\ + QDeclarativeBuiltinFunctions=QQmlBuiltinFunctions\ + QDeclarativeBulkValueAnimator=QQuickBulkValueAnimator\ + QDeclarativeChangeSet=QQuickChangeSet\ + QDeclarativeCleanup=QQmlCleanup\ + QDeclarativeColorAnimation=QQuickColorAnimation\ + QDeclarativeColorValueType=QQmlColorValueType\ + QDeclarativeCompiledData=QQmlCompiledData\ + QDeclarativeCompiler=QQmlCompiler\ + QDeclarativeCompilerTypes=QQmlCompilerTypes\ + QDeclarativeComponent=QQmlComponent\ + QDeclarativeComponentAttached=QQmlComponentAttached\ + QDeclarativeComponentPrivate=QQmlComponentPrivate\ + QDeclarativeConnections=QQuickConnections\ + QDeclarativeContext=QQmlContext\ + QDeclarativeContextData=QQmlContextData\ + QDeclarativeCurve=QQuickCurve\ + QDeclarativeCustomParser=QQmlCustomParser\ + QDeclarativeCustomParserNode=QQmlCustomParserNode\ + QDeclarativeCustomParserProperty=QQmlCustomParserProperty\ + QDeclarativeData=QQmlData\ + QDeclarativeDataBlob=QQmlDataBlob\ + QDeclarativeDataLoader=QQmlDataLoader\ + QDeclarativeDebug=QQmlDebug\ + QDeclarativeDebugClient=QQmlDebugClient\ + QDeclarativeDebugConnection=QQmlDebugConnection\ + QDeclarativeDebugContextReference=QQmlDebugContextReference\ + QDeclarativeDebugData=QQmlDebugData\ + QDeclarativeDebugEngineReference=QQmlDebugEngineReference\ + QDeclarativeDebugEnginesQuery=QQmlDebugEnginesQuery\ + QDeclarativeDebugExpressionQuery=QQmlDebugExpressionQuery\ + QDeclarativeDebugFileReference=QQmlDebugFileReference\ + QDeclarativeDebuggingEnabler=QQmlDebuggingEnabler\ + QDeclarativeDebugHelper=QQmlDebugHelper\ + QDeclarativeDebugObjectExpressionWatch=QQmlDebugObjectExpressionWatch\ + QDeclarativeDebugObjectQuery=QQmlDebugObjectQuery\ + QDeclarativeDebugObjectReference=QQmlDebugObjectReference\ + QDeclarativeDebugPropertyReference=QQmlDebugPropertyReference\ + QDeclarativeDebugPropertyWatch=QQmlDebugPropertyWatch\ + QDeclarativeDebugQuery=QQmlDebugQuery\ + QDeclarativeDebugRootContextQuery=QQmlDebugRootContextQuery\ + QDeclarativeDebugServer=QQmlDebugServer\ + QDeclarativeDebugServerConnection=QQmlDebugServerConnection\ + QDeclarativeDebugService=QQmlDebugService\ + QDeclarativeDebugTrace=QQmlDebugTrace\ + QDeclarativeDebugWatch=QQmlDebugWatch\ + QDeclarativeEasingValueType=QQmlEasingValueType\ + QDeclarativeEngine=QQmlEngine\ + QDeclarativeEngineDebug=QQmlEngineDebug\ + QDeclarativeEngineDebugService=QQmlEngineDebugService\ + QDeclarativeEnginePrivate=QQmlEnginePrivate\ + QDeclarativeError=QQmlError\ + QDeclarativeExpression=QQmlExpression\ + QDeclarativeExpressionPrivate=QQmlExpressionPrivate\ + QDeclarativeExtensionInterface=QQmlExtensionInterface\ + QDeclarativeExtensionPlugin=QQmlExtensionPlugin\ + QDeclarativeFontLoader=QQuickFontLoader\ + QDeclarativeFontValueType=QQmlFontValueType\ + QDeclarativeGuard=QQmlGuard\ + QDeclarativeImageProvider=QQmlImageProvider\ + QDeclarativeImports=QQmlImports\ + QDeclarativeIncubationController=QQmlIncubationController\ + QDeclarativeIncubator=QQmlIncubator\ + QDeclarativeInfo=QQmlInfo\ + QDeclarativeInspector=QQmlInspector\ + QDeclarativeInspectorInterface=QQmlInspectorInterface\ + QDeclarativeInspectorService=QQmlInspectorService\ + QDeclarativeInstruction=QQmlInstruction\ + QDeclarativeJS=QQmlJS\ + QDeclarativeListAccessor=QQuickListAccessor\ + QDeclarativeListCompositor=QQuickListCompositor\ + QDeclarativeListModel=QQuickListModel\ + QDeclarativeListModelWorkerAgent=QQuickListModelWorkerAgent\ + QDeclarativeListProperty=QQmlListProperty\ + QDeclarativeListReference=QQmlListReference\ + QDeclarativeLocale=QQmlLocale\ + QDeclarativeMatrix4x4ValueType=QQmlMatrix4x4ValueType\ + QDeclarativeMetaType=QQmlMetaType\ + QDeclarativeNetworkAccessManagerFactory=QQmlNetworkAccessManagerFactory\ + QDeclarativeNotifier=QQmlNotifier\ + QDeclarativeNullableValue=QQmlNullableValue\ + QDeclarativeNumberAnimation=QQuickNumberAnimation\ + QDeclarativeOpenMetaObject=QQmlOpenMetaObject\ + QDeclarativeOpenMetaObjectType=QQmlOpenMetaObjectType\ + QDeclarativePackage=QQuickPackage\ + QDeclarativeParser=QQmlParser\ + QDeclarativeParserStatus=QQmlParserStatus\ + QDeclarativePath=QQuickPath\ + QDeclarativePathArc=QQuickPathArc\ + QDeclarativePathAttribute=QQuickPathAttribute\ + QDeclarativePathCatmullRomCurve=QQuickPathCatmullRomCurve\ + QDeclarativePathCubic=QQuickPathCubic\ + QDeclarativePathElement=QQuickPathElement\ + QDeclarativePathInterpolator=QQuickPathInterpolator\ + QDeclarativePathLine=QQuickPathLine\ + QDeclarativePathPercent=QQuickPathPercent\ + QDeclarativePathQuad=QQuickPathQuad\ + QDeclarativePathSvg=QQuickPathSvg\ + QDeclarativePauseAnimation=QQuickPauseAnimation\ + QDeclarativePixmap=QQuickPixmap\ + QDeclarativePointFValueType=QQmlPointFValueType\ + QDeclarativePointValueType=QQmlPointValueType\ + QDeclarativePool=QQmlPool\ + QDeclarativePrivate=QQmlPrivate\ + QDeclarativeProperty=QQmlProperty\ + QDeclarativePropertyAnimation=QQuickPropertyAnimation\ + QDeclarativePropertyCache=QQmlPropertyCache\ + QDeclarativePropertyChanges=QQuickPropertyChanges\ + QDeclarativePropertyMap=QQmlPropertyMap\ + QDeclarativePropertyPrivate=QQmlPropertyPrivate\ + QDeclarativePropertyValueInterceptor=QQmlPropertyValueInterceptor\ + QDeclarativePropertyValueSource=QQmlPropertyValueSource\ + QDeclarativeQmldirData=QQmlQmldirData\ + QDeclarativeQtQuick1Module=QQmlQtQuick1Module\ + QDeclarativeQtQuick2Module=QQmlQtQuick2Module\ + QDeclarativeQuaternionValueType=QQmlQuaternionValueType\ + QDeclarativeRectFValueType=QQmlRectFValueType\ + QDeclarativeRectValueType=QQmlRectValueType\ + QDeclarativeRewrite=QQmlRewrite\ + QDeclarativeRotationAnimation=QQuickRotationAnimation\ + QDeclarativeScript=QQmlScript\ + QDeclarativeScriptAction=QQuickScriptAction\ + QDeclarativeScriptBlob=QQmlScriptBlob\ + QDeclarativeStringConverters=QQmlStringConverters\ + QDeclarativeScriptData=QQmlScriptData\ + QDeclarativeScriptString=QQmlScriptString\ + QDeclarativeSizeFValueType=QQmlSizeFValueType\ + QDeclarativeSizeValueType=QQmlSizeValueType\ + QDeclarativeSmoothedAnimation=QQuickSmoothedAnimation\ + QDeclarativeSpringAnimation=QQuickSpringAnimation\ + QDeclarativeState=QQuickState\ + QDeclarativeStateChangeScript=QQuickStateChangeScript\ + QDeclarativeStateGroup=QQuickStateGroup\ + QDeclarativeStateOperation=QQuickStateOperation\ + QDeclarativeStyledText=QQuickStyledText\ + QDeclarativeStyledTextImgTag=QQuickStyledTextImgTag\ + QDeclarativeSvgParser=QQmlSvgParser\ + QDeclarativeSystemPalette=QQuickSystemPalette\ + QDeclarativeTextureFactory=QQuickTextureFactory\ + QDeclarativeTimeLine=QQuickTimeLine\ + QDeclarativeTimeLineCallback=QQuickTimeLineCallback\ + QDeclarativeTimeLineObject=QQuickTimeLineObject\ + QDeclarativeTimeLineValue=QQuickTimeLineValue\ + QDeclarativeTimer=QQuickTimer\ + QDeclarativeTransition=QQuickTransition\ + QDeclarativeTransitionManager=QQuickTransitionManager\ + QDeclarativeType=QQmlType\ + QDeclarativeTypeData=QQmlTypeData\ + QDeclarativeTypeLoader=QQmlTypeLoader\ + QDeclarativeTypesExtensionInterface=QQmlTypesExtensionInterface\ + QDeclarativeV8Function=QQmlV8Function\ + QDeclarativeValueType=QQmlValueType\ + QDeclarativeValueTypeFactory=QQmlValueTypeFactory\ + QDeclarativeVector2DValueType=QQmlVector2DValueType\ + QDeclarativeVector3dAnimation=QQuickVector3dAnimation\ + QDeclarativeVector3DValueType=QQmlVector3DValueType\ + QDeclarativeVector4DValueType=QQmlVector4DValueType\ + QDeclarativeVME=QQmlVME\ + QDeclarativeVMEMetaObject=QQmlVMEMetaObject\ + QDeclarativeVMETypes=QQmlVMETypes\ + QDeclarativeWorkerScript=QQuickWorkerScript\ + QDeclarativeXmlListModel=QQuickXmlListModel QT_CONFIG += declarative diff --git a/modules/qt_qml.pri b/modules/qt_qml.pri new file mode 100644 index 0000000000..82e70e3e93 --- /dev/null +++ b/modules/qt_qml.pri @@ -0,0 +1,17 @@ +QT.qml.VERSION = 5.0.0 +QT.qml.MAJOR_VERSION = 5 +QT.qml.MINOR_VERSION = 0 +QT.qml.PATCH_VERSION = 0 + +QT.qml.name = QtQml +QT.qml.bins = $$QT_MODULE_BIN_BASE +QT.qml.includes = $$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/QtQml +QT.qml.private_includes = $$QT_MODULE_INCLUDE_BASE/QtQml/$$QT.qml.VERSION +QT.qml.sources = $$QT_MODULE_BASE/src/qml +QT.qml.libs = $$QT_MODULE_LIB_BASE +QT.qml.plugins = $$QT_MODULE_PLUGIN_BASE +QT.qml.imports = $$QT_MODULE_IMPORT_BASE +QT.qml.depends = gui network xmlpatterns +QT.qml.DEFINES = QT_QML_LIB + +QT_CONFIG += qml diff --git a/modules/qt_qmltest.pri b/modules/qt_qmltest.pri index d00f621237..e3d747f700 100644 --- a/modules/qt_qmltest.pri +++ b/modules/qt_qmltest.pri @@ -11,7 +11,7 @@ QT.qmltest.sources = $$QT_MODULE_BASE/src/qmltest QT.qmltest.libs = $$QT_MODULE_LIB_BASE QT.qmltest.plugins = $$QT_MODULE_PLUGIN_BASE QT.qmltest.imports = $$QT_MODULE_IMPORT_BASE -QT.qmltest.depends = declarative testlib +QT.qmltest.depends = qml testlib QT.qmltest.DEFINES = QT_QMLTEST_LIB QT_CONFIG += qmltest diff --git a/modules/qt_quick.pri b/modules/qt_quick.pri index 0dc827b732..dc71b31194 100644 --- a/modules/qt_quick.pri +++ b/modules/qt_quick.pri @@ -11,7 +11,7 @@ QT.quick.sources = $$QT_MODULE_BASE/src/quick QT.quick.libs = $$QT_MODULE_LIB_BASE QT.quick.plugins = $$QT_MODULE_PLUGIN_BASE QT.quick.imports = $$QT_MODULE_IMPORT_BASE -QT.quick.depends = declarative +QT.quick.depends = qml QT.quick.DEFINES = QT_QUICK_LIB QT_CONFIG += quick diff --git a/src/compatibility/compatibility.pro b/src/compatibility/compatibility.pro new file mode 100644 index 0000000000..7dd6e43f75 --- /dev/null +++ b/src/compatibility/compatibility.pro @@ -0,0 +1,33 @@ +TARGET = QtDeclarative +TEMPLATE = subdirs + +MODULE_PRI = ../../modules/qt_declarative.pri + +QT = qml + +pritarget.path = $$[QT_INSTALL_DATA]/mkspecs/modules +pritarget.files = $$MODULE_PRI +INSTALLS += pritarget + +#load up the headers info +CONFIG += qt_install_headers +HEADERS_PRI = ../../include/QtDeclarative/headers.pri +include($$HEADERS_PRI, "", true)|clear(HEADERS_PRI) + +INSTALL_HEADERS = $$SYNCQT.HEADER_FILES + +flat_headers.files = $$INSTALL_HEADERS +flat_headers.path = $$[QT_INSTALL_HEADERS]/Qt +INSTALLS += flat_headers + +class_headers.path = $$[QT_INSTALL_HEADERS]/$$TARGET +class_headers.files = $$SYNCQT.HEADER_CLASSES +INSTALLS += class_headers + +targ_headers.files = $$INSTALL_HEADERS +targ_headers.path = $$[QT_INSTALL_HEADERS]/$$TARGET +INSTALLS += targ_headers + +private_headers.files = $$SYNCQT.PRIVATE_HEADER_FILES +private_headers.path = $$[QT_INSTALL_HEADERS]/$$TARGET/$${QT.declarative.VERSION}/$$TARGET/private +INSTALLS += private_headers diff --git a/src/declarative/debugger/debugger.pri b/src/declarative/debugger/debugger.pri deleted file mode 100644 index 8e29e9fdf6..0000000000 --- a/src/declarative/debugger/debugger.pri +++ /dev/null @@ -1,32 +0,0 @@ -SOURCES += \ - $$PWD/qpacketprotocol.cpp \ - $$PWD/qdeclarativedebugservice.cpp \ - $$PWD/qdeclarativedebugclient.cpp \ - $$PWD/qdeclarativeenginedebug.cpp \ - $$PWD/qdeclarativeprofilerservice.cpp \ - $$PWD/qdeclarativedebughelper.cpp \ - $$PWD/qdeclarativedebugserver.cpp \ - $$PWD/qdeclarativeinspectorservice.cpp \ - $$PWD/qv8debugservice.cpp \ - $$PWD/qv8profilerservice.cpp \ - $$PWD/qdeclarativeenginedebugservice.cpp \ - $$PWD/qdebugmessageservice.cpp - -HEADERS += \ - $$PWD/qpacketprotocol_p.h \ - $$PWD/qdeclarativedebugservice_p.h \ - $$PWD/qdeclarativedebugservice_p_p.h \ - $$PWD/qdeclarativedebugclient_p.h \ - $$PWD/qdeclarativeenginedebug_p.h \ - $$PWD/qdeclarativeprofilerservice_p.h \ - $$PWD/qdeclarativedebughelper_p.h \ - $$PWD/qdeclarativedebugserver_p.h \ - $$PWD/qdeclarativedebugserverconnection_p.h \ - $$PWD/qdeclarativedebugstatesdelegate_p.h \ - $$PWD/qdeclarativeinspectorservice_p.h \ - $$PWD/qdeclarativeinspectorinterface_p.h \ - $$PWD/qv8debugservice_p.h \ - $$PWD/qv8profilerservice_p.h \ - $$PWD/qdeclarativeenginedebugservice_p.h \ - $$PWD/qdeclarativedebug.h \ - $$PWD/qdebugmessageservice_p.h diff --git a/src/declarative/debugger/qdeclarativedebug.h b/src/declarative/debugger/qdeclarativedebug.h deleted file mode 100644 index e23e4ff41a..0000000000 --- a/src/declarative/debugger/qdeclarativedebug.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEDEBUG_H -#define QDECLARATIVEDEBUG_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -struct Q_DECLARATIVE_EXPORT QDeclarativeDebuggingEnabler -{ - QDeclarativeDebuggingEnabler(); -}; - -// Execute code in constructor before first QDeclarativeEngine is instantiated -#if defined(QT_DECLARATIVE_DEBUG) -static QDeclarativeDebuggingEnabler qmlEnableDebuggingHelper; -#endif - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUG_H diff --git a/src/declarative/debugger/qdeclarativedebugclient.cpp b/src/declarative/debugger/qdeclarativedebugclient.cpp deleted file mode 100644 index df250f3ef6..0000000000 --- a/src/declarative/debugger/qdeclarativedebugclient.cpp +++ /dev/null @@ -1,421 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativedebugclient_p.h" - -#include "qpacketprotocol_p.h" - -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -const int protocolVersion = 1; -const QString serverId = QLatin1String("QDeclarativeDebugServer"); -const QString clientId = QLatin1String("QDeclarativeDebugClient"); - -class QDeclarativeDebugClientPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeDebugClient) -public: - QDeclarativeDebugClientPrivate(); - - QString name; - QDeclarativeDebugConnection *connection; -}; - -class QDeclarativeDebugConnectionPrivate : public QObject -{ - Q_OBJECT -public: - QDeclarativeDebugConnectionPrivate(QDeclarativeDebugConnection *c); - QDeclarativeDebugConnection *q; - QPacketProtocol *protocol; - QIODevice *device; - - bool gotHello; - QHash serverPlugins; - QHash plugins; - - void advertisePlugins(); - void connectDeviceSignals(); - -public Q_SLOTS: - void connected(); - void readyRead(); - void deviceAboutToClose(); -}; - -QDeclarativeDebugConnectionPrivate::QDeclarativeDebugConnectionPrivate(QDeclarativeDebugConnection *c) - : QObject(c), q(c), protocol(0), device(0), gotHello(false) -{ - protocol = new QPacketProtocol(q, this); - QObject::connect(c, SIGNAL(connected()), this, SLOT(connected())); - QObject::connect(protocol, SIGNAL(readyRead()), this, SLOT(readyRead())); -} - -void QDeclarativeDebugConnectionPrivate::advertisePlugins() -{ - if (!q->isConnected()) - return; - - QPacket pack; - pack << serverId << 1 << plugins.keys(); - protocol->send(pack); - q->flush(); -} - -void QDeclarativeDebugConnectionPrivate::connected() -{ - QPacket pack; - pack << serverId << 0 << protocolVersion << plugins.keys(); - protocol->send(pack); - q->flush(); -} - -void QDeclarativeDebugConnectionPrivate::readyRead() -{ - if (!gotHello) { - QPacket pack = protocol->read(); - QString name; - - pack >> name; - - bool validHello = false; - if (name == clientId) { - int op = -1; - pack >> op; - if (op == 0) { - int version = -1; - pack >> version; - if (version == protocolVersion) { - QStringList pluginNames; - QList pluginVersions; - pack >> pluginNames; - if (!pack.isEmpty()) - pack >> pluginVersions; - - const int pluginNamesSize = pluginNames.size(); - const int pluginVersionsSize = pluginVersions.size(); - for (int i = 0; i < pluginNamesSize; ++i) { - float pluginVersion = 1.0; - if (i < pluginVersionsSize) - pluginVersion = pluginVersions.at(i); - serverPlugins.insert(pluginNames.at(i), pluginVersion); - } - - validHello = true; - } - } - } - - if (!validHello) { - qWarning("QDeclarativeDebugConnection: Invalid hello message"); - QObject::disconnect(protocol, SIGNAL(readyRead()), this, SLOT(readyRead())); - return; - } - gotHello = true; - - QHash::Iterator iter = plugins.begin(); - for (; iter != plugins.end(); ++iter) { - QDeclarativeDebugClient::State newState = QDeclarativeDebugClient::Unavailable; - if (serverPlugins.contains(iter.key())) - newState = QDeclarativeDebugClient::Enabled; - iter.value()->stateChanged(newState); - } - } - - while (protocol->packetsAvailable()) { - QPacket pack = protocol->read(); - QString name; - pack >> name; - - if (name == clientId) { - int op = -1; - pack >> op; - - if (op == 1) { - // Service Discovery - QHash oldServerPlugins = serverPlugins; - serverPlugins.clear(); - - QStringList pluginNames; - QList pluginVersions; - pack >> pluginNames; - if (!pack.isEmpty()) - pack >> pluginVersions; - - const int pluginNamesSize = pluginNames.size(); - const int pluginVersionsSize = pluginVersions.size(); - for (int i = 0; i < pluginNamesSize; ++i) { - float pluginVersion = 1.0; - if (i < pluginVersionsSize) - pluginVersion = pluginVersions.at(i); - serverPlugins.insert(pluginNames.at(i), pluginVersion); - } - - QHash::Iterator iter = plugins.begin(); - for (; iter != plugins.end(); ++iter) { - const QString pluginName = iter.key(); - QDeclarativeDebugClient::State newSate = QDeclarativeDebugClient::Unavailable; - if (serverPlugins.contains(pluginName)) - newSate = QDeclarativeDebugClient::Enabled; - - if (oldServerPlugins.contains(pluginName) - != serverPlugins.contains(pluginName)) { - iter.value()->stateChanged(newSate); - } - } - } else { - qWarning() << "QDeclarativeDebugConnection: Unknown control message id" << op; - } - } else { - QByteArray message; - pack >> message; - - QHash::Iterator iter = - plugins.find(name); - if (iter == plugins.end()) { - qWarning() << "QDeclarativeDebugConnection: Message received for missing plugin" << name; - } else { - (*iter)->messageReceived(message); - } - } - } -} - -void QDeclarativeDebugConnectionPrivate::deviceAboutToClose() -{ - // This is nasty syntax but we want to emit our own aboutToClose signal (by calling QIODevice::close()) - // without calling the underlying device close fn as that would cause an infinite loop - q->QIODevice::close(); -} - -QDeclarativeDebugConnection::QDeclarativeDebugConnection(QObject *parent) - : QIODevice(parent), d(new QDeclarativeDebugConnectionPrivate(this)) -{ -} - -QDeclarativeDebugConnection::~QDeclarativeDebugConnection() -{ - QHash::iterator iter = d->plugins.begin(); - for (; iter != d->plugins.end(); ++iter) { - iter.value()->d_func()->connection = 0; - iter.value()->stateChanged(QDeclarativeDebugClient::NotConnected); - } -} - -bool QDeclarativeDebugConnection::isConnected() const -{ - return state() == QAbstractSocket::ConnectedState; -} - -qint64 QDeclarativeDebugConnection::readData(char *data, qint64 maxSize) -{ - return d->device->read(data, maxSize); -} - -qint64 QDeclarativeDebugConnection::writeData(const char *data, qint64 maxSize) -{ - return d->device->write(data, maxSize); -} - -qint64 QDeclarativeDebugConnection::bytesAvailable() const -{ - return d->device->bytesAvailable(); -} - -bool QDeclarativeDebugConnection::isSequential() const -{ - return true; -} - -void QDeclarativeDebugConnection::close() -{ - if (isOpen()) { - QIODevice::close(); - d->device->close(); - emit stateChanged(QAbstractSocket::UnconnectedState); - - QHash::iterator iter = d->plugins.begin(); - for (; iter != d->plugins.end(); ++iter) { - iter.value()->stateChanged(QDeclarativeDebugClient::NotConnected); - } - } -} - -bool QDeclarativeDebugConnection::waitForConnected(int msecs) -{ - QAbstractSocket *socket = qobject_cast(d->device); - if (socket) - return socket->waitForConnected(msecs); - return false; -} - -QAbstractSocket::SocketState QDeclarativeDebugConnection::state() const -{ - QAbstractSocket *socket = qobject_cast(d->device); - if (socket) - return socket->state(); - - return QAbstractSocket::UnconnectedState; -} - -void QDeclarativeDebugConnection::flush() -{ - QAbstractSocket *socket = qobject_cast(d->device); - if (socket) { - socket->flush(); - return; - } -} - -void QDeclarativeDebugConnection::connectToHost(const QString &hostName, quint16 port) -{ - QTcpSocket *socket = new QTcpSocket(d); - socket->setProxy(QNetworkProxy::NoProxy); - d->device = socket; - d->connectDeviceSignals(); - d->gotHello = false; - connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SIGNAL(stateChanged(QAbstractSocket::SocketState))); - connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SIGNAL(error(QAbstractSocket::SocketError))); - connect(socket, SIGNAL(connected()), this, SIGNAL(connected())); - socket->connectToHost(hostName, port); - QIODevice::open(ReadWrite | Unbuffered); -} - -void QDeclarativeDebugConnectionPrivate::connectDeviceSignals() -{ - connect(device, SIGNAL(bytesWritten(qint64)), q, SIGNAL(bytesWritten(qint64))); - connect(device, SIGNAL(readyRead()), q, SIGNAL(readyRead())); - connect(device, SIGNAL(aboutToClose()), this, SLOT(deviceAboutToClose())); -} - -// - -QDeclarativeDebugClientPrivate::QDeclarativeDebugClientPrivate() - : connection(0) -{ -} - -QDeclarativeDebugClient::QDeclarativeDebugClient(const QString &name, - QDeclarativeDebugConnection *parent) - : QObject(*(new QDeclarativeDebugClientPrivate), parent) -{ - Q_D(QDeclarativeDebugClient); - d->name = name; - d->connection = parent; - - if (!d->connection) - return; - - if (d->connection->d->plugins.contains(name)) { - qWarning() << "QDeclarativeDebugClient: Conflicting plugin name" << name; - d->connection = 0; - } else { - d->connection->d->plugins.insert(name, this); - d->connection->d->advertisePlugins(); - } -} - -QDeclarativeDebugClient::~QDeclarativeDebugClient() -{ - Q_D(QDeclarativeDebugClient); - if (d->connection && d->connection->d) { - d->connection->d->plugins.remove(d->name); - d->connection->d->advertisePlugins(); - } -} - -QString QDeclarativeDebugClient::name() const -{ - Q_D(const QDeclarativeDebugClient); - return d->name; -} - -float QDeclarativeDebugClient::serviceVersion() const -{ - Q_D(const QDeclarativeDebugClient); - if (d->connection->d->serverPlugins.contains(d->name)) - return d->connection->d->serverPlugins.value(d->name); - return -1; -} - -QDeclarativeDebugClient::State QDeclarativeDebugClient::state() const -{ - Q_D(const QDeclarativeDebugClient); - if (!d->connection - || !d->connection->isConnected() - || !d->connection->d->gotHello) - return NotConnected; - - if (d->connection->d->serverPlugins.contains(d->name)) - return Enabled; - - return Unavailable; -} - -void QDeclarativeDebugClient::sendMessage(const QByteArray &message) -{ - Q_D(QDeclarativeDebugClient); - if (state() != Enabled) - return; - - QPacket pack; - pack << d->name << message; - d->connection->d->protocol->send(pack); - d->connection->flush(); -} - -void QDeclarativeDebugClient::stateChanged(State) -{ -} - -void QDeclarativeDebugClient::messageReceived(const QByteArray &) -{ -} - -QT_END_NAMESPACE - -#include diff --git a/src/declarative/debugger/qdeclarativedebugclient_p.h b/src/declarative/debugger/qdeclarativedebugclient_p.h deleted file mode 100644 index 93c5be9e44..0000000000 --- a/src/declarative/debugger/qdeclarativedebugclient_p.h +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEDEBUGCLIENT_H -#define QDECLARATIVEDEBUGCLIENT_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 - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeDebugConnectionPrivate; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugConnection : public QIODevice -{ - Q_OBJECT - Q_DISABLE_COPY(QDeclarativeDebugConnection) -public: - QDeclarativeDebugConnection(QObject * = 0); - ~QDeclarativeDebugConnection(); - - void connectToHost(const QString &hostName, quint16 port); - - qint64 bytesAvailable() const; - bool isConnected() const; - QAbstractSocket::SocketState state() const; - void flush(); - bool isSequential() const; - void close(); - bool waitForConnected(int msecs = 30000); - -signals: - void connected(); - void stateChanged(QAbstractSocket::SocketState socketState); - void error(QAbstractSocket::SocketError socketError); - -protected: - qint64 readData(char *data, qint64 maxSize); - qint64 writeData(const char *data, qint64 maxSize); - -private: - QDeclarativeDebugConnectionPrivate *d; - friend class QDeclarativeDebugClient; - friend class QDeclarativeDebugClientPrivate; -}; - -class QDeclarativeDebugClientPrivate; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugClient : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarativeDebugClient) - Q_DISABLE_COPY(QDeclarativeDebugClient) - -public: - enum State { NotConnected, Unavailable, Enabled }; - - QDeclarativeDebugClient(const QString &, QDeclarativeDebugConnection *parent); - ~QDeclarativeDebugClient(); - - QString name() const; - float serviceVersion() const; - State state() const; - - virtual void sendMessage(const QByteArray &); - -protected: - virtual void stateChanged(State); - virtual void messageReceived(const QByteArray &); - -private: - friend class QDeclarativeDebugConnection; - friend class QDeclarativeDebugConnectionPrivate; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUGCLIENT_H diff --git a/src/declarative/debugger/qdeclarativedebughelper.cpp b/src/declarative/debugger/qdeclarativedebughelper.cpp deleted file mode 100644 index 45d488fe1b..0000000000 --- a/src/declarative/debugger/qdeclarativedebughelper.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativedebughelper_p.h" - -#include -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -void QDeclarativeDebugHelper::setAnimationSlowDownFactor(qreal factor) -{ - QUnifiedTimer *timer = QUnifiedTimer::instance(); - timer->setSlowModeEnabled(factor != 1.0); - timer->setSlowdownFactor(factor); -} - -void QDeclarativeDebugHelper::enableDebugging() { - qWarning("QDeclarativeDebugHelper::enableDebugging() is deprecated! Add CONFIG += declarative_debug to your .pro file instead."); -#ifndef QDECLARATIVE_NO_DEBUG_PROTOCOL - if (!QDeclarativeEnginePrivate::qml_debugging_enabled) { - qWarning("Qml debugging is enabled. Only use this in a safe environment!"); - } - QDeclarativeEnginePrivate::qml_debugging_enabled = true; -#endif -} - -QT_END_NAMESPACE diff --git a/src/declarative/debugger/qdeclarativedebughelper_p.h b/src/declarative/debugger/qdeclarativedebughelper_p.h deleted file mode 100644 index d24bc8c19f..0000000000 --- a/src/declarative/debugger/qdeclarativedebughelper_p.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEDEBUGHELPER_P_H -#define QDECLARATIVEDEBUGHELPER_P_H - -#include - -#include - -// -// 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. -// - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QDeclarativeEngine; - -#ifndef QT_BUILD_DECLARATIVE_LIB -#warning Use of this header file is deprecated! Add CONFIG += declarative_debug to your .pro file instead. -#endif - -// Helper methods to access private API through a stable interface -// This is used in the qmljsdebugger library of QtCreator. -class Q_DECLARATIVE_EXPORT QDeclarativeDebugHelper -{ -public: - static void setAnimationSlowDownFactor(qreal factor); - - // Enables remote debugging functionality - // Only use this for debugging in a safe environment! - static void enableDebugging(); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUGHELPER_P_H diff --git a/src/declarative/debugger/qdeclarativedebugserver.cpp b/src/declarative/debugger/qdeclarativedebugserver.cpp deleted file mode 100644 index 482847c7a7..0000000000 --- a/src/declarative/debugger/qdeclarativedebugserver.cpp +++ /dev/null @@ -1,539 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativedebugserver_p.h" -#include "qdeclarativedebugservice_p.h" -#include "qdeclarativedebugservice_p_p.h" -#include - -#include -#include -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -/* - QDeclarativeDebug Protocol (Version 1): - - handshake: - 1. Client sends - "QDeclarativeDebugServer" 0 version pluginNames - version: an int representing the highest protocol version the client knows - pluginNames: plugins available on client side - 2. Server sends - "QDeclarativeDebugClient" 0 version pluginNames pluginVersions - version: an int representing the highest protocol version the client & server know - pluginNames: plugins available on server side. plugins both in the client and server message are enabled. - client plugin advertisement - 1. Client sends - "QDeclarativeDebugServer" 1 pluginNames - server plugin advertisement - 1. Server sends - "QDeclarativeDebugClient" 1 pluginNames pluginVersions - plugin communication: - Everything send with a header different to "QDeclarativeDebugServer" is sent to the appropriate plugin. - */ - -const int protocolVersion = 1; - -// print detailed information about loading of plugins -DEFINE_BOOL_CONFIG_OPTION(qmlDebugVerbose, QML_DEBUGGER_VERBOSE) - -class QDeclarativeDebugServerThread; - -class QDeclarativeDebugServerPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeDebugServer) -public: - QDeclarativeDebugServerPrivate(); - - void advertisePlugins(); - QDeclarativeDebugServerConnection *loadConnectionPlugin(const QString &pluginName); - - QDeclarativeDebugServerConnection *connection; - QHash plugins; - mutable QReadWriteLock pluginsLock; - QStringList clientPlugins; - bool gotHello; - - QMutex messageArrivedMutex; - QWaitCondition messageArrivedCondition; - QStringList waitingForMessageNames; - QDeclarativeDebugServerThread *thread; - QPluginLoader loader; - -private: - // private slot - void _q_sendMessages(const QList &messages); -}; - -class QDeclarativeDebugServerThread : public QThread -{ -public: - void setPluginName(const QString &pluginName) { - m_pluginName = pluginName; - } - - void setPort(int port, bool block) { - m_port = port; - m_block = block; - } - - void run(); - -private: - QString m_pluginName; - int m_port; - bool m_block; -}; - -QDeclarativeDebugServerPrivate::QDeclarativeDebugServerPrivate() : - connection(0), - gotHello(false), - thread(0) -{ - // used in _q_sendMessages - qRegisterMetaType >("QList"); -} - -void QDeclarativeDebugServerPrivate::advertisePlugins() -{ - Q_Q(QDeclarativeDebugServer); - - if (!gotHello) - return; - - QByteArray message; - { - QDataStream out(&message, QIODevice::WriteOnly); - QStringList pluginNames; - QList pluginVersions; - foreach (QDeclarativeDebugService *service, plugins.values()) { - pluginNames << service->name(); - pluginVersions << service->version(); - } - out << QString(QLatin1String("QDeclarativeDebugClient")) << 1 << pluginNames << pluginVersions; - } - - QMetaObject::invokeMethod(q, "_q_sendMessages", Qt::QueuedConnection, Q_ARG(QList, QList() << message)); -} - -QDeclarativeDebugServerConnection *QDeclarativeDebugServerPrivate::loadConnectionPlugin( - const QString &pluginName) -{ -#ifndef QT_NO_LIBRARY - QStringList pluginCandidates; - const QStringList paths = QCoreApplication::libraryPaths(); - foreach (const QString &libPath, paths) { - const QDir dir(libPath + QLatin1String("/qmltooling")); - if (dir.exists()) { - QStringList plugins(dir.entryList(QDir::Files)); - foreach (const QString &pluginPath, plugins) { - if (QFileInfo(pluginPath).fileName().contains(pluginName)) - pluginCandidates << dir.absoluteFilePath(pluginPath); - } - } - } - - foreach (const QString &pluginPath, pluginCandidates) { - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeDebugServer: Trying to load plugin " << pluginPath << "..."; - - loader.setFileName(pluginPath); - if (!loader.load()) { - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeDebugServer: Error while loading: " << loader.errorString(); - continue; - } - if (QObject *instance = loader.instance()) - connection = qobject_cast(instance); - - if (connection) { - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeDebugServer: Plugin successfully loaded."; - - return connection; - } - - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeDebugServer: Plugin does not implement interface QDeclarativeDebugServerConnection."; - - loader.unload(); - } -#endif - return 0; -} - -void QDeclarativeDebugServerThread::run() -{ - QDeclarativeDebugServer *server = QDeclarativeDebugServer::instance(); - QDeclarativeDebugServerConnection *connection - = server->d_func()->loadConnectionPlugin(m_pluginName); - if (connection) { - connection->setServer(QDeclarativeDebugServer::instance()); - connection->setPort(m_port, m_block); - } else { - QCoreApplicationPrivate *appD = static_cast(QObjectPrivate::get(qApp)); - qWarning() << QString::fromAscii("QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". " - "Remote debugger plugin has not been found.").arg(appD->qmljsDebugArgumentsString()); - } - - exec(); - - // make sure events still waiting are processed - QEventLoop eventLoop; - eventLoop.processEvents(QEventLoop::AllEvents); -} - -bool QDeclarativeDebugServer::hasDebuggingClient() const -{ - Q_D(const QDeclarativeDebugServer); - return d->connection - && d->connection->isConnected() - && d->gotHello; -} - -static QDeclarativeDebugServer *qDeclarativeDebugServer = 0; - - -static void cleanup() -{ - delete qDeclarativeDebugServer; - qDeclarativeDebugServer = 0; -} - -QDeclarativeDebugServer *QDeclarativeDebugServer::instance() -{ - static bool commandLineTested = false; - - if (!commandLineTested) { - commandLineTested = true; - - QCoreApplicationPrivate *appD = static_cast(QObjectPrivate::get(qApp)); -#ifndef QDECLARATIVE_NO_DEBUG_PROTOCOL - // ### remove port definition when protocol is changed - int port = 0; - bool block = false; - bool ok = false; - - // format: qmljsdebugger=port:3768[,block] OR qmljsdebugger=ost[,block] - if (!appD->qmljsDebugArgumentsString().isEmpty()) { - if (!QDeclarativeEnginePrivate::qml_debugging_enabled) { - qWarning() << QString::fromLatin1( - "QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". " - "Debugging has not been enabled.").arg( - appD->qmljsDebugArgumentsString()); - return 0; - } - - QString pluginName; - if (appD->qmljsDebugArgumentsString().indexOf(QLatin1String("port:")) == 0) { - int separatorIndex = appD->qmljsDebugArgumentsString().indexOf(QLatin1Char(',')); - port = appD->qmljsDebugArgumentsString().mid(5, separatorIndex - 5).toInt(&ok); - pluginName = QLatin1String("qmldbg_tcp"); - } else if (appD->qmljsDebugArgumentsString().contains(QLatin1String("ost"))) { - pluginName = QLatin1String("qmldbg_ost"); - ok = true; - } - - block = appD->qmljsDebugArgumentsString().contains(QLatin1String("block")); - - if (ok) { - qDeclarativeDebugServer = new QDeclarativeDebugServer(); - QDeclarativeDebugServerThread *thread = new QDeclarativeDebugServerThread; - qDeclarativeDebugServer->d_func()->thread = thread; - qDeclarativeDebugServer->moveToThread(thread); - thread->setPluginName(pluginName); - thread->setPort(port, block); - thread->start(); - - if (block) { - QDeclarativeDebugServerPrivate *d = qDeclarativeDebugServer->d_func(); - d->messageArrivedMutex.lock(); - d->messageArrivedCondition.wait(&d->messageArrivedMutex); - d->messageArrivedMutex.unlock(); - } - - } else { - qWarning() << QString::fromLatin1( - "QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". " - "Format is -qmljsdebugger=port:[,block]").arg( - appD->qmljsDebugArgumentsString()); - } - } -#else - if (!appD->qmljsDebugArgumentsString().isEmpty()) { - qWarning() << QString::fromLatin1( - "QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". " - "QtDeclarative is not configured for debugging.").arg( - appD->qmljsDebugArgumentsString()); - } -#endif - } - - return qDeclarativeDebugServer; -} - -QDeclarativeDebugServer::QDeclarativeDebugServer() - : QObject(*(new QDeclarativeDebugServerPrivate)) -{ - qAddPostRoutine(cleanup); -} - -QDeclarativeDebugServer::~QDeclarativeDebugServer() -{ - Q_D(QDeclarativeDebugServer); - - QReadLocker(&d->pluginsLock); - { - foreach (QDeclarativeDebugService *service, d->plugins.values()) { - service->stateAboutToBeChanged(QDeclarativeDebugService::NotConnected); - service->d_func()->server = 0; - service->d_func()->state = QDeclarativeDebugService::NotConnected; - service->stateChanged(QDeclarativeDebugService::NotConnected); - } - } - - if (d->thread) { - d->thread->exit(); - d->thread->wait(); - delete d->thread; - } - delete d->connection; -} - -void QDeclarativeDebugServer::receiveMessage(const QByteArray &message) -{ - Q_D(QDeclarativeDebugServer); - - QDataStream in(message); - - QString name; - - in >> name; - if (name == QLatin1String("QDeclarativeDebugServer")) { - int op = -1; - in >> op; - if (op == 0) { - int version; - in >> version >> d->clientPlugins; - - // Send the hello answer immediately, since it needs to arrive before - // the plugins below start sending messages. - QByteArray helloAnswer; - { - QDataStream out(&helloAnswer, QIODevice::WriteOnly); - QStringList pluginNames; - QList pluginVersions; - foreach (QDeclarativeDebugService *service, d->plugins.values()) { - pluginNames << service->name(); - pluginVersions << service->version(); - } - - out << QString(QLatin1String("QDeclarativeDebugClient")) << 0 << protocolVersion << pluginNames << pluginVersions; - } - d->connection->send(QList() << helloAnswer); - - d->gotHello = true; - - QReadLocker(&d->pluginsLock); - QHash::ConstIterator iter = d->plugins.constBegin(); - for (; iter != d->plugins.constEnd(); ++iter) { - QDeclarativeDebugService::State newState = QDeclarativeDebugService::Unavailable; - if (d->clientPlugins.contains(iter.key())) - newState = QDeclarativeDebugService::Enabled; - iter.value()->d_func()->state = newState; - iter.value()->stateChanged(newState); - } - - qWarning("QDeclarativeDebugServer: Connection established"); - d->messageArrivedCondition.wakeAll(); - - } else if (op == 1) { - - // Service Discovery - QStringList oldClientPlugins = d->clientPlugins; - in >> d->clientPlugins; - - QReadLocker(&d->pluginsLock); - QHash::ConstIterator iter = d->plugins.constBegin(); - for (; iter != d->plugins.constEnd(); ++iter) { - const QString pluginName = iter.key(); - QDeclarativeDebugService::State newState = QDeclarativeDebugService::Unavailable; - if (d->clientPlugins.contains(pluginName)) - newState = QDeclarativeDebugService::Enabled; - - if (oldClientPlugins.contains(pluginName) - != d->clientPlugins.contains(pluginName)) { - iter.value()->d_func()->state = newState; - iter.value()->stateChanged(newState); - } - } - - } else { - qWarning("QDeclarativeDebugServer: Invalid control message %d", op); - d->connection->disconnect(); - return; - } - - } else { - if (d->gotHello) { - QByteArray message; - in >> message; - - QReadLocker(&d->pluginsLock); - QHash::Iterator iter = d->plugins.find(name); - if (iter == d->plugins.end()) { - qWarning() << "QDeclarativeDebugServer: Message received for missing plugin" << name; - } else { - (*iter)->messageReceived(message); - - if (d->waitingForMessageNames.removeOne(name)) - d->messageArrivedCondition.wakeAll(); - } - } else { - qWarning("QDeclarativeDebugServer: Invalid hello message"); - } - - } -} - -void QDeclarativeDebugServerPrivate::_q_sendMessages(const QList &messages) -{ - if (connection) - connection->send(messages); -} - -QList QDeclarativeDebugServer::services() const -{ - const Q_D(QDeclarativeDebugServer); - QReadLocker(&d->pluginsLock); - return d->plugins.values(); -} - -QStringList QDeclarativeDebugServer::serviceNames() const -{ - const Q_D(QDeclarativeDebugServer); - QReadLocker(&d->pluginsLock); - return d->plugins.keys(); -} - -bool QDeclarativeDebugServer::addService(QDeclarativeDebugService *service) -{ - Q_D(QDeclarativeDebugServer); - { - QWriteLocker(&d->pluginsLock); - if (!service || d->plugins.contains(service->name())) - return false; - d->plugins.insert(service->name(), service); - } - { - QReadLocker(&d->pluginsLock); - d->advertisePlugins(); - QDeclarativeDebugService::State newState = QDeclarativeDebugService::Unavailable; - if (d->clientPlugins.contains(service->name())) - newState = QDeclarativeDebugService::Enabled; - service->d_func()->state = newState; - } - return true; -} - -bool QDeclarativeDebugServer::removeService(QDeclarativeDebugService *service) -{ - Q_D(QDeclarativeDebugServer); - { - QWriteLocker(&d->pluginsLock); - if (!service || !d->plugins.contains(service->name())) - return false; - d->plugins.remove(service->name()); - } - { - QReadLocker(&d->pluginsLock); - QDeclarativeDebugService::State newState = QDeclarativeDebugService::NotConnected; - service->stateAboutToBeChanged(newState); - d->advertisePlugins(); - service->d_func()->server = 0; - service->d_func()->state = newState; - service->stateChanged(newState); - } - - return true; -} - -void QDeclarativeDebugServer::sendMessages(QDeclarativeDebugService *service, - const QList &messages) -{ - QList prefixedMessages; - foreach (const QByteArray &message, messages) { - QByteArray prefixed; - QDataStream out(&prefixed, QIODevice::WriteOnly); - out << service->name() << message; - prefixedMessages << prefixed; - } - - QMetaObject::invokeMethod(this, "_q_sendMessages", Qt::QueuedConnection, Q_ARG(QList, prefixedMessages)); -} - -bool QDeclarativeDebugServer::waitForMessage(QDeclarativeDebugService *service) -{ - Q_D(QDeclarativeDebugServer); - QReadLocker(&d->pluginsLock); - - if (!service - || !d->plugins.contains(service->name())) - return false; - - d->messageArrivedMutex.lock(); - d->waitingForMessageNames << service->name(); - do { - d->messageArrivedCondition.wait(&d->messageArrivedMutex); - } while (d->waitingForMessageNames.contains(service->name())); - d->messageArrivedMutex.unlock(); - return true; -} - -QT_END_NAMESPACE - -#include "moc_qdeclarativedebugserver_p.cpp" diff --git a/src/declarative/debugger/qdeclarativedebugserver_p.h b/src/declarative/debugger/qdeclarativedebugserver_p.h deleted file mode 100644 index 8f7f748761..0000000000 --- a/src/declarative/debugger/qdeclarativedebugserver_p.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEDEBUGSERVER_H -#define QDECLARATIVEDEBUGSERVER_H - -#include -#include - -// -// 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. -// - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeDebugService; - -class QDeclarativeDebugServerPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeDebugServer : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarativeDebugServer) - Q_DISABLE_COPY(QDeclarativeDebugServer) -public: - ~QDeclarativeDebugServer(); - - static QDeclarativeDebugServer *instance(); - - void setConnection(QDeclarativeDebugServerConnection *connection); - - bool hasDebuggingClient() const; - - QList services() const; - QStringList serviceNames() const; - - - bool addService(QDeclarativeDebugService *service); - bool removeService(QDeclarativeDebugService *service); - - void receiveMessage(const QByteArray &message); - - bool waitForMessage(QDeclarativeDebugService *service); - void sendMessages(QDeclarativeDebugService *service, const QList &messages); - -private: - friend class QDeclarativeDebugService; - friend class QDeclarativeDebugServicePrivate; - friend class QDeclarativeDebugServerThread; - QDeclarativeDebugServer(); - Q_PRIVATE_SLOT(d_func(), void _q_sendMessages(QList)) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUGSERVICE_H diff --git a/src/declarative/debugger/qdeclarativedebugserverconnection_p.h b/src/declarative/debugger/qdeclarativedebugserverconnection_p.h deleted file mode 100644 index e78657a73d..0000000000 --- a/src/declarative/debugger/qdeclarativedebugserverconnection_p.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEDEBUGSERVERCONNECTION_H -#define QDECLARATIVEDEBUGSERVERCONNECTION_H - -#include - -// -// 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. -// - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeDebugServer; -class Q_DECLARATIVE_EXPORT QDeclarativeDebugServerConnection -{ -public: - QDeclarativeDebugServerConnection() {} - virtual ~QDeclarativeDebugServerConnection() {} - - virtual void setServer(QDeclarativeDebugServer *server) = 0; - virtual void setPort(int port, bool bock) = 0; - virtual bool isConnected() const = 0; - virtual void send(const QList &messages) = 0; - virtual void disconnect() = 0; - virtual bool waitForMessage() = 0; -}; - -#define QDeclarativeDebugServerConnection_iid "org.qt-project.Qt.QDeclarativeDebugServerConnection" - -Q_DECLARE_INTERFACE(QDeclarativeDebugServerConnection, QDeclarativeDebugServerConnection_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUGSERVERCONNECTION_H diff --git a/src/declarative/debugger/qdeclarativedebugservice.cpp b/src/declarative/debugger/qdeclarativedebugservice.cpp deleted file mode 100644 index 96344d7717..0000000000 --- a/src/declarative/debugger/qdeclarativedebugservice.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativedebugservice_p.h" -#include "qdeclarativedebugservice_p_p.h" -#include "qdeclarativedebugserver_p.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -QDeclarativeDebugServicePrivate::QDeclarativeDebugServicePrivate() - : server(0) -{ -} - -QDeclarativeDebugService::QDeclarativeDebugService(const QString &name, float version, QObject *parent) - : QObject(*(new QDeclarativeDebugServicePrivate), parent) -{ - Q_D(QDeclarativeDebugService); - d->name = name; - d->version = version; - d->server = QDeclarativeDebugServer::instance(); - d->state = QDeclarativeDebugService::NotConnected; - - -} - -QDeclarativeDebugService::QDeclarativeDebugService(QDeclarativeDebugServicePrivate &dd, - const QString &name, float version, QObject *parent) - : QObject(dd, parent) -{ - Q_D(QDeclarativeDebugService); - d->name = name; - d->version = version; - d->server = QDeclarativeDebugServer::instance(); - d->state = QDeclarativeDebugService::NotConnected; -} - -/** - Registers the service. This should be called in the constructor of the inherited class. From - then on the service might get asynchronous calls to messageReceived(). - */ -QDeclarativeDebugService::State QDeclarativeDebugService::registerService() -{ - Q_D(QDeclarativeDebugService); - if (!d->server) - return NotConnected; - - if (d->server->serviceNames().contains(d->name)) { - qWarning() << "QDeclarativeDebugService: Conflicting plugin name" << d->name; - d->server = 0; - } else { - d->server->addService(this); - } - return state(); -} - -QDeclarativeDebugService::~QDeclarativeDebugService() -{ - Q_D(const QDeclarativeDebugService); - if (d->server) { - d->server->removeService(this); - } -} - -QString QDeclarativeDebugService::name() const -{ - Q_D(const QDeclarativeDebugService); - return d->name; -} - -float QDeclarativeDebugService::version() const -{ - Q_D(const QDeclarativeDebugService); - return d->version; -} - -QDeclarativeDebugService::State QDeclarativeDebugService::state() const -{ - Q_D(const QDeclarativeDebugService); - return d->state; -} - -namespace { - -struct ObjectReference -{ - QPointer object; - int id; -}; - -struct ObjectReferenceHash -{ - ObjectReferenceHash() : nextId(0) {} - - QHash objects; - QHash ids; - - int nextId; -}; - -} -Q_GLOBAL_STATIC(ObjectReferenceHash, objectReferenceHash); - - -/*! - Returns a unique id for \a object. Calling this method multiple times - for the same object will return the same id. -*/ -int QDeclarativeDebugService::idForObject(QObject *object) -{ - if (!object) - return -1; - - ObjectReferenceHash *hash = objectReferenceHash(); - QHash::Iterator iter = - hash->objects.find(object); - - if (iter == hash->objects.end()) { - int id = hash->nextId++; - - hash->ids.insert(id, object); - iter = hash->objects.insert(object, ObjectReference()); - iter->object = object; - iter->id = id; - } else if (iter->object != object) { - int id = hash->nextId++; - - hash->ids.remove(iter->id); - - hash->ids.insert(id, object); - iter->object = object; - iter->id = id; - } - return iter->id; -} - -/*! - Returns the object for unique \a id. If the object has not previously been - assigned an id, through idForObject(), then 0 is returned. If the object - has been destroyed, 0 is returned. -*/ -QObject *QDeclarativeDebugService::objectForId(int id) -{ - ObjectReferenceHash *hash = objectReferenceHash(); - - QHash::Iterator iter = hash->ids.find(id); - if (iter == hash->ids.end()) - return 0; - - - QHash::Iterator objIter = - hash->objects.find(*iter); - Q_ASSERT(objIter != hash->objects.end()); - - if (objIter->object == 0) { - hash->ids.erase(iter); - hash->objects.erase(objIter); - return 0; - } else { - return *iter; - } -} - -bool QDeclarativeDebugService::isDebuggingEnabled() -{ - return QDeclarativeDebugServer::instance() != 0; -} - -bool QDeclarativeDebugService::hasDebuggingClient() -{ - return QDeclarativeDebugServer::instance() != 0 - && QDeclarativeDebugServer::instance()->hasDebuggingClient(); -} - -QString QDeclarativeDebugService::objectToString(QObject *obj) -{ - if(!obj) - return QLatin1String("NULL"); - - QString objectName = obj->objectName(); - if(objectName.isEmpty()) - objectName = QLatin1String(""); - - QString rv = QString::fromUtf8(obj->metaObject()->className()) + - QLatin1String(": ") + objectName; - - return rv; -} - -void QDeclarativeDebugService::sendMessage(const QByteArray &message) -{ - sendMessages(QList() << message); -} - -void QDeclarativeDebugService::sendMessages(const QList &messages) -{ - Q_D(QDeclarativeDebugService); - - if (state() != Enabled) - return; - - d->server->sendMessages(this, messages); -} - -bool QDeclarativeDebugService::waitForMessage() -{ - Q_D(QDeclarativeDebugService); - - if (state() != Enabled) - return false; - - return d->server->waitForMessage(this); -} - -void QDeclarativeDebugService::stateAboutToBeChanged(State) -{ -} - -void QDeclarativeDebugService::stateChanged(State) -{ -} - -void QDeclarativeDebugService::messageReceived(const QByteArray &) -{ -} - -QT_END_NAMESPACE diff --git a/src/declarative/debugger/qdeclarativedebugservice_p.h b/src/declarative/debugger/qdeclarativedebugservice_p.h deleted file mode 100644 index 203e27ad09..0000000000 --- a/src/declarative/debugger/qdeclarativedebugservice_p.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEDEBUGSERVICE_H -#define QDECLARATIVEDEBUGSERVICE_H - -#include - -#include - -// -// 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. -// - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeDebugServicePrivate; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugService : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarativeDebugService) - Q_DISABLE_COPY(QDeclarativeDebugService) - -public: - explicit QDeclarativeDebugService(const QString &, float version, QObject *parent = 0); - ~QDeclarativeDebugService(); - - QString name() const; - float version() const; - - enum State { NotConnected, Unavailable, Enabled }; - State state() const; - - void sendMessage(const QByteArray &); - void sendMessages(const QList &); - bool waitForMessage(); - - static int idForObject(QObject *); - static QObject *objectForId(int); - - static QString objectToString(QObject *obj); - - static bool isDebuggingEnabled(); - static bool hasDebuggingClient(); - -protected: - QDeclarativeDebugService(QDeclarativeDebugServicePrivate &dd, const QString &name, float version, QObject *parent = 0); - - State registerService(); - - virtual void stateAboutToBeChanged(State); - virtual void stateChanged(State); - virtual void messageReceived(const QByteArray &); - -private: - friend class QDeclarativeDebugServer; - friend class QDeclarativeDebugServerPrivate; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUGSERVICE_H - diff --git a/src/declarative/debugger/qdeclarativedebugservice_p_p.h b/src/declarative/debugger/qdeclarativedebugservice_p_p.h deleted file mode 100644 index 6638ccbec7..0000000000 --- a/src/declarative/debugger/qdeclarativedebugservice_p_p.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEDEBUGSERVICE_P_H -#define QDECLARATIVEDEBUGSERVICE_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 - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeDebugServer; - -class QDeclarativeDebugServicePrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeDebugService) -public: - QDeclarativeDebugServicePrivate(); - - QString name; - float version; - QDeclarativeDebugServer *server; - QDeclarativeDebugService::State state; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUGSERVICE_P_H diff --git a/src/declarative/debugger/qdeclarativedebugstatesdelegate_p.h b/src/declarative/debugger/qdeclarativedebugstatesdelegate_p.h deleted file mode 100644 index 868357723d..0000000000 --- a/src/declarative/debugger/qdeclarativedebugstatesdelegate_p.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEDEBUGSTATESDELEGATE_P_H -#define QDECLARATIVEDEBUGSTATESDELEGATE_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 - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeContext; -class QDeclarativeProperty; -class QObject; -class QString; -class QVariant; - -class QDeclarativeDebugStatesDelegate -{ -protected: - QDeclarativeDebugStatesDelegate() {} - -public: - virtual ~QDeclarativeDebugStatesDelegate() {} - - virtual void buildStatesList(QDeclarativeContext *ctxt, bool cleanList) = 0; - virtual void updateBinding(QDeclarativeContext *context, - const QDeclarativeProperty &property, - const QVariant &expression, bool isLiteralValue, - const QString &fileName, int line, int column, - bool *inBaseState) = 0; - virtual bool setBindingForInvalidProperty(QObject *object, - const QString &propertyName, - const QVariant &expression, - bool isLiteralValue) = 0; - virtual void resetBindingForInvalidProperty(QObject *object, - const QString &propertyName) = 0; - -private: - Q_DISABLE_COPY(QDeclarativeDebugStatesDelegate) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUGSTATESDELEGATE_P_H diff --git a/src/declarative/debugger/qdeclarativeenginedebug.cpp b/src/declarative/debugger/qdeclarativeenginedebug.cpp deleted file mode 100644 index 462f99937e..0000000000 --- a/src/declarative/debugger/qdeclarativeenginedebug.cpp +++ /dev/null @@ -1,1072 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativeenginedebug_p.h" - -#include "qdeclarativedebugclient_p.h" - -#include "qdeclarativeenginedebugservice_p.h" - -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeEngineDebugClient : public QDeclarativeDebugClient -{ -public: - QDeclarativeEngineDebugClient(QDeclarativeDebugConnection *client, QDeclarativeEngineDebugPrivate *p); - -protected: - virtual void stateChanged(State state); - virtual void messageReceived(const QByteArray &); - -private: - QDeclarativeEngineDebugPrivate *priv; - friend class QDeclarativeEngineDebugPrivate; -}; - -class QDeclarativeEngineDebugPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeEngineDebug) -public: - QDeclarativeEngineDebugPrivate(QDeclarativeDebugConnection *); - ~QDeclarativeEngineDebugPrivate(); - - void stateChanged(QDeclarativeEngineDebug::State status); - void message(const QByteArray &); - - QDeclarativeEngineDebugClient *client; - int nextId; - int getId(); - - void decode(QDataStream &, QDeclarativeDebugContextReference &); - void decode(QDataStream &, QDeclarativeDebugObjectReference &, bool simple); - - static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugEnginesQuery *); - static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugRootContextQuery *); - static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugObjectQuery *); - static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugExpressionQuery *); - static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugWatch *); - - QHash enginesQuery; - QHash rootContextQuery; - QHash objectQuery; - QHash expressionQuery; - - QHash watched; -}; - -QDeclarativeEngineDebugClient::QDeclarativeEngineDebugClient(QDeclarativeDebugConnection *client, - QDeclarativeEngineDebugPrivate *p) - : QDeclarativeDebugClient(QLatin1String("QDeclarativeEngine"), client), priv(p) -{ -} - -void QDeclarativeEngineDebugClient::stateChanged(State status) -{ - if (priv) - priv->stateChanged(static_cast(status)); -} - -void QDeclarativeEngineDebugClient::messageReceived(const QByteArray &data) -{ - if (priv) - priv->message(data); -} - -QDeclarativeEngineDebugPrivate::QDeclarativeEngineDebugPrivate(QDeclarativeDebugConnection *c) - : client(new QDeclarativeEngineDebugClient(c, this)), nextId(0) -{ -} - -QDeclarativeEngineDebugPrivate::~QDeclarativeEngineDebugPrivate() -{ - if (client) - client->priv = 0; - delete client; - - QHash::iterator enginesIter = enginesQuery.begin(); - for (; enginesIter != enginesQuery.end(); ++enginesIter) { - enginesIter.value()->m_client = 0; - if (enginesIter.value()->state() == QDeclarativeDebugQuery::Waiting) - enginesIter.value()->setState(QDeclarativeDebugQuery::Error); - } - - QHash::iterator rootContextIter = rootContextQuery.begin(); - for (; rootContextIter != rootContextQuery.end(); ++rootContextIter) { - rootContextIter.value()->m_client = 0; - if (rootContextIter.value()->state() == QDeclarativeDebugQuery::Waiting) - rootContextIter.value()->setState(QDeclarativeDebugQuery::Error); - } - - QHash::iterator objectIter = objectQuery.begin(); - for (; objectIter != objectQuery.end(); ++objectIter) { - objectIter.value()->m_client = 0; - if (objectIter.value()->state() == QDeclarativeDebugQuery::Waiting) - objectIter.value()->setState(QDeclarativeDebugQuery::Error); - } - - QHash::iterator exprIter = expressionQuery.begin(); - for (; exprIter != expressionQuery.end(); ++exprIter) { - exprIter.value()->m_client = 0; - if (exprIter.value()->state() == QDeclarativeDebugQuery::Waiting) - exprIter.value()->setState(QDeclarativeDebugQuery::Error); - } - - QHash::iterator watchIter = watched.begin(); - for (; watchIter != watched.end(); ++watchIter) { - watchIter.value()->m_client = 0; - watchIter.value()->setState(QDeclarativeDebugWatch::Dead); - } -} - -int QDeclarativeEngineDebugPrivate::getId() -{ - return nextId++; -} - -void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugEnginesQuery *q) -{ - if (c && q) { - QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); - p->enginesQuery.remove(q->m_queryId); - } -} - -void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, - QDeclarativeDebugRootContextQuery *q) -{ - if (c && q) { - QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); - p->rootContextQuery.remove(q->m_queryId); - } -} - -void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugObjectQuery *q) -{ - if (c && q) { - QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); - p->objectQuery.remove(q->m_queryId); - } -} - -void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugExpressionQuery *q) -{ - if (c && q) { - QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); - p->expressionQuery.remove(q->m_queryId); - } -} - -void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugWatch *w) -{ - if (c && w) { - QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); - p->watched.remove(w->m_queryId); - } -} - -void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugObjectReference &o, - bool simple) -{ - QDeclarativeEngineDebugService::QDeclarativeObjectData data; - ds >> data; - o.m_debugId = data.objectId; - o.m_class = data.objectType; - o.m_idString = data.idString; - o.m_name = data.objectName; - o.m_source.m_url = data.url; - o.m_source.m_lineNumber = data.lineNumber; - o.m_source.m_columnNumber = data.columnNumber; - o.m_contextDebugId = data.contextId; - - if (simple) - return; - - int childCount; - bool recur; - ds >> childCount >> recur; - - for (int ii = 0; ii < childCount; ++ii) { - o.m_children.append(QDeclarativeDebugObjectReference()); - decode(ds, o.m_children.last(), !recur); - } - - int propCount; - ds >> propCount; - - for (int ii = 0; ii < propCount; ++ii) { - QDeclarativeEngineDebugService::QDeclarativeObjectProperty data; - ds >> data; - QDeclarativeDebugPropertyReference prop; - prop.m_objectDebugId = o.m_debugId; - prop.m_name = data.name; - prop.m_binding = data.binding; - prop.m_hasNotifySignal = data.hasNotifySignal; - prop.m_valueTypeName = data.valueTypeName; - switch (data.type) { - case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Basic: - case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::List: - case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::SignalProperty: - { - prop.m_value = data.value; - break; - } - case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Object: - { - QDeclarativeDebugObjectReference obj; - obj.m_debugId = prop.m_value.toInt(); - prop.m_value = QVariant::fromValue(obj); - break; - } - case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Unknown: - break; - } - o.m_properties << prop; - } -} - -void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugContextReference &c) -{ - ds >> c.m_name >> c.m_debugId; - - int contextCount; - ds >> contextCount; - - for (int ii = 0; ii < contextCount; ++ii) { - c.m_contexts.append(QDeclarativeDebugContextReference()); - decode(ds, c.m_contexts.last()); - } - - int objectCount; - ds >> objectCount; - - for (int ii = 0; ii < objectCount; ++ii) { - QDeclarativeDebugObjectReference obj; - decode(ds, obj, true); - - obj.m_contextDebugId = c.m_debugId; - c.m_objects << obj; - } -} - -void QDeclarativeEngineDebugPrivate::stateChanged(QDeclarativeEngineDebug::State status) -{ - emit q_func()->stateChanged(status); -} - -void QDeclarativeEngineDebugPrivate::message(const QByteArray &data) -{ - QDataStream ds(data); - - QByteArray type; - ds >> type; - - //qDebug() << "QDeclarativeEngineDebugPrivate::message()" << type; - - if (type == "LIST_ENGINES_R") { - int queryId; - ds >> queryId; - - QDeclarativeDebugEnginesQuery *query = enginesQuery.value(queryId); - if (!query) - return; - enginesQuery.remove(queryId); - - int count; - ds >> count; - - for (int ii = 0; ii < count; ++ii) { - QDeclarativeDebugEngineReference ref; - ds >> ref.m_name; - ds >> ref.m_debugId; - query->m_engines << ref; - } - - query->m_client = 0; - query->setState(QDeclarativeDebugQuery::Completed); - } else if (type == "LIST_OBJECTS_R") { - int queryId; - ds >> queryId; - - QDeclarativeDebugRootContextQuery *query = rootContextQuery.value(queryId); - if (!query) - return; - rootContextQuery.remove(queryId); - - if (!ds.atEnd()) - decode(ds, query->m_context); - - query->m_client = 0; - query->setState(QDeclarativeDebugQuery::Completed); - } else if (type == "FETCH_OBJECT_R") { - int queryId; - ds >> queryId; - - QDeclarativeDebugObjectQuery *query = objectQuery.value(queryId); - if (!query) - return; - objectQuery.remove(queryId); - - if (!ds.atEnd()) - decode(ds, query->m_object, false); - - query->m_client = 0; - query->setState(QDeclarativeDebugQuery::Completed); - } else if (type == "EVAL_EXPRESSION_R") { - int queryId; - QVariant result; - ds >> queryId >> result; - - QDeclarativeDebugExpressionQuery *query = expressionQuery.value(queryId); - if (!query) - return; - expressionQuery.remove(queryId); - - query->m_result = result; - query->m_client = 0; - query->setState(QDeclarativeDebugQuery::Completed); - } else if (type == "WATCH_PROPERTY_R") { - int queryId; - bool ok; - ds >> queryId >> ok; - - QDeclarativeDebugWatch *watch = watched.value(queryId); - if (!watch) - return; - - watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive); - } else if (type == "WATCH_OBJECT_R") { - int queryId; - bool ok; - ds >> queryId >> ok; - - QDeclarativeDebugWatch *watch = watched.value(queryId); - if (!watch) - return; - - watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive); - } else if (type == "WATCH_EXPR_OBJECT_R") { - int queryId; - bool ok; - ds >> queryId >> ok; - - QDeclarativeDebugWatch *watch = watched.value(queryId); - if (!watch) - return; - - watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive); - } else if (type == "UPDATE_WATCH") { - int queryId; - int debugId; - QByteArray name; - QVariant value; - ds >> queryId >> debugId >> name >> value; - - QDeclarativeDebugWatch *watch = watched.value(queryId, 0); - if (!watch) - return; - emit watch->valueChanged(name, value); - } else if (type == "OBJECT_CREATED") { - emit q_func()->newObjects(); - } -} - -QDeclarativeEngineDebug::QDeclarativeEngineDebug(QDeclarativeDebugConnection *client, QObject *parent) - : QObject(*(new QDeclarativeEngineDebugPrivate(client)), parent) -{ -} - -QDeclarativeEngineDebug::~QDeclarativeEngineDebug() -{ -} - -QDeclarativeEngineDebug::State QDeclarativeEngineDebug::state() const -{ - Q_D(const QDeclarativeEngineDebug); - - return static_cast(d->client->state()); -} - -QDeclarativeDebugPropertyWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugPropertyReference &property, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugPropertyWatch *watch = new QDeclarativeDebugPropertyWatch(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled) { - int queryId = d->getId(); - watch->m_queryId = queryId; - watch->m_client = this; - watch->m_objectDebugId = property.objectDebugId(); - watch->m_name = property.name(); - d->watched.insert(queryId, watch); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("WATCH_PROPERTY") << queryId << property.objectDebugId() << property.name().toUtf8(); - d->client->sendMessage(message); - } else { - watch->m_state = QDeclarativeDebugWatch::Dead; - } - - return watch; -} - -QDeclarativeDebugWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugContextReference &, const QString &, QObject *) -{ - qWarning("QDeclarativeEngineDebug::addWatch(): Not implemented"); - return 0; -} - -QDeclarativeDebugObjectExpressionWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugObjectReference &object, const QString &expr, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - QDeclarativeDebugObjectExpressionWatch *watch = new QDeclarativeDebugObjectExpressionWatch(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled) { - int queryId = d->getId(); - watch->m_queryId = queryId; - watch->m_client = this; - watch->m_objectDebugId = object.debugId(); - watch->m_expr = expr; - d->watched.insert(queryId, watch); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("WATCH_EXPR_OBJECT") << queryId << object.debugId() << expr; - d->client->sendMessage(message); - } else { - watch->m_state = QDeclarativeDebugWatch::Dead; - } - return watch; -} - -QDeclarativeDebugWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugObjectReference &object, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugWatch *watch = new QDeclarativeDebugWatch(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled) { - int queryId = d->getId(); - watch->m_queryId = queryId; - watch->m_client = this; - watch->m_objectDebugId = object.debugId(); - d->watched.insert(queryId, watch); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("WATCH_OBJECT") << queryId << object.debugId(); - d->client->sendMessage(message); - } else { - watch->m_state = QDeclarativeDebugWatch::Dead; - } - - return watch; -} - -QDeclarativeDebugWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugFileReference &, QObject *) -{ - qWarning("QDeclarativeEngineDebug::addWatch(): Not implemented"); - return 0; -} - -void QDeclarativeEngineDebug::removeWatch(QDeclarativeDebugWatch *watch) -{ - Q_D(QDeclarativeEngineDebug); - - if (!watch || !watch->m_client) - return; - - watch->m_client = 0; - watch->setState(QDeclarativeDebugWatch::Inactive); - - d->watched.remove(watch->queryId()); - - if (d->client && d->client->state() == QDeclarativeDebugClient::Enabled) { - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("NO_WATCH") << watch->queryId(); - d->client->sendMessage(message); - } -} - -QDeclarativeDebugEnginesQuery *QDeclarativeEngineDebug::queryAvailableEngines(QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugEnginesQuery *query = new QDeclarativeDebugEnginesQuery(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->enginesQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("LIST_ENGINES") << queryId; - d->client->sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; - } - - return query; -} - -QDeclarativeDebugRootContextQuery *QDeclarativeEngineDebug::queryRootContexts(const QDeclarativeDebugEngineReference &engine, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugRootContextQuery *query = new QDeclarativeDebugRootContextQuery(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled && engine.debugId() != -1) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->rootContextQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("LIST_OBJECTS") << queryId << engine.debugId(); - d->client->sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; - } - - return query; -} - -QDeclarativeDebugObjectQuery *QDeclarativeEngineDebug::queryObject(const QDeclarativeDebugObjectReference &object, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugObjectQuery *query = new QDeclarativeDebugObjectQuery(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled && object.debugId() != -1) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->objectQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId() - << false << true; - d->client->sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; - } - - return query; -} - -QDeclarativeDebugObjectQuery *QDeclarativeEngineDebug::queryObjectRecursive(const QDeclarativeDebugObjectReference &object, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugObjectQuery *query = new QDeclarativeDebugObjectQuery(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled && object.debugId() != -1) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->objectQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId() - << true << true; - d->client->sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; - } - - return query; -} - -QDeclarativeDebugExpressionQuery *QDeclarativeEngineDebug::queryExpressionResult(int objectDebugId, const QString &expr, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugExpressionQuery *query = new QDeclarativeDebugExpressionQuery(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { - query->m_client = this; - query->m_expr = expr; - int queryId = d->getId(); - query->m_queryId = queryId; - d->expressionQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("EVAL_EXPRESSION") << queryId << objectDebugId << expr; - d->client->sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; - } - - return query; -} - -bool QDeclarativeEngineDebug::setBindingForObject(int objectDebugId, const QString &propertyName, - const QVariant &bindingExpression, - bool isLiteralValue, - QString source, int line) -{ - Q_D(QDeclarativeEngineDebug); - - if (d->client->state() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("SET_BINDING") << objectDebugId << propertyName << bindingExpression << isLiteralValue << source << line; - d->client->sendMessage(message); - return true; - } else { - return false; - } -} - -bool QDeclarativeEngineDebug::resetBindingForObject(int objectDebugId, const QString &propertyName) -{ - Q_D(QDeclarativeEngineDebug); - - if (d->client->state() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("RESET_BINDING") << objectDebugId << propertyName; - d->client->sendMessage(message); - return true; - } else { - return false; - } -} - -bool QDeclarativeEngineDebug::setMethodBody(int objectDebugId, const QString &methodName, - const QString &methodBody) -{ - Q_D(QDeclarativeEngineDebug); - - if (d->client->state() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("SET_METHOD_BODY") << objectDebugId << methodName << methodBody; - d->client->sendMessage(message); - return true; - } else { - return false; - } -} - -QDeclarativeDebugWatch::QDeclarativeDebugWatch(QObject *parent) - : QObject(parent), m_state(Waiting), m_queryId(-1), m_client(0), m_objectDebugId(-1) -{ -} - -QDeclarativeDebugWatch::~QDeclarativeDebugWatch() -{ - if (m_client && m_queryId != -1) - QDeclarativeEngineDebugPrivate::remove(m_client, this); -} - -int QDeclarativeDebugWatch::queryId() const -{ - return m_queryId; -} - -int QDeclarativeDebugWatch::objectDebugId() const -{ - return m_objectDebugId; -} - -QDeclarativeDebugWatch::State QDeclarativeDebugWatch::state() const -{ - return m_state; -} - -void QDeclarativeDebugWatch::setState(State s) -{ - if (m_state == s) - return; - m_state = s; - emit stateChanged(m_state); -} - -QDeclarativeDebugPropertyWatch::QDeclarativeDebugPropertyWatch(QObject *parent) - : QDeclarativeDebugWatch(parent) -{ -} - -QString QDeclarativeDebugPropertyWatch::name() const -{ - return m_name; -} - - -QDeclarativeDebugObjectExpressionWatch::QDeclarativeDebugObjectExpressionWatch(QObject *parent) - : QDeclarativeDebugWatch(parent) -{ -} - -QString QDeclarativeDebugObjectExpressionWatch::expression() const -{ - return m_expr; -} - - -QDeclarativeDebugQuery::QDeclarativeDebugQuery(QObject *parent) - : QObject(parent), m_state(Waiting) -{ -} - -QDeclarativeDebugQuery::State QDeclarativeDebugQuery::state() const -{ - return m_state; -} - -bool QDeclarativeDebugQuery::isWaiting() const -{ - return m_state == Waiting; -} - -void QDeclarativeDebugQuery::setState(State s) -{ - if (m_state == s) - return; - m_state = s; - emit stateChanged(m_state); -} - -QDeclarativeDebugEnginesQuery::QDeclarativeDebugEnginesQuery(QObject *parent) - : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QDeclarativeDebugEnginesQuery::~QDeclarativeDebugEnginesQuery() -{ - if (m_client && m_queryId != -1) - QDeclarativeEngineDebugPrivate::remove(m_client, this); -} - -QList QDeclarativeDebugEnginesQuery::engines() const -{ - return m_engines; -} - -QDeclarativeDebugRootContextQuery::QDeclarativeDebugRootContextQuery(QObject *parent) - : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QDeclarativeDebugRootContextQuery::~QDeclarativeDebugRootContextQuery() -{ - if (m_client && m_queryId != -1) - QDeclarativeEngineDebugPrivate::remove(m_client, this); -} - -QDeclarativeDebugContextReference QDeclarativeDebugRootContextQuery::rootContext() const -{ - return m_context; -} - -QDeclarativeDebugObjectQuery::QDeclarativeDebugObjectQuery(QObject *parent) - : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QDeclarativeDebugObjectQuery::~QDeclarativeDebugObjectQuery() -{ - if (m_client && m_queryId != -1) - QDeclarativeEngineDebugPrivate::remove(m_client, this); -} - -QDeclarativeDebugObjectReference QDeclarativeDebugObjectQuery::object() const -{ - return m_object; -} - -QDeclarativeDebugExpressionQuery::QDeclarativeDebugExpressionQuery(QObject *parent) - : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QDeclarativeDebugExpressionQuery::~QDeclarativeDebugExpressionQuery() -{ - if (m_client && m_queryId != -1) - QDeclarativeEngineDebugPrivate::remove(m_client, this); -} - -QVariant QDeclarativeDebugExpressionQuery::expression() const -{ - return m_expr; -} - -QVariant QDeclarativeDebugExpressionQuery::result() const -{ - return m_result; -} - -QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference() - : m_debugId(-1) -{ -} - -QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference(int debugId) - : m_debugId(debugId) -{ -} - -QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference(const QDeclarativeDebugEngineReference &o) - : m_debugId(o.m_debugId), m_name(o.m_name) -{ -} - -QDeclarativeDebugEngineReference & -QDeclarativeDebugEngineReference::operator=(const QDeclarativeDebugEngineReference &o) -{ - m_debugId = o.m_debugId; m_name = o.m_name; - return *this; -} - -int QDeclarativeDebugEngineReference::debugId() const -{ - return m_debugId; -} - -QString QDeclarativeDebugEngineReference::name() const -{ - return m_name; -} - -QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference() - : m_debugId(-1), m_contextDebugId(-1) -{ -} - -QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(int debugId) - : m_debugId(debugId), m_contextDebugId(-1) -{ -} - -QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference &o) - : m_debugId(o.m_debugId), m_class(o.m_class), m_idString(o.m_idString), - m_name(o.m_name), m_source(o.m_source), m_contextDebugId(o.m_contextDebugId), - m_properties(o.m_properties), m_children(o.m_children) -{ -} - -QDeclarativeDebugObjectReference & -QDeclarativeDebugObjectReference::operator=(const QDeclarativeDebugObjectReference &o) -{ - m_debugId = o.m_debugId; m_class = o.m_class; m_idString = o.m_idString; - m_name = o.m_name; m_source = o.m_source; m_contextDebugId = o.m_contextDebugId; - m_properties = o.m_properties; m_children = o.m_children; - return *this; -} - -int QDeclarativeDebugObjectReference::debugId() const -{ - return m_debugId; -} - -QString QDeclarativeDebugObjectReference::className() const -{ - return m_class; -} - -QString QDeclarativeDebugObjectReference::idString() const -{ - return m_idString; -} - -QString QDeclarativeDebugObjectReference::name() const -{ - return m_name; -} - -QDeclarativeDebugFileReference QDeclarativeDebugObjectReference::source() const -{ - return m_source; -} - -int QDeclarativeDebugObjectReference::contextDebugId() const -{ - return m_contextDebugId; -} - -QList QDeclarativeDebugObjectReference::properties() const -{ - return m_properties; -} - -QList QDeclarativeDebugObjectReference::children() const -{ - return m_children; -} - -QDeclarativeDebugContextReference::QDeclarativeDebugContextReference() - : m_debugId(-1) -{ -} - -QDeclarativeDebugContextReference::QDeclarativeDebugContextReference(const QDeclarativeDebugContextReference &o) - : m_debugId(o.m_debugId), m_name(o.m_name), m_objects(o.m_objects), m_contexts(o.m_contexts) -{ -} - -QDeclarativeDebugContextReference &QDeclarativeDebugContextReference::operator=(const QDeclarativeDebugContextReference &o) -{ - m_debugId = o.m_debugId; m_name = o.m_name; m_objects = o.m_objects; - m_contexts = o.m_contexts; - return *this; -} - -int QDeclarativeDebugContextReference::debugId() const -{ - return m_debugId; -} - -QString QDeclarativeDebugContextReference::name() const -{ - return m_name; -} - -QList QDeclarativeDebugContextReference::objects() const -{ - return m_objects; -} - -QList QDeclarativeDebugContextReference::contexts() const -{ - return m_contexts; -} - -QDeclarativeDebugFileReference::QDeclarativeDebugFileReference() - : m_lineNumber(-1), m_columnNumber(-1) -{ -} - -QDeclarativeDebugFileReference::QDeclarativeDebugFileReference(const QDeclarativeDebugFileReference &o) - : m_url(o.m_url), m_lineNumber(o.m_lineNumber), m_columnNumber(o.m_columnNumber) -{ -} - -QDeclarativeDebugFileReference &QDeclarativeDebugFileReference::operator=(const QDeclarativeDebugFileReference &o) -{ - m_url = o.m_url; m_lineNumber = o.m_lineNumber; m_columnNumber = o.m_columnNumber; - return *this; -} - -QUrl QDeclarativeDebugFileReference::url() const -{ - return m_url; -} - -void QDeclarativeDebugFileReference::setUrl(const QUrl &u) -{ - m_url = u; -} - -int QDeclarativeDebugFileReference::lineNumber() const -{ - return m_lineNumber; -} - -void QDeclarativeDebugFileReference::setLineNumber(int l) -{ - m_lineNumber = l; -} - -int QDeclarativeDebugFileReference::columnNumber() const -{ - return m_columnNumber; -} - -void QDeclarativeDebugFileReference::setColumnNumber(int c) -{ - m_columnNumber = c; -} - -QDeclarativeDebugPropertyReference::QDeclarativeDebugPropertyReference() - : m_objectDebugId(-1), m_hasNotifySignal(false) -{ -} - -QDeclarativeDebugPropertyReference::QDeclarativeDebugPropertyReference(const QDeclarativeDebugPropertyReference &o) - : m_objectDebugId(o.m_objectDebugId), m_name(o.m_name), m_value(o.m_value), - m_valueTypeName(o.m_valueTypeName), m_binding(o.m_binding), - m_hasNotifySignal(o.m_hasNotifySignal) -{ -} - -QDeclarativeDebugPropertyReference &QDeclarativeDebugPropertyReference::operator=(const QDeclarativeDebugPropertyReference &o) -{ - m_objectDebugId = o.m_objectDebugId; m_name = o.m_name; m_value = o.m_value; - m_valueTypeName = o.m_valueTypeName; m_binding = o.m_binding; - m_hasNotifySignal = o.m_hasNotifySignal; - return *this; -} - -int QDeclarativeDebugPropertyReference::objectDebugId() const -{ - return m_objectDebugId; -} - -QString QDeclarativeDebugPropertyReference::name() const -{ - return m_name; -} - -QString QDeclarativeDebugPropertyReference::valueTypeName() const -{ - return m_valueTypeName; -} - -QVariant QDeclarativeDebugPropertyReference::value() const -{ - return m_value; -} - -QString QDeclarativeDebugPropertyReference::binding() const -{ - return m_binding; -} - -bool QDeclarativeDebugPropertyReference::hasNotifySignal() const -{ - return m_hasNotifySignal; -} - -QT_END_NAMESPACE - diff --git a/src/declarative/debugger/qdeclarativeenginedebug_p.h b/src/declarative/debugger/qdeclarativeenginedebug_p.h deleted file mode 100644 index 5ca2987da3..0000000000 --- a/src/declarative/debugger/qdeclarativeenginedebug_p.h +++ /dev/null @@ -1,397 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEENGINEDEBUG_H -#define QDECLARATIVEENGINEDEBUG_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 -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeDebugConnection; -class QDeclarativeDebugWatch; -class QDeclarativeDebugPropertyWatch; -class QDeclarativeDebugObjectExpressionWatch; -class QDeclarativeDebugEnginesQuery; -class QDeclarativeDebugRootContextQuery; -class QDeclarativeDebugObjectQuery; -class QDeclarativeDebugExpressionQuery; -class QDeclarativeDebugPropertyReference; -class QDeclarativeDebugContextReference; -class QDeclarativeDebugObjectReference; -class QDeclarativeDebugFileReference; -class QDeclarativeDebugEngineReference; -class QDeclarativeEngineDebugPrivate; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeEngineDebug : public QObject -{ - Q_OBJECT -public: - enum State { NotConnected, Unavailable, Enabled }; - - explicit QDeclarativeEngineDebug(QDeclarativeDebugConnection *, QObject * = 0); - ~QDeclarativeEngineDebug(); - - State state() const; - - QDeclarativeDebugPropertyWatch *addWatch(const QDeclarativeDebugPropertyReference &, - QObject *parent = 0); - QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugContextReference &, const QString &, - QObject *parent = 0); - QDeclarativeDebugObjectExpressionWatch *addWatch(const QDeclarativeDebugObjectReference &, const QString &, - QObject *parent = 0); - QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugObjectReference &, - QObject *parent = 0); - QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugFileReference &, - QObject *parent = 0); - - void removeWatch(QDeclarativeDebugWatch *watch); - - QDeclarativeDebugEnginesQuery *queryAvailableEngines(QObject *parent = 0); - QDeclarativeDebugRootContextQuery *queryRootContexts(const QDeclarativeDebugEngineReference &, - QObject *parent = 0); - QDeclarativeDebugObjectQuery *queryObject(const QDeclarativeDebugObjectReference &, - QObject *parent = 0); - QDeclarativeDebugObjectQuery *queryObjectRecursive(const QDeclarativeDebugObjectReference &, - QObject *parent = 0); - QDeclarativeDebugExpressionQuery *queryExpressionResult(int objectDebugId, - const QString &expr, - QObject *parent = 0); - bool setBindingForObject(int objectDebugId, const QString &propertyName, - const QVariant &bindingExpression, bool isLiteralValue, - QString source = QString(), int line = -1); - bool resetBindingForObject(int objectDebugId, const QString &propertyName); - bool setMethodBody(int objectDebugId, const QString &methodName, const QString &methodBody); - -Q_SIGNALS: - void newObjects(); - void stateChanged(State state); - -private: - Q_DECLARE_PRIVATE(QDeclarativeEngineDebug) -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugWatch : public QObject -{ - Q_OBJECT -public: - enum State { Waiting, Active, Inactive, Dead }; - - QDeclarativeDebugWatch(QObject *); - ~QDeclarativeDebugWatch(); - - int queryId() const; - int objectDebugId() const; - State state() const; - -Q_SIGNALS: - void stateChanged(QDeclarativeDebugWatch::State); - //void objectChanged(int, const QDeclarativeDebugObjectReference &); - //void valueChanged(int, const QVariant &); - - // Server sends value as string if it is a user-type variant - void valueChanged(const QByteArray &name, const QVariant &value); - -private: - friend class QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - void setState(State); - State m_state; - int m_queryId; - QDeclarativeEngineDebug *m_client; - int m_objectDebugId; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugPropertyWatch : public QDeclarativeDebugWatch -{ - Q_OBJECT -public: - QDeclarativeDebugPropertyWatch(QObject *parent); - - QString name() const; - -private: - friend class QDeclarativeEngineDebug; - QString m_name; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectExpressionWatch : public QDeclarativeDebugWatch -{ - Q_OBJECT -public: - QDeclarativeDebugObjectExpressionWatch(QObject *parent); - - QString expression() const; - -private: - friend class QDeclarativeEngineDebug; - QString m_expr; - int m_debugId; -}; - - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugQuery : public QObject -{ - Q_OBJECT -public: - enum State { Waiting, Error, Completed }; - - State state() const; - bool isWaiting() const; - -Q_SIGNALS: - void stateChanged(QDeclarativeDebugQuery::State); - -protected: - QDeclarativeDebugQuery(QObject *); - -private: - friend class QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - void setState(State); - State m_state; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugFileReference -{ -public: - QDeclarativeDebugFileReference(); - QDeclarativeDebugFileReference(const QDeclarativeDebugFileReference &); - QDeclarativeDebugFileReference &operator=(const QDeclarativeDebugFileReference &); - - QUrl url() const; - void setUrl(const QUrl &); - int lineNumber() const; - void setLineNumber(int); - int columnNumber() const; - void setColumnNumber(int); - -private: - friend class QDeclarativeEngineDebugPrivate; - QUrl m_url; - int m_lineNumber; - int m_columnNumber; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugEngineReference -{ -public: - QDeclarativeDebugEngineReference(); - QDeclarativeDebugEngineReference(int); - QDeclarativeDebugEngineReference(const QDeclarativeDebugEngineReference &); - QDeclarativeDebugEngineReference &operator=(const QDeclarativeDebugEngineReference &); - - int debugId() const; - QString name() const; - -private: - friend class QDeclarativeEngineDebugPrivate; - int m_debugId; - QString m_name; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectReference -{ -public: - QDeclarativeDebugObjectReference(); - QDeclarativeDebugObjectReference(int); - QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference &); - QDeclarativeDebugObjectReference &operator=(const QDeclarativeDebugObjectReference &); - - int debugId() const; - QString className() const; - QString idString() const; - QString name() const; - - QDeclarativeDebugFileReference source() const; - int contextDebugId() const; - - QList properties() const; - QList children() const; - -private: - friend class QDeclarativeEngineDebugPrivate; - int m_debugId; - QString m_class; - QString m_idString; - QString m_name; - QDeclarativeDebugFileReference m_source; - int m_contextDebugId; - QList m_properties; - QList m_children; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugContextReference -{ -public: - QDeclarativeDebugContextReference(); - QDeclarativeDebugContextReference(const QDeclarativeDebugContextReference &); - QDeclarativeDebugContextReference &operator=(const QDeclarativeDebugContextReference &); - - int debugId() const; - QString name() const; - - QList objects() const; - QList contexts() const; - -private: - friend class QDeclarativeEngineDebugPrivate; - int m_debugId; - QString m_name; - QList m_objects; - QList m_contexts; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugPropertyReference -{ -public: - QDeclarativeDebugPropertyReference(); - QDeclarativeDebugPropertyReference(const QDeclarativeDebugPropertyReference &); - QDeclarativeDebugPropertyReference &operator=(const QDeclarativeDebugPropertyReference &); - - int objectDebugId() const; - QString name() const; - QVariant value() const; - QString valueTypeName() const; - QString binding() const; - bool hasNotifySignal() const; - -private: - friend class QDeclarativeEngineDebugPrivate; - int m_objectDebugId; - QString m_name; - QVariant m_value; - QString m_valueTypeName; - QString m_binding; - bool m_hasNotifySignal; -}; - - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugEnginesQuery : public QDeclarativeDebugQuery -{ - Q_OBJECT -public: - virtual ~QDeclarativeDebugEnginesQuery(); - QList engines() const; -private: - friend class QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - QDeclarativeDebugEnginesQuery(QObject *); - QDeclarativeEngineDebug *m_client; - int m_queryId; - QList m_engines; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugRootContextQuery : public QDeclarativeDebugQuery -{ - Q_OBJECT -public: - virtual ~QDeclarativeDebugRootContextQuery(); - QDeclarativeDebugContextReference rootContext() const; -private: - friend class QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - QDeclarativeDebugRootContextQuery(QObject *); - QDeclarativeEngineDebug *m_client; - int m_queryId; - QDeclarativeDebugContextReference m_context; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectQuery : public QDeclarativeDebugQuery -{ - Q_OBJECT -public: - virtual ~QDeclarativeDebugObjectQuery(); - QDeclarativeDebugObjectReference object() const; -private: - friend class QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - QDeclarativeDebugObjectQuery(QObject *); - QDeclarativeEngineDebug *m_client; - int m_queryId; - QDeclarativeDebugObjectReference m_object; - -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugExpressionQuery : public QDeclarativeDebugQuery -{ - Q_OBJECT -public: - virtual ~QDeclarativeDebugExpressionQuery(); - QVariant expression() const; - QVariant result() const; -private: - friend class QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - QDeclarativeDebugExpressionQuery(QObject *); - QDeclarativeEngineDebug *m_client; - int m_queryId; - QVariant m_expr; - QVariant m_result; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QDeclarativeDebugEngineReference) -Q_DECLARE_METATYPE(QDeclarativeDebugObjectReference) -Q_DECLARE_METATYPE(QDeclarativeDebugContextReference) -Q_DECLARE_METATYPE(QDeclarativeDebugPropertyReference) - -QT_END_HEADER - -#endif // QDECLARATIVEENGINEDEBUG_H diff --git a/src/declarative/debugger/qdeclarativeenginedebugservice.cpp b/src/declarative/debugger/qdeclarativeenginedebugservice.cpp deleted file mode 100644 index 4943959c33..0000000000 --- a/src/declarative/debugger/qdeclarativeenginedebugservice.cpp +++ /dev/null @@ -1,733 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativeenginedebugservice_p.h" - -#include "qdeclarativedebugstatesdelegate_p.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC(QDeclarativeEngineDebugService, qmlEngineDebugService); - -QDeclarativeEngineDebugService *QDeclarativeEngineDebugService::instance() -{ - return qmlEngineDebugService(); -} - -QDeclarativeEngineDebugService::QDeclarativeEngineDebugService(QObject *parent) - : QDeclarativeDebugService(QLatin1String("QDeclarativeEngine"), 1, parent), - m_watch(new QDeclarativeWatcher(this)), - m_statesDelegate(0) -{ - QObject::connect(m_watch, SIGNAL(propertyChanged(int,int,QMetaProperty,QVariant)), - this, SLOT(propertyChanged(int,int,QMetaProperty,QVariant))); - - registerService(); -} - -QDeclarativeEngineDebugService::~QDeclarativeEngineDebugService() -{ - delete m_statesDelegate; -} - -QDataStream &operator<<(QDataStream &ds, - const QDeclarativeEngineDebugService::QDeclarativeObjectData &data) -{ - ds << data.url << data.lineNumber << data.columnNumber << data.idString - << data.objectName << data.objectType << data.objectId << data.contextId; - return ds; -} - -QDataStream &operator>>(QDataStream &ds, - QDeclarativeEngineDebugService::QDeclarativeObjectData &data) -{ - ds >> data.url >> data.lineNumber >> data.columnNumber >> data.idString - >> data.objectName >> data.objectType >> data.objectId >> data.contextId; - return ds; -} - -QDataStream &operator<<(QDataStream &ds, - const QDeclarativeEngineDebugService::QDeclarativeObjectProperty &data) -{ - ds << (int)data.type << data.name << data.value << data.valueTypeName - << data.binding << data.hasNotifySignal; - return ds; -} - -QDataStream &operator>>(QDataStream &ds, - QDeclarativeEngineDebugService::QDeclarativeObjectProperty &data) -{ - int type; - ds >> type >> data.name >> data.value >> data.valueTypeName - >> data.binding >> data.hasNotifySignal; - data.type = (QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Type)type; - return ds; -} - -static inline bool isSignalPropertyName(const QString &signalName) -{ - // see QmlCompiler::isSignalPropertyName - return signalName.length() >= 3 && signalName.startsWith(QLatin1String("on")) && - signalName.at(2).isLetter() && signalName.at(2).isUpper(); -} - -static bool hasValidSignal(QObject *object, const QString &propertyName) -{ - if (!isSignalPropertyName(propertyName)) - return false; - - QString signalName = propertyName.mid(2); - signalName[0] = signalName.at(0).toLower(); - - int sigIdx = QDeclarativePropertyPrivate::findSignalByName(object->metaObject(), signalName.toLatin1()).methodIndex(); - - if (sigIdx == -1) - return false; - - return true; -} - -QDeclarativeEngineDebugService::QDeclarativeObjectProperty -QDeclarativeEngineDebugService::propertyData(QObject *obj, int propIdx) -{ - QDeclarativeObjectProperty rv; - - QMetaProperty prop = obj->metaObject()->property(propIdx); - - rv.type = QDeclarativeObjectProperty::Unknown; - rv.valueTypeName = QString::fromUtf8(prop.typeName()); - rv.name = QString::fromUtf8(prop.name()); - rv.hasNotifySignal = prop.hasNotifySignal(); - QDeclarativeAbstractBinding *binding = - QDeclarativePropertyPrivate::binding(QDeclarativeProperty(obj, rv.name)); - if (binding) - rv.binding = binding->expression(); - - if (QDeclarativeValueTypeFactory::isValueType(prop.userType())) { - rv.type = QDeclarativeObjectProperty::Basic; - } else if (QDeclarativeMetaType::isQObject(prop.userType())) { - rv.type = QDeclarativeObjectProperty::Object; - } else if (QDeclarativeMetaType::isList(prop.userType())) { - rv.type = QDeclarativeObjectProperty::List; - } - - QVariant value; - if (rv.type != QDeclarativeObjectProperty::Unknown && prop.userType() != 0) { - value = prop.read(obj); - } - rv.value = valueContents(value); - - return rv; -} - -QVariant QDeclarativeEngineDebugService::valueContents(const QVariant &value) const -{ - int userType = value.userType(); - - //QObject * is not streamable. - //Convert all such instances to a String value - - if (value.type() == QVariant::List) { - QVariantList contents; - QVariantList list = value.toList(); - int count = list.size(); - for (int i = 0; i < count; i++) - contents << valueContents(list.at(i)); - return contents; - } - - if (value.type() == QVariant::Map) { - QVariantMap contents; - QMapIterator i(value.toMap()); - while (i.hasNext()) { - i.next(); - contents.insert(i.key(), valueContents(i.value())); - } - return contents; - } - - if (QDeclarativeValueTypeFactory::isValueType(userType)) - return value; - - if (QDeclarativeMetaType::isQObject(userType)) { - QObject *o = QDeclarativeMetaType::toQObject(value); - if (o) { - QString name = o->objectName(); - if (name.isEmpty()) - name = QLatin1String(""); - return name; - } - } - - return QLatin1String(""); -} - -void QDeclarativeEngineDebugService::buildObjectDump(QDataStream &message, - QObject *object, bool recur, bool dumpProperties) -{ - message << objectData(object); - - QObjectList children = object->children(); - - int childrenCount = children.count(); - for (int ii = 0; ii < children.count(); ++ii) { - if (qobject_cast(children[ii]) || QDeclarativeBoundSignal::cast(children[ii])) - --childrenCount; - } - - message << childrenCount << recur; - - QList fakeProperties; - - for (int ii = 0; ii < children.count(); ++ii) { - QObject *child = children.at(ii); - if (qobject_cast(child)) - continue; - QDeclarativeBoundSignal *signal = QDeclarativeBoundSignal::cast(child); - if (signal) { - if (!dumpProperties) - continue; - QDeclarativeObjectProperty prop; - prop.type = QDeclarativeObjectProperty::SignalProperty; - prop.hasNotifySignal = false; - QDeclarativeExpression *expr = signal->expression(); - if (expr) { - prop.value = expr->expression(); - QObject *scope = expr->scopeObject(); - if (scope) { - QString sig = QLatin1String(scope->metaObject()->method(signal->index()).signature()); - int lparen = sig.indexOf(QLatin1Char('(')); - if (lparen >= 0) { - QString methodName = sig.mid(0, lparen); - prop.name = QLatin1String("on") + methodName[0].toUpper() - + methodName.mid(1); - } - } - } - fakeProperties << prop; - } else { - if (recur) - buildObjectDump(message, child, recur, dumpProperties); - else - message << objectData(child); - } - } - - if (!dumpProperties) { - message << 0; - return; - } - - QList propertyIndexes; - for (int ii = 0; ii < object->metaObject()->propertyCount(); ++ii) { - if (object->metaObject()->property(ii).isScriptable()) - propertyIndexes << ii; - } - - message << propertyIndexes.size() + fakeProperties.count(); - - for (int ii = 0; ii < propertyIndexes.size(); ++ii) - message << propertyData(object, propertyIndexes.at(ii)); - - for (int ii = 0; ii < fakeProperties.count(); ++ii) - message << fakeProperties[ii]; -} - -void QDeclarativeEngineDebugService::prepareDeferredObjects(QObject *obj) -{ - qmlExecuteDeferred(obj); - - QObjectList children = obj->children(); - for (int ii = 0; ii < children.count(); ++ii) { - QObject *child = children.at(ii); - prepareDeferredObjects(child); - } - -} - -void QDeclarativeEngineDebugService::buildObjectList(QDataStream &message, QDeclarativeContext *ctxt) -{ - QDeclarativeContextData *p = QDeclarativeContextData::get(ctxt); - - QString ctxtName = ctxt->objectName(); - int ctxtId = QDeclarativeDebugService::idForObject(ctxt); - - message << ctxtName << ctxtId; - - int count = 0; - - QDeclarativeContextData *child = p->childContexts; - while (child) { - ++count; - child = child->nextChild; - } - - message << count; - - child = p->childContexts; - while (child) { - buildObjectList(message, child->asQDeclarativeContext()); - child = child->nextChild; - } - - // Clean deleted objects - QDeclarativeContextPrivate *ctxtPriv = QDeclarativeContextPrivate::get(ctxt); - for (int ii = 0; ii < ctxtPriv->instances.count(); ++ii) { - if (!ctxtPriv->instances.at(ii)) { - ctxtPriv->instances.removeAt(ii); - --ii; - } - } - - message << ctxtPriv->instances.count(); - for (int ii = 0; ii < ctxtPriv->instances.count(); ++ii) { - message << objectData(ctxtPriv->instances.at(ii)); - } -} - -void QDeclarativeEngineDebugService::buildStatesList(QDeclarativeContext *ctxt, bool cleanList) -{ - if (m_statesDelegate) - m_statesDelegate->buildStatesList(ctxt, cleanList); -} - -QDeclarativeEngineDebugService::QDeclarativeObjectData -QDeclarativeEngineDebugService::objectData(QObject *object) -{ - QDeclarativeData *ddata = QDeclarativeData::get(object); - QDeclarativeObjectData rv; - if (ddata && ddata->outerContext) { - rv.url = ddata->outerContext->url; - rv.lineNumber = ddata->lineNumber; - rv.columnNumber = ddata->columnNumber; - } else { - rv.lineNumber = -1; - rv.columnNumber = -1; - } - - QDeclarativeContext *context = qmlContext(object); - if (context) { - QDeclarativeContextData *cdata = QDeclarativeContextData::get(context); - if (cdata) - rv.idString = cdata->findObjectId(object); - } - - rv.objectName = object->objectName(); - rv.objectId = QDeclarativeDebugService::idForObject(object); - rv.contextId = QDeclarativeDebugService::idForObject(qmlContext(object)); - - QDeclarativeType *type = QDeclarativeMetaType::qmlType(object->metaObject()); - if (type) { - QString typeName = type->qmlTypeName(); - int lastSlash = typeName.lastIndexOf(QLatin1Char('/')); - rv.objectType = lastSlash < 0 ? typeName : typeName.mid(lastSlash+1); - } else { - rv.objectType = QString::fromUtf8(object->metaObject()->className()); - int marker = rv.objectType.indexOf(QLatin1String("_QMLTYPE_")); - if (marker != -1) - rv.objectType = rv.objectType.left(marker); - } - - return rv; -} - -void QDeclarativeEngineDebugService::messageReceived(const QByteArray &message) -{ - QMetaObject::invokeMethod(this, "processMessage", Qt::QueuedConnection, Q_ARG(QByteArray, message)); -} - -void QDeclarativeEngineDebugService::processMessage(const QByteArray &message) -{ - QDataStream ds(message); - - QByteArray type; - ds >> type; - - if (type == "LIST_ENGINES") { - int queryId; - ds >> queryId; - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("LIST_ENGINES_R"); - rs << queryId << m_engines.count(); - - for (int ii = 0; ii < m_engines.count(); ++ii) { - QDeclarativeEngine *engine = m_engines.at(ii); - - QString engineName = engine->objectName(); - int engineId = QDeclarativeDebugService::idForObject(engine); - - rs << engineName << engineId; - } - - sendMessage(reply); - } else if (type == "LIST_OBJECTS") { - int queryId; - int engineId = -1; - ds >> queryId >> engineId; - - QDeclarativeEngine *engine = - qobject_cast(QDeclarativeDebugService::objectForId(engineId)); - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("LIST_OBJECTS_R") << queryId; - - if (engine) { - buildObjectList(rs, engine->rootContext()); - buildStatesList(engine->rootContext(), true); - } - - sendMessage(reply); - } else if (type == "FETCH_OBJECT") { - int queryId; - int objectId; - bool recurse; - bool dumpProperties = true; - - ds >> queryId >> objectId >> recurse >> dumpProperties; - - QObject *object = QDeclarativeDebugService::objectForId(objectId); - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("FETCH_OBJECT_R") << queryId; - - if (object) { - if (recurse) - prepareDeferredObjects(object); - buildObjectDump(rs, object, recurse, dumpProperties); - } - - sendMessage(reply); - } else if (type == "WATCH_OBJECT") { - int queryId; - int objectId; - - ds >> queryId >> objectId; - bool ok = m_watch->addWatch(queryId, objectId); - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("WATCH_OBJECT_R") << queryId << ok; - - sendMessage(reply); - } else if (type == "WATCH_PROPERTY") { - int queryId; - int objectId; - QByteArray property; - - ds >> queryId >> objectId >> property; - bool ok = m_watch->addWatch(queryId, objectId, property); - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("WATCH_PROPERTY_R") << queryId << ok; - - sendMessage(reply); - } else if (type == "WATCH_EXPR_OBJECT") { - int queryId; - int debugId; - QString expr; - - ds >> queryId >> debugId >> expr; - bool ok = m_watch->addWatch(queryId, debugId, expr); - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("WATCH_EXPR_OBJECT_R") << queryId << ok; - sendMessage(reply); - } else if (type == "NO_WATCH") { - int queryId; - - ds >> queryId; - m_watch->removeWatch(queryId); - } else if (type == "EVAL_EXPRESSION") { - int queryId; - int objectId; - QString expr; - - ds >> queryId >> objectId >> expr; - - QObject *object = QDeclarativeDebugService::objectForId(objectId); - QDeclarativeContext *context = qmlContext(object); - QVariant result; - if (object && context) { - QDeclarativeExpression exprObj(context, object, expr); - bool undefined = false; - QVariant value = exprObj.evaluate(&undefined); - if (undefined) - result = QLatin1String(""); - else - result = valueContents(value); - } else { - result = QLatin1String(""); - } - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("EVAL_EXPRESSION_R") << queryId << result; - - sendMessage(reply); - } else if (type == "SET_BINDING") { - int objectId; - QString propertyName; - QVariant expr; - bool isLiteralValue; - QString filename; - int line; - ds >> objectId >> propertyName >> expr >> isLiteralValue; - if (!ds.atEnd()) { // backward compatibility from 2.1, 2.2 - ds >> filename >> line; - } - setBinding(objectId, propertyName, expr, isLiteralValue, filename, line); - } else if (type == "RESET_BINDING") { - int objectId; - QString propertyName; - ds >> objectId >> propertyName; - resetBinding(objectId, propertyName); - } else if (type == "SET_METHOD_BODY") { - int objectId; - QString methodName; - QString methodBody; - ds >> objectId >> methodName >> methodBody; - setMethodBody(objectId, methodName, methodBody); - } -} - -void QDeclarativeEngineDebugService::setBinding(int objectId, - const QString &propertyName, - const QVariant &expression, - bool isLiteralValue, - QString filename, - int line, - int column) -{ - QObject *object = objectForId(objectId); - QDeclarativeContext *context = qmlContext(object); - - if (object && context) { - QDeclarativeProperty property(object, propertyName, context); - if (property.isValid()) { - - bool inBaseState = true; - if (m_statesDelegate) { - m_statesDelegate->updateBinding(context, property, expression, isLiteralValue, - filename, line, column, &inBaseState); - } - - if (inBaseState) { - if (isLiteralValue) { - property.write(expression); - } else if (hasValidSignal(object, propertyName)) { - QDeclarativeExpression *declarativeExpression = new QDeclarativeExpression(context, object, expression.toString()); - QDeclarativePropertyPrivate::setSignalExpression(property, declarativeExpression); - declarativeExpression->setSourceLocation(filename, line, column); - } else if (property.isProperty()) { - QDeclarativeBinding *binding = new QDeclarativeBinding(expression.toString(), object, context); - binding->setTarget(property); - binding->setSourceLocation(filename, line, column); - binding->setNotifyOnValueChanged(true); - QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, binding); - if (oldBinding) - oldBinding->destroy(); - binding->update(); - } else { - qWarning() << "QDeclarativeEngineDebugService::setBinding: unable to set property" << propertyName << "on object" << object; - } - } - - } else { - // not a valid property - bool ok = false; - if (m_statesDelegate) - ok = m_statesDelegate->setBindingForInvalidProperty(object, propertyName, expression, isLiteralValue); - if (!ok) - qWarning() << "QDeclarativeEngineDebugService::setBinding: unable to set property" << propertyName << "on object" << object; - } - } -} - -void QDeclarativeEngineDebugService::resetBinding(int objectId, const QString &propertyName) -{ - QObject *object = objectForId(objectId); - QDeclarativeContext *context = qmlContext(object); - - if (object && context) { - if (object->property(propertyName.toLatin1()).isValid()) { - QDeclarativeProperty property(object, propertyName); - QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(property); - if (oldBinding) { - QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, 0); - if (oldBinding) - oldBinding->destroy(); - } - if (property.isResettable()) { - // Note: this will reset the property in any case, without regard to states - // Right now almost no QDeclarativeItem has reset methods for its properties (with the - // notable exception of QDeclarativeAnchors), so this is not a big issue - // later on, setBinding does take states into account - property.reset(); - } else { - // overwrite with default value - if (QDeclarativeType *objType = QDeclarativeMetaType::qmlType(object->metaObject())) { - if (QObject *emptyObject = objType->create()) { - if (emptyObject->property(propertyName.toLatin1()).isValid()) { - QVariant defaultValue = QDeclarativeProperty(emptyObject, propertyName).read(); - if (defaultValue.isValid()) { - setBinding(objectId, propertyName, defaultValue, true); - } - } - delete emptyObject; - } - } - } - } else if (hasValidSignal(object, propertyName)) { - QDeclarativeProperty property(object, propertyName, context); - QDeclarativePropertyPrivate::setSignalExpression(property, 0); - } else { - if (m_statesDelegate) - m_statesDelegate->resetBindingForInvalidProperty(object, propertyName); - } - } -} - -void QDeclarativeEngineDebugService::setMethodBody(int objectId, const QString &method, const QString &body) -{ - QObject *object = objectForId(objectId); - QDeclarativeContext *context = qmlContext(object); - if (!object || !context || !context->engine()) - return; - QDeclarativeContextData *contextData = QDeclarativeContextData::get(context); - if (!contextData) - return; - - QDeclarativePropertyData dummy; - QDeclarativePropertyData *prop = - QDeclarativePropertyCache::property(context->engine(), object, method, dummy); - - if (!prop || !prop->isVMEFunction()) - return; - - QMetaMethod metaMethod = object->metaObject()->method(prop->coreIndex); - QList paramNames = metaMethod.parameterNames(); - - QString paramStr; - for (int ii = 0; ii < paramNames.count(); ++ii) { - if (ii != 0) paramStr.append(QLatin1String(",")); - paramStr.append(QString::fromUtf8(paramNames.at(ii))); - } - - QString jsfunction = QLatin1String("(function ") + method + QLatin1String("(") + paramStr + - QLatin1String(") {"); - jsfunction += body; - jsfunction += QLatin1String("\n})"); - - QDeclarativeVMEMetaObject *vmeMetaObject = - static_cast(QObjectPrivate::get(object)->metaObject); - Q_ASSERT(vmeMetaObject); // the fact we found the property above should guarentee this - - int lineNumber = vmeMetaObject->vmeMethodLineNumber(prop->coreIndex); - vmeMetaObject->setVmeMethod(prop->coreIndex, QDeclarativeExpressionPrivate::evalFunction(contextData, object, jsfunction, contextData->url.toString(), lineNumber)); -} - -void QDeclarativeEngineDebugService::propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value) -{ - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - - rs << QByteArray("UPDATE_WATCH") << id << objectId << QByteArray(property.name()) << valueContents(value); - - sendMessage(reply); -} - -void QDeclarativeEngineDebugService::addEngine(QDeclarativeEngine *engine) -{ - Q_ASSERT(engine); - Q_ASSERT(!m_engines.contains(engine)); - - m_engines.append(engine); -} - -void QDeclarativeEngineDebugService::remEngine(QDeclarativeEngine *engine) -{ - Q_ASSERT(engine); - Q_ASSERT(m_engines.contains(engine)); - - m_engines.removeAll(engine); -} - -void QDeclarativeEngineDebugService::objectCreated(QDeclarativeEngine *engine, QObject *object) -{ - Q_ASSERT(engine); - Q_ASSERT(m_engines.contains(engine)); - - int engineId = QDeclarativeDebugService::idForObject(engine); - int objectId = QDeclarativeDebugService::idForObject(object); - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - - rs << QByteArray("OBJECT_CREATED") << engineId << objectId; - sendMessage(reply); -} - -void QDeclarativeEngineDebugService::setStatesDelegate(QDeclarativeDebugStatesDelegate *delegate) -{ - m_statesDelegate = delegate; -} - -QT_END_NAMESPACE diff --git a/src/declarative/debugger/qdeclarativeenginedebugservice_p.h b/src/declarative/debugger/qdeclarativeenginedebugservice_p.h deleted file mode 100644 index d252654492..0000000000 --- a/src/declarative/debugger/qdeclarativeenginedebugservice_p.h +++ /dev/null @@ -1,136 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEENGINEDEBUGSERVICE_P_H -#define QDECLARATIVEENGINEDEBUGSERVICE_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 -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeEngine; -class QDeclarativeContext; -class QDeclarativeWatcher; -class QDataStream; -class QDeclarativeDebugStatesDelegate; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeEngineDebugService : public QDeclarativeDebugService -{ - Q_OBJECT -public: - QDeclarativeEngineDebugService(QObject * = 0); - ~QDeclarativeEngineDebugService(); - - struct QDeclarativeObjectData { - QUrl url; - int lineNumber; - int columnNumber; - QString idString; - QString objectName; - QString objectType; - int objectId; - int contextId; - }; - - struct QDeclarativeObjectProperty { - enum Type { Unknown, Basic, Object, List, SignalProperty }; - Type type; - QString name; - QVariant value; - QString valueTypeName; - QString binding; - bool hasNotifySignal; - }; - - void addEngine(QDeclarativeEngine *); - void remEngine(QDeclarativeEngine *); - void objectCreated(QDeclarativeEngine *, QObject *); - - void setStatesDelegate(QDeclarativeDebugStatesDelegate *); - - static QDeclarativeEngineDebugService *instance(); - -protected: - virtual void messageReceived(const QByteArray &); - -private Q_SLOTS: - void processMessage(const QByteArray &msg); - void propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value); - -private: - void prepareDeferredObjects(QObject *); - void buildObjectList(QDataStream &, QDeclarativeContext *); - void buildObjectDump(QDataStream &, QObject *, bool, bool); - void buildStatesList(QDeclarativeContext *, bool); - QDeclarativeObjectData objectData(QObject *); - QDeclarativeObjectProperty propertyData(QObject *, int); - QVariant valueContents(const QVariant &defaultValue) const; - void setBinding(int objectId, const QString &propertyName, const QVariant &expression, bool isLiteralValue, QString filename = QString(), int line = -1, int column = 0); - void resetBinding(int objectId, const QString &propertyName); - void setMethodBody(int objectId, const QString &method, const QString &body); - - QList m_engines; - QDeclarativeWatcher *m_watch; - QDeclarativeDebugStatesDelegate *m_statesDelegate; -}; -Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator<<(QDataStream &, const QDeclarativeEngineDebugService::QDeclarativeObjectData &); -Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator>>(QDataStream &, QDeclarativeEngineDebugService::QDeclarativeObjectData &); -Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator<<(QDataStream &, const QDeclarativeEngineDebugService::QDeclarativeObjectProperty &); -Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator>>(QDataStream &, QDeclarativeEngineDebugService::QDeclarativeObjectProperty &); - -QT_END_NAMESPACE - -#endif // QDECLARATIVEENGINEDEBUGSERVICE_P_H - diff --git a/src/declarative/debugger/qdeclarativeinspectorinterface_p.h b/src/declarative/debugger/qdeclarativeinspectorinterface_p.h deleted file mode 100644 index 77f208ce5b..0000000000 --- a/src/declarative/debugger/qdeclarativeinspectorinterface_p.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEINSPECTORINTERFACE_H -#define QDECLARATIVEINSPECTORINTERFACE_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 - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class Q_DECLARATIVE_EXPORT QDeclarativeInspectorInterface -{ -public: - QDeclarativeInspectorInterface() {} - virtual ~QDeclarativeInspectorInterface() {} - - virtual bool canHandleView(QObject *view) = 0; - - virtual void activate(QObject *view) = 0; - virtual void deactivate() = 0; - - virtual void clientMessage(const QByteArray &message) = 0; -}; - -#define QDeclarativeInspectorInterface_iid "org.qt-project.Qt.QDeclarativeInspectorInterface" - -Q_DECLARE_INTERFACE(QDeclarativeInspectorInterface, QDeclarativeInspectorInterface_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEINSPECTORINTERFACE_H diff --git a/src/declarative/debugger/qdeclarativeinspectorservice.cpp b/src/declarative/debugger/qdeclarativeinspectorservice.cpp deleted file mode 100644 index 94b04985ba..0000000000 --- a/src/declarative/debugger/qdeclarativeinspectorservice.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativeinspectorservice_p.h" -#include "qdeclarativeinspectorinterface_p.h" -#include "qdeclarativedebugserver_p.h" - -#include -#include -#include -#include - -// print detailed information about loading of plugins -DEFINE_BOOL_CONFIG_OPTION(qmlDebugVerbose, QML_DEBUGGER_VERBOSE) - -QT_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC(QDeclarativeInspectorService, serviceInstance) - -QDeclarativeInspectorService::QDeclarativeInspectorService() - : QDeclarativeDebugService(QLatin1String("QDeclarativeObserverMode"), 1) - , m_currentInspectorPlugin(0) -{ - registerService(); -} - -QDeclarativeInspectorService *QDeclarativeInspectorService::instance() -{ - return serviceInstance(); -} - -void QDeclarativeInspectorService::addView(QObject *view) -{ - m_views.append(view); - updateState(); -} - -void QDeclarativeInspectorService::removeView(QObject *view) -{ - m_views.removeAll(view); - updateState(); -} - -void QDeclarativeInspectorService::sendMessage(const QByteArray &message) -{ - if (state() != Enabled) - return; - - QDeclarativeDebugService::sendMessage(message); -} - -void QDeclarativeInspectorService::stateChanged(State /*state*/) -{ - QMetaObject::invokeMethod(this, "updateState", Qt::QueuedConnection); -} - -void QDeclarativeInspectorService::updateState() -{ - if (m_views.isEmpty()) { - if (m_currentInspectorPlugin) { - m_currentInspectorPlugin->deactivate(); - m_currentInspectorPlugin = 0; - } - return; - } - - if (state() == Enabled) { - if (m_inspectorPlugins.isEmpty()) - loadInspectorPlugins(); - - if (m_inspectorPlugins.isEmpty()) { - qWarning() << "QDeclarativeInspector: No plugins found."; - QDeclarativeDebugServer::instance()->removeService(this); - return; - } - - foreach (QDeclarativeInspectorInterface *inspector, m_inspectorPlugins) { - if (inspector->canHandleView(m_views.first())) { - m_currentInspectorPlugin = inspector; - break; - } - } - - if (!m_currentInspectorPlugin) { - qWarning() << "QDeclarativeInspector: No plugin available for view '" << m_views.first()->metaObject()->className() << "'."; - return; - } - m_currentInspectorPlugin->activate(m_views.first()); - } else { - if (m_currentInspectorPlugin) { - m_currentInspectorPlugin->deactivate(); - m_currentInspectorPlugin = 0; - } - } -} - -void QDeclarativeInspectorService::messageReceived(const QByteArray &message) -{ - QMetaObject::invokeMethod(this, "processMessage", Qt::QueuedConnection, Q_ARG(QByteArray, message)); -} - -void QDeclarativeInspectorService::processMessage(const QByteArray &message) -{ - if (m_currentInspectorPlugin) - m_currentInspectorPlugin->clientMessage(message); -} - -void QDeclarativeInspectorService::loadInspectorPlugins() -{ - QStringList pluginCandidates; - const QStringList paths = QCoreApplication::libraryPaths(); - foreach (const QString &libPath, paths) { - const QDir dir(libPath + QLatin1String("/qmltooling")); - if (dir.exists()) - foreach (const QString &pluginPath, dir.entryList(QDir::Files)) - pluginCandidates << dir.absoluteFilePath(pluginPath); - } - - foreach (const QString &pluginPath, pluginCandidates) { - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeInspector: Trying to load plugin " << pluginPath << "..."; - - QPluginLoader loader(pluginPath); - if (!loader.load()) { - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeInspector: Error while loading: " << loader.errorString(); - - continue; - } - - QDeclarativeInspectorInterface *inspector = - qobject_cast(loader.instance()); - if (inspector) { - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeInspector: Plugin successfully loaded."; - m_inspectorPlugins << inspector; - } else { - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeInspector: Plugin does not implement interface QDeclarativeInspectorInterface."; - - loader.unload(); - } - } -} - -QT_END_NAMESPACE diff --git a/src/declarative/debugger/qdeclarativeinspectorservice_p.h b/src/declarative/debugger/qdeclarativeinspectorservice_p.h deleted file mode 100644 index 7ed530adc0..0000000000 --- a/src/declarative/debugger/qdeclarativeinspectorservice_p.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEINSPECTORSERVICE_H -#define QDECLARATIVEINSPECTORSERVICE_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 "qdeclarativedebugservice_p.h" -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeInspectorInterface; - -class Q_DECLARATIVE_EXPORT QDeclarativeInspectorService : public QDeclarativeDebugService -{ - Q_OBJECT - -public: - QDeclarativeInspectorService(); - static QDeclarativeInspectorService *instance(); - - void addView(QObject *); - void removeView(QObject *); - - void sendMessage(const QByteArray &message); - -protected: - virtual void stateChanged(State state); - virtual void messageReceived(const QByteArray &); - -private slots: - void processMessage(const QByteArray &message); - void updateState(); - -private: - void loadInspectorPlugins(); - - QList m_views; - QDeclarativeInspectorInterface *m_currentInspectorPlugin; - QList m_inspectorPlugins; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEINSPECTORSERVICE_H diff --git a/src/declarative/debugger/qdeclarativeprofilerservice.cpp b/src/declarative/debugger/qdeclarativeprofilerservice.cpp deleted file mode 100644 index 3ad87495bb..0000000000 --- a/src/declarative/debugger/qdeclarativeprofilerservice.cpp +++ /dev/null @@ -1,315 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativeprofilerservice_p.h" - -#include -#include -#include -#include -#include - -// this contains QUnifiedTimer -#include - -QT_BEGIN_NAMESPACE - -// instance will be set, unset in constructor. Allows static methods to be inlined. -QDeclarativeProfilerService *QDeclarativeProfilerService::instance = 0; -Q_GLOBAL_STATIC(QDeclarativeProfilerService, profilerInstance) - - -// convert to a QByteArray that can be sent to the debug client -// use of QDataStream can skew results -// (see tst_qdeclarativedebugtrace::trace() benchmark) -QByteArray QDeclarativeProfilerData::toByteArray() const -{ - QByteArray data; - //### using QDataStream is relatively expensive - QDataStream ds(&data, QIODevice::WriteOnly); - ds << time << messageType << detailType; - if (messageType == (int)QDeclarativeProfilerService::RangeData) - ds << detailData; - if (messageType == (int)QDeclarativeProfilerService::RangeLocation) - ds << detailData << line << column; - if (messageType == (int)QDeclarativeProfilerService::Event && - detailType == (int)QDeclarativeProfilerService::AnimationFrame) - ds << framerate << animationcount; - return data; -} - -QDeclarativeProfilerService::QDeclarativeProfilerService() - : QDeclarativeDebugService(QLatin1String("CanvasFrameRate"), 1), - m_enabled(false), m_messageReceived(false) -{ - m_timer.start(); - - if (registerService() == Enabled) { - // wait for first message indicating whether to trace or not - while (!m_messageReceived) - waitForMessage(); - - QUnifiedTimer::instance()->registerProfilerCallback( &animationFrame ); - } -} - -QDeclarativeProfilerService::~QDeclarativeProfilerService() -{ - instance = 0; -} - -void QDeclarativeProfilerService::initialize() -{ - // just make sure that the service is properly registered - instance = profilerInstance(); -} - -bool QDeclarativeProfilerService::startProfiling() -{ - return profilerInstance()->startProfilingImpl(); -} - -bool QDeclarativeProfilerService::stopProfiling() -{ - return profilerInstance()->stopProfilingImpl(); -} - -void QDeclarativeProfilerService::sendStartedProfilingMessage() -{ - profilerInstance()->sendStartedProfilingMessageImpl(); -} - -void QDeclarativeProfilerService::addEvent(EventType t) -{ - profilerInstance()->addEventImpl(t); -} - -void QDeclarativeProfilerService::animationFrame(qint64 delta) -{ - profilerInstance()->animationFrameImpl(delta); -} - -void QDeclarativeProfilerService::sendProfilingData() -{ - profilerInstance()->sendMessages(); -} - -bool QDeclarativeProfilerService::startProfilingImpl() -{ - bool success = false; - if (!profilingEnabled()) { - setProfilingEnabled(true); - sendStartedProfilingMessageImpl(); - success = true; - } - return success; -} - -bool QDeclarativeProfilerService::stopProfilingImpl() -{ - bool success = false; - if (profilingEnabled()) { - addEventImpl(EndTrace); - setProfilingEnabled(false); - success = true; - } - return success; -} - -void QDeclarativeProfilerService::sendStartedProfilingMessageImpl() -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData ed = {m_timer.nsecsElapsed(), (int)Event, (int)StartTrace, QString(), -1, -1, 0, 0}; - QDeclarativeDebugService::sendMessage(ed.toByteArray()); -} - -void QDeclarativeProfilerService::addEventImpl(EventType event) -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData ed = {m_timer.nsecsElapsed(), (int)Event, (int)event, QString(), -1, -1, 0, 0}; - processMessage(ed); -} - -void QDeclarativeProfilerService::startRange(RangeType range) -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeStart, (int)range, QString(), -1, -1, 0, 0}; - processMessage(rd); -} - -void QDeclarativeProfilerService::rangeData(RangeType range, const QString &rData) -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeData, (int)range, rData, -1, -1, 0, 0}; - processMessage(rd); -} - -void QDeclarativeProfilerService::rangeData(RangeType range, const QUrl &rData) -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeData, (int)range, rData.toString(QUrl::FormattingOption(0x100)), -1, -1, 0, 0}; - processMessage(rd); -} - -void QDeclarativeProfilerService::rangeLocation(RangeType range, const QString &fileName, int line, int column) -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeLocation, (int)range, fileName, line, column, 0, 0}; - processMessage(rd); -} - -void QDeclarativeProfilerService::rangeLocation(RangeType range, const QUrl &fileName, int line, int column) -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeLocation, (int)range, fileName.toString(QUrl::FormattingOption(0x100)), line, column, 0, 0}; - processMessage(rd); -} - -void QDeclarativeProfilerService::endRange(RangeType range) -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeEnd, (int)range, QString(), -1, -1, 0, 0}; - processMessage(rd); -} - -void QDeclarativeProfilerService::animationFrameImpl(qint64 delta) -{ - Q_ASSERT(QDeclarativeDebugService::isDebuggingEnabled()); - if (!m_enabled) - return; - - int animCount = QUnifiedTimer::instance()->runningAnimationCount(); - - if (animCount > 0 && delta > 0) { - // trim fps to integer - int fps = 1000 / delta; - QDeclarativeProfilerData ed = {m_timer.nsecsElapsed(), (int)Event, (int)AnimationFrame, QString(), -1, -1, fps, animCount}; - processMessage(ed); - } -} - -/* - Either send the message directly, or queue up - a list of messages to send later (via sendMessages) -*/ -void QDeclarativeProfilerService::processMessage(const QDeclarativeProfilerData &message) -{ - QMutexLocker locker(&m_mutex); - m_data.append(message); -} - -bool QDeclarativeProfilerService::profilingEnabled() -{ - return m_enabled; -} - -void QDeclarativeProfilerService::setProfilingEnabled(bool enable) -{ - m_enabled = enable; -} - -/* - Send the messages queued up by processMessage -*/ -void QDeclarativeProfilerService::sendMessages() -{ - QMutexLocker locker(&m_mutex); - QList messages; - for (int i = 0; i < m_data.count(); ++i) - messages << m_data.at(i).toByteArray(); - m_data.clear(); - - //indicate completion - QByteArray data; - QDataStream ds(&data, QIODevice::WriteOnly); - ds << (qint64)-1 << (int)Complete; - messages << data; - - QDeclarativeDebugService::sendMessages(messages); -} - -void QDeclarativeProfilerService::stateAboutToBeChanged(QDeclarativeDebugService::State newState) -{ - if (state() == newState) - return; - - if (state() == Enabled - && m_enabled) { - stopProfilingImpl(); - sendMessages(); - } -} - -void QDeclarativeProfilerService::messageReceived(const QByteArray &message) -{ - QByteArray rwData = message; - QDataStream stream(&rwData, QIODevice::ReadOnly); - - bool enabled; - stream >> enabled; - - m_messageReceived = true; - - if (enabled) { - startProfilingImpl(); - } else { - if (stopProfilingImpl()) - sendMessages(); - } -} - -QT_END_NAMESPACE diff --git a/src/declarative/debugger/qdeclarativeprofilerservice_p.h b/src/declarative/debugger/qdeclarativeprofilerservice_p.h deleted file mode 100644 index ef92e6800e..0000000000 --- a/src/declarative/debugger/qdeclarativeprofilerservice_p.h +++ /dev/null @@ -1,302 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEPROFILERSERVICE_P_H -#define QDECLARATIVEPROFILERSERVICE_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 -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -struct Q_AUTOTEST_EXPORT QDeclarativeProfilerData -{ - qint64 time; - int messageType; - int detailType; - - //### - QString detailData; //used by RangeData and RangeLocation - int line; //used by RangeLocation - int column; //used by RangeLocation - int framerate; //used by animation events - int animationcount; //used by animation events - - QByteArray toByteArray() const; -}; - -Q_DECLARE_TYPEINFO(QDeclarativeProfilerData, Q_MOVABLE_TYPE); - -class QUrl; -class QDeclarativeEngine; - - -class Q_DECLARATIVE_EXPORT QDeclarativeProfilerService : public QDeclarativeDebugService -{ -public: - enum Message { - Event, - RangeStart, - RangeData, - RangeLocation, - RangeEnd, - Complete, // end of transmission - - MaximumMessage - }; - - enum EventType { - FramePaint, - Mouse, - Key, - AnimationFrame, - EndTrace, - StartTrace, - - MaximumEventType - }; - - enum RangeType { - Painting, - Compiling, - Creating, - Binding, //running a binding - HandlingSignal, //running a signal handler - - MaximumRangeType - }; - - static void initialize(); - - static bool startProfiling(); - static bool stopProfiling(); - static void sendStartedProfilingMessage(); - static void addEvent(EventType); - static void animationFrame(qint64); - - static void sendProfilingData(); - - QDeclarativeProfilerService(); - ~QDeclarativeProfilerService(); - -protected: - virtual void stateAboutToBeChanged(State state); - virtual void messageReceived(const QByteArray &); - -private: - bool startProfilingImpl(); - bool stopProfilingImpl(); - void sendStartedProfilingMessageImpl(); - void addEventImpl(EventType); - void animationFrameImpl(qint64); - - void startRange(RangeType); - void rangeData(RangeType, const QString &); - void rangeData(RangeType, const QUrl &); - void rangeLocation(RangeType, const QString &, int, int); - void rangeLocation(RangeType, const QUrl &, int, int); - void endRange(RangeType); - - - bool profilingEnabled(); - void setProfilingEnabled(bool enable); - void sendMessages(); - void processMessage(const QDeclarativeProfilerData &); - -private: - QElapsedTimer m_timer; - bool m_enabled; - bool m_messageReceived; - QVector m_data; - QMutex m_mutex; - - static QDeclarativeProfilerService *instance; - - friend struct QDeclarativeBindingProfiler; - friend struct QDeclarativeHandlingSignalProfiler; - friend struct QDeclarativeObjectCreatingProfiler; - friend struct QDeclarativeCompilingProfiler; -}; - -// -// RAII helper structs -// - -struct QDeclarativeBindingProfiler { - QDeclarativeBindingProfiler(const QString &url, int line, int column) - { - QDeclarativeProfilerService *instance = QDeclarativeProfilerService::instance; - enabled = instance ? instance->profilingEnabled() : false; - if (enabled) { - instance->startRange(QDeclarativeProfilerService::Binding); - instance->rangeLocation(QDeclarativeProfilerService::Binding, url, line, column); - } - } - - ~QDeclarativeBindingProfiler() - { - if (enabled) - QDeclarativeProfilerService::instance->endRange(QDeclarativeProfilerService::Binding); - } - - void addDetail(const QString &details) - { - if (enabled) - QDeclarativeProfilerService::instance->rangeData(QDeclarativeProfilerService::Binding, - details); - } -\ - bool enabled; -}; - -struct QDeclarativeHandlingSignalProfiler { - QDeclarativeHandlingSignalProfiler() - { - enabled = QDeclarativeProfilerService::instance - ? QDeclarativeProfilerService::instance->profilingEnabled() : false; - if (enabled) { - QDeclarativeProfilerService::instance->startRange( - QDeclarativeProfilerService::HandlingSignal); - } - } - - void setSignalInfo(const QString &name, const QString &expression) - { - if (enabled) - QDeclarativeProfilerService::instance->rangeData( - QDeclarativeProfilerService::HandlingSignal, - name % QLatin1String(": ") % expression); - } - - void setLocation(const QString &file, int line, int column) - { - if (enabled) - QDeclarativeProfilerService::instance->rangeLocation( - QDeclarativeProfilerService::HandlingSignal, file, line, column); - } - - ~QDeclarativeHandlingSignalProfiler() - { - if (enabled) - QDeclarativeProfilerService::instance->endRange( - QDeclarativeProfilerService::HandlingSignal); - } - - bool enabled; -}; - -struct QDeclarativeObjectCreatingProfiler { - QDeclarativeObjectCreatingProfiler() - { - QDeclarativeProfilerService *instance = QDeclarativeProfilerService::instance; - enabled = instance ? - instance->profilingEnabled() : false; - if (enabled) - instance->startRange(QDeclarativeProfilerService::Creating); - } - - void setTypeName(const QString &typeName) - { - if (enabled) - QDeclarativeProfilerService::instance->rangeData( - QDeclarativeProfilerService::Creating, typeName); - } - - void setLocation(const QUrl &url, int line, int column) - { - if (enabled) - QDeclarativeProfilerService::instance->rangeLocation( - QDeclarativeProfilerService::Creating, url, line, column); - } - - ~QDeclarativeObjectCreatingProfiler() - { - if (enabled) - QDeclarativeProfilerService::instance->endRange(QDeclarativeProfilerService::Creating); - } - - bool enabled; -}; - -struct QDeclarativeCompilingProfiler { - QDeclarativeCompilingProfiler(const QString &name) - { - QDeclarativeProfilerService *instance = QDeclarativeProfilerService::instance; - enabled = instance ? - instance->profilingEnabled() : false; - if (enabled) { - instance->startRange(QDeclarativeProfilerService::Compiling); - instance->rangeLocation(QDeclarativeProfilerService::Compiling, name, 1, 1); - instance->rangeData(QDeclarativeProfilerService::Compiling, name); - } - } - - ~QDeclarativeCompilingProfiler() - { - if (enabled) - QDeclarativeProfilerService::instance->endRange(QDeclarativeProfilerService::Compiling); - } - - bool enabled; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEPROFILERSERVICE_P_H - diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro deleted file mode 100644 index 1da58ce5d9..0000000000 --- a/src/declarative/declarative.pro +++ /dev/null @@ -1,34 +0,0 @@ -load(qt_module) - -TARGET = QtDeclarative -QPRO_PWD = $$PWD - -CONFIG += module -MODULE_PRI += ../../modules/qt_declarative.pri - -QT = core-private gui gui-private network v8-private - -DEFINES += QT_BUILD_DECLARATIVE_LIB QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES -win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x66000000 -win32-msvc*:DEFINES *= _CRT_SECURE_NO_WARNINGS -solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2 - -unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui - -exists("qdeclarative_enable_gcov") { - QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage -fno-elide-constructors - LIBS += -lgcov -} - -load(qt_module_config) - -HEADERS += qtdeclarativeversion.h - -#INCLUDEPATH -= $$QMAKE_INCDIR_QT/$$TARGET -#DESTDIR=. - -#modules -include(util/util.pri) -include(qml/qml.pri) -include(debugger/debugger.pri) -include(animations/animations.pri) \ No newline at end of file diff --git a/src/declarative/qml/ftw/ftw.pri b/src/declarative/qml/ftw/ftw.pri deleted file mode 100644 index 26343422c5..0000000000 --- a/src/declarative/qml/ftw/ftw.pri +++ /dev/null @@ -1,29 +0,0 @@ -HEADERS += \ - $$PWD/qbitfield_p.h \ - $$PWD/qintrusivelist_p.h \ - $$PWD/qpodvector_p.h \ - $$PWD/qhashedstring_p.h \ - $$PWD/qdeclarativerefcount_p.h \ - $$PWD/qdeclarativepool_p.h \ - $$PWD/qfieldlist_p.h \ - $$PWD/qfastmetabuilder_p.h \ - $$PWD/qhashfield_p.h \ - $$PWD/qdeclarativethread_p.h \ - $$PWD/qfinitestack_p.h \ - $$PWD/qrecursionwatcher_p.h \ - $$PWD/qdeletewatcher_p.h \ - $$PWD/qrecyclepool_p.h \ - $$PWD/qflagpointer_p.h \ - $$PWD/qdeclarativetrace_p.h \ - $$PWD/qpointervaluepair_p.h \ - $$PWD/qlazilyallocated_p.h \ - -SOURCES += \ - $$PWD/qintrusivelist.cpp \ - $$PWD/qhashedstring.cpp \ - $$PWD/qdeclarativepool.cpp \ - $$PWD/qfastmetabuilder.cpp \ - $$PWD/qdeclarativethread.cpp \ - $$PWD/qdeclarativetrace.cpp \ - -contains(QT_CONFIG, clock-gettime):include($$QT_SOURCE_TREE/config.tests/unix/clock-gettime/clock-gettime.pri) diff --git a/src/declarative/qml/ftw/qdeclarativepool.cpp b/src/declarative/qml/ftw/qdeclarativepool.cpp deleted file mode 100644 index d816e5bb95..0000000000 --- a/src/declarative/qml/ftw/qdeclarativepool.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativepool_p.h" - -// #define POOL_DEBUG - -QT_BEGIN_NAMESPACE - -void QDeclarativePool::newpage() -{ -#ifdef POOL_DEBUG - qWarning("QDeclarativePool: Allocating page"); -#endif - - Page *page = (Page *)malloc(sizeof(Page)); - page->header.next = _page; - page->header.free = page->memory; - _page = page; -} - -void QDeclarativePool::clear() -{ -#ifdef POOL_DEBUG - int count = 0; -#endif - - Class *c = _classList; - while (c) { - Class *n = c->_next; - c->_destroy(c); -#ifdef POOL_DEBUG - ++count; -#endif - c = n; - } - -#ifdef POOL_DEBUG - qWarning("QDeclarativePool: Destroyed %d objects", count); -#endif - - Page *p = _page; - while (p) { - Page *n = p->header.next; - free(p); - p = n; - } - - _classList = 0; - _page = 0; -} - - -QT_END_NAMESPACE diff --git a/src/declarative/qml/ftw/qdeclarativepool_p.h b/src/declarative/qml/ftw/qdeclarativepool_p.h deleted file mode 100644 index d04c0e9eef..0000000000 --- a/src/declarative/qml/ftw/qdeclarativepool_p.h +++ /dev/null @@ -1,278 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEPOOL_P_H -#define QDECLARATIVEPOOL_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 -#include - -QT_BEGIN_NAMESPACE - -// Exported for QtQuick1 -class Q_DECLARATIVE_EXPORT QDeclarativePool -{ -public: - // The class has a destructor that needs to be called - class Class { - public: - inline QDeclarativePool *pool() const; - - private: - void *operator new(size_t); - void *operator new(size_t, void *m) { return m; } - friend class QDeclarativePool; - - QDeclarativePool *_pool; - Class *_next; - void (*_destroy)(Class *); - }; - - // The class is plain old data and no destructor needs to - // be called - class POD { - public: - inline QDeclarativePool *pool() const; - - private: - void *operator new(size_t); - void *operator new(size_t, void *m) { return m; } - friend class QDeclarativePool; - - QDeclarativePool *_pool; - }; - - inline QDeclarativePool(); - inline ~QDeclarativePool(); - - void clear(); - - template - inline T *New(); - template - inline T *NewRaw(); - template - inline T *NewRawArray(int length); - - inline QString *NewString(const QString &); - inline QByteArray *NewByteArray(const QByteArray &); - inline QUrl *NewUrl(const QUrl &); - - template - struct List { - List() : m_length(0), m_data(0) {} - List(const List &o) : m_length(o.m_length), m_data(o.m_data) {} - List &operator=(const List &o) { - m_length = o.m_length; - m_data = o.m_data; - return *this; - } - - int count() const { - return m_length; - } - int length() const { - return m_length; - } - const T &at(int index) const { - Q_ASSERT(index < m_length); - return m_data[index]; - }; - T &operator[](int index) { - Q_ASSERT(index < m_length); - return m_data[index]; - }; - private: - friend class QDeclarativePool; - List(T *d, int l) : m_length(l), m_data(d) {} - int m_length; - T *m_data; - }; - - template - inline List NewRawList(int length); - -private: - struct StringClass : public QString, public Class { - }; - struct ByteArrayClass : public QByteArray, public Class { - }; - struct UrlClass : public QUrl, public Class { - }; - - inline void *allocate(int size); - void newpage(); - - template - inline void initialize(POD *); - template - inline void initialize(Class *); - template - static void destroy(Class *c); - - struct Page { - struct Header { - Page *next; - char *free; - } header; - - static const int pageSize = 4 * 4096 - sizeof(Header); - - char memory[pageSize]; - }; - - Page *_page; - Class *_classList; -}; - -QDeclarativePool::QDeclarativePool() -: _page(0), _classList(0) -{ -} - -QDeclarativePool::~QDeclarativePool() -{ - clear(); -} - -template -T *QDeclarativePool::New() -{ - T *rv = new (allocate(sizeof(T))) T; - initialize(rv); - rv->_pool = this; - return rv; -} - -template -T *QDeclarativePool::NewRaw() -{ - return (T*)allocate(sizeof(T)); -} - -template -T *QDeclarativePool::NewRawArray(int length) -{ - return (T*)allocate(length * sizeof(T)); -} - -template -QDeclarativePool::List QDeclarativePool::NewRawList(int length) -{ - return List(NewRawArray(length), length); -} - -QString *QDeclarativePool::NewString(const QString &s) -{ - QString *rv = New(); - *rv = s; - return rv; -} - -QByteArray *QDeclarativePool::NewByteArray(const QByteArray &s) -{ - QByteArray *rv = New(); - *rv = s; - return rv; -} - -QUrl *QDeclarativePool::NewUrl(const QUrl &s) -{ - QUrl *rv = New(); - *rv = s; - return rv; -} - -void *QDeclarativePool::allocate(int size) -{ - if (!_page || (_page->header.free + size) > (_page->memory + Page::pageSize)) - newpage(); - - void *rv = _page->header.free; - _page->header.free += size + ((8 - size) & 7); // ensure 8 byte alignment; - return rv; -} - -template -void QDeclarativePool::initialize(QDeclarativePool::POD *) -{ -} - -template -void QDeclarativePool::initialize(QDeclarativePool::Class *c) -{ - c->_next = _classList; - c->_destroy = &destroy; - _classList = c; -} - -template -void QDeclarativePool::destroy(Class *c) -{ - static_cast(c)->~T(); -} - -QDeclarativePool *QDeclarativePool::Class::pool() const -{ - return _pool; -} - -QDeclarativePool *QDeclarativePool::POD::pool() const -{ - return _pool; -} - -QT_END_NAMESPACE - -#endif // QDECLARATIVEPOOL_P_H - diff --git a/src/declarative/qml/ftw/qdeclarativerefcount_p.h b/src/declarative/qml/ftw/qdeclarativerefcount_p.h deleted file mode 100644 index 05aede4534..0000000000 --- a/src/declarative/qml/ftw/qdeclarativerefcount_p.h +++ /dev/null @@ -1,192 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEREFCOUNT_P_H -#define QDECLARATIVEREFCOUNT_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 - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeRefCount -{ -public: - inline QDeclarativeRefCount(); - inline virtual ~QDeclarativeRefCount(); - inline void addref(); - inline void release(); - -protected: - inline virtual void destroy(); - -private: - QAtomicInt refCount; -}; - -template -class QDeclarativeRefPointer -{ -public: - inline QDeclarativeRefPointer(); - inline QDeclarativeRefPointer(T *); - inline QDeclarativeRefPointer(const QDeclarativeRefPointer &); - inline ~QDeclarativeRefPointer(); - - inline QDeclarativeRefPointer &operator=(const QDeclarativeRefPointer &o); - inline QDeclarativeRefPointer &operator=(T *); - - inline bool isNull() const { return !o; } - - inline T* operator->() const { return o; } - inline T& operator*() const { return *o; } - inline operator T*() const { return o; } - inline T* data() const { return o; } - - inline QDeclarativeRefPointer &take(T *); - -private: - T *o; -}; - -QDeclarativeRefCount::QDeclarativeRefCount() -: refCount(1) -{ -} - -QDeclarativeRefCount::~QDeclarativeRefCount() -{ - Q_ASSERT(refCount.load() == 0); -} - -void QDeclarativeRefCount::addref() -{ - Q_ASSERT(refCount.load() > 0); - refCount.ref(); -} - -void QDeclarativeRefCount::release() -{ - Q_ASSERT(refCount.load() > 0); - if (!refCount.deref()) - destroy(); -} - -void QDeclarativeRefCount::destroy() -{ - delete this; -} - -template -QDeclarativeRefPointer::QDeclarativeRefPointer() -: o(0) -{ -} - -template -QDeclarativeRefPointer::QDeclarativeRefPointer(T *o) -: o(o) -{ - if (o) o->addref(); -} - -template -QDeclarativeRefPointer::QDeclarativeRefPointer(const QDeclarativeRefPointer &other) -: o(other.o) -{ - if (o) o->addref(); -} - -template -QDeclarativeRefPointer::~QDeclarativeRefPointer() -{ - if (o) o->release(); -} - -template -QDeclarativeRefPointer &QDeclarativeRefPointer::operator=(const QDeclarativeRefPointer &other) -{ - if (other.o) other.o->addref(); - if (o) o->release(); - o = other.o; - return *this; -} - -template -QDeclarativeRefPointer &QDeclarativeRefPointer::operator=(T *other) -{ - if (other) other->addref(); - if (o) o->release(); - o = other; - return *this; -} - -/*! -Takes ownership of \a other. take() does *not* add a reference, as it assumes ownership -of the callers reference of other. -*/ -template -QDeclarativeRefPointer &QDeclarativeRefPointer::take(T *other) -{ - if (o) o->release(); - o = other; - return *this; -} - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEREFCOUNT_P_H diff --git a/src/declarative/qml/ftw/qdeclarativethread.cpp b/src/declarative/qml/ftw/qdeclarativethread.cpp deleted file mode 100644 index be51a09f8d..0000000000 --- a/src/declarative/qml/ftw/qdeclarativethread.cpp +++ /dev/null @@ -1,359 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativethread_p.h" - -#include - -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeThreadPrivate : public QThread -{ -public: - QDeclarativeThreadPrivate(QDeclarativeThread *); - QDeclarativeThread *q; - - virtual void run(); - - inline void lock() { _mutex.lock(); } - inline void unlock() { _mutex.unlock(); } - inline void wait() { _wait.wait(&_mutex); } - inline void wakeOne() { _wait.wakeOne(); } - inline void wakeAll() { _wait.wakeAll(); } - - quint32 m_threadProcessing:1; // Set when the thread is processing messages - quint32 m_mainProcessing:1; // Set when the main thread is processing messages - quint32 m_shutdown:1; // Set by main thread to request a shutdown - quint32 m_mainThreadWaiting:1; // Set by main thread if it is waiting for the message queue to empty - - typedef QFieldList MessageList; - MessageList threadList; - MessageList mainList; - - QDeclarativeThread::Message *mainSync; - - void triggerMainEvent(); - void triggerThreadEvent(); - - void mainEvent(); - void threadEvent(); - -protected: - virtual bool event(QEvent *); - -private: - struct MainObject : public QObject { - MainObject(QDeclarativeThreadPrivate *p); - virtual bool event(QEvent *e); - QDeclarativeThreadPrivate *p; - }; - MainObject m_mainObject; - - QMutex _mutex; - QWaitCondition _wait; -}; - -QDeclarativeThreadPrivate::MainObject::MainObject(QDeclarativeThreadPrivate *p) -: p(p) -{ -} - -// Trigger mainEvent in main thread. Must be called from thread. -void QDeclarativeThreadPrivate::triggerMainEvent() -{ - Q_ASSERT(q->isThisThread()); - QCoreApplication::postEvent(&m_mainObject, new QEvent(QEvent::User)); -} - -// Trigger even in thread. Must be called from main thread. -void QDeclarativeThreadPrivate::triggerThreadEvent() -{ - Q_ASSERT(!q->isThisThread()); - QCoreApplication::postEvent(this, new QEvent(QEvent::User)); -} - -bool QDeclarativeThreadPrivate::MainObject::event(QEvent *e) -{ - if (e->type() == QEvent::User) - p->mainEvent(); - return QObject::event(e); -} - -QDeclarativeThreadPrivate::QDeclarativeThreadPrivate(QDeclarativeThread *q) -: q(q), m_threadProcessing(false), m_mainProcessing(false), m_shutdown(false), - m_mainThreadWaiting(false), mainSync(0), m_mainObject(this) -{ -} - -bool QDeclarativeThreadPrivate::event(QEvent *e) -{ - if (e->type() == QEvent::User) - threadEvent(); - return QThread::event(e); -} - -void QDeclarativeThreadPrivate::run() -{ - lock(); - - wakeOne(); - - unlock(); - - q->startupThread(); - exec(); -} - -void QDeclarativeThreadPrivate::mainEvent() -{ - lock(); - - m_mainProcessing = true; - - while (!mainList.isEmpty() || mainSync) { - bool isSync = mainSync != 0; - QDeclarativeThread::Message *message = isSync?mainSync:mainList.takeFirst(); - unlock(); - - message->call(q); - delete message; - - lock(); - - if (isSync) { - mainSync = 0; - wakeOne(); - } - } - - m_mainProcessing = false; - - unlock(); -} - -void QDeclarativeThreadPrivate::threadEvent() -{ - lock(); - - if (m_shutdown) { - quit(); - wakeOne(); - unlock(); - q->shutdownThread(); - } else { - m_threadProcessing = true; - - while (!threadList.isEmpty()) { - QDeclarativeThread::Message *message = threadList.first(); - - unlock(); - - message->call(q); - - lock(); - - delete threadList.takeFirst(); - } - - wakeOne(); - - m_threadProcessing = false; - - unlock(); - } -} - -QDeclarativeThread::QDeclarativeThread() -: d(new QDeclarativeThreadPrivate(this)) -{ - d->lock(); - d->start(); - d->wait(); - d->unlock(); - d->moveToThread(d); - -} - -QDeclarativeThread::~QDeclarativeThread() -{ - delete d; -} - -void QDeclarativeThread::shutdown() -{ - d->lock(); - Q_ASSERT(!d->m_shutdown); - d->m_shutdown = true; - if (d->threadList.isEmpty() && d->m_threadProcessing == false) - d->triggerThreadEvent(); - d->wait(); - d->unlock(); - d->QThread::wait(); -} - -void QDeclarativeThread::lock() -{ - d->lock(); -} - -void QDeclarativeThread::unlock() -{ - d->unlock(); -} - -void QDeclarativeThread::wakeOne() -{ - d->wakeOne(); -} - -void QDeclarativeThread::wakeAll() -{ - d->wakeAll(); -} - -void QDeclarativeThread::wait() -{ - d->wait(); -} - -bool QDeclarativeThread::isThisThread() const -{ - return QThread::currentThread() == d; -} - -QThread *QDeclarativeThread::thread() const -{ - return const_cast(static_cast(d)); -} - -// Called when the thread starts. Do startup stuff in here. -void QDeclarativeThread::startupThread() -{ -} - -// Called when the thread shuts down. Do cleanup in here. -void QDeclarativeThread::shutdownThread() -{ -} - -void QDeclarativeThread::internalCallMethodInThread(Message *message) -{ - Q_ASSERT(!isThisThread()); - d->lock(); - Q_ASSERT(d->m_mainThreadWaiting == false); - - bool wasEmpty = d->threadList.isEmpty(); - d->threadList.append(message); - if (wasEmpty && d->m_threadProcessing == false) - d->triggerThreadEvent(); - - d->m_mainThreadWaiting = true; - - do { - if (d->mainSync) { - QDeclarativeThread::Message *message = d->mainSync; - unlock(); - message->call(this); - delete message; - lock(); - d->mainSync = 0; - wakeOne(); - } else { - d->wait(); - } - } while (d->mainSync || !d->threadList.isEmpty()); - - d->m_mainThreadWaiting = false; - d->unlock(); -} - -void QDeclarativeThread::internalCallMethodInMain(Message *message) -{ - Q_ASSERT(isThisThread()); - - d->lock(); - - Q_ASSERT(d->mainSync == 0); - d->mainSync = message; - - if (d->m_mainThreadWaiting) { - d->wakeOne(); - } else if (d->m_mainProcessing) { - // Do nothing - it is already looping - } else { - d->triggerMainEvent(); - } - - while (d->mainSync && !d->m_shutdown) - d->wait(); - - d->unlock(); -} - -void QDeclarativeThread::internalPostMethodToThread(Message *message) -{ - Q_ASSERT(!isThisThread()); - d->lock(); - bool wasEmpty = d->threadList.isEmpty(); - d->threadList.append(message); - if (wasEmpty && d->m_threadProcessing == false) - d->triggerThreadEvent(); - d->unlock(); -} - -void QDeclarativeThread::internalPostMethodToMain(Message *message) -{ - Q_ASSERT(isThisThread()); - d->lock(); - bool wasEmpty = d->mainList.isEmpty(); - d->mainList.append(message); - if (wasEmpty && d->m_mainProcessing == false) - d->triggerMainEvent(); - d->unlock(); -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/ftw/qdeclarativethread_p.h b/src/declarative/qml/ftw/qdeclarativethread_p.h deleted file mode 100644 index ce9eb1d88f..0000000000 --- a/src/declarative/qml/ftw/qdeclarativethread_p.h +++ /dev/null @@ -1,318 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVETHREAD_P_H -#define QDECLARATIVETHREAD_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 - -QT_BEGIN_NAMESPACE - -class QThread; - -class QDeclarativeThreadPrivate; -class QDeclarativeThread -{ -public: - QDeclarativeThread(); - virtual ~QDeclarativeThread(); - void shutdown(); - - void lock(); - void unlock(); - void wakeOne(); - void wakeAll(); - void wait(); - - QThread *thread() const; - bool isThisThread() const; - - // Synchronously invoke a method in the thread - template - inline void callMethodInThread(void (O::*Member)()); - template - inline void callMethodInThread(void (O::*Member)(V), const T &); - template - inline void callMethodInThread(void (O::*Member)(V, V2), const T &, const T2 &); - - // Synchronously invoke a method in the main thread. If the main thread is - // blocked in a callMethodInThread() call, the call is made from within that - // call. - template - inline void callMethodInMain(void (O::*Member)()); - template - inline void callMethodInMain(void (O::*Member)(V), const T &); - template - inline void callMethodInMain(void (O::*Member)(V, V2), const T &, const T2 &); - - // Asynchronously invoke a method in the thread. - template - inline void postMethodToThread(void (O::*Member)()); - template - inline void postMethodToThread(void (O::*Member)(V), const T &); - template - inline void postMethodToThread(void (O::*Member)(V, V2), const T &, const T2 &); - - // Asynchronously invoke a method in the main thread. - template - inline void postMethodToMain(void (O::*Member)()); - template - inline void postMethodToMain(void (O::*Member)(V), const T &); - template - inline void postMethodToMain(void (O::*Member)(V, V2), const T &, const T2 &); - -protected: - virtual void startupThread(); - virtual void shutdownThread(); - -private: - friend class QDeclarativeThreadPrivate; - - struct Message { - Message() : next(0) {} - virtual ~Message() {} - Message *next; - virtual void call(QDeclarativeThread *) = 0; - }; - void internalCallMethodInThread(Message *); - void internalCallMethodInMain(Message *); - void internalPostMethodToThread(Message *); - void internalPostMethodToMain(Message *); - QDeclarativeThreadPrivate *d; -}; - -template -void QDeclarativeThread::callMethodInThread(void (O::*Member)()) -{ - struct I : public Message { - void (O::*Member)(); - I(void (O::*Member)()) : Member(Member) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(); - } - }; - internalCallMethodInThread(new I(Member)); -} - -template -void QDeclarativeThread::callMethodInThread(void (O::*Member)(V), const T &arg) -{ - struct I : public Message { - void (O::*Member)(V); - T arg; - I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(arg); - } - }; - internalCallMethodInThread(new I(Member, arg)); -} - -template -void QDeclarativeThread::callMethodInThread(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) -{ - struct I : public Message { - void (O::*Member)(V, V2); - T arg; - T2 arg2; - I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(arg, arg2); - } - }; - internalCallMethodInThread(new I(Member, arg, arg2)); -} - -template -void QDeclarativeThread::callMethodInMain(void (O::*Member)()) -{ - struct I : public Message { - void (O::*Member)(); - I(void (O::*Member)()) : Member(Member) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(); - } - }; - internalCallMethodInMain(new I(Member)); -} - -template -void QDeclarativeThread::callMethodInMain(void (O::*Member)(V), const T &arg) -{ - struct I : public Message { - void (O::*Member)(V); - T arg; - I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(arg); - } - }; - internalCallMethodInMain(new I(Member, arg)); -} - -template -void QDeclarativeThread::callMethodInMain(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) -{ - struct I : public Message { - void (O::*Member)(V, V2); - T arg; - T2 arg2; - I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(arg, arg2); - } - }; - internalCallMethodInMain(new I(Member, arg, arg2)); -} - -template -void QDeclarativeThread::postMethodToThread(void (O::*Member)()) -{ - struct I : public Message { - void (O::*Member)(); - I(void (O::*Member)()) : Member(Member) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(); - } - }; - internalPostMethodToThread(new I(Member)); -} - -template -void QDeclarativeThread::postMethodToThread(void (O::*Member)(V), const T &arg) -{ - struct I : public Message { - void (O::*Member)(V); - T arg; - I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(arg); - } - }; - internalPostMethodToThread(new I(Member, arg)); -} - -template -void QDeclarativeThread::postMethodToThread(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) -{ - struct I : public Message { - void (O::*Member)(V, V2); - T arg; - T2 arg2; - I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(arg, arg2); - } - }; - internalPostMethodToThread(new I(Member, arg, arg2)); -} - -template -void QDeclarativeThread::postMethodToMain(void (O::*Member)()) -{ - struct I : public Message { - void (O::*Member)(); - I(void (O::*Member)()) : Member(Member) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(); - } - }; - internalPostMethodToMain(new I(Member)); -} - -template -void QDeclarativeThread::postMethodToMain(void (O::*Member)(V), const T &arg) -{ - struct I : public Message { - void (O::*Member)(V); - T arg; - I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(arg); - } - }; - internalPostMethodToMain(new I(Member, arg)); -} - -template -void QDeclarativeThread::postMethodToMain(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) -{ - struct I : public Message { - void (O::*Member)(V, V2); - T arg; - T2 arg2; - I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(arg, arg2); - } - }; - internalPostMethodToMain(new I(Member, arg, arg2)); -} - -QT_END_NAMESPACE - -#endif // QDECLARATIVETHREAD_P_H diff --git a/src/declarative/qml/ftw/qdeclarativetrace.cpp b/src/declarative/qml/ftw/qdeclarativetrace.cpp deleted file mode 100644 index 7c814e37c1..0000000000 --- a/src/declarative/qml/ftw/qdeclarativetrace.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativetrace_p.h" - -#ifdef QML_ENABLE_TRACE -#include -#endif - -QT_BEGIN_NAMESPACE - -#ifdef QML_ENABLE_TRACE - -QDeclarativeTrace::Pool QDeclarativeTrace::logPool; -QDeclarativeTrace::Entry *QDeclarativeTrace::first = 0; -QDeclarativeTrace::Entry *QDeclarativeTrace::last = 0; - -static qint64 toNsecs(QDeclarativeTrace::TimeType time) -{ -#ifdef Q_OS_MAC - static mach_timebase_info_data_t info = {0,0}; - if (info.denom == 0) - mach_timebase_info(&info); - return time * info.numer / info.denom; -#else - qint64 rv = time.tv_sec * 1000000000 + time.tv_nsec; - return rv; -#endif -} - -QDeclarativeTrace::Pool::Pool() -{ - first = New(); - last = first; -} - -QDeclarativeTrace::Pool::~Pool() -{ - char buffer[128]; - sprintf(buffer, "qml.%d.log", ::getpid()); - FILE *out = fopen(buffer, "w"); - if (!out) { - fprintf (stderr, "QML Log: Could not open %s\n", buffer); - return; - } else { - fprintf (stderr, "QML Log: Writing log to %s\n", buffer); - } - - QDeclarativeTrace::Entry *cur = QDeclarativeTrace::first; - QByteArray indent; - int depth = -1; - - qint64 firstTime = -1; - - while (cur) { - - switch (cur->type) { - case QDeclarativeTrace::Entry::RangeStart: { - RangeStart *rs = static_cast(cur); - - qint64 nsecs = toNsecs(rs->time); - - if (firstTime == -1) - firstTime = nsecs; - - nsecs -= firstTime; - - depth++; - indent = QByteArray(depth * 4, ' '); - fprintf(out, "%s%s @%lld (%lld ns)\n", indent.constData(), - rs->description, nsecs, toNsecs(rs->end->time) - nsecs - firstTime); - } break; - case QDeclarativeTrace::Entry::RangeEnd: - depth--; - indent = QByteArray(depth * 4, ' '); - break; - case QDeclarativeTrace::Entry::Detail: - fprintf(out, "%s %s\n", indent.constData(), - static_cast(cur)->description); - break; - case QDeclarativeTrace::Entry::IntDetail: - fprintf(out, "%s %s: %d\n", indent.constData(), - static_cast(cur)->description, - static_cast(cur)->value); - break; - case QDeclarativeTrace::Entry::StringDetail: { - QByteArray vLatin1 = static_cast(cur)->value->toLatin1(); - fprintf(out, "%s %s: %s\n", indent.constData(), - static_cast(cur)->description, - vLatin1.constData()); - } break; - case QDeclarativeTrace::Entry::UrlDetail: { - QByteArray vLatin1 = static_cast(cur)->value->toString().toLatin1(); - fprintf(out, "%s %s: %s\n", indent.constData(), - static_cast(cur)->description, - vLatin1.constData()); - } break; - case QDeclarativeTrace::Entry::Event: { - Event *ev = static_cast(cur); - qint64 nsecs = toNsecs(ev->time) - firstTime; - fprintf(out, "%s + %s @%lld +%lld ns\n", indent.constData(), - ev->description, nsecs, nsecs - (toNsecs(ev->start->time) - firstTime)); - } break; - case QDeclarativeTrace::Entry::Null: - default: - break; - } - cur = cur->next; - } - fclose(out); -} - -#endif - -QT_END_NAMESPACE - diff --git a/src/declarative/qml/ftw/qdeclarativetrace_p.h b/src/declarative/qml/ftw/qdeclarativetrace_p.h deleted file mode 100644 index 89ed26e925..0000000000 --- a/src/declarative/qml/ftw/qdeclarativetrace_p.h +++ /dev/null @@ -1,294 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVETRACE_P_H -#define QDECLARATIVETRACE_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 - -// #define QML_ENABLE_TRACE - -#if defined(QML_ENABLE_TRACE) && defined(Q_OS_MAC) -#include -#endif - -QT_BEGIN_NAMESPACE - -class QUrl; -class QDeclarativeTrace -{ -public: - inline QDeclarativeTrace(const char *desc); - inline ~QDeclarativeTrace(); - - inline void addDetail(const char *); - inline void addDetail(const char *, int); - inline void addDetail(const char *, const QString &); - inline void addDetail(const char *, const QUrl &); - - inline void event(const char *desc); - -#ifdef QML_ENABLE_TRACE - -#ifdef Q_OS_MAC - typedef uint64_t TimeType; -#else - typedef timespec TimeType; -#endif - - struct Entry : public QDeclarativePool::POD { - enum Type { Null, RangeStart, RangeEnd, Detail, IntDetail, StringDetail, UrlDetail, Event }; - inline Entry(); - inline Entry(Type); - Type type; - Entry *next; - }; - struct RangeEnd : public Entry { - inline RangeEnd(); - TimeType time; - }; - struct RangeStart : public Entry { - inline RangeStart(); - const char *description; - TimeType time; - QDeclarativeTrace::RangeEnd *end; - }; - struct Detail : public Entry { - inline Detail(); - inline Detail(Type t); - const char *description; - }; - struct IntDetail : public Detail { - inline IntDetail(); - int value; - }; - struct StringDetail : public Detail { - inline StringDetail(); - QString *value; - }; - struct UrlDetail : public Detail { - inline UrlDetail(); - QUrl *value; - }; - struct Event : public Entry { - inline Event(); - const char *description; - TimeType time; - QDeclarativeTrace::RangeStart *start; - }; - - struct Pool : public QDeclarativePool { - Pool(); - ~Pool(); - }; - - static Pool logPool; - static Entry *first; - static Entry *last; - -private: - RangeStart *start; - - static TimeType gettime() { -#ifdef Q_OS_MAC - return mach_absolute_time(); -#else - TimeType ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - return ts; -#endif - } -#endif -}; - -#ifdef QML_ENABLE_TRACE -QDeclarativeTrace::Entry::Entry() -: type(Null), next(0) -{ -} - -QDeclarativeTrace::Entry::Entry(Type type) -: type(type), next(0) -{ - QDeclarativeTrace::last->next = this; - QDeclarativeTrace::last = this; -} - -QDeclarativeTrace::RangeEnd::RangeEnd() -: QDeclarativeTrace::Entry(QDeclarativeTrace::Entry::RangeEnd), - time(gettime()) -{ -} - -QDeclarativeTrace::RangeStart::RangeStart() -: QDeclarativeTrace::Entry(QDeclarativeTrace::Entry::RangeStart), - description(0), time(gettime()) -{ -} - -QDeclarativeTrace::Detail::Detail() -: QDeclarativeTrace::Entry(QDeclarativeTrace::Entry::Detail), - description(0) -{ -} - -QDeclarativeTrace::Detail::Detail(Type type) -: QDeclarativeTrace::Entry(type), description(0) -{ -} - -QDeclarativeTrace::IntDetail::IntDetail() -: QDeclarativeTrace::Detail(QDeclarativeTrace::Entry::IntDetail), - value(0) -{ -} - -QDeclarativeTrace::StringDetail::StringDetail() -: QDeclarativeTrace::Detail(QDeclarativeTrace::Entry::StringDetail), - value(0) -{ -} - -QDeclarativeTrace::UrlDetail::UrlDetail() -: QDeclarativeTrace::Detail(QDeclarativeTrace::Entry::UrlDetail), - value(0) -{ -} - -QDeclarativeTrace::Event::Event() -: QDeclarativeTrace::Entry(QDeclarativeTrace::Entry::Event), - description(0), time(gettime()), start(0) -{ -} -#endif - -QDeclarativeTrace::QDeclarativeTrace(const char *desc) -{ -#ifdef QML_ENABLE_TRACE - RangeStart *e = logPool.New(); - e->description = desc; - e->end = 0; - start = e; -#else - Q_UNUSED(desc); -#endif -} - -QDeclarativeTrace::~QDeclarativeTrace() -{ -#ifdef QML_ENABLE_TRACE - RangeEnd *e = logPool.New(); - start->end = e; -#endif -} - -void QDeclarativeTrace::addDetail(const char *desc) -{ -#ifdef QML_ENABLE_TRACE - Detail *e = logPool.New(); - e->description = desc; -#else - Q_UNUSED(desc); -#endif -} - -void QDeclarativeTrace::addDetail(const char *desc, int v) -{ -#ifdef QML_ENABLE_TRACE - IntDetail *e = logPool.New(); - e->description = desc; - e->value = v; -#else - Q_UNUSED(desc); - Q_UNUSED(v); -#endif -} - -void QDeclarativeTrace::addDetail(const char *desc, const QString &v) -{ -#ifdef QML_ENABLE_TRACE - StringDetail *e = logPool.New(); - e->description = desc; - e->value = logPool.NewString(v); -#else - Q_UNUSED(desc); - Q_UNUSED(v); -#endif -} - -void QDeclarativeTrace::addDetail(const char *desc, const QUrl &v) -{ -#ifdef QML_ENABLE_TRACE - UrlDetail *e = logPool.New(); - e->description = desc; - e->value = logPool.NewUrl(v); -#else - Q_UNUSED(desc); - Q_UNUSED(v); -#endif -} - -void QDeclarativeTrace::event(const char *desc) -{ -#ifdef QML_ENABLE_TRACE - Event *e = logPool.New(); - e->start = start; - e->description = desc; -#else - Q_UNUSED(desc); -#endif -} - -QT_END_NAMESPACE - -#endif // QDECLARATIVETRACE_P_H diff --git a/src/declarative/qml/parser/parser.pri b/src/declarative/qml/parser/parser.pri deleted file mode 100644 index 3ae0a6d8eb..0000000000 --- a/src/declarative/qml/parser/parser.pri +++ /dev/null @@ -1,19 +0,0 @@ -HEADERS += \ - $$PWD/qdeclarativejsast_p.h \ - $$PWD/qdeclarativejsastfwd_p.h \ - $$PWD/qdeclarativejsastvisitor_p.h \ - $$PWD/qdeclarativejsengine_p.h \ - $$PWD/qdeclarativejsgrammar_p.h \ - $$PWD/qdeclarativejslexer_p.h \ - $$PWD/qdeclarativejsmemorypool_p.h \ - $$PWD/qdeclarativejsparser_p.h \ - $$PWD/qdeclarativejsglobal_p.h \ - $$PWD/qdeclarativejskeywords_p.h - -SOURCES += \ - $$PWD/qdeclarativejsast.cpp \ - $$PWD/qdeclarativejsastvisitor.cpp \ - $$PWD/qdeclarativejsengine_p.cpp \ - $$PWD/qdeclarativejsgrammar.cpp \ - $$PWD/qdeclarativejslexer.cpp \ - $$PWD/qdeclarativejsparser.cpp diff --git a/src/declarative/qml/parser/qdeclarativejs.g b/src/declarative/qml/parser/qdeclarativejs.g deleted file mode 100644 index b87f9f8a65..0000000000 --- a/src/declarative/qml/parser/qdeclarativejs.g +++ /dev/null @@ -1,3016 +0,0 @@ ----------------------------------------------------------------------------- --- --- Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). --- Contact: http://www.qt-project.org/ --- --- This file is part of the QtDeclarative module of the Qt Toolkit. --- --- $QT_BEGIN_LICENSE:LGPL-ONLY$ --- GNU Lesser General Public License Usage --- 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. --- --- If you have questions regarding the use of this file, please contact --- us via http://www.qt-project.org/. --- --- $QT_END_LICENSE$ --- ----------------------------------------------------------------------------- - -%parser QDeclarativeJSGrammar -%decl qdeclarativejsparser_p.h -%impl qdeclarativejsparser.cpp -%expect 2 -%expect-rr 2 - -%token T_AND "&" T_AND_AND "&&" T_AND_EQ "&=" -%token T_BREAK "break" T_CASE "case" T_CATCH "catch" -%token T_COLON ":" T_COMMA "," T_CONTINUE "continue" -%token T_DEFAULT "default" T_DELETE "delete" T_DIVIDE_ "/" -%token T_DIVIDE_EQ "/=" T_DO "do" T_DOT "." -%token T_ELSE "else" T_EQ "=" T_EQ_EQ "==" -%token T_EQ_EQ_EQ "===" T_FINALLY "finally" T_FOR "for" -%token T_FUNCTION "function" T_GE ">=" T_GT ">" -%token T_GT_GT ">>" T_GT_GT_EQ ">>=" T_GT_GT_GT ">>>" -%token T_GT_GT_GT_EQ ">>>=" T_IDENTIFIER "identifier" T_IF "if" -%token T_IN "in" T_INSTANCEOF "instanceof" T_LBRACE "{" -%token T_LBRACKET "[" T_LE "<=" T_LPAREN "(" -%token T_LT "<" T_LT_LT "<<" T_LT_LT_EQ "<<=" -%token T_MINUS "-" T_MINUS_EQ "-=" T_MINUS_MINUS "--" -%token T_NEW "new" T_NOT "!" T_NOT_EQ "!=" -%token T_NOT_EQ_EQ "!==" T_NUMERIC_LITERAL "numeric literal" T_OR "|" -%token T_OR_EQ "|=" T_OR_OR "||" T_PLUS "+" -%token T_PLUS_EQ "+=" T_PLUS_PLUS "++" T_QUESTION "?" -%token T_RBRACE "}" T_RBRACKET "]" T_REMAINDER "%" -%token T_REMAINDER_EQ "%=" T_RETURN "return" T_RPAREN ")" -%token T_SEMICOLON ";" T_AUTOMATIC_SEMICOLON T_STAR "*" -%token T_STAR_EQ "*=" T_STRING_LITERAL "string literal" -%token T_PROPERTY "property" T_SIGNAL "signal" T_READONLY "readonly" -%token T_SWITCH "switch" T_THIS "this" T_THROW "throw" -%token T_TILDE "~" T_TRY "try" T_TYPEOF "typeof" -%token T_VAR "var" T_VOID "void" T_WHILE "while" -%token T_WITH "with" T_XOR "^" T_XOR_EQ "^=" -%token T_NULL "null" T_TRUE "true" T_FALSE "false" -%token T_CONST "const" -%token T_DEBUGGER "debugger" -%token T_RESERVED_WORD "reserved word" -%token T_MULTILINE_STRING_LITERAL "multiline string literal" -%token T_COMMENT "comment" - ---- context keywords. -%token T_PUBLIC "public" -%token T_IMPORT "import" -%token T_AS "as" -%token T_ON "on" - -%token T_ERROR - ---- feed tokens -%token T_FEED_UI_PROGRAM -%token T_FEED_UI_OBJECT_MEMBER -%token T_FEED_JS_STATEMENT -%token T_FEED_JS_EXPRESSION -%token T_FEED_JS_SOURCE_ELEMENT -%token T_FEED_JS_PROGRAM - -%nonassoc SHIFT_THERE -%nonassoc T_IDENTIFIER T_COLON T_SIGNAL T_PROPERTY T_READONLY -%nonassoc REDUCE_HERE - -%start TopLevel - -/./**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include - -#include "qdeclarativejsengine_p.h" -#include "qdeclarativejslexer_p.h" -#include "qdeclarativejsast_p.h" -#include "qdeclarativejsmemorypool_p.h" - -./ - -/:/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -// -// 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. -// - -// -// This file is automatically generated from qmljs.g. -// Changes will be lost. -// - -#ifndef QDECLARATIVEJSPARSER_P_H -#define QDECLARATIVEJSPARSER_P_H - -#include "qdeclarativejsglobal_p.h" -#include "qdeclarativejsgrammar_p.h" -#include "qdeclarativejsast_p.h" -#include "qdeclarativejsengine_p.h" - -#include -#include - -QT_QML_BEGIN_NAMESPACE - -namespace QDeclarativeJS { - -class Engine; - -class QML_PARSER_EXPORT Parser: protected $table -{ -public: - union Value { - int ival; - double dval; - AST::ArgumentList *ArgumentList; - AST::CaseBlock *CaseBlock; - AST::CaseClause *CaseClause; - AST::CaseClauses *CaseClauses; - AST::Catch *Catch; - AST::DefaultClause *DefaultClause; - AST::ElementList *ElementList; - AST::Elision *Elision; - AST::ExpressionNode *Expression; - AST::Finally *Finally; - AST::FormalParameterList *FormalParameterList; - AST::FunctionBody *FunctionBody; - AST::FunctionDeclaration *FunctionDeclaration; - AST::Node *Node; - AST::PropertyName *PropertyName; - AST::PropertyNameAndValueList *PropertyNameAndValueList; - AST::SourceElement *SourceElement; - AST::SourceElements *SourceElements; - AST::Statement *Statement; - AST::StatementList *StatementList; - AST::Block *Block; - AST::VariableDeclaration *VariableDeclaration; - AST::VariableDeclarationList *VariableDeclarationList; - - AST::UiProgram *UiProgram; - AST::UiImportList *UiImportList; - AST::UiImport *UiImport; - AST::UiParameterList *UiParameterList; - AST::UiPublicMember *UiPublicMember; - AST::UiObjectDefinition *UiObjectDefinition; - AST::UiObjectInitializer *UiObjectInitializer; - AST::UiObjectBinding *UiObjectBinding; - AST::UiScriptBinding *UiScriptBinding; - AST::UiArrayBinding *UiArrayBinding; - AST::UiObjectMember *UiObjectMember; - AST::UiObjectMemberList *UiObjectMemberList; - AST::UiArrayMemberList *UiArrayMemberList; - AST::UiQualifiedId *UiQualifiedId; - }; - -public: - Parser(Engine *engine); - ~Parser(); - - // parse a UI program - bool parse() { return parse(T_FEED_UI_PROGRAM); } - bool parseStatement() { return parse(T_FEED_JS_STATEMENT); } - bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); } - bool parseSourceElement() { return parse(T_FEED_JS_SOURCE_ELEMENT); } - bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); } - bool parseProgram() { return parse(T_FEED_JS_PROGRAM); } - - AST::UiProgram *ast() const - { return AST::cast(program); } - - AST::Statement *statement() const - { - if (! program) - return 0; - - return program->statementCast(); - } - - AST::ExpressionNode *expression() const - { - if (! program) - return 0; - - return program->expressionCast(); - } - - AST::UiObjectMember *uiObjectMember() const - { - if (! program) - return 0; - - return program->uiObjectMemberCast(); - } - - AST::Node *rootNode() const - { return program; } - - QList diagnosticMessages() const - { return diagnostic_messages; } - - inline DiagnosticMessage diagnosticMessage() const - { - foreach (const DiagnosticMessage &d, diagnostic_messages) { - if (! d.kind == DiagnosticMessage::Warning) - return d; - } - - return DiagnosticMessage(); - } - - inline QString errorMessage() const - { return diagnosticMessage().message; } - - inline int errorLineNumber() const - { return diagnosticMessage().loc.startLine; } - - inline int errorColumnNumber() const - { return diagnosticMessage().loc.startColumn; } - -protected: - bool parse(int startToken); - - void reallocateStack(); - - inline Value &sym(int index) - { return sym_stack [tos + index - 1]; } - - inline QStringRef &stringRef(int index) - { return string_stack [tos + index - 1]; } - - inline AST::SourceLocation &loc(int index) - { return location_stack [tos + index - 1]; } - - AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr); - -protected: - Engine *driver; - MemoryPool *pool; - int tos; - int stack_size; - Value *sym_stack; - int *state_stack; - AST::SourceLocation *location_stack; - QStringRef *string_stack; - - AST::Node *program; - - // error recovery - enum { TOKEN_BUFFER_SIZE = 3 }; - - struct SavedToken { - int token; - double dval; - AST::SourceLocation loc; - QStringRef spell; - }; - - double yylval; - QStringRef yytokenspell; - AST::SourceLocation yylloc; - AST::SourceLocation yyprevlloc; - - SavedToken token_buffer[TOKEN_BUFFER_SIZE]; - SavedToken *first_token; - SavedToken *last_token; - - QList diagnostic_messages; -}; - -} // end of namespace QDeclarativeJS - - -:/ - - -/. - -#include "qdeclarativejsparser_p.h" -#include - -// -// This file is automatically generated from qmljs.g. -// Changes will be lost. -// - -using namespace QDeclarativeJS; - -QT_QML_BEGIN_NAMESPACE - -void Parser::reallocateStack() -{ - if (! stack_size) - stack_size = 128; - else - stack_size <<= 1; - - sym_stack = reinterpret_cast (realloc(sym_stack, stack_size * sizeof(Value))); - state_stack = reinterpret_cast (realloc(state_stack, stack_size * sizeof(int))); - location_stack = reinterpret_cast (realloc(location_stack, stack_size * sizeof(AST::SourceLocation))); - string_stack = reinterpret_cast (realloc(string_stack, stack_size * sizeof(QStringRef))); -} - -Parser::Parser(Engine *engine): - driver(engine), - pool(engine->pool()), - tos(0), - stack_size(0), - sym_stack(0), - state_stack(0), - location_stack(0), - string_stack(0), - first_token(0), - last_token(0) -{ -} - -Parser::~Parser() -{ - if (stack_size) { - free(sym_stack); - free(state_stack); - free(location_stack); - free(string_stack); - } -} - -static inline AST::SourceLocation location(Lexer *lexer) -{ - AST::SourceLocation loc; - loc.offset = lexer->tokenOffset(); - loc.length = lexer->tokenLength(); - loc.startLine = lexer->tokenStartLine(); - loc.startColumn = lexer->tokenStartColumn(); - return loc; -} - -AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr) -{ - QVarLengthArray nameIds; - QVarLengthArray locations; - - AST::ExpressionNode *it = expr; - while (AST::FieldMemberExpression *m = AST::cast(it)) { - nameIds.append(m->name); - locations.append(m->identifierToken); - it = m->base; - } - - if (AST::IdentifierExpression *idExpr = AST::cast(it)) { - AST::UiQualifiedId *q = new (pool) AST::UiQualifiedId(idExpr->name); - q->identifierToken = idExpr->identifierToken; - - AST::UiQualifiedId *currentId = q; - for (int i = nameIds.size() - 1; i != -1; --i) { - currentId = new (pool) AST::UiQualifiedId(currentId, nameIds[i]); - currentId->identifierToken = locations[i]; - } - - return currentId->finish(); - } - - return 0; -} - -bool Parser::parse(int startToken) -{ - Lexer *lexer = driver->lexer(); - bool hadErrors = false; - int yytoken = -1; - int action = 0; - - token_buffer[0].token = startToken; - first_token = &token_buffer[0]; - last_token = &token_buffer[1]; - - tos = -1; - program = 0; - - do { - if (++tos == stack_size) - reallocateStack(); - - state_stack[tos] = action; - - _Lcheck_token: - if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) { - yyprevlloc = yylloc; - - if (first_token == last_token) { - yytoken = lexer->lex(); - yylval = lexer->tokenValue(); - yytokenspell = lexer->tokenSpell(); - yylloc = location(lexer); - } else { - yytoken = first_token->token; - yylval = first_token->dval; - yytokenspell = first_token->spell; - yylloc = first_token->loc; - ++first_token; - } - } - - action = t_action(action, yytoken); - if (action > 0) { - if (action != ACCEPT_STATE) { - yytoken = -1; - sym(1).dval = yylval; - stringRef(1) = yytokenspell; - loc(1) = yylloc; - } else { - --tos; - return ! hadErrors; - } - } else if (action < 0) { - const int r = -action - 1; - tos -= rhs[r]; - - switch (r) { -./ - --------------------------------------------------------------------------------------------------------- --- Declarative UI --------------------------------------------------------------------------------------------------------- - -TopLevel: T_FEED_UI_PROGRAM UiProgram ; -/. -case $rule_number: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; -./ - -TopLevel: T_FEED_JS_STATEMENT Statement ; -/. -case $rule_number: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; -./ - -TopLevel: T_FEED_JS_EXPRESSION Expression ; -/. -case $rule_number: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; -./ - -TopLevel: T_FEED_JS_SOURCE_ELEMENT SourceElement ; -/. -case $rule_number: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; -./ - -TopLevel: T_FEED_UI_OBJECT_MEMBER UiObjectMember ; -/. -case $rule_number: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; -./ - -TopLevel: T_FEED_JS_PROGRAM Program ; -/. -case $rule_number: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; -./ - -UiProgram: UiImportListOpt UiRootMember ; -/. -case $rule_number: { - sym(1).UiProgram = new (pool) AST::UiProgram(sym(1).UiImportList, - sym(2).UiObjectMemberList->finish()); -} break; -./ - -UiImportListOpt: Empty ; -UiImportListOpt: UiImportList ; -/. -case $rule_number: { - sym(1).Node = sym(1).UiImportList->finish(); -} break; -./ - -UiImportList: UiImport ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImport); -} break; -./ - -UiImportList: UiImportList UiImport ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImportList, sym(2).UiImport); -} break; -./ - -ImportId: MemberExpression ; - -UiImport: UiImportHead T_AUTOMATIC_SEMICOLON ; -UiImport: UiImportHead T_SEMICOLON ; -/. -case $rule_number: { - sym(1).UiImport->semicolonToken = loc(2); -} break; -./ - -UiImport: UiImportHead T_NUMERIC_LITERAL T_AUTOMATIC_SEMICOLON ; -UiImport: UiImportHead T_NUMERIC_LITERAL T_SEMICOLON ; -/. -case $rule_number: { - sym(1).UiImport->versionToken = loc(2); - sym(1).UiImport->semicolonToken = loc(3); -} break; -./ - -UiImport: UiImportHead T_NUMERIC_LITERAL T_AS JsIdentifier T_AUTOMATIC_SEMICOLON ; -UiImport: UiImportHead T_NUMERIC_LITERAL T_AS JsIdentifier T_SEMICOLON ; -/. -case $rule_number: { - sym(1).UiImport->versionToken = loc(2); - sym(1).UiImport->asToken = loc(3); - sym(1).UiImport->importIdToken = loc(4); - sym(1).UiImport->importId = stringRef(4); - sym(1).UiImport->semicolonToken = loc(5); -} break; -./ - -UiImport: UiImportHead T_AS JsIdentifier T_AUTOMATIC_SEMICOLON ; -UiImport: UiImportHead T_AS JsIdentifier T_SEMICOLON ; -/. -case $rule_number: { - sym(1).UiImport->asToken = loc(2); - sym(1).UiImport->importIdToken = loc(3); - sym(1).UiImport->importId = stringRef(3); - sym(1).UiImport->semicolonToken = loc(4); -} break; -./ - - -UiImportHead: T_IMPORT ImportId ; -/. -case $rule_number: { - AST::UiImport *node = 0; - - if (AST::StringLiteral *importIdLiteral = AST::cast(sym(2).Expression)) { - node = new (pool) AST::UiImport(importIdLiteral->value); - node->fileNameToken = loc(2); - } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) { - node = new (pool) AST::UiImport(qualifiedId); - node->fileNameToken = loc(2); - } - - sym(1).Node = node; - - if (node) { - node->importToken = loc(1); - } else { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1), - QLatin1String("Expected a qualified name id or a string literal"))); - - return false; // ### remove me - } -} break; -./ - -Empty: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -UiRootMember: UiObjectDefinition ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember); -} break; -./ - -UiObjectMemberList: UiObjectMember ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember); -} break; -./ - -UiObjectMemberList: UiObjectMemberList UiObjectMember ; -/. -case $rule_number: { - AST::UiObjectMemberList *node = new (pool) AST:: UiObjectMemberList( - sym(1).UiObjectMemberList, sym(2).UiObjectMember); - sym(1).Node = node; -} break; -./ - -UiArrayMemberList: UiObjectDefinition ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::UiArrayMemberList(sym(1).UiObjectMember); -} break; -./ - -UiArrayMemberList: UiArrayMemberList T_COMMA UiObjectDefinition ; -/. -case $rule_number: { - AST::UiArrayMemberList *node = new (pool) AST::UiArrayMemberList( - sym(1).UiArrayMemberList, sym(3).UiObjectMember); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -UiObjectInitializer: T_LBRACE T_RBRACE ; -/. -case $rule_number: { - AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer((AST::UiObjectMemberList*)0); - node->lbraceToken = loc(1); - node->rbraceToken = loc(2); - sym(1).Node = node; -} break; -./ - -UiObjectInitializer: T_LBRACE UiObjectMemberList T_RBRACE ; -/. -case $rule_number: { - AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer(sym(2).UiObjectMemberList->finish()); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; -./ - -UiObjectDefinition: UiQualifiedId UiObjectInitializer ; -/. -case $rule_number: { - AST::UiObjectDefinition *node = new (pool) AST::UiObjectDefinition(sym(1).UiQualifiedId, - sym(2).UiObjectInitializer); - sym(1).Node = node; -} break; -./ - -UiObjectMember: UiObjectDefinition ; - -UiObjectMember: UiQualifiedId T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ; -/. -case $rule_number: { - AST::UiArrayBinding *node = new (pool) AST::UiArrayBinding( - sym(1).UiQualifiedId, sym(4).UiArrayMemberList->finish()); - node->colonToken = loc(2); - node->lbracketToken = loc(3); - node->rbracketToken = loc(5); - sym(1).Node = node; -} break; -./ - -UiObjectMember: UiQualifiedId T_COLON UiQualifiedId UiObjectInitializer ; -/. -case $rule_number: { - AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding( - sym(1).UiQualifiedId, sym(3).UiQualifiedId, sym(4).UiObjectInitializer); - node->colonToken = loc(2); - sym(1).Node = node; -} break; -./ - -UiObjectMember: UiQualifiedId T_ON UiQualifiedId UiObjectInitializer ; -/. -case $rule_number: { - AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding( - sym(3).UiQualifiedId, sym(1).UiQualifiedId, sym(4).UiObjectInitializer); - node->colonToken = loc(2); - node->hasOnToken = true; - sym(1).Node = node; -} break; -./ - -UiScriptStatement: Block ; -UiScriptStatement: EmptyStatement ; -UiScriptStatement: ExpressionStatement ; -UiScriptStatement: IfStatement ; -UiScriptStatement: WithStatement ; -UiScriptStatement: SwitchStatement ; -UiScriptStatement: TryStatement ; - -UiObjectMember: UiQualifiedId T_COLON UiScriptStatement ; -/. -case $rule_number: -{ - AST::UiScriptBinding *node = new (pool) AST::UiScriptBinding( - sym(1).UiQualifiedId, sym(3).Statement); - node->colonToken = loc(2); - sym(1).Node = node; -} break; -./ - -UiPropertyType: T_VAR ; -UiPropertyType: T_RESERVED_WORD ; -UiPropertyType: T_IDENTIFIER ; - -UiParameterListOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -UiParameterListOpt: UiParameterList ; -/. -case $rule_number: { - sym(1).Node = sym(1).UiParameterList->finish (); -} break; -./ - -UiParameterList: UiPropertyType JsIdentifier ; -/. -case $rule_number: { - AST::UiParameterList *node = new (pool) AST::UiParameterList(stringRef(1), stringRef(2)); - node->propertyTypeToken = loc(1); - node->identifierToken = loc(2); - sym(1).Node = node; -} break; -./ - -UiParameterList: UiParameterList T_COMMA UiPropertyType JsIdentifier ; -/. -case $rule_number: { - AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, stringRef(3), stringRef(4)); - node->commaToken = loc(2); - node->identifierToken = loc(4); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_AUTOMATIC_SEMICOLON ; -UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_SEMICOLON ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); - node->type = AST::UiPublicMember::Signal; - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(2); - node->parameters = sym(4).UiParameterList; - node->semicolonToken = loc(6); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_SIGNAL T_IDENTIFIER T_AUTOMATIC_SEMICOLON ; -UiObjectMember: T_SIGNAL T_IDENTIFIER T_SEMICOLON ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); - node->type = AST::UiPublicMember::Signal; - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(2); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_AUTOMATIC_SEMICOLON ; -UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_SEMICOLON ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); - node->typeModifier = stringRef(2); - node->propertyToken = loc(1); - node->typeModifierToken = loc(2); - node->typeToken = loc(4); - node->identifierToken = loc(6); - node->semicolonToken = loc(7); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEMICOLON ; -UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(3); - node->semicolonToken = loc(4); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEMICOLON ; -UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4)); - node->isDefaultMember = true; - node->defaultToken = loc(1); - node->propertyToken = loc(2); - node->typeToken = loc(3); - node->identifierToken = loc(4); - node->semicolonToken = loc(5); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3), - sym(5).Statement); - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(3); - node->colonToken = loc(4); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), - sym(6).Statement); - node->isReadonlyMember = true; - node->readonlyToken = loc(1); - node->propertyToken = loc(2); - node->typeToken = loc(3); - node->identifierToken = loc(4); - node->colonToken = loc(5); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), - sym(6).Statement); - node->isDefaultMember = true; - node->defaultToken = loc(1); - node->propertyToken = loc(2); - node->typeToken = loc(3); - node->identifierToken = loc(4); - node->colonToken = loc(5); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); - node->typeModifier = stringRef(2); - node->propertyToken = loc(1); - node->typeModifierToken = loc(2); - node->typeToken = loc(4); - node->identifierToken = loc(6); - node->semicolonToken = loc(7); // insert a fake ';' before ':' - - AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(6)); - propertyName->identifierToken = loc(6); - propertyName->next = 0; - - AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding( - propertyName, sym(9).UiArrayMemberList->finish()); - binding->colonToken = loc(7); - binding->lbracketToken = loc(8); - binding->rbracketToken = loc(10); - - node->binding = binding; - - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON UiQualifiedId UiObjectInitializer ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(3); - node->semicolonToken = loc(4); // insert a fake ';' before ':' - - AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(3)); - propertyName->identifierToken = loc(3); - propertyName->next = 0; - - AST::UiObjectBinding *binding = new (pool) AST::UiObjectBinding( - propertyName, sym(5).UiQualifiedId, sym(6).UiObjectInitializer); - binding->colonToken = loc(4); - - node->binding = binding; - - sym(1).Node = node; -} break; -./ - -UiObjectMember: FunctionDeclaration ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); -} break; -./ - -UiObjectMember: VariableStatement ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); -} break; -./ - -JsIdentifier: T_IDENTIFIER; - -JsIdentifier: T_PROPERTY ; -JsIdentifier: T_SIGNAL ; -JsIdentifier: T_READONLY ; -JsIdentifier: T_ON ; - --------------------------------------------------------------------------------------------------------- --- Expressions --------------------------------------------------------------------------------------------------------- - -PrimaryExpression: T_THIS ; -/. -case $rule_number: { - AST::ThisExpression *node = new (pool) AST::ThisExpression(); - node->thisToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: JsIdentifier ; -/. -case $rule_number: { - AST::IdentifierExpression *node = new (pool) AST::IdentifierExpression(stringRef(1)); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_NULL ; -/. -case $rule_number: { - AST::NullExpression *node = new (pool) AST::NullExpression(); - node->nullToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_TRUE ; -/. -case $rule_number: { - AST::TrueLiteral *node = new (pool) AST::TrueLiteral(); - node->trueToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_FALSE ; -/. -case $rule_number: { - AST::FalseLiteral *node = new (pool) AST::FalseLiteral(); - node->falseToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_NUMERIC_LITERAL ; -/. -case $rule_number: { - AST::NumericLiteral *node = new (pool) AST::NumericLiteral(sym(1).dval); - node->literalToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_MULTILINE_STRING_LITERAL ; -/.case $rule_number:./ - -PrimaryExpression: T_STRING_LITERAL ; -/. -case $rule_number: { - AST::StringLiteral *node = new (pool) AST::StringLiteral(stringRef(1)); - node->literalToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_DIVIDE_ ; -/: -#define J_SCRIPT_REGEXPLITERAL_RULE1 $rule_number -:/ -/. -case $rule_number: { - bool rx = lexer->scanRegExp(Lexer::NoPrefix); - if (!rx) { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); - return false; // ### remove me - } - - loc(1).length = lexer->tokenLength(); - yylloc = loc(1); // adjust the location of the current token - - AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral( - driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags()); - node->literalToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_DIVIDE_EQ ; -/: -#define J_SCRIPT_REGEXPLITERAL_RULE2 $rule_number -:/ -/. -case $rule_number: { - bool rx = lexer->scanRegExp(Lexer::EqualPrefix); - if (!rx) { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); - return false; - } - - loc(1).length = lexer->tokenLength(); - yylloc = loc(1); // adjust the location of the current token - - AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral( - driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags()); - node->literalToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_LBRACKET T_RBRACKET ; -/. -case $rule_number: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral((AST::Elision *) 0); - node->lbracketToken = loc(1); - node->rbracketToken = loc(2); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_LBRACKET Elision T_RBRACKET ; -/. -case $rule_number: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).Elision->finish()); - node->lbracketToken = loc(1); - node->rbracketToken = loc(3); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_LBRACKET ElementList T_RBRACKET ; -/. -case $rule_number: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish ()); - node->lbracketToken = loc(1); - node->rbracketToken = loc(3); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_LBRACKET ElementList T_COMMA T_RBRACKET ; -/. -case $rule_number: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), - (AST::Elision *) 0); - node->lbracketToken = loc(1); - node->commaToken = loc(3); - node->rbracketToken = loc(4); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_LBRACKET ElementList T_COMMA Elision T_RBRACKET ; -/. -case $rule_number: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), - sym(4).Elision->finish()); - node->lbracketToken = loc(1); - node->commaToken = loc(3); - node->rbracketToken = loc(5); - sym(1).Node = node; -} break; -./ - --- PrimaryExpression: T_LBRACE T_RBRACE ; --- /. --- case $rule_number: { --- sym(1).Node = new (pool) AST::ObjectLiteral(); --- } break; --- ./ - -PrimaryExpression: T_LBRACE PropertyNameAndValueListOpt T_RBRACE ; -/. -case $rule_number: { - AST::ObjectLiteral *node = 0; - if (sym(2).Node) - node = new (pool) AST::ObjectLiteral( - sym(2).PropertyNameAndValueList->finish ()); - else - node = new (pool) AST::ObjectLiteral(); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_LBRACE PropertyNameAndValueList T_COMMA T_RBRACE ; -/. -case $rule_number: { - AST::ObjectLiteral *node = new (pool) AST::ObjectLiteral( - sym(2).PropertyNameAndValueList->finish ()); - node->lbraceToken = loc(1); - node->rbraceToken = loc(4); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_LPAREN Expression T_RPAREN ; -/. -case $rule_number: { - AST::NestedExpression *node = new (pool) AST::NestedExpression(sym(2).Expression); - node->lparenToken = loc(1); - node->rparenToken = loc(3); - sym(1).Node = node; -} break; -./ - -UiQualifiedId: MemberExpression ; -/. -case $rule_number: { - if (AST::ArrayMemberExpression *mem = AST::cast(sym(1).Expression)) { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken, - QLatin1String("Ignored annotation"))); - - sym(1).Expression = mem->base; - } - - if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(1).Expression)) { - sym(1).UiQualifiedId = qualifiedId; - } else { - sym(1).UiQualifiedId = 0; - - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1), - QLatin1String("Expected a qualified name id"))); - - return false; // ### recover - } -} break; -./ - -ElementList: AssignmentExpression ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::ElementList((AST::Elision *) 0, sym(1).Expression); -} break; -./ - -ElementList: Elision AssignmentExpression ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::ElementList(sym(1).Elision->finish(), sym(2).Expression); -} break; -./ - -ElementList: ElementList T_COMMA AssignmentExpression ; -/. -case $rule_number: { - AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, - (AST::Elision *) 0, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -ElementList: ElementList T_COMMA Elision AssignmentExpression ; -/. -case $rule_number: { - AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, sym(3).Elision->finish(), - sym(4).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -Elision: T_COMMA ; -/. -case $rule_number: { - AST::Elision *node = new (pool) AST::Elision(); - node->commaToken = loc(1); - sym(1).Node = node; -} break; -./ - -Elision: Elision T_COMMA ; -/. -case $rule_number: { - AST::Elision *node = new (pool) AST::Elision(sym(1).Elision); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -PropertyNameAndValueList: PropertyName T_COLON AssignmentExpression ; -/. -case $rule_number: { - AST::PropertyNameAndValueList *node = new (pool) AST::PropertyNameAndValueList( - sym(1).PropertyName, sym(3).Expression); - node->colonToken = loc(2); - sym(1).Node = node; -} break; -./ - -PropertyNameAndValueList: PropertyNameAndValueList T_COMMA PropertyName T_COLON AssignmentExpression ; -/. -case $rule_number: { - AST::PropertyNameAndValueList *node = new (pool) AST::PropertyNameAndValueList( - sym(1).PropertyNameAndValueList, sym(3).PropertyName, sym(5).Expression); - node->commaToken = loc(2); - node->colonToken = loc(4); - sym(1).Node = node; -} break; -./ - -PropertyName: T_IDENTIFIER %prec SHIFT_THERE ; -/. -case $rule_number: { - AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; -./ - -PropertyName: T_SIGNAL ; -/.case $rule_number:./ - -PropertyName: T_PROPERTY ; -/. -case $rule_number: { - AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; -./ - -PropertyName: T_STRING_LITERAL ; -/. -case $rule_number: { - AST::StringLiteralPropertyName *node = new (pool) AST::StringLiteralPropertyName(stringRef(1)); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; -./ - -PropertyName: T_NUMERIC_LITERAL ; -/. -case $rule_number: { - AST::NumericLiteralPropertyName *node = new (pool) AST::NumericLiteralPropertyName(sym(1).dval); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; -./ - -PropertyName: ReservedIdentifier ; -/. -case $rule_number: { - AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; -./ - -ReservedIdentifier: T_BREAK ; -ReservedIdentifier: T_CASE ; -ReservedIdentifier: T_CATCH ; -ReservedIdentifier: T_CONTINUE ; -ReservedIdentifier: T_DEFAULT ; -ReservedIdentifier: T_DELETE ; -ReservedIdentifier: T_DO ; -ReservedIdentifier: T_ELSE ; -ReservedIdentifier: T_FALSE ; -ReservedIdentifier: T_FINALLY ; -ReservedIdentifier: T_FOR ; -ReservedIdentifier: T_FUNCTION ; -ReservedIdentifier: T_IF ; -ReservedIdentifier: T_IN ; -ReservedIdentifier: T_INSTANCEOF ; -ReservedIdentifier: T_NEW ; -ReservedIdentifier: T_NULL ; -ReservedIdentifier: T_RETURN ; -ReservedIdentifier: T_SWITCH ; -ReservedIdentifier: T_THIS ; -ReservedIdentifier: T_THROW ; -ReservedIdentifier: T_TRUE ; -ReservedIdentifier: T_TRY ; -ReservedIdentifier: T_TYPEOF ; -ReservedIdentifier: T_VAR ; -ReservedIdentifier: T_VOID ; -ReservedIdentifier: T_WHILE ; -ReservedIdentifier: T_CONST ; -ReservedIdentifier: T_DEBUGGER ; -ReservedIdentifier: T_RESERVED_WORD ; -ReservedIdentifier: T_WITH ; - -PropertyIdentifier: JsIdentifier ; -PropertyIdentifier: ReservedIdentifier ; - -MemberExpression: PrimaryExpression ; -MemberExpression: FunctionExpression ; - -MemberExpression: MemberExpression T_LBRACKET Expression T_RBRACKET ; -/. -case $rule_number: { - AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression); - node->lbracketToken = loc(2); - node->rbracketToken = loc(4); - sym(1).Node = node; -} break; -./ - -MemberExpression: MemberExpression T_DOT PropertyIdentifier ; -/. -case $rule_number: { - AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3)); - node->dotToken = loc(2); - node->identifierToken = loc(3); - sym(1).Node = node; -} break; -./ - -MemberExpression: T_NEW MemberExpression T_LPAREN ArgumentListOpt T_RPAREN ; -/. -case $rule_number: { - AST::NewMemberExpression *node = new (pool) AST::NewMemberExpression(sym(2).Expression, sym(4).ArgumentList); - node->newToken = loc(1); - node->lparenToken = loc(3); - node->rparenToken = loc(5); - sym(1).Node = node; -} break; -./ - -NewExpression: MemberExpression ; - -NewExpression: T_NEW NewExpression ; -/. -case $rule_number: { - AST::NewExpression *node = new (pool) AST::NewExpression(sym(2).Expression); - node->newToken = loc(1); - sym(1).Node = node; -} break; -./ - -CallExpression: MemberExpression T_LPAREN ArgumentListOpt T_RPAREN ; -/. -case $rule_number: { - AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; -./ - -CallExpression: CallExpression T_LPAREN ArgumentListOpt T_RPAREN ; -/. -case $rule_number: { - AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; -./ - -CallExpression: CallExpression T_LBRACKET Expression T_RBRACKET ; -/. -case $rule_number: { - AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression); - node->lbracketToken = loc(2); - node->rbracketToken = loc(4); - sym(1).Node = node; -} break; -./ - -CallExpression: CallExpression T_DOT PropertyIdentifier ; -/. -case $rule_number: { - AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3)); - node->dotToken = loc(2); - node->identifierToken = loc(3); - sym(1).Node = node; -} break; -./ - -ArgumentListOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -ArgumentListOpt: ArgumentList ; -/. -case $rule_number: { - sym(1).Node = sym(1).ArgumentList->finish(); -} break; -./ - -ArgumentList: AssignmentExpression ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::ArgumentList(sym(1).Expression); -} break; -./ - -ArgumentList: ArgumentList T_COMMA AssignmentExpression ; -/. -case $rule_number: { - AST::ArgumentList *node = new (pool) AST::ArgumentList(sym(1).ArgumentList, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -LeftHandSideExpression: NewExpression ; -LeftHandSideExpression: CallExpression ; -PostfixExpression: LeftHandSideExpression ; - -PostfixExpression: LeftHandSideExpression T_PLUS_PLUS ; -/. -case $rule_number: { - AST::PostIncrementExpression *node = new (pool) AST::PostIncrementExpression(sym(1).Expression); - node->incrementToken = loc(2); - sym(1).Node = node; -} break; -./ - -PostfixExpression: LeftHandSideExpression T_MINUS_MINUS ; -/. -case $rule_number: { - AST::PostDecrementExpression *node = new (pool) AST::PostDecrementExpression(sym(1).Expression); - node->decrementToken = loc(2); - sym(1).Node = node; -} break; -./ - -UnaryExpression: PostfixExpression ; - -UnaryExpression: T_DELETE UnaryExpression ; -/. -case $rule_number: { - AST::DeleteExpression *node = new (pool) AST::DeleteExpression(sym(2).Expression); - node->deleteToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_VOID UnaryExpression ; -/. -case $rule_number: { - AST::VoidExpression *node = new (pool) AST::VoidExpression(sym(2).Expression); - node->voidToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_TYPEOF UnaryExpression ; -/. -case $rule_number: { - AST::TypeOfExpression *node = new (pool) AST::TypeOfExpression(sym(2).Expression); - node->typeofToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_PLUS_PLUS UnaryExpression ; -/. -case $rule_number: { - AST::PreIncrementExpression *node = new (pool) AST::PreIncrementExpression(sym(2).Expression); - node->incrementToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_MINUS_MINUS UnaryExpression ; -/. -case $rule_number: { - AST::PreDecrementExpression *node = new (pool) AST::PreDecrementExpression(sym(2).Expression); - node->decrementToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_PLUS UnaryExpression ; -/. -case $rule_number: { - AST::UnaryPlusExpression *node = new (pool) AST::UnaryPlusExpression(sym(2).Expression); - node->plusToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_MINUS UnaryExpression ; -/. -case $rule_number: { - AST::UnaryMinusExpression *node = new (pool) AST::UnaryMinusExpression(sym(2).Expression); - node->minusToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_TILDE UnaryExpression ; -/. -case $rule_number: { - AST::TildeExpression *node = new (pool) AST::TildeExpression(sym(2).Expression); - node->tildeToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_NOT UnaryExpression ; -/. -case $rule_number: { - AST::NotExpression *node = new (pool) AST::NotExpression(sym(2).Expression); - node->notToken = loc(1); - sym(1).Node = node; -} break; -./ - -MultiplicativeExpression: UnaryExpression ; - -MultiplicativeExpression: MultiplicativeExpression T_STAR UnaryExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Mul, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -MultiplicativeExpression: MultiplicativeExpression T_DIVIDE_ UnaryExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Div, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -MultiplicativeExpression: MultiplicativeExpression T_REMAINDER UnaryExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Mod, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -AdditiveExpression: MultiplicativeExpression ; - -AdditiveExpression: AdditiveExpression T_PLUS MultiplicativeExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Add, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -AdditiveExpression: AdditiveExpression T_MINUS MultiplicativeExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Sub, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -ShiftExpression: AdditiveExpression ; - -ShiftExpression: ShiftExpression T_LT_LT AdditiveExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::LShift, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -ShiftExpression: ShiftExpression T_GT_GT AdditiveExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::RShift, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -ShiftExpression: ShiftExpression T_GT_GT_GT AdditiveExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::URShift, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpression: ShiftExpression ; - -RelationalExpression: RelationalExpression T_LT ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Lt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpression: RelationalExpression T_GT ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Gt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpression: RelationalExpression T_LE ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Le, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpression: RelationalExpression T_GE ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Ge, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpression: RelationalExpression T_INSTANCEOF ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::InstanceOf, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpression: RelationalExpression T_IN ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::In, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpressionNotIn: ShiftExpression ; - -RelationalExpressionNotIn: RelationalExpressionNotIn T_LT ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Lt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpressionNotIn: RelationalExpressionNotIn T_GT ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Gt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpressionNotIn: RelationalExpressionNotIn T_LE ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Le, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpressionNotIn: RelationalExpressionNotIn T_GE ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Ge, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpressionNotIn: RelationalExpressionNotIn T_INSTANCEOF ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::InstanceOf, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpression: RelationalExpression ; - -EqualityExpression: EqualityExpression T_EQ_EQ RelationalExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Equal, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpression: EqualityExpression T_NOT_EQ RelationalExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::NotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpression: EqualityExpression T_EQ_EQ_EQ RelationalExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpression: EqualityExpression T_NOT_EQ_EQ RelationalExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictNotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpressionNotIn: RelationalExpressionNotIn ; - -EqualityExpressionNotIn: EqualityExpressionNotIn T_EQ_EQ RelationalExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Equal, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpressionNotIn: EqualityExpressionNotIn T_NOT_EQ RelationalExpressionNotIn; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::NotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpressionNotIn: EqualityExpressionNotIn T_EQ_EQ_EQ RelationalExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpressionNotIn: EqualityExpressionNotIn T_NOT_EQ_EQ RelationalExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictNotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -BitwiseANDExpression: EqualityExpression ; - -BitwiseANDExpression: BitwiseANDExpression T_AND EqualityExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitAnd, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -BitwiseANDExpressionNotIn: EqualityExpressionNotIn ; - -BitwiseANDExpressionNotIn: BitwiseANDExpressionNotIn T_AND EqualityExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitAnd, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -BitwiseXORExpression: BitwiseANDExpression ; - -BitwiseXORExpression: BitwiseXORExpression T_XOR BitwiseANDExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitXor, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -BitwiseXORExpressionNotIn: BitwiseANDExpressionNotIn ; - -BitwiseXORExpressionNotIn: BitwiseXORExpressionNotIn T_XOR BitwiseANDExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitXor, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -BitwiseORExpression: BitwiseXORExpression ; - -BitwiseORExpression: BitwiseORExpression T_OR BitwiseXORExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitOr, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -BitwiseORExpressionNotIn: BitwiseXORExpressionNotIn ; - -BitwiseORExpressionNotIn: BitwiseORExpressionNotIn T_OR BitwiseXORExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitOr, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -LogicalANDExpression: BitwiseORExpression ; - -LogicalANDExpression: LogicalANDExpression T_AND_AND BitwiseORExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::And, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -LogicalANDExpressionNotIn: BitwiseORExpressionNotIn ; - -LogicalANDExpressionNotIn: LogicalANDExpressionNotIn T_AND_AND BitwiseORExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::And, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -LogicalORExpression: LogicalANDExpression ; - -LogicalORExpression: LogicalORExpression T_OR_OR LogicalANDExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Or, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -LogicalORExpressionNotIn: LogicalANDExpressionNotIn ; - -LogicalORExpressionNotIn: LogicalORExpressionNotIn T_OR_OR LogicalANDExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Or, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -ConditionalExpression: LogicalORExpression ; - -ConditionalExpression: LogicalORExpression T_QUESTION AssignmentExpression T_COLON AssignmentExpression ; -/. -case $rule_number: { - AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression, - sym(3).Expression, sym(5).Expression); - node->questionToken = loc(2); - node->colonToken = loc(4); - sym(1).Node = node; -} break; -./ - -ConditionalExpressionNotIn: LogicalORExpressionNotIn ; - -ConditionalExpressionNotIn: LogicalORExpressionNotIn T_QUESTION AssignmentExpressionNotIn T_COLON AssignmentExpressionNotIn ; -/. -case $rule_number: { - AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression, - sym(3).Expression, sym(5).Expression); - node->questionToken = loc(2); - node->colonToken = loc(4); - sym(1).Node = node; -} break; -./ - -AssignmentExpression: ConditionalExpression ; - -AssignmentExpression: LeftHandSideExpression AssignmentOperator AssignmentExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - sym(2).ival, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -AssignmentExpressionNotIn: ConditionalExpressionNotIn ; - -AssignmentExpressionNotIn: LeftHandSideExpression AssignmentOperator AssignmentExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - sym(2).ival, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -AssignmentOperator: T_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::Assign; -} break; -./ - -AssignmentOperator: T_STAR_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceMul; -} break; -./ - -AssignmentOperator: T_DIVIDE_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceDiv; -} break; -./ - -AssignmentOperator: T_REMAINDER_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceMod; -} break; -./ - -AssignmentOperator: T_PLUS_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceAdd; -} break; -./ - -AssignmentOperator: T_MINUS_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceSub; -} break; -./ - -AssignmentOperator: T_LT_LT_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceLeftShift; -} break; -./ - -AssignmentOperator: T_GT_GT_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceRightShift; -} break; -./ - -AssignmentOperator: T_GT_GT_GT_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceURightShift; -} break; -./ - -AssignmentOperator: T_AND_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceAnd; -} break; -./ - -AssignmentOperator: T_XOR_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceXor; -} break; -./ - -AssignmentOperator: T_OR_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceOr; -} break; -./ - -Expression: AssignmentExpression ; - -Expression: Expression T_COMMA AssignmentExpression ; -/. -case $rule_number: { - AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -ExpressionOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -ExpressionOpt: Expression ; - -ExpressionNotIn: AssignmentExpressionNotIn ; - -ExpressionNotIn: ExpressionNotIn T_COMMA AssignmentExpressionNotIn ; -/. -case $rule_number: { - AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -ExpressionNotInOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -ExpressionNotInOpt: ExpressionNotIn ; - -Statement: Block ; -Statement: VariableStatement ; -Statement: EmptyStatement ; -Statement: ExpressionStatement ; -Statement: IfStatement ; -Statement: IterationStatement ; -Statement: ContinueStatement ; -Statement: BreakStatement ; -Statement: ReturnStatement ; -Statement: WithStatement ; -Statement: LabelledStatement ; -Statement: SwitchStatement ; -Statement: ThrowStatement ; -Statement: TryStatement ; -Statement: DebuggerStatement ; - - -Block: T_LBRACE StatementListOpt T_RBRACE ; -/. -case $rule_number: { - AST::Block *node = new (pool) AST::Block(sym(2).StatementList); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; -./ - -StatementList: Statement ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::StatementList(sym(1).Statement); -} break; -./ - -StatementList: StatementList Statement ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::StatementList(sym(1).StatementList, sym(2).Statement); -} break; -./ - -StatementListOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -StatementListOpt: StatementList ; -/. -case $rule_number: { - sym(1).Node = sym(1).StatementList->finish (); -} break; -./ - -VariableStatement: VariableDeclarationKind VariableDeclarationList T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -VariableStatement: VariableDeclarationKind VariableDeclarationList T_SEMICOLON ; -/. -case $rule_number: { - AST::VariableStatement *node = new (pool) AST::VariableStatement( - sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST)); - node->declarationKindToken = loc(1); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; -./ - -VariableDeclarationKind: T_CONST ; -/. -case $rule_number: { - sym(1).ival = T_CONST; -} break; -./ - -VariableDeclarationKind: T_VAR ; -/. -case $rule_number: { - sym(1).ival = T_VAR; -} break; -./ - -VariableDeclarationList: VariableDeclaration ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); -} break; -./ - -VariableDeclarationList: VariableDeclarationList T_COMMA VariableDeclaration ; -/. -case $rule_number: { - AST::VariableDeclarationList *node = new (pool) AST::VariableDeclarationList( - sym(1).VariableDeclarationList, sym(3).VariableDeclaration); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -VariableDeclarationListNotIn: VariableDeclarationNotIn ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); -} break; -./ - -VariableDeclarationListNotIn: VariableDeclarationListNotIn T_COMMA VariableDeclarationNotIn ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclarationList, sym(3).VariableDeclaration); -} break; -./ - -VariableDeclaration: JsIdentifier InitialiserOpt ; -/. -case $rule_number: { - AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; -./ - -VariableDeclarationNotIn: JsIdentifier InitialiserNotInOpt ; -/. -case $rule_number: { - AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; -./ - -Initialiser: T_EQ AssignmentExpression ; -/. -case $rule_number: { - // ### TODO: AST for initializer - sym(1) = sym(2); -} break; -./ - -InitialiserOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -InitialiserOpt: Initialiser ; - -InitialiserNotIn: T_EQ AssignmentExpressionNotIn ; -/. -case $rule_number: { - // ### TODO: AST for initializer - sym(1) = sym(2); -} break; -./ - -InitialiserNotInOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -InitialiserNotInOpt: InitialiserNotIn ; - -EmptyStatement: T_SEMICOLON ; -/. -case $rule_number: { - AST::EmptyStatement *node = new (pool) AST::EmptyStatement(); - node->semicolonToken = loc(1); - sym(1).Node = node; -} break; -./ - -ExpressionStatement: Expression T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -ExpressionStatement: Expression T_SEMICOLON ; -/. -case $rule_number: { - AST::ExpressionStatement *node = new (pool) AST::ExpressionStatement(sym(1).Expression); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; -./ - -IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement T_ELSE Statement ; -/. -case $rule_number: { - AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement, sym(7).Statement); - node->ifToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - node->elseToken = loc(6); - sym(1).Node = node; -} break; -./ - -IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement ; -/. -case $rule_number: { - AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement); - node->ifToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; -./ - - -IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_SEMICOLON ; -/. -case $rule_number: { - AST::DoWhileStatement *node = new (pool) AST::DoWhileStatement(sym(2).Statement, sym(5).Expression); - node->doToken = loc(1); - node->whileToken = loc(3); - node->lparenToken = loc(4); - node->rparenToken = loc(6); - node->semicolonToken = loc(7); - sym(1).Node = node; -} break; -./ - -IterationStatement: T_WHILE T_LPAREN Expression T_RPAREN Statement ; -/. -case $rule_number: { - AST::WhileStatement *node = new (pool) AST::WhileStatement(sym(3).Expression, sym(5).Statement); - node->whileToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; -./ - -IterationStatement: T_FOR T_LPAREN ExpressionNotInOpt T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ; -/. -case $rule_number: { - AST::ForStatement *node = new (pool) AST::ForStatement(sym(3).Expression, - sym(5).Expression, sym(7).Expression, sym(9).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->firstSemicolonToken = loc(4); - node->secondSemicolonToken = loc(6); - node->rparenToken = loc(8); - sym(1).Node = node; -} break; -./ - -IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationListNotIn T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ; -/. -case $rule_number: { - AST::LocalForStatement *node = new (pool) AST::LocalForStatement( - sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression, - sym(8).Expression, sym(10).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->varToken = loc(3); - node->firstSemicolonToken = loc(5); - node->secondSemicolonToken = loc(7); - node->rparenToken = loc(9); - sym(1).Node = node; -} break; -./ - -IterationStatement: T_FOR T_LPAREN LeftHandSideExpression T_IN Expression T_RPAREN Statement ; -/. -case $rule_number: { - AST:: ForEachStatement *node = new (pool) AST::ForEachStatement(sym(3).Expression, - sym(5).Expression, sym(7).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->inToken = loc(4); - node->rparenToken = loc(6); - sym(1).Node = node; -} break; -./ - -IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationNotIn T_IN Expression T_RPAREN Statement ; -/. -case $rule_number: { - AST::LocalForEachStatement *node = new (pool) AST::LocalForEachStatement( - sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->varToken = loc(3); - node->inToken = loc(5); - node->rparenToken = loc(7); - sym(1).Node = node; -} break; -./ - -ContinueStatement: T_CONTINUE T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -ContinueStatement: T_CONTINUE T_SEMICOLON ; -/. -case $rule_number: { - AST::ContinueStatement *node = new (pool) AST::ContinueStatement(); - node->continueToken = loc(1); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; -./ - -ContinueStatement: T_CONTINUE JsIdentifier T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -ContinueStatement: T_CONTINUE JsIdentifier T_SEMICOLON ; -/. -case $rule_number: { - AST::ContinueStatement *node = new (pool) AST::ContinueStatement(stringRef(2)); - node->continueToken = loc(1); - node->identifierToken = loc(2); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; -./ - -BreakStatement: T_BREAK T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -BreakStatement: T_BREAK T_SEMICOLON ; -/. -case $rule_number: { - AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringRef()); - node->breakToken = loc(1); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; -./ - -BreakStatement: T_BREAK JsIdentifier T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -BreakStatement: T_BREAK JsIdentifier T_SEMICOLON ; -/. -case $rule_number: { - AST::BreakStatement *node = new (pool) AST::BreakStatement(stringRef(2)); - node->breakToken = loc(1); - node->identifierToken = loc(2); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; -./ - -ReturnStatement: T_RETURN ExpressionOpt T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -ReturnStatement: T_RETURN ExpressionOpt T_SEMICOLON ; -/. -case $rule_number: { - AST::ReturnStatement *node = new (pool) AST::ReturnStatement(sym(2).Expression); - node->returnToken = loc(1); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; -./ - -WithStatement: T_WITH T_LPAREN Expression T_RPAREN Statement ; -/. -case $rule_number: { - AST::WithStatement *node = new (pool) AST::WithStatement(sym(3).Expression, sym(5).Statement); - node->withToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; -./ - -SwitchStatement: T_SWITCH T_LPAREN Expression T_RPAREN CaseBlock ; -/. -case $rule_number: { - AST::SwitchStatement *node = new (pool) AST::SwitchStatement(sym(3).Expression, sym(5).CaseBlock); - node->switchToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; -./ - -CaseBlock: T_LBRACE CaseClausesOpt T_RBRACE ; -/. -case $rule_number: { - AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; -./ - -CaseBlock: T_LBRACE CaseClausesOpt DefaultClause CaseClausesOpt T_RBRACE ; -/. -case $rule_number: { - AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses); - node->lbraceToken = loc(1); - node->rbraceToken = loc(5); - sym(1).Node = node; -} break; -./ - -CaseClauses: CaseClause ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClause); -} break; -./ - -CaseClauses: CaseClauses CaseClause ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClauses, sym(2).CaseClause); -} break; -./ - -CaseClausesOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -CaseClausesOpt: CaseClauses ; -/. -case $rule_number: { - sym(1).Node = sym(1).CaseClauses->finish (); -} break; -./ - -CaseClause: T_CASE Expression T_COLON StatementListOpt ; -/. -case $rule_number: { - AST::CaseClause *node = new (pool) AST::CaseClause(sym(2).Expression, sym(4).StatementList); - node->caseToken = loc(1); - node->colonToken = loc(3); - sym(1).Node = node; -} break; -./ - -DefaultClause: T_DEFAULT T_COLON StatementListOpt ; -/. -case $rule_number: { - AST::DefaultClause *node = new (pool) AST::DefaultClause(sym(3).StatementList); - node->defaultToken = loc(1); - node->colonToken = loc(2); - sym(1).Node = node; -} break; -./ - -LabelledStatement: T_SIGNAL T_COLON Statement ; -/.case $rule_number:./ - -LabelledStatement: T_PROPERTY T_COLON Statement ; -/. -case $rule_number: { - AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement); - node->identifierToken = loc(1); - node->colonToken = loc(2); - sym(1).Node = node; -} break; -./ - -LabelledStatement: T_IDENTIFIER T_COLON Statement ; -/. -case $rule_number: { - AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement); - node->identifierToken = loc(1); - node->colonToken = loc(2); - sym(1).Node = node; -} break; -./ - -ThrowStatement: T_THROW Expression T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -ThrowStatement: T_THROW Expression T_SEMICOLON ; -/. -case $rule_number: { - AST::ThrowStatement *node = new (pool) AST::ThrowStatement(sym(2).Expression); - node->throwToken = loc(1); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; -./ - -TryStatement: T_TRY Block Catch ; -/. -case $rule_number: { - AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch); - node->tryToken = loc(1); - sym(1).Node = node; -} break; -./ - -TryStatement: T_TRY Block Finally ; -/. -case $rule_number: { - AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Finally); - node->tryToken = loc(1); - sym(1).Node = node; -} break; -./ - -TryStatement: T_TRY Block Catch Finally ; -/. -case $rule_number: { - AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch, sym(4).Finally); - node->tryToken = loc(1); - sym(1).Node = node; -} break; -./ - -Catch: T_CATCH T_LPAREN JsIdentifier T_RPAREN Block ; -/. -case $rule_number: { - AST::Catch *node = new (pool) AST::Catch(stringRef(3), sym(5).Block); - node->catchToken = loc(1); - node->lparenToken = loc(2); - node->identifierToken = loc(3); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; -./ - -Finally: T_FINALLY Block ; -/. -case $rule_number: { - AST::Finally *node = new (pool) AST::Finally(sym(2).Block); - node->finallyToken = loc(1); - sym(1).Node = node; -} break; -./ - -DebuggerStatement: T_DEBUGGER T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -DebuggerStatement: T_DEBUGGER T_SEMICOLON ; -/. -case $rule_number: { - AST::DebuggerStatement *node = new (pool) AST::DebuggerStatement(); - node->debuggerToken = loc(1); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; -./ - -FunctionDeclaration: T_FUNCTION JsIdentifier T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ; -/. -case $rule_number: { - AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); - node->functionToken = loc(1); - node->identifierToken = loc(2); - node->lparenToken = loc(3); - node->rparenToken = loc(5); - node->lbraceToken = loc(6); - node->rbraceToken = loc(8); - sym(1).Node = node; -} break; -./ - -FunctionExpression: T_FUNCTION IdentifierOpt T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ; -/. -case $rule_number: { - AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); - node->functionToken = loc(1); - if (! stringRef(2).isNull()) - node->identifierToken = loc(2); - node->lparenToken = loc(3); - node->rparenToken = loc(5); - node->lbraceToken = loc(6); - node->rbraceToken = loc(8); - sym(1).Node = node; -} break; -./ - -FormalParameterList: JsIdentifier ; -/. -case $rule_number: { - AST::FormalParameterList *node = new (pool) AST::FormalParameterList(stringRef(1)); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; -./ - -FormalParameterList: FormalParameterList T_COMMA JsIdentifier ; -/. -case $rule_number: { - AST::FormalParameterList *node = new (pool) AST::FormalParameterList(sym(1).FormalParameterList, stringRef(3)); - node->commaToken = loc(2); - node->identifierToken = loc(3); - sym(1).Node = node; -} break; -./ - -FormalParameterListOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -FormalParameterListOpt: FormalParameterList ; -/. -case $rule_number: { - sym(1).Node = sym(1).FormalParameterList->finish (); -} break; -./ - -FunctionBodyOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -FunctionBodyOpt: FunctionBody ; - -FunctionBody: SourceElements ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::FunctionBody(sym(1).SourceElements->finish ()); -} break; -./ - -Program: Empty ; - -Program: SourceElements ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::Program(sym(1).SourceElements->finish ()); -} break; -./ - -SourceElements: SourceElement ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElement); -} break; -./ - -SourceElements: SourceElements SourceElement ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElements, sym(2).SourceElement); -} break; -./ - -SourceElement: Statement ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::StatementSourceElement(sym(1).Statement); -} break; -./ - -SourceElement: FunctionDeclaration ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::FunctionSourceElement(sym(1).FunctionDeclaration); -} break; -./ - -IdentifierOpt: ; -/. -case $rule_number: { - stringRef(1) = QStringRef(); -} break; -./ - -IdentifierOpt: JsIdentifier ; - -PropertyNameAndValueListOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -PropertyNameAndValueListOpt: PropertyNameAndValueList ; - -/. - } // switch - action = nt_action(state_stack[tos], lhs[r] - TERMINAL_COUNT); - } // if - } while (action != 0); - - if (first_token == last_token) { - const int errorState = state_stack[tos]; - - // automatic insertion of `;' - if (yytoken != -1 && t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken)) { - SavedToken &tk = token_buffer[0]; - tk.token = yytoken; - tk.dval = yylval; - tk.spell = yytokenspell; - tk.loc = yylloc; - - yylloc = yyprevlloc; - yylloc.offset += yylloc.length; - yylloc.startColumn += yylloc.length; - yylloc.length = 0; - - //const QString msg = qApp->translate("QDeclarativeParser", "Missing `;'"); - //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg)); - - first_token = &token_buffer[0]; - last_token = &token_buffer[1]; - - yytoken = T_SEMICOLON; - yylval = 0; - - action = errorState; - - goto _Lcheck_token; - } - - hadErrors = true; - - token_buffer[0].token = yytoken; - token_buffer[0].dval = yylval; - token_buffer[0].spell = yytokenspell; - token_buffer[0].loc = yylloc; - - token_buffer[1].token = yytoken = lexer->lex(); - token_buffer[1].dval = yylval = lexer->tokenValue(); - token_buffer[1].spell = yytokenspell = lexer->tokenSpell(); - token_buffer[1].loc = yylloc = location(lexer); - - if (t_action(errorState, yytoken)) { - QString msg; - int token = token_buffer[0].token; - if (token < 0 || token >= TERMINAL_COUNT) - msg = qApp->translate("QDeclarativeParser", "Syntax error"); - else - msg = qApp->translate("QDeclarativeParser", "Unexpected token `%1'").arg(QLatin1String(spell[token])); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - - action = errorState; - goto _Lcheck_token; - } - - static int tokens[] = { - T_PLUS, - T_EQ, - - T_COMMA, - T_COLON, - T_SEMICOLON, - - T_RPAREN, T_RBRACKET, T_RBRACE, - - T_NUMERIC_LITERAL, - T_IDENTIFIER, - - T_LPAREN, T_LBRACKET, T_LBRACE, - - EOF_SYMBOL - }; - - for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) { - int a = t_action(errorState, *tk); - if (a > 0 && t_action(a, yytoken)) { - const QString msg = qApp->translate("QDeclarativeParser", "Expected token `%1'").arg(QLatin1String(spell[*tk])); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - - yytoken = *tk; - yylval = 0; - yylloc = token_buffer[0].loc; - yylloc.length = 0; - - first_token = &token_buffer[0]; - last_token = &token_buffer[2]; - - action = errorState; - goto _Lcheck_token; - } - } - - for (int tk = 1; tk < TERMINAL_COUNT; ++tk) { - if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM || - tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION || - tk == T_FEED_JS_SOURCE_ELEMENT) - continue; - - int a = t_action(errorState, tk); - if (a > 0 && t_action(a, yytoken)) { - const QString msg = qApp->translate("QDeclarativeParser", "Expected token `%1'").arg(QLatin1String(spell[tk])); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - - yytoken = tk; - yylval = 0; - yylloc = token_buffer[0].loc; - yylloc.length = 0; - - action = errorState; - goto _Lcheck_token; - } - } - - const QString msg = qApp->translate("QDeclarativeParser", "Syntax error"); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - } - - return false; -} - -QT_QML_END_NAMESPACE - - -./ -/: -QT_QML_END_NAMESPACE - - - -#endif // QDECLARATIVEJSPARSER_P_H -:/ diff --git a/src/declarative/qml/parser/qdeclarativejsast.cpp b/src/declarative/qml/parser/qdeclarativejsast.cpp deleted file mode 100644 index 8654c4392f..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsast.cpp +++ /dev/null @@ -1,931 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativejsast_p.h" - -#include "qdeclarativejsastvisitor_p.h" - -QT_QML_BEGIN_NAMESPACE - -namespace QDeclarativeJS { 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; -} - -BinaryExpression *Node::binaryExpressionCast() -{ - return 0; -} - -Statement *Node::statementCast() -{ - return 0; -} - -UiObjectMember *Node::uiObjectMemberCast() -{ - return 0; -} - -ExpressionNode *ExpressionNode::expressionCast() -{ - return this; -} - -BinaryExpression *BinaryExpression::binaryExpressionCast() -{ - return this; -} - -Statement *Statement::statementCast() -{ - return this; -} - -UiObjectMember *UiObjectMember::uiObjectMemberCast() -{ - return this; -} - -void NestedExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - visitor->endVisit(this); -} - -void ThisExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void IdentifierExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void NullExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void TrueLiteral::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void FalseLiteral::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void StringLiteral::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void NumericLiteral::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void RegExpLiteral::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void ArrayLiteral::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(elements, visitor); - accept(elision, visitor); - } - - visitor->endVisit(this); -} - -void ObjectLiteral::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(properties, visitor); - } - - visitor->endVisit(this); -} - -void ElementList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (ElementList *it = this; it; it = it->next) { - accept(it->elision, visitor); - accept(it->expression, visitor); - } - } - - visitor->endVisit(this); -} - -void Elision::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - // ### - } - - visitor->endVisit(this); -} - -void PropertyNameAndValueList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (PropertyNameAndValueList *it = this; it; it = it->next) { - accept(it->name, visitor); - accept(it->value, visitor); - } - } - - visitor->endVisit(this); -} - -void IdentifierPropertyName::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void StringLiteralPropertyName::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void NumericLiteralPropertyName::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void ArrayMemberExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(base, visitor); - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void FieldMemberExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(base, visitor); - } - - visitor->endVisit(this); -} - -void NewMemberExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(base, visitor); - accept(arguments, visitor); - } - - visitor->endVisit(this); -} - -void NewExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void CallExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(base, visitor); - accept(arguments, visitor); - } - - visitor->endVisit(this); -} - -void ArgumentList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (ArgumentList *it = this; it; it = it->next) { - accept(it->expression, visitor); - } - } - - visitor->endVisit(this); -} - -void PostIncrementExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(base, visitor); - } - - visitor->endVisit(this); -} - -void PostDecrementExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(base, visitor); - } - - visitor->endVisit(this); -} - -void DeleteExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void VoidExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void TypeOfExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void PreIncrementExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void PreDecrementExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void UnaryPlusExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void UnaryMinusExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void TildeExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void NotExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void BinaryExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(left, visitor); - accept(right, visitor); - } - - visitor->endVisit(this); -} - -void ConditionalExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - accept(ok, visitor); - accept(ko, visitor); - } - - visitor->endVisit(this); -} - -void Expression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(left, visitor); - accept(right, visitor); - } - - visitor->endVisit(this); -} - -void Block::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statements, visitor); - } - - visitor->endVisit(this); -} - -void StatementList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (StatementList *it = this; it; it = it->next) { - accept(it->statement, visitor); - } - } - - visitor->endVisit(this); -} - -void VariableStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(declarations, visitor); - } - - visitor->endVisit(this); -} - -void VariableDeclarationList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (VariableDeclarationList *it = this; it; it = it->next) { - accept(it->declaration, visitor); - } - } - - visitor->endVisit(this); -} - -void VariableDeclaration::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void EmptyStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void ExpressionStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void IfStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - accept(ok, visitor); - accept(ko, visitor); - } - - visitor->endVisit(this); -} - -void DoWhileStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statement, visitor); - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void WhileStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void ForStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(initialiser, visitor); - accept(condition, visitor); - accept(expression, visitor); - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void LocalForStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(declarations, visitor); - accept(condition, visitor); - accept(expression, visitor); - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void ForEachStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(initialiser, visitor); - accept(expression, visitor); - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void LocalForEachStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(declaration, visitor); - accept(expression, visitor); - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void ContinueStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void BreakStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void ReturnStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void WithStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void SwitchStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - accept(block, visitor); - } - - visitor->endVisit(this); -} - -void CaseBlock::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(clauses, visitor); - accept(defaultClause, visitor); - accept(moreClauses, visitor); - } - - visitor->endVisit(this); -} - -void CaseClauses::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (CaseClauses *it = this; it; it = it->next) { - accept(it->clause, visitor); - } - } - - visitor->endVisit(this); -} - -void CaseClause::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - accept(statements, visitor); - } - - visitor->endVisit(this); -} - -void DefaultClause::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statements, visitor); - } - - visitor->endVisit(this); -} - -void LabelledStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void ThrowStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void TryStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statement, visitor); - accept(catchExpression, visitor); - accept(finallyExpression, visitor); - } - - visitor->endVisit(this); -} - -void Catch::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void Finally::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void FunctionDeclaration::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(formals, visitor); - accept(body, visitor); - } - - visitor->endVisit(this); -} - -void FunctionExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(formals, visitor); - accept(body, visitor); - } - - visitor->endVisit(this); -} - -void FormalParameterList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - // ### - } - - visitor->endVisit(this); -} - -void FunctionBody::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(elements, visitor); - } - - visitor->endVisit(this); -} - -void Program::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(elements, visitor); - } - - visitor->endVisit(this); -} - -void SourceElements::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (SourceElements *it = this; it; it = it->next) { - accept(it->element, visitor); - } - } - - visitor->endVisit(this); -} - -void FunctionSourceElement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(declaration, visitor); - } - - visitor->endVisit(this); -} - -void StatementSourceElement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void DebuggerStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void UiProgram::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(imports, visitor); - accept(members, visitor); - } - - visitor->endVisit(this); -} - -void UiPublicMember::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statement, visitor); - accept(binding, visitor); - } - - visitor->endVisit(this); -} - -void UiObjectDefinition::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(qualifiedTypeNameId, visitor); - accept(initializer, visitor); - } - - visitor->endVisit(this); -} - -void UiObjectInitializer::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(members, visitor); - } - - visitor->endVisit(this); -} - -void UiObjectBinding::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(qualifiedId, visitor); - accept(qualifiedTypeNameId, visitor); - accept(initializer, visitor); - } - - visitor->endVisit(this); -} - -void UiScriptBinding::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(qualifiedId, visitor); - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void UiArrayBinding::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(qualifiedId, visitor); - accept(members, visitor); - } - - visitor->endVisit(this); -} - -void UiObjectMemberList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (UiObjectMemberList *it = this; it; it = it->next) - accept(it->member, visitor); - } - - visitor->endVisit(this); -} - -void UiArrayMemberList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (UiArrayMemberList *it = this; it; it = it->next) - accept(it->member, visitor); - } - - visitor->endVisit(this); -} - -void UiQualifiedId::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void UiImport::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(importUri, visitor); - } - - visitor->endVisit(this); -} - -void UiImportList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(import, visitor); - accept(next, visitor); - } - - visitor->endVisit(this); -} - -void UiSourceElement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(sourceElement, visitor); - } - - visitor->endVisit(this); -} - -} } // namespace QDeclarativeJS::AST - -QT_QML_END_NAMESPACE - - diff --git a/src/declarative/qml/parser/qdeclarativejsast_p.h b/src/declarative/qml/parser/qdeclarativejsast_p.h deleted file mode 100644 index 04bf3ce122..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsast_p.h +++ /dev/null @@ -1,2640 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEJSAST_P_H -#define QDECLARATIVEJSAST_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 "qdeclarativejsastvisitor_p.h" -#include "qdeclarativejsglobal_p.h" -#include "qdeclarativejsmemorypool_p.h" - -#include - -QT_QML_BEGIN_NAMESPACE - -#define QDECLARATIVEJS_DECLARE_AST_NODE(name) \ - enum { K = Kind_##name }; - -namespace QSOperator // ### rename -{ - -enum Op { - Add, - And, - InplaceAnd, - Assign, - BitAnd, - BitOr, - BitXor, - InplaceSub, - Div, - InplaceDiv, - Equal, - Ge, - Gt, - In, - InplaceAdd, - InstanceOf, - Le, - LShift, - InplaceLeftShift, - Lt, - Mod, - InplaceMod, - Mul, - InplaceMul, - NotEqual, - Or, - InplaceOr, - RShift, - InplaceRightShift, - StrictEqual, - StrictNotEqual, - Sub, - URShift, - InplaceURightShift, - InplaceXor -}; - -} // namespace QSOperator - -namespace QDeclarativeJS { - -namespace AST { - -template -_T1 cast(_T2 *ast) -{ - if (ast && ast->kind == static_cast<_T1>(0)->K) - return static_cast<_T1>(ast); - - return 0; -} - -class QML_PARSER_EXPORT Node: public Managed -{ -public: - enum Kind { - Kind_Undefined, - - Kind_ArgumentList, - Kind_ArrayLiteral, - Kind_ArrayMemberExpression, - Kind_BinaryExpression, - Kind_Block, - Kind_BreakStatement, - Kind_CallExpression, - Kind_CaseBlock, - Kind_CaseClause, - Kind_CaseClauses, - Kind_Catch, - Kind_ConditionalExpression, - Kind_ContinueStatement, - Kind_DebuggerStatement, - Kind_DefaultClause, - Kind_DeleteExpression, - Kind_DoWhileStatement, - Kind_ElementList, - Kind_Elision, - Kind_EmptyStatement, - Kind_Expression, - Kind_ExpressionStatement, - Kind_FalseLiteral, - Kind_FieldMemberExpression, - Kind_Finally, - Kind_ForEachStatement, - Kind_ForStatement, - Kind_FormalParameterList, - Kind_FunctionBody, - Kind_FunctionDeclaration, - Kind_FunctionExpression, - Kind_FunctionSourceElement, - Kind_IdentifierExpression, - Kind_IdentifierPropertyName, - Kind_IfStatement, - Kind_LabelledStatement, - Kind_LocalForEachStatement, - Kind_LocalForStatement, - Kind_NewExpression, - Kind_NewMemberExpression, - Kind_NotExpression, - Kind_NullExpression, - Kind_NumericLiteral, - Kind_NumericLiteralPropertyName, - Kind_ObjectLiteral, - Kind_PostDecrementExpression, - Kind_PostIncrementExpression, - Kind_PreDecrementExpression, - Kind_PreIncrementExpression, - Kind_Program, - Kind_PropertyName, - Kind_PropertyNameAndValueList, - Kind_RegExpLiteral, - Kind_ReturnStatement, - Kind_SourceElement, - Kind_SourceElements, - Kind_StatementList, - Kind_StatementSourceElement, - Kind_StringLiteral, - Kind_StringLiteralPropertyName, - Kind_SwitchStatement, - Kind_ThisExpression, - Kind_ThrowStatement, - Kind_TildeExpression, - Kind_TrueLiteral, - Kind_TryStatement, - Kind_TypeOfExpression, - Kind_UnaryMinusExpression, - Kind_UnaryPlusExpression, - Kind_VariableDeclaration, - Kind_VariableDeclarationList, - Kind_VariableStatement, - Kind_VoidExpression, - Kind_WhileStatement, - Kind_WithStatement, - Kind_NestedExpression, - - Kind_UiArrayBinding, - Kind_UiImport, - Kind_UiImportList, - Kind_UiObjectBinding, - Kind_UiObjectDefinition, - Kind_UiObjectInitializer, - Kind_UiObjectMemberList, - Kind_UiArrayMemberList, - Kind_UiProgram, - Kind_UiParameterList, - Kind_UiPublicMember, - Kind_UiQualifiedId, - Kind_UiScriptBinding, - Kind_UiSourceElement - }; - - inline Node() - : kind(Kind_Undefined) {} - - // NOTE: node destructors are never called, - // instead we block free the memory - // (see the NodePool class) - virtual ~Node() {} - - virtual ExpressionNode *expressionCast(); - virtual BinaryExpression *binaryExpressionCast(); - virtual Statement *statementCast(); - virtual UiObjectMember *uiObjectMemberCast(); - - void accept(Visitor *visitor); - static void accept(Node *node, Visitor *visitor); - - inline static void acceptChild(Node *node, Visitor *visitor) - { return accept(node, visitor); } // ### remove - - virtual void accept0(Visitor *visitor) = 0; - virtual SourceLocation firstSourceLocation() const = 0; - virtual SourceLocation lastSourceLocation() const = 0; - -// attributes - int kind; -}; - -class QML_PARSER_EXPORT ExpressionNode: public Node -{ -public: - ExpressionNode() {} - - virtual ExpressionNode *expressionCast(); -}; - -class QML_PARSER_EXPORT Statement: public Node -{ -public: - Statement() {} - - virtual Statement *statementCast(); -}; - -class QML_PARSER_EXPORT NestedExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(NestedExpression) - - NestedExpression(ExpressionNode *expression) - : expression(expression) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return lparenToken; } - - virtual SourceLocation lastSourceLocation() const - { return rparenToken; } - -// attributes - ExpressionNode *expression; - SourceLocation lparenToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT ThisExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ThisExpression) - - ThisExpression() { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return thisToken; } - - virtual SourceLocation lastSourceLocation() const - { return thisToken; } - -// attributes - SourceLocation thisToken; -}; - -class QML_PARSER_EXPORT IdentifierExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(IdentifierExpression) - - IdentifierExpression(const QStringRef &n): - name (n) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return identifierToken; } - -// attributes - QStringRef name; - SourceLocation identifierToken; -}; - -class QML_PARSER_EXPORT NullExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(NullExpression) - - NullExpression() { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return nullToken; } - - virtual SourceLocation lastSourceLocation() const - { return nullToken; } - -// attributes - SourceLocation nullToken; -}; - -class QML_PARSER_EXPORT TrueLiteral: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(TrueLiteral) - - TrueLiteral() { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return trueToken; } - - virtual SourceLocation lastSourceLocation() const - { return trueToken; } - -// attributes - SourceLocation trueToken; -}; - -class QML_PARSER_EXPORT FalseLiteral: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(FalseLiteral) - - FalseLiteral() { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return falseToken; } - - virtual SourceLocation lastSourceLocation() const - { return falseToken; } - -// attributes - SourceLocation falseToken; -}; - -class QML_PARSER_EXPORT NumericLiteral: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(NumericLiteral) - - NumericLiteral(double v): - value(v) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return literalToken; } - - virtual SourceLocation lastSourceLocation() const - { return literalToken; } - -// attributes: - double value; - SourceLocation literalToken; -}; - -class QML_PARSER_EXPORT StringLiteral: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(StringLiteral) - - StringLiteral(const QStringRef &v): - value (v) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return literalToken; } - - virtual SourceLocation lastSourceLocation() const - { return literalToken; } - -// attributes: - QStringRef value; - SourceLocation literalToken; -}; - -class QML_PARSER_EXPORT RegExpLiteral: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(RegExpLiteral) - - RegExpLiteral(const QStringRef &p, int f): - pattern (p), flags (f) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return literalToken; } - - virtual SourceLocation lastSourceLocation() const - { return literalToken; } - -// attributes: - QStringRef pattern; - int flags; - SourceLocation literalToken; -}; - -class QML_PARSER_EXPORT ArrayLiteral: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ArrayLiteral) - - ArrayLiteral(Elision *e): - elements (0), elision (e) - { kind = K; } - - ArrayLiteral(ElementList *elts): - elements (elts), elision (0) - { kind = K; } - - ArrayLiteral(ElementList *elts, Elision *e): - elements (elts), elision (e) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return lbracketToken; } - - virtual SourceLocation lastSourceLocation() const - { return rbracketToken; } - -// attributes - ElementList *elements; - Elision *elision; - SourceLocation lbracketToken; - SourceLocation commaToken; - SourceLocation rbracketToken; -}; - -class QML_PARSER_EXPORT ObjectLiteral: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ObjectLiteral) - - ObjectLiteral(): - properties (0) { kind = K; } - - ObjectLiteral(PropertyNameAndValueList *plist): - properties (plist) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return lbraceToken; } - - virtual SourceLocation lastSourceLocation() const - { return rbraceToken; } - -// attributes - PropertyNameAndValueList *properties; - SourceLocation lbraceToken; - SourceLocation rbraceToken; -}; - -class QML_PARSER_EXPORT Elision: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(Elision) - - Elision(): - next (this) { kind = K; } - - Elision(Elision *previous) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return commaToken; } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : commaToken; } - - inline Elision *finish () - { - Elision *front = next; - next = 0; - return front; - } - -// attributes - Elision *next; - SourceLocation commaToken; -}; - -class QML_PARSER_EXPORT ElementList: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ElementList) - - ElementList(Elision *e, ExpressionNode *expr): - elision (e), expression (expr), next (this) - { kind = K; } - - ElementList(ElementList *previous, Elision *e, ExpressionNode *expr): - elision (e), expression (expr) - { - kind = K; - next = previous->next; - previous->next = this; - } - - inline ElementList *finish () - { - ElementList *front = next; - next = 0; - return front; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { - if (elision) - return elision->firstSourceLocation(); - return expression->firstSourceLocation(); - } - - virtual SourceLocation lastSourceLocation() const - { - if (next) - return next->lastSourceLocation(); - return expression->lastSourceLocation(); - } - -// attributes - Elision *elision; - ExpressionNode *expression; - ElementList *next; - SourceLocation commaToken; -}; - -class QML_PARSER_EXPORT PropertyName: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(PropertyName) - - PropertyName() { kind = K; } - - virtual SourceLocation firstSourceLocation() const - { return propertyNameToken; } - - virtual SourceLocation lastSourceLocation() const - { return propertyNameToken; } - -// attributes - SourceLocation propertyNameToken; -}; - -class QML_PARSER_EXPORT PropertyNameAndValueList: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(PropertyNameAndValueList) - - PropertyNameAndValueList(PropertyName *n, ExpressionNode *v): - name (n), value (v), next (this) - { kind = K; } - - PropertyNameAndValueList(PropertyNameAndValueList *previous, PropertyName *n, ExpressionNode *v): - name (n), value (v) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return name->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { - if (next) - return next->lastSourceLocation(); - return value->lastSourceLocation(); - } - - inline PropertyNameAndValueList *finish () - { - PropertyNameAndValueList *front = next; - next = 0; - return front; - } - -// attributes - PropertyName *name; - ExpressionNode *value; - PropertyNameAndValueList *next; - SourceLocation colonToken; - SourceLocation commaToken; -}; - -class QML_PARSER_EXPORT IdentifierPropertyName: public PropertyName -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(IdentifierPropertyName) - - IdentifierPropertyName(const QStringRef &n): - id (n) { kind = K; } - - virtual void accept0(Visitor *visitor); - -// attributes - QStringRef id; -}; - -class QML_PARSER_EXPORT StringLiteralPropertyName: public PropertyName -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(StringLiteralPropertyName) - - StringLiteralPropertyName(const QStringRef &n): - id (n) { kind = K; } - - virtual void accept0(Visitor *visitor); - -// attributes - QStringRef id; -}; - -class QML_PARSER_EXPORT NumericLiteralPropertyName: public PropertyName -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(NumericLiteralPropertyName) - - NumericLiteralPropertyName(double n): - id (n) { kind = K; } - - virtual void accept0(Visitor *visitor); - -// attributes - double id; -}; - -class QML_PARSER_EXPORT ArrayMemberExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ArrayMemberExpression) - - ArrayMemberExpression(ExpressionNode *b, ExpressionNode *e): - base (b), expression (e) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return base->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return rbracketToken; } - -// attributes - ExpressionNode *base; - ExpressionNode *expression; - SourceLocation lbracketToken; - SourceLocation rbracketToken; -}; - -class QML_PARSER_EXPORT FieldMemberExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(FieldMemberExpression) - - FieldMemberExpression(ExpressionNode *b, const QStringRef &n): - base (b), name (n) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return base->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return identifierToken; } - - // attributes - ExpressionNode *base; - QStringRef name; - SourceLocation dotToken; - SourceLocation identifierToken; -}; - -class QML_PARSER_EXPORT NewMemberExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(NewMemberExpression) - - NewMemberExpression(ExpressionNode *b, ArgumentList *a): - base (b), arguments (a) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return newToken; } - - virtual SourceLocation lastSourceLocation() const - { return rparenToken; } - - // attributes - ExpressionNode *base; - ArgumentList *arguments; - SourceLocation newToken; - SourceLocation lparenToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT NewExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(NewExpression) - - NewExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return newToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation newToken; -}; - -class QML_PARSER_EXPORT CallExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(CallExpression) - - CallExpression(ExpressionNode *b, ArgumentList *a): - base (b), arguments (a) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return base->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return rparenToken; } - -// attributes - ExpressionNode *base; - ArgumentList *arguments; - SourceLocation lparenToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT ArgumentList: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ArgumentList) - - ArgumentList(ExpressionNode *e): - expression (e), next (this) - { kind = K; } - - ArgumentList(ArgumentList *previous, ExpressionNode *e): - expression (e) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return expression->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { - if (next) - return next->lastSourceLocation(); - return expression->lastSourceLocation(); - } - - inline ArgumentList *finish () - { - ArgumentList *front = next; - next = 0; - return front; - } - -// attributes - ExpressionNode *expression; - ArgumentList *next; - SourceLocation commaToken; -}; - -class QML_PARSER_EXPORT PostIncrementExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(PostIncrementExpression) - - PostIncrementExpression(ExpressionNode *b): - base (b) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return base->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return incrementToken; } - -// attributes - ExpressionNode *base; - SourceLocation incrementToken; -}; - -class QML_PARSER_EXPORT PostDecrementExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(PostDecrementExpression) - - PostDecrementExpression(ExpressionNode *b): - base (b) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return base->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return decrementToken; } - -// attributes - ExpressionNode *base; - SourceLocation decrementToken; -}; - -class QML_PARSER_EXPORT DeleteExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(DeleteExpression) - - DeleteExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return deleteToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation deleteToken; -}; - -class QML_PARSER_EXPORT VoidExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(VoidExpression) - - VoidExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return voidToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation voidToken; -}; - -class QML_PARSER_EXPORT TypeOfExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(TypeOfExpression) - - TypeOfExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return typeofToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation typeofToken; -}; - -class QML_PARSER_EXPORT PreIncrementExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(PreIncrementExpression) - - PreIncrementExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return incrementToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation incrementToken; -}; - -class QML_PARSER_EXPORT PreDecrementExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(PreDecrementExpression) - - PreDecrementExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return decrementToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation decrementToken; -}; - -class QML_PARSER_EXPORT UnaryPlusExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UnaryPlusExpression) - - UnaryPlusExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return plusToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation plusToken; -}; - -class QML_PARSER_EXPORT UnaryMinusExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UnaryMinusExpression) - - UnaryMinusExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return minusToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation minusToken; -}; - -class QML_PARSER_EXPORT TildeExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(TildeExpression) - - TildeExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return tildeToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation tildeToken; -}; - -class QML_PARSER_EXPORT NotExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(NotExpression) - - NotExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return notToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation notToken; -}; - -class QML_PARSER_EXPORT BinaryExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(BinaryExpression) - - BinaryExpression(ExpressionNode *l, int o, ExpressionNode *r): - left (l), op (o), right (r) - { kind = K; } - - virtual BinaryExpression *binaryExpressionCast(); - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return left->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return right->lastSourceLocation(); } - -// attributes - ExpressionNode *left; - int op; - ExpressionNode *right; - SourceLocation operatorToken; -}; - -class QML_PARSER_EXPORT ConditionalExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ConditionalExpression) - - ConditionalExpression(ExpressionNode *e, ExpressionNode *t, ExpressionNode *f): - expression (e), ok (t), ko (f) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return expression->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return ko->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - ExpressionNode *ok; - ExpressionNode *ko; - SourceLocation questionToken; - SourceLocation colonToken; -}; - -class QML_PARSER_EXPORT Expression: public ExpressionNode // ### rename -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(Expression) - - Expression(ExpressionNode *l, ExpressionNode *r): - left (l), right (r) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return left->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return right->lastSourceLocation(); } - -// attributes - ExpressionNode *left; - ExpressionNode *right; - SourceLocation commaToken; -}; - -class QML_PARSER_EXPORT Block: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(Block) - - Block(StatementList *slist): - statements (slist) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return lbraceToken; } - - virtual SourceLocation lastSourceLocation() const - { return rbraceToken; } - - // attributes - StatementList *statements; - SourceLocation lbraceToken; - SourceLocation rbraceToken; -}; - -class QML_PARSER_EXPORT StatementList: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(StatementList) - - StatementList(Statement *stmt): - statement (stmt), next (this) - { kind = K; } - - StatementList(StatementList *previous, Statement *stmt): - statement (stmt) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return statement->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : statement->lastSourceLocation(); } - - inline StatementList *finish () - { - StatementList *front = next; - next = 0; - return front; - } - -// attributes - Statement *statement; - StatementList *next; -}; - -class QML_PARSER_EXPORT VariableStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(VariableStatement) - - VariableStatement(VariableDeclarationList *vlist): - declarations (vlist) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return declarationKindToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - VariableDeclarationList *declarations; - SourceLocation declarationKindToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT VariableDeclaration: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(VariableDeclaration) - - VariableDeclaration(const QStringRef &n, ExpressionNode *e): - name (n), expression (e), readOnly(false) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression ? expression->lastSourceLocation() : identifierToken; } - -// attributes - QStringRef name; - ExpressionNode *expression; - bool readOnly; - SourceLocation identifierToken; -}; - -class QML_PARSER_EXPORT VariableDeclarationList: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(VariableDeclarationList) - - VariableDeclarationList(VariableDeclaration *decl): - declaration (decl), next (this) - { kind = K; } - - VariableDeclarationList(VariableDeclarationList *previous, VariableDeclaration *decl): - declaration (decl) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return declaration->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { - if (next) - return next->lastSourceLocation(); - return declaration->lastSourceLocation(); - } - - inline VariableDeclarationList *finish (bool readOnly) - { - VariableDeclarationList *front = next; - next = 0; - if (readOnly) { - VariableDeclarationList *vdl; - for (vdl = front; vdl != 0; vdl = vdl->next) - vdl->declaration->readOnly = true; - } - return front; - } - -// attributes - VariableDeclaration *declaration; - VariableDeclarationList *next; - SourceLocation commaToken; -}; - -class QML_PARSER_EXPORT EmptyStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(EmptyStatement) - - EmptyStatement() { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return semicolonToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT ExpressionStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ExpressionStatement) - - ExpressionStatement(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return expression->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - ExpressionNode *expression; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT IfStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(IfStatement) - - IfStatement(ExpressionNode *e, Statement *t, Statement *f = 0): - expression (e), ok (t), ko (f) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return ifToken; } - - virtual SourceLocation lastSourceLocation() const - { - if (ko) - return ko->lastSourceLocation(); - - return ok->lastSourceLocation(); - } - -// attributes - ExpressionNode *expression; - Statement *ok; - Statement *ko; - SourceLocation ifToken; - SourceLocation lparenToken; - SourceLocation rparenToken; - SourceLocation elseToken; -}; - -class QML_PARSER_EXPORT DoWhileStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(DoWhileStatement) - - DoWhileStatement(Statement *stmt, ExpressionNode *e): - statement (stmt), expression (e) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return doToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - Statement *statement; - ExpressionNode *expression; - SourceLocation doToken; - SourceLocation whileToken; - SourceLocation lparenToken; - SourceLocation rparenToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT WhileStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(WhileStatement) - - WhileStatement(ExpressionNode *e, Statement *stmt): - expression (e), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return whileToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - Statement *statement; - SourceLocation whileToken; - SourceLocation lparenToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT ForStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ForStatement) - - ForStatement(ExpressionNode *i, ExpressionNode *c, ExpressionNode *e, Statement *stmt): - initialiser (i), condition (c), expression (e), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return forToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - ExpressionNode *initialiser; - ExpressionNode *condition; - ExpressionNode *expression; - Statement *statement; - SourceLocation forToken; - SourceLocation lparenToken; - SourceLocation firstSemicolonToken; - SourceLocation secondSemicolonToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT LocalForStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(LocalForStatement) - - LocalForStatement(VariableDeclarationList *vlist, ExpressionNode *c, ExpressionNode *e, Statement *stmt): - declarations (vlist), condition (c), expression (e), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return forToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - VariableDeclarationList *declarations; - ExpressionNode *condition; - ExpressionNode *expression; - Statement *statement; - SourceLocation forToken; - SourceLocation lparenToken; - SourceLocation varToken; - SourceLocation firstSemicolonToken; - SourceLocation secondSemicolonToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT ForEachStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ForEachStatement) - - ForEachStatement(ExpressionNode *i, ExpressionNode *e, Statement *stmt): - initialiser (i), expression (e), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return forToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - ExpressionNode *initialiser; - ExpressionNode *expression; - Statement *statement; - SourceLocation forToken; - SourceLocation lparenToken; - SourceLocation inToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT LocalForEachStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(LocalForEachStatement) - - LocalForEachStatement(VariableDeclaration *v, ExpressionNode *e, Statement *stmt): - declaration (v), expression (e), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return forToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - VariableDeclaration *declaration; - ExpressionNode *expression; - Statement *statement; - SourceLocation forToken; - SourceLocation lparenToken; - SourceLocation varToken; - SourceLocation inToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT ContinueStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ContinueStatement) - - ContinueStatement(const QStringRef &l = QStringRef()): - label (l) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return continueToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - QStringRef label; - SourceLocation continueToken; - SourceLocation identifierToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT BreakStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(BreakStatement) - - BreakStatement(const QStringRef &l): - label (l) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return breakToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - - // attributes - QStringRef label; - SourceLocation breakToken; - SourceLocation identifierToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT ReturnStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ReturnStatement) - - ReturnStatement(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return returnToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - ExpressionNode *expression; - SourceLocation returnToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT WithStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(WithStatement) - - WithStatement(ExpressionNode *e, Statement *stmt): - expression (e), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return withToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - Statement *statement; - SourceLocation withToken; - SourceLocation lparenToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT CaseBlock: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(CaseBlock) - - CaseBlock(CaseClauses *c, DefaultClause *d = 0, CaseClauses *r = 0): - clauses (c), defaultClause (d), moreClauses (r) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return lbraceToken; } - - virtual SourceLocation lastSourceLocation() const - { return rbraceToken; } - -// attributes - CaseClauses *clauses; - DefaultClause *defaultClause; - CaseClauses *moreClauses; - SourceLocation lbraceToken; - SourceLocation rbraceToken; -}; - -class QML_PARSER_EXPORT SwitchStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(SwitchStatement) - - SwitchStatement(ExpressionNode *e, CaseBlock *b): - expression (e), block (b) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return switchToken; } - - virtual SourceLocation lastSourceLocation() const - { return block->rbraceToken; } - -// attributes - ExpressionNode *expression; - CaseBlock *block; - SourceLocation switchToken; - SourceLocation lparenToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT CaseClause: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(CaseClause) - - CaseClause(ExpressionNode *e, StatementList *slist): - expression (e), statements (slist) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return caseToken; } - - virtual SourceLocation lastSourceLocation() const - { return statements ? statements->lastSourceLocation() : colonToken; } - -// attributes - ExpressionNode *expression; - StatementList *statements; - SourceLocation caseToken; - SourceLocation colonToken; -}; - -class QML_PARSER_EXPORT CaseClauses: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(CaseClauses) - - CaseClauses(CaseClause *c): - clause (c), next (this) - { kind = K; } - - CaseClauses(CaseClauses *previous, CaseClause *c): - clause (c) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return clause->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : clause->lastSourceLocation(); } - - inline CaseClauses *finish () - { - CaseClauses *front = next; - next = 0; - return front; - } - -//attributes - CaseClause *clause; - CaseClauses *next; -}; - -class QML_PARSER_EXPORT DefaultClause: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(DefaultClause) - - DefaultClause(StatementList *slist): - statements (slist) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return defaultToken; } - - virtual SourceLocation lastSourceLocation() const - { return statements ? statements->lastSourceLocation() : colonToken; } - -// attributes - StatementList *statements; - SourceLocation defaultToken; - SourceLocation colonToken; -}; - -class QML_PARSER_EXPORT LabelledStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(LabelledStatement) - - LabelledStatement(const QStringRef &l, Statement *stmt): - label (l), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - QStringRef label; - Statement *statement; - SourceLocation identifierToken; - SourceLocation colonToken; -}; - -class QML_PARSER_EXPORT ThrowStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ThrowStatement) - - ThrowStatement(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return throwToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - - // attributes - ExpressionNode *expression; - SourceLocation throwToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT Catch: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(Catch) - - Catch(const QStringRef &n, Block *stmt): - name (n), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return catchToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - QStringRef name; - Block *statement; - SourceLocation catchToken; - SourceLocation lparenToken; - SourceLocation identifierToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT Finally: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(Finally) - - Finally(Block *stmt): - statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return finallyToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement ? statement->lastSourceLocation() : finallyToken; } - -// attributes - Block *statement; - SourceLocation finallyToken; -}; - -class QML_PARSER_EXPORT TryStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(TryStatement) - - TryStatement(Statement *stmt, Catch *c, Finally *f): - statement (stmt), catchExpression (c), finallyExpression (f) - { kind = K; } - - TryStatement(Statement *stmt, Finally *f): - statement (stmt), catchExpression (0), finallyExpression (f) - { kind = K; } - - TryStatement(Statement *stmt, Catch *c): - statement (stmt), catchExpression (c), finallyExpression (0) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return tryToken; } - - virtual SourceLocation lastSourceLocation() const - { - if (finallyExpression) - return finallyExpression->statement->rbraceToken; - else if (catchExpression) - return catchExpression->statement->rbraceToken; - - return statement->lastSourceLocation(); - } - -// attributes - Statement *statement; - Catch *catchExpression; - Finally *finallyExpression; - SourceLocation tryToken; -}; - -class QML_PARSER_EXPORT FunctionExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(FunctionExpression) - - FunctionExpression(const QStringRef &n, FormalParameterList *f, FunctionBody *b): - name (n), formals (f), body (b) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return functionToken; } - - virtual SourceLocation lastSourceLocation() const - { return rbraceToken; } - -// attributes - QStringRef name; - FormalParameterList *formals; - FunctionBody *body; - SourceLocation functionToken; - SourceLocation identifierToken; - SourceLocation lparenToken; - SourceLocation rparenToken; - SourceLocation lbraceToken; - SourceLocation rbraceToken; -}; - -class QML_PARSER_EXPORT FunctionDeclaration: public FunctionExpression -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(FunctionDeclaration) - - FunctionDeclaration(const QStringRef &n, FormalParameterList *f, FunctionBody *b): - FunctionExpression(n, f, b) - { kind = K; } - - virtual void accept0(Visitor *visitor); -}; - -class QML_PARSER_EXPORT FormalParameterList: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(FormalParameterList) - - FormalParameterList(const QStringRef &n): - name (n), next (this) - { kind = K; } - - FormalParameterList(FormalParameterList *previous, const QStringRef &n): - name (n) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : identifierToken; } - - inline FormalParameterList *finish () - { - FormalParameterList *front = next; - next = 0; - return front; - } - -// attributes - QStringRef name; - FormalParameterList *next; - SourceLocation commaToken; - SourceLocation identifierToken; -}; - -class QML_PARSER_EXPORT SourceElement: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(SourceElement) - - inline SourceElement() - { kind = K; } -}; - -class QML_PARSER_EXPORT SourceElements: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(SourceElements) - - SourceElements(SourceElement *elt): - element (elt), next (this) - { kind = K; } - - SourceElements(SourceElements *previous, SourceElement *elt): - element (elt) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return element->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : element->lastSourceLocation(); } - - inline SourceElements *finish () - { - SourceElements *front = next; - next = 0; - return front; - } - -// attributes - SourceElement *element; - SourceElements *next; -}; - -class QML_PARSER_EXPORT FunctionBody: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(FunctionBody) - - FunctionBody(SourceElements *elts): - elements (elts) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return elements ? elements->firstSourceLocation() : SourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return elements ? elements->lastSourceLocation() : SourceLocation(); } - -// attributes - SourceElements *elements; -}; - -class QML_PARSER_EXPORT Program: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(Program) - - Program(SourceElements *elts): - elements (elts) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return elements ? elements->firstSourceLocation() : SourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return elements ? elements->lastSourceLocation() : SourceLocation(); } - -// attributes - SourceElements *elements; -}; - -class QML_PARSER_EXPORT FunctionSourceElement: public SourceElement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(FunctionSourceElement) - - FunctionSourceElement(FunctionDeclaration *f): - declaration (f) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return declaration->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return declaration->lastSourceLocation(); } - -// attributes - FunctionDeclaration *declaration; -}; - -class QML_PARSER_EXPORT StatementSourceElement: public SourceElement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(StatementSourceElement) - - StatementSourceElement(Statement *stmt): - statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return statement->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - Statement *statement; -}; - -class QML_PARSER_EXPORT DebuggerStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(DebuggerStatement) - - DebuggerStatement() - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return debuggerToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - SourceLocation debuggerToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT UiQualifiedId: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiQualifiedId) - - UiQualifiedId(const QStringRef &name) - : next(this), name(name) - { kind = K; } - - UiQualifiedId(UiQualifiedId *previous, const QStringRef &name) - : name(name) - { - kind = K; - next = previous->next; - previous->next = this; - } - - UiQualifiedId *finish() - { - UiQualifiedId *head = next; - next = 0; - return head; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : identifierToken; } - -// attributes - UiQualifiedId *next; - QStringRef name; - SourceLocation identifierToken; -}; - -class QML_PARSER_EXPORT UiImport: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiImport) - - UiImport(const QStringRef &fileName) - : fileName(fileName), importUri(0) - { kind = K; } - - UiImport(UiQualifiedId *uri) - : importUri(uri) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return importToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - QStringRef fileName; - UiQualifiedId *importUri; - QStringRef importId; - SourceLocation importToken; - SourceLocation fileNameToken; - SourceLocation versionToken; - SourceLocation asToken; - SourceLocation importIdToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT UiImportList: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiImportList) - - UiImportList(UiImport *import) - : import(import), - next(this) - { kind = K; } - - UiImportList(UiImportList *previous, UiImport *import) - : import(import) - { - kind = K; - next = previous->next; - previous->next = this; - } - - UiImportList *finish() - { - UiImportList *head = next; - next = 0; - return head; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return import->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : import->lastSourceLocation(); } - -// attributes - UiImport *import; - UiImportList *next; -}; - -class QML_PARSER_EXPORT UiObjectMember: public Node -{ -public: - virtual SourceLocation firstSourceLocation() const = 0; - virtual SourceLocation lastSourceLocation() const = 0; - - virtual UiObjectMember *uiObjectMemberCast(); -}; - -class QML_PARSER_EXPORT UiObjectMemberList: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiObjectMemberList) - - UiObjectMemberList(UiObjectMember *member) - : next(this), member(member) - { kind = K; } - - UiObjectMemberList(UiObjectMemberList *previous, UiObjectMember *member) - : member(member) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return member->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : member->lastSourceLocation(); } - - UiObjectMemberList *finish() - { - UiObjectMemberList *head = next; - next = 0; - return head; - } - -// attributes - UiObjectMemberList *next; - UiObjectMember *member; -}; - -class QML_PARSER_EXPORT UiProgram: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiProgram) - - UiProgram(UiImportList *imports, UiObjectMemberList *members) - : imports(imports), members(members) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { - if (imports) - return imports->firstSourceLocation(); - else if (members) - return members->firstSourceLocation(); - return SourceLocation(); - } - - virtual SourceLocation lastSourceLocation() const - { - if (members) - return members->lastSourceLocation(); - else if (imports) - return imports->lastSourceLocation(); - return SourceLocation(); - } - -// attributes - UiImportList *imports; - UiObjectMemberList *members; -}; - -class QML_PARSER_EXPORT UiArrayMemberList: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiArrayMemberList) - - UiArrayMemberList(UiObjectMember *member) - : next(this), member(member) - { kind = K; } - - UiArrayMemberList(UiArrayMemberList *previous, UiObjectMember *member) - : member(member) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return member->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : member->lastSourceLocation(); } - - UiArrayMemberList *finish() - { - UiArrayMemberList *head = next; - next = 0; - return head; - } - -// attributes - UiArrayMemberList *next; - UiObjectMember *member; - SourceLocation commaToken; -}; - -class QML_PARSER_EXPORT UiObjectInitializer: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiObjectInitializer) - - UiObjectInitializer(UiObjectMemberList *members) - : members(members) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return lbraceToken; } - - virtual SourceLocation lastSourceLocation() const - { return rbraceToken; } - -// attributes - SourceLocation lbraceToken; - UiObjectMemberList *members; - SourceLocation rbraceToken; -}; - -class QML_PARSER_EXPORT UiParameterList: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiParameterList) - - UiParameterList(const QStringRef &t, const QStringRef &n): - type (t), name (n), next (this) - { kind = K; } - - UiParameterList(UiParameterList *previous, const QStringRef &t, const QStringRef &n): - type (t), name (n) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *) {} - - virtual SourceLocation firstSourceLocation() const - { return propertyTypeToken; } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : identifierToken; } - - inline UiParameterList *finish () - { - UiParameterList *front = next; - next = 0; - return front; - } - -// attributes - QStringRef type; - QStringRef name; - UiParameterList *next; - SourceLocation commaToken; - SourceLocation propertyTypeToken; - SourceLocation identifierToken; -}; - -class QML_PARSER_EXPORT UiPublicMember: public UiObjectMember -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiPublicMember) - - UiPublicMember(const QStringRef &memberType, - const QStringRef &name) - : type(Property), memberType(memberType), name(name), statement(0), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0) - { kind = K; } - - UiPublicMember(const QStringRef &memberType, - const QStringRef &name, - Statement *statement) - : type(Property), memberType(memberType), name(name), statement(statement), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { - if (defaultToken.isValid()) - return defaultToken; - else if (readonlyToken.isValid()) - return readonlyToken; - - return propertyToken; - } - - virtual SourceLocation lastSourceLocation() const - { - if (binding) - return binding->lastSourceLocation(); - if (statement) - return statement->lastSourceLocation(); - - return semicolonToken; - } - -// attributes - enum { Signal, Property } type; - QStringRef typeModifier; - QStringRef memberType; - QStringRef name; - Statement *statement; // initialized with a JS expression - UiObjectMember *binding; // initialized with a QML object or array. - bool isDefaultMember; - bool isReadonlyMember; - UiParameterList *parameters; - SourceLocation defaultToken; - SourceLocation readonlyToken; - SourceLocation propertyToken; - SourceLocation typeModifierToken; - SourceLocation typeToken; - SourceLocation identifierToken; - SourceLocation colonToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT UiObjectDefinition: public UiObjectMember -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiObjectDefinition) - - UiObjectDefinition(UiQualifiedId *qualifiedTypeNameId, - UiObjectInitializer *initializer) - : qualifiedTypeNameId(qualifiedTypeNameId), initializer(initializer) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return qualifiedTypeNameId->identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return initializer->rbraceToken; } - -// attributes - UiQualifiedId *qualifiedTypeNameId; - UiObjectInitializer *initializer; -}; - -class QML_PARSER_EXPORT UiSourceElement: public UiObjectMember -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiSourceElement) - - UiSourceElement(Node *sourceElement) - : sourceElement(sourceElement) - { kind = K; } - - virtual SourceLocation firstSourceLocation() const - { - if (FunctionDeclaration *funDecl = cast(sourceElement)) - return funDecl->firstSourceLocation(); - else if (VariableStatement *varStmt = cast(sourceElement)) - return varStmt->firstSourceLocation(); - - return SourceLocation(); - } - - virtual SourceLocation lastSourceLocation() const - { - if (FunctionDeclaration *funDecl = cast(sourceElement)) - return funDecl->lastSourceLocation(); - else if (VariableStatement *varStmt = cast(sourceElement)) - return varStmt->lastSourceLocation(); - - return SourceLocation(); - } - - virtual void accept0(Visitor *visitor); - - -// attributes - Node *sourceElement; -}; - -class QML_PARSER_EXPORT UiObjectBinding: public UiObjectMember -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiObjectBinding) - - UiObjectBinding(UiQualifiedId *qualifiedId, - UiQualifiedId *qualifiedTypeNameId, - UiObjectInitializer *initializer) - : qualifiedId(qualifiedId), - qualifiedTypeNameId(qualifiedTypeNameId), - initializer(initializer), - hasOnToken(false) - { kind = K; } - - virtual SourceLocation firstSourceLocation() const - { - if (hasOnToken && qualifiedTypeNameId) - return qualifiedTypeNameId->identifierToken; - - return qualifiedId->identifierToken; - } - - virtual SourceLocation lastSourceLocation() const - { return initializer->rbraceToken; } - - virtual void accept0(Visitor *visitor); - - -// attributes - UiQualifiedId *qualifiedId; - UiQualifiedId *qualifiedTypeNameId; - UiObjectInitializer *initializer; - SourceLocation colonToken; - bool hasOnToken; -}; - -class QML_PARSER_EXPORT UiScriptBinding: public UiObjectMember -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiScriptBinding) - - UiScriptBinding(UiQualifiedId *qualifiedId, - Statement *statement) - : qualifiedId(qualifiedId), - statement(statement) - { kind = K; } - - virtual SourceLocation firstSourceLocation() const - { return qualifiedId->identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - - virtual void accept0(Visitor *visitor); - -// attributes - UiQualifiedId *qualifiedId; - Statement *statement; - SourceLocation colonToken; -}; - -class QML_PARSER_EXPORT UiArrayBinding: public UiObjectMember -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiArrayBinding) - - UiArrayBinding(UiQualifiedId *qualifiedId, - UiArrayMemberList *members) - : qualifiedId(qualifiedId), - members(members) - { kind = K; } - - virtual SourceLocation firstSourceLocation() const - { return qualifiedId->identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return rbracketToken; } - - virtual void accept0(Visitor *visitor); - -// attributes - UiQualifiedId *qualifiedId; - UiArrayMemberList *members; - SourceLocation colonToken; - SourceLocation lbracketToken; - SourceLocation rbracketToken; -}; - -} } // namespace AST - - - -QT_QML_END_NAMESPACE - -#endif diff --git a/src/declarative/qml/parser/qdeclarativejsastfwd_p.h b/src/declarative/qml/parser/qdeclarativejsastfwd_p.h deleted file mode 100644 index 9c7d0a51e6..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsastfwd_p.h +++ /dev/null @@ -1,186 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEJSAST_FWD_P_H -#define QDECLARATIVEJSAST_FWD_P_H - -#include "qdeclarativejsglobal_p.h" - -#include - -// -// 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. -// - -QT_QML_BEGIN_NAMESPACE - -namespace QDeclarativeJS { namespace AST { - -class SourceLocation -{ -public: - SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0) - : offset(offset), length(length), - startLine(line), startColumn(column) - { } - - bool isValid() const { return length != 0; } - - quint32 begin() const { return offset; } - quint32 end() const { return offset + length; } - -// attributes - // ### encode - quint32 offset; - quint32 length; - quint32 startLine; - quint32 startColumn; -}; - -class Visitor; -class Node; -class ExpressionNode; -class Statement; -class ThisExpression; -class IdentifierExpression; -class NullExpression; -class TrueLiteral; -class FalseLiteral; -class NumericLiteral; -class StringLiteral; -class RegExpLiteral; -class ArrayLiteral; -class ObjectLiteral; -class ElementList; -class Elision; -class PropertyNameAndValueList; -class PropertyName; -class IdentifierPropertyName; -class StringLiteralPropertyName; -class NumericLiteralPropertyName; -class ArrayMemberExpression; -class FieldMemberExpression; -class NewMemberExpression; -class NewExpression; -class CallExpression; -class ArgumentList; -class PostIncrementExpression; -class PostDecrementExpression; -class DeleteExpression; -class VoidExpression; -class TypeOfExpression; -class PreIncrementExpression; -class PreDecrementExpression; -class UnaryPlusExpression; -class UnaryMinusExpression; -class TildeExpression; -class NotExpression; -class BinaryExpression; -class ConditionalExpression; -class Expression; // ### rename -class Block; -class StatementList; -class VariableStatement; -class VariableDeclarationList; -class VariableDeclaration; -class EmptyStatement; -class ExpressionStatement; -class IfStatement; -class DoWhileStatement; -class WhileStatement; -class ForStatement; -class LocalForStatement; -class ForEachStatement; -class LocalForEachStatement; -class ContinueStatement; -class BreakStatement; -class ReturnStatement; -class WithStatement; -class SwitchStatement; -class CaseBlock; -class CaseClauses; -class CaseClause; -class DefaultClause; -class LabelledStatement; -class ThrowStatement; -class TryStatement; -class Catch; -class Finally; -class FunctionDeclaration; -class FunctionExpression; -class FormalParameterList; -class FunctionBody; -class Program; -class SourceElements; -class SourceElement; -class FunctionSourceElement; -class StatementSourceElement; -class DebuggerStatement; -class NestedExpression; - -// ui elements -class UiProgram; -class UiImportList; -class UiImport; -class UiPublicMember; -class UiObjectDefinition; -class UiObjectInitializer; -class UiObjectBinding; -class UiScriptBinding; -class UiSourceElement; -class UiArrayBinding; -class UiObjectMember; -class UiObjectMemberList; -class UiArrayMemberList; -class UiQualifiedId; - -} } // namespace AST - -QT_QML_END_NAMESPACE - -#endif diff --git a/src/declarative/qml/parser/qdeclarativejsastvisitor.cpp b/src/declarative/qml/parser/qdeclarativejsastvisitor.cpp deleted file mode 100644 index 671abd76db..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsastvisitor.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativejsastvisitor_p.h" - -QT_QML_BEGIN_NAMESPACE - -namespace QDeclarativeJS { namespace AST { - -Visitor::Visitor() -{ -} - -Visitor::~Visitor() -{ -} - -} } // namespace QDeclarativeJS::AST - -QT_QML_END_NAMESPACE diff --git a/src/declarative/qml/parser/qdeclarativejsastvisitor_p.h b/src/declarative/qml/parser/qdeclarativejsastvisitor_p.h deleted file mode 100644 index 639cb33d49..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsastvisitor_p.h +++ /dev/null @@ -1,329 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEJSASTVISITOR_P_H -#define QDECLARATIVEJSASTVISITOR_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 "qdeclarativejsastfwd_p.h" -#include "qdeclarativejsglobal_p.h" - -QT_QML_BEGIN_NAMESPACE - -namespace QDeclarativeJS { namespace AST { - -class QML_PARSER_EXPORT Visitor -{ -public: - Visitor(); - virtual ~Visitor(); - - virtual bool preVisit(Node *) { return true; } - virtual void postVisit(Node *) {} - - // Ui - virtual bool visit(UiProgram *) { return true; } - virtual bool visit(UiImportList *) { return true; } - virtual bool visit(UiImport *) { return true; } - virtual bool visit(UiPublicMember *) { return true; } - virtual bool visit(UiSourceElement *) { return true; } - virtual bool visit(UiObjectDefinition *) { return true; } - virtual bool visit(UiObjectInitializer *) { return true; } - virtual bool visit(UiObjectBinding *) { return true; } - virtual bool visit(UiScriptBinding *) { return true; } - virtual bool visit(UiArrayBinding *) { return true; } - virtual bool visit(UiObjectMemberList *) { return true; } - virtual bool visit(UiArrayMemberList *) { return true; } - virtual bool visit(UiQualifiedId *) { return true; } - - virtual void endVisit(UiProgram *) {} - virtual void endVisit(UiImportList *) {} - virtual void endVisit(UiImport *) {} - virtual void endVisit(UiPublicMember *) {} - virtual void endVisit(UiSourceElement *) {} - virtual void endVisit(UiObjectDefinition *) {} - virtual void endVisit(UiObjectInitializer *) {} - virtual void endVisit(UiObjectBinding *) {} - virtual void endVisit(UiScriptBinding *) {} - virtual void endVisit(UiArrayBinding *) {} - virtual void endVisit(UiObjectMemberList *) {} - virtual void endVisit(UiArrayMemberList *) {} - virtual void endVisit(UiQualifiedId *) {} - - // QDeclarativeJS - virtual bool visit(ThisExpression *) { return true; } - virtual void endVisit(ThisExpression *) {} - - virtual bool visit(IdentifierExpression *) { return true; } - virtual void endVisit(IdentifierExpression *) {} - - virtual bool visit(NullExpression *) { return true; } - virtual void endVisit(NullExpression *) {} - - virtual bool visit(TrueLiteral *) { return true; } - virtual void endVisit(TrueLiteral *) {} - - virtual bool visit(FalseLiteral *) { return true; } - virtual void endVisit(FalseLiteral *) {} - - virtual bool visit(StringLiteral *) { return true; } - virtual void endVisit(StringLiteral *) {} - - virtual bool visit(NumericLiteral *) { return true; } - virtual void endVisit(NumericLiteral *) {} - - virtual bool visit(RegExpLiteral *) { return true; } - virtual void endVisit(RegExpLiteral *) {} - - virtual bool visit(ArrayLiteral *) { return true; } - virtual void endVisit(ArrayLiteral *) {} - - virtual bool visit(ObjectLiteral *) { return true; } - virtual void endVisit(ObjectLiteral *) {} - - virtual bool visit(ElementList *) { return true; } - virtual void endVisit(ElementList *) {} - - virtual bool visit(Elision *) { return true; } - virtual void endVisit(Elision *) {} - - virtual bool visit(PropertyNameAndValueList *) { return true; } - virtual void endVisit(PropertyNameAndValueList *) {} - - virtual bool visit(NestedExpression *) { return true; } - virtual void endVisit(NestedExpression *) {} - - virtual bool visit(IdentifierPropertyName *) { return true; } - virtual void endVisit(IdentifierPropertyName *) {} - - virtual bool visit(StringLiteralPropertyName *) { return true; } - virtual void endVisit(StringLiteralPropertyName *) {} - - virtual bool visit(NumericLiteralPropertyName *) { return true; } - virtual void endVisit(NumericLiteralPropertyName *) {} - - virtual bool visit(ArrayMemberExpression *) { return true; } - virtual void endVisit(ArrayMemberExpression *) {} - - virtual bool visit(FieldMemberExpression *) { return true; } - virtual void endVisit(FieldMemberExpression *) {} - - virtual bool visit(NewMemberExpression *) { return true; } - virtual void endVisit(NewMemberExpression *) {} - - virtual bool visit(NewExpression *) { return true; } - virtual void endVisit(NewExpression *) {} - - virtual bool visit(CallExpression *) { return true; } - virtual void endVisit(CallExpression *) {} - - virtual bool visit(ArgumentList *) { return true; } - virtual void endVisit(ArgumentList *) {} - - virtual bool visit(PostIncrementExpression *) { return true; } - virtual void endVisit(PostIncrementExpression *) {} - - virtual bool visit(PostDecrementExpression *) { return true; } - virtual void endVisit(PostDecrementExpression *) {} - - virtual bool visit(DeleteExpression *) { return true; } - virtual void endVisit(DeleteExpression *) {} - - virtual bool visit(VoidExpression *) { return true; } - virtual void endVisit(VoidExpression *) {} - - virtual bool visit(TypeOfExpression *) { return true; } - virtual void endVisit(TypeOfExpression *) {} - - virtual bool visit(PreIncrementExpression *) { return true; } - virtual void endVisit(PreIncrementExpression *) {} - - virtual bool visit(PreDecrementExpression *) { return true; } - virtual void endVisit(PreDecrementExpression *) {} - - virtual bool visit(UnaryPlusExpression *) { return true; } - virtual void endVisit(UnaryPlusExpression *) {} - - virtual bool visit(UnaryMinusExpression *) { return true; } - virtual void endVisit(UnaryMinusExpression *) {} - - virtual bool visit(TildeExpression *) { return true; } - virtual void endVisit(TildeExpression *) {} - - virtual bool visit(NotExpression *) { return true; } - virtual void endVisit(NotExpression *) {} - - virtual bool visit(BinaryExpression *) { return true; } - virtual void endVisit(BinaryExpression *) {} - - virtual bool visit(ConditionalExpression *) { return true; } - virtual void endVisit(ConditionalExpression *) {} - - virtual bool visit(Expression *) { return true; } - virtual void endVisit(Expression *) {} - - virtual bool visit(Block *) { return true; } - virtual void endVisit(Block *) {} - - virtual bool visit(StatementList *) { return true; } - virtual void endVisit(StatementList *) {} - - virtual bool visit(VariableStatement *) { return true; } - virtual void endVisit(VariableStatement *) {} - - virtual bool visit(VariableDeclarationList *) { return true; } - virtual void endVisit(VariableDeclarationList *) {} - - virtual bool visit(VariableDeclaration *) { return true; } - virtual void endVisit(VariableDeclaration *) {} - - virtual bool visit(EmptyStatement *) { return true; } - virtual void endVisit(EmptyStatement *) {} - - virtual bool visit(ExpressionStatement *) { return true; } - virtual void endVisit(ExpressionStatement *) {} - - virtual bool visit(IfStatement *) { return true; } - virtual void endVisit(IfStatement *) {} - - virtual bool visit(DoWhileStatement *) { return true; } - virtual void endVisit(DoWhileStatement *) {} - - virtual bool visit(WhileStatement *) { return true; } - virtual void endVisit(WhileStatement *) {} - - virtual bool visit(ForStatement *) { return true; } - virtual void endVisit(ForStatement *) {} - - virtual bool visit(LocalForStatement *) { return true; } - virtual void endVisit(LocalForStatement *) {} - - virtual bool visit(ForEachStatement *) { return true; } - virtual void endVisit(ForEachStatement *) {} - - virtual bool visit(LocalForEachStatement *) { return true; } - virtual void endVisit(LocalForEachStatement *) {} - - virtual bool visit(ContinueStatement *) { return true; } - virtual void endVisit(ContinueStatement *) {} - - virtual bool visit(BreakStatement *) { return true; } - virtual void endVisit(BreakStatement *) {} - - virtual bool visit(ReturnStatement *) { return true; } - virtual void endVisit(ReturnStatement *) {} - - virtual bool visit(WithStatement *) { return true; } - virtual void endVisit(WithStatement *) {} - - virtual bool visit(SwitchStatement *) { return true; } - virtual void endVisit(SwitchStatement *) {} - - virtual bool visit(CaseBlock *) { return true; } - virtual void endVisit(CaseBlock *) {} - - virtual bool visit(CaseClauses *) { return true; } - virtual void endVisit(CaseClauses *) {} - - virtual bool visit(CaseClause *) { return true; } - virtual void endVisit(CaseClause *) {} - - virtual bool visit(DefaultClause *) { return true; } - virtual void endVisit(DefaultClause *) {} - - virtual bool visit(LabelledStatement *) { return true; } - virtual void endVisit(LabelledStatement *) {} - - virtual bool visit(ThrowStatement *) { return true; } - virtual void endVisit(ThrowStatement *) {} - - virtual bool visit(TryStatement *) { return true; } - virtual void endVisit(TryStatement *) {} - - virtual bool visit(Catch *) { return true; } - virtual void endVisit(Catch *) {} - - virtual bool visit(Finally *) { return true; } - virtual void endVisit(Finally *) {} - - virtual bool visit(FunctionDeclaration *) { return true; } - virtual void endVisit(FunctionDeclaration *) {} - - virtual bool visit(FunctionExpression *) { return true; } - virtual void endVisit(FunctionExpression *) {} - - virtual bool visit(FormalParameterList *) { return true; } - virtual void endVisit(FormalParameterList *) {} - - virtual bool visit(FunctionBody *) { return true; } - virtual void endVisit(FunctionBody *) {} - - virtual bool visit(Program *) { return true; } - virtual void endVisit(Program *) {} - - virtual bool visit(SourceElements *) { return true; } - virtual void endVisit(SourceElements *) {} - - virtual bool visit(FunctionSourceElement *) { return true; } - virtual void endVisit(FunctionSourceElement *) {} - - virtual bool visit(StatementSourceElement *) { return true; } - virtual void endVisit(StatementSourceElement *) {} - - virtual bool visit(DebuggerStatement *) { return true; } - virtual void endVisit(DebuggerStatement *) {} -}; - -} } // namespace AST - -QT_QML_END_NAMESPACE - -#endif // QDECLARATIVEJSASTVISITOR_P_H diff --git a/src/declarative/qml/parser/qdeclarativejsengine_p.cpp b/src/declarative/qml/parser/qdeclarativejsengine_p.cpp deleted file mode 100644 index 534849cd53..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsengine_p.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativejsengine_p.h" -#include "qdeclarativejsglobal_p.h" - -#include -#include -#include - -QT_QML_BEGIN_NAMESPACE - -namespace QDeclarativeJS { - -static int toDigit(char c) -{ - if ((c >= '0') && (c <= '9')) - return c - '0'; - else if ((c >= 'a') && (c <= 'z')) - return 10 + c - 'a'; - else if ((c >= 'A') && (c <= 'Z')) - return 10 + c - 'A'; - return -1; -} - -double integerFromString(const char *buf, int size, int radix) -{ - if (size == 0) - return qSNaN(); - - double sign = 1.0; - int i = 0; - if (buf[0] == '+') { - ++i; - } else if (buf[0] == '-') { - sign = -1.0; - ++i; - } - - if (((size-i) >= 2) && (buf[i] == '0')) { - if (((buf[i+1] == 'x') || (buf[i+1] == 'X')) - && (radix < 34)) { - if ((radix != 0) && (radix != 16)) - return 0; - radix = 16; - i += 2; - } else { - if (radix == 0) { - radix = 8; - ++i; - } - } - } else if (radix == 0) { - radix = 10; - } - - int j = i; - for ( ; i < size; ++i) { - int d = toDigit(buf[i]); - if ((d == -1) || (d >= radix)) - break; - } - double result; - if (j == i) { - if (!qstrcmp(buf, "Infinity")) - result = qInf(); - else - result = qSNaN(); - } else { - result = 0; - double multiplier = 1; - for (--i ; i >= j; --i, multiplier *= radix) - result += toDigit(buf[i]) * multiplier; - } - result *= sign; - return result; -} - -double integerFromString(const QString &str, int radix) -{ - QByteArray ba = str.trimmed().toLatin1(); - return integerFromString(ba.constData(), ba.size(), radix); -} - - -Engine::Engine() - : _lexer(0) -{ } - -Engine::~Engine() -{ } - -void Engine::setCode(const QString &code) -{ _code = code; } - -void Engine::addComment(int pos, int len, int line, int col) -{ if (len > 0) _comments.append(QDeclarativeJS::AST::SourceLocation(pos, len, line, col)); } - -QList Engine::comments() const -{ return _comments; } - -Lexer *Engine::lexer() const -{ return _lexer; } - -void Engine::setLexer(Lexer *lexer) -{ _lexer = lexer; } - -MemoryPool *Engine::pool() -{ return &_pool; } - -QStringRef Engine::newStringRef(const QString &text) -{ - const int pos = _extraCode.length(); - _extraCode += text; - return _extraCode.midRef(pos, text.length()); -} - -QStringRef Engine::newStringRef(const QChar *chars, int size) -{ return newStringRef(QString(chars, size)); } - -} // end of namespace QDeclarativeJS - -QT_QML_END_NAMESPACE diff --git a/src/declarative/qml/parser/qdeclarativejsengine_p.h b/src/declarative/qml/parser/qdeclarativejsengine_p.h deleted file mode 100644 index db8a462d3f..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsengine_p.h +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEJSENGINE_P_H -#define QDECLARATIVEJSENGINE_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 "qdeclarativejsglobal_p.h" -#include "qdeclarativejsastfwd_p.h" -#include "qdeclarativejsmemorypool_p.h" - -#include -#include - -QT_QML_BEGIN_NAMESPACE - -namespace QDeclarativeJS { - -class Lexer; -class MemoryPool; - -class QML_PARSER_EXPORT DiagnosticMessage -{ -public: - enum Kind { Warning, Error }; - - DiagnosticMessage() - : kind(Error) {} - - DiagnosticMessage(Kind kind, const AST::SourceLocation &loc, const QString &message) - : kind(kind), loc(loc), message(message) {} - - bool isWarning() const - { return kind == Warning; } - - bool isError() const - { return kind == Error; } - - Kind kind; - AST::SourceLocation loc; - QString message; -}; - -class QML_PARSER_EXPORT Engine -{ - Lexer *_lexer; - MemoryPool _pool; - QList _comments; - QString _extraCode; - QString _code; - -public: - Engine(); - ~Engine(); - - void setCode(const QString &code); - - void addComment(int pos, int len, int line, int col); - QList comments() const; - - Lexer *lexer() const; - void setLexer(Lexer *lexer); - - MemoryPool *pool(); - - inline QStringRef midRef(int position, int size) { return _code.midRef(position, size); } - - QStringRef newStringRef(const QString &s); - QStringRef newStringRef(const QChar *chars, int size); -}; - -double integerFromString(const char *buf, int size, int radix); - -} // end of namespace QDeclarativeJS - -QT_QML_END_NAMESPACE - -#endif // QDECLARATIVEJSENGINE_P_H diff --git a/src/declarative/qml/parser/qdeclarativejsglobal_p.h b/src/declarative/qml/parser/qdeclarativejsglobal_p.h deleted file mode 100644 index 993f4ae3dc..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsglobal_p.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QDECLARATIVEJSGLOBAL_P_H -#define QDECLARATIVEJSGLOBAL_P_H - -#include - -#ifdef QT_CREATOR -# define QT_QML_BEGIN_NAMESPACE -# define QT_QML_END_NAMESPACE - -# ifdef QDECLARATIVEJS_BUILD_DIR -# define QML_PARSER_EXPORT Q_DECL_EXPORT -# elif QML_BUILD_STATIC_LIB -# define QML_PARSER_EXPORT -# else -# define QML_PARSER_EXPORT Q_DECL_IMPORT -# endif // QDECLARATIVEJS_BUILD_DIR - -#else // !QT_CREATOR -# define QT_QML_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE -# define QT_QML_END_NAMESPACE QT_END_NAMESPACE -# if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB) - // QmlDevTools is a static library -# define QML_PARSER_EXPORT -# else -# define QML_PARSER_EXPORT Q_AUTOTEST_EXPORT -# endif -#endif // QT_CREATOR - -#endif // QDECLARATIVEJSGLOBAL_P_H diff --git a/src/declarative/qml/parser/qdeclarativejsgrammar.cpp b/src/declarative/qml/parser/qdeclarativejsgrammar.cpp deleted file mode 100644 index 1e509e5651..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsgrammar.cpp +++ /dev/null @@ -1,1013 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This file was generated by qlalr - DO NOT EDIT! -#include "qdeclarativejsgrammar_p.h" - -QT_BEGIN_NAMESPACE - -const char *const QDeclarativeJSGrammar::spell [] = { - "end of file", "&", "&&", "&=", "break", "case", "catch", ":", ",", "continue", - "default", "delete", "/", "/=", "do", ".", "else", "=", "==", "===", - "finally", "for", "function", ">=", ">", ">>", ">>=", ">>>", ">>>=", "identifier", - "if", "in", "instanceof", "{", "[", "<=", "(", "<", "<<", "<<=", - "-", "-=", "--", "new", "!", "!=", "!==", "numeric literal", "|", "|=", - "||", "+", "+=", "++", "?", "}", "]", "%", "%=", "return", - ")", ";", 0, "*", "*=", "string literal", "property", "signal", "readonly", "switch", - "this", "throw", "~", "try", "typeof", "var", "void", "while", "with", "^", - "^=", "null", "true", "false", "const", "debugger", "reserved word", "multiline string literal", "comment", "public", - "import", "as", "on", 0, 0, 0, 0, 0, 0, 0, - 0, 0}; - -const short QDeclarativeJSGrammar::lhs [] = { - 102, 102, 102, 102, 102, 102, 103, 109, 109, 112, - 112, 114, 113, 113, 113, 113, 113, 113, 113, 113, - 116, 111, 110, 119, 119, 120, 120, 121, 121, 118, - 107, 107, 107, 107, 123, 123, 123, 123, 123, 123, - 123, 107, 131, 131, 131, 132, 132, 133, 133, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 107, 107, 107, 107, 117, 117, 117, 117, - 117, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 136, 136, 136, 136, 136, 136, 136, 122, - 138, 138, 138, 138, 137, 137, 140, 140, 142, 142, - 142, 142, 142, 142, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 144, 144, 115, 115, 115, - 115, 115, 147, 147, 148, 148, 148, 148, 146, 146, - 149, 149, 150, 150, 151, 151, 151, 152, 152, 152, - 152, 152, 152, 152, 152, 152, 152, 153, 153, 153, - 153, 154, 154, 154, 155, 155, 155, 155, 156, 156, - 156, 156, 156, 156, 156, 157, 157, 157, 157, 157, - 157, 158, 158, 158, 158, 158, 159, 159, 159, 159, - 159, 160, 160, 161, 161, 162, 162, 163, 163, 164, - 164, 165, 165, 166, 166, 167, 167, 168, 168, 169, - 169, 170, 170, 171, 171, 141, 141, 172, 172, 173, - 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, - 173, 105, 105, 174, 174, 175, 175, 176, 176, 104, - 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, - 104, 104, 104, 104, 124, 185, 185, 184, 184, 135, - 135, 186, 186, 187, 187, 189, 189, 188, 190, 193, - 191, 191, 194, 192, 192, 125, 126, 126, 127, 127, - 177, 177, 177, 177, 177, 177, 177, 178, 178, 178, - 178, 179, 179, 179, 179, 180, 180, 128, 129, 195, - 195, 198, 198, 196, 196, 199, 197, 181, 181, 181, - 182, 182, 130, 130, 130, 200, 201, 183, 183, 134, - 145, 205, 205, 202, 202, 203, 203, 206, 108, 108, - 207, 207, 106, 106, 204, 204, 139, 139, 208}; - -const short QDeclarativeJSGrammar::rhs [] = { - 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, - 2, 1, 2, 2, 3, 3, 5, 5, 4, 4, - 2, 0, 1, 1, 2, 1, 3, 2, 3, 2, - 1, 5, 4, 4, 1, 1, 1, 1, 1, 1, - 1, 3, 1, 1, 1, 0, 1, 2, 4, 6, - 6, 3, 3, 7, 7, 4, 4, 5, 5, 5, - 6, 6, 10, 6, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 3, 3, 4, 5, 3, 4, 3, 1, - 1, 2, 3, 4, 1, 2, 3, 5, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, - 3, 5, 1, 2, 4, 4, 4, 3, 0, 1, - 1, 3, 1, 1, 1, 2, 2, 1, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 1, 3, 3, - 3, 1, 3, 3, 1, 3, 3, 3, 1, 3, - 3, 3, 3, 3, 3, 1, 3, 3, 3, 3, - 3, 1, 3, 3, 3, 3, 1, 3, 3, 3, - 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, - 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, - 3, 1, 5, 1, 5, 1, 3, 1, 3, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 3, 0, 1, 1, 3, 0, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 3, 1, 2, 0, 1, 3, - 3, 1, 1, 1, 3, 1, 3, 2, 2, 2, - 0, 1, 2, 0, 1, 1, 2, 2, 7, 5, - 7, 7, 5, 9, 10, 7, 8, 2, 2, 3, - 3, 2, 2, 3, 3, 3, 3, 5, 5, 3, - 5, 1, 2, 0, 1, 4, 3, 3, 3, 3, - 3, 3, 3, 3, 4, 5, 2, 2, 2, 8, - 8, 1, 3, 0, 1, 0, 1, 1, 1, 1, - 1, 2, 1, 1, 0, 1, 0, 1, 2}; - -const short QDeclarativeJSGrammar::action_default [] = { - 0, 0, 22, 0, 0, 0, 22, 0, 175, 242, - 206, 214, 210, 154, 226, 202, 3, 139, 73, 155, - 218, 222, 143, 172, 153, 158, 138, 192, 179, 0, - 80, 81, 76, 345, 67, 347, 0, 0, 0, 0, - 78, 0, 0, 74, 77, 71, 0, 0, 68, 70, - 69, 79, 72, 0, 75, 0, 0, 168, 0, 0, - 155, 174, 157, 156, 0, 0, 0, 170, 171, 169, - 173, 0, 203, 0, 0, 0, 0, 193, 0, 0, - 0, 0, 0, 0, 183, 0, 0, 0, 177, 178, - 176, 181, 185, 184, 182, 180, 195, 194, 196, 0, - 211, 0, 207, 0, 0, 149, 136, 148, 137, 105, - 106, 107, 132, 108, 133, 109, 110, 111, 112, 113, - 114, 115, 116, 117, 118, 119, 120, 121, 134, 122, - 123, 124, 125, 126, 127, 128, 129, 130, 131, 135, - 0, 0, 147, 243, 150, 0, 151, 0, 152, 146, - 0, 239, 232, 230, 237, 238, 236, 235, 241, 234, - 233, 231, 240, 227, 0, 215, 0, 0, 219, 0, - 0, 223, 0, 0, 149, 141, 0, 140, 0, 145, - 159, 0, 346, 334, 335, 0, 332, 0, 333, 0, - 336, 250, 257, 256, 264, 252, 0, 253, 337, 0, - 344, 254, 255, 260, 258, 341, 338, 343, 261, 0, - 272, 0, 0, 0, 0, 345, 67, 0, 347, 68, - 244, 286, 69, 0, 0, 0, 273, 0, 0, 262, - 263, 0, 251, 259, 287, 288, 331, 342, 0, 302, - 303, 304, 305, 0, 298, 299, 300, 301, 328, 329, - 0, 0, 0, 0, 0, 291, 292, 248, 246, 208, - 216, 212, 228, 204, 249, 0, 155, 220, 224, 197, - 186, 0, 0, 205, 0, 0, 0, 0, 198, 0, - 0, 0, 0, 0, 190, 188, 191, 189, 187, 200, - 199, 201, 0, 213, 0, 209, 0, 247, 155, 0, - 229, 244, 245, 0, 244, 0, 0, 294, 0, 0, - 0, 296, 0, 217, 0, 0, 221, 0, 0, 225, - 284, 0, 276, 285, 279, 0, 283, 0, 244, 277, - 0, 244, 0, 0, 295, 0, 0, 0, 297, 346, - 334, 0, 0, 336, 0, 330, 0, 320, 0, 0, - 0, 290, 0, 289, 0, 348, 0, 104, 266, 269, - 0, 105, 272, 108, 133, 110, 111, 76, 115, 116, - 67, 117, 120, 74, 77, 68, 244, 69, 79, 123, - 72, 125, 75, 127, 128, 273, 130, 131, 135, 0, - 97, 0, 0, 99, 103, 101, 88, 100, 102, 0, - 98, 87, 267, 265, 143, 144, 149, 0, 142, 0, - 319, 0, 306, 307, 0, 318, 0, 0, 0, 309, - 314, 312, 315, 0, 0, 313, 314, 0, 310, 0, - 311, 268, 317, 0, 268, 316, 0, 321, 322, 0, - 268, 323, 324, 0, 0, 325, 0, 0, 0, 326, - 327, 161, 160, 0, 0, 0, 293, 0, 0, 0, - 308, 281, 274, 0, 282, 278, 0, 280, 270, 0, - 271, 275, 91, 0, 0, 95, 82, 0, 84, 93, - 0, 85, 94, 96, 86, 92, 83, 0, 89, 165, - 163, 167, 164, 162, 166, 339, 6, 340, 4, 2, - 65, 90, 0, 0, 68, 70, 69, 31, 5, 0, - 66, 0, 45, 44, 43, 0, 0, 58, 0, 59, - 35, 36, 37, 38, 40, 41, 62, 39, 0, 45, - 0, 0, 0, 0, 0, 54, 0, 55, 0, 0, - 26, 0, 0, 63, 27, 0, 30, 28, 24, 0, - 29, 25, 0, 56, 0, 57, 143, 0, 60, 64, - 0, 0, 0, 0, 61, 0, 52, 46, 53, 47, - 0, 0, 0, 0, 49, 0, 50, 51, 48, 0, - 0, 143, 268, 0, 0, 42, 105, 272, 108, 133, - 110, 111, 76, 115, 116, 67, 117, 120, 74, 77, - 68, 244, 69, 79, 123, 72, 125, 75, 127, 128, - 273, 130, 131, 135, 0, 32, 33, 0, 34, 8, - 0, 10, 0, 9, 0, 1, 21, 12, 0, 13, - 0, 14, 0, 19, 20, 0, 15, 16, 0, 17, - 18, 11, 23, 7, 349}; - -const short QDeclarativeJSGrammar::goto_default [] = { - 7, 625, 207, 196, 205, 508, 496, 624, 643, 495, - 623, 621, 626, 22, 622, 18, 507, 549, 539, 546, - 541, 526, 191, 195, 197, 201, 233, 208, 230, 530, - 570, 569, 200, 232, 26, 474, 473, 356, 355, 9, - 354, 357, 107, 17, 145, 24, 13, 144, 19, 25, - 57, 23, 8, 28, 27, 269, 15, 263, 10, 259, - 12, 261, 11, 260, 20, 267, 21, 268, 14, 262, - 258, 299, 411, 264, 265, 202, 193, 192, 204, 203, - 229, 194, 360, 359, 231, 463, 462, 321, 322, 465, - 324, 464, 323, 419, 423, 426, 422, 421, 441, 442, - 185, 199, 181, 184, 198, 206, 0}; - -const short QDeclarativeJSGrammar::action_index [] = { - 404, 1275, 2411, 2411, 2509, 1000, 68, 92, 90, -102, - 88, 62, 60, 256, -102, 298, 86, -102, -102, 638, - 83, 134, 172, 219, -102, -102, -102, 454, 194, 1275, - -102, -102, -102, 381, -102, 2215, 1555, 1275, 1275, 1275, - -102, 790, 1275, -102, -102, -102, 1275, 1275, -102, -102, - -102, -102, -102, 1275, -102, 1275, 1275, -102, 1275, 1275, - 102, 217, -102, -102, 1275, 1275, 1275, -102, -102, -102, - 204, 1275, 304, 1275, 1275, 1275, 1275, 539, 1275, 1275, - 1275, 1275, 1275, 1275, 308, 1275, 1275, 1275, 103, 131, - 135, 308, 210, 225, 216, 308, 444, 390, 434, 1275, - 82, 1275, 100, 2117, 1275, 1275, -102, -102, -102, -102, - -102, -102, -102, -102, -102, -102, -102, -102, -102, -102, - -102, -102, -102, -102, -102, -102, -102, -102, -102, -102, - -102, -102, -102, -102, -102, -102, -102, -102, -102, -102, - 139, 1275, -102, -102, 91, 10, -102, 1275, -102, -102, - 1275, -102, -102, -102, -102, -102, -102, -102, -102, -102, - -102, -102, -102, -102, 1275, 26, 1275, 1275, 69, 66, - 1275, -102, 2117, 1275, 1275, -102, 97, -102, 44, -102, - -102, 67, -102, 297, 78, 24, -102, 291, -102, 36, - 2411, -102, -102, -102, -102, -102, 234, -102, -102, 12, - -102, -102, -102, -102, -102, -102, 2411, -102, -102, 464, - -102, 461, 115, 2509, 42, 381, 58, 46, 2705, 70, - 1275, -102, 74, 57, 1275, 65, -102, 59, 61, -102, - -102, 367, -102, -102, -102, -102, -102, -102, 106, -102, - -102, -102, -102, 87, -102, -102, -102, -102, -102, -102, - 56, 55, 1275, 99, 84, -102, -102, 1461, -102, 75, - 48, 52, -102, 306, 72, 53, 579, 77, 110, 370, - 230, 381, 1275, 286, 1275, 1275, 1275, 1275, 380, 1275, - 1275, 1275, 1275, 1275, 184, 169, 166, 190, 198, 460, - 363, 353, 1275, 50, 1275, 63, 1275, -102, 638, 1275, - -102, 1275, 64, 39, 1275, 30, 2509, -102, 1275, 173, - 2509, -102, 1275, 79, 1275, 1275, 81, 80, 1275, -102, - 71, 149, 32, -102, -102, 1275, -102, 381, 1275, -102, - 73, 1275, 76, 2509, -102, 1275, 142, 2509, -102, -16, - 381, -42, -12, 2411, -39, -102, 2509, -102, 1275, 154, - 2509, 14, 2509, -102, 20, 16, -32, -102, -102, 2509, - -51, 519, -4, 511, 136, 1275, 2509, -2, -35, 395, - -1, -27, 908, 4, 6, -102, 1370, -102, 0, -36, - 27, 1275, 47, 22, 1275, 45, 1275, 21, 17, 1275, - -102, 2313, 144, -102, -102, -102, -102, -102, -102, 1275, - -102, -102, -102, -102, 274, -102, 1275, -21, -102, 2509, - -102, 138, -102, -102, 2509, -102, 1275, 132, 5, -102, - 40, -102, 41, 101, 1275, -102, 38, 34, -102, -38, - -102, 2509, -102, 105, 2509, -102, 245, -102, -102, 96, - 2509, 11, -102, -7, -11, -102, 352, 8, 18, -102, - -102, -102, -102, 1275, 129, 2509, -102, 1275, 130, 2509, - -102, 49, -102, 226, -102, -102, 1275, -102, -102, 362, - -102, -102, -102, 107, 1837, -102, -102, 1649, -102, -102, - 1743, -102, -102, -102, -102, -102, -102, 114, -102, -102, - -102, -102, -102, -102, -102, -102, -102, 2411, -102, -102, - -102, 94, 9, 818, 189, -10, 31, -102, -102, 223, - -102, 191, -102, -102, -102, 300, 178, -102, 1928, -102, - -102, -102, -102, -102, -102, -102, -102, -102, 257, -25, - 381, 195, -22, 305, 240, -102, -6, -102, 818, 127, - -102, -18, 818, -102, -102, 1184, -102, -102, -102, 1092, - -102, -102, 237, -102, 1928, -102, 294, -8, -102, -102, - 176, 381, 19, 1928, -102, 165, -102, 174, -102, 2, - -52, 381, 183, 381, -102, 117, -102, -102, -102, 2019, - 880, 285, 2607, 1555, 3, -102, 522, 35, 453, 108, - 1275, 2509, 51, 23, 475, 54, -17, 700, 7, 43, - -102, 1370, -102, 28, -3, 33, 1275, 37, 15, 1275, - 25, 1275, 1, 13, 124, -102, -102, 29, -102, -102, - 728, -102, 250, -43, 627, -102, -102, 231, 372, -102, - 222, -102, 111, -102, -102, 381, -102, -102, 104, -102, - -102, -102, -102, -102, -102, - - -107, 9, -103, 2, 5, 266, 1, -107, -107, -107, - -107, -107, -107, -107, -107, -107, -107, -107, -107, -39, - -107, -107, -107, -107, -107, -107, -107, -107, -107, 86, - -107, -107, -107, 8, -107, -107, -22, 19, 71, 174, - -107, 186, 171, -107, -107, -107, 184, 178, -107, -107, - -107, -107, -107, 144, -107, 124, 150, -107, 165, 161, - -107, -107, -107, -107, 156, 160, 157, -107, -107, -107, - -107, 147, -107, 142, 135, 179, 166, -107, 177, 170, - 117, 72, 134, 92, -107, 75, 94, 66, -107, -107, - -107, -107, -107, -107, -107, -107, -107, -107, -107, 181, - -107, 106, -107, 143, 78, 55, -107, -107, -107, -107, - -107, -107, -107, -107, -107, -107, -107, -107, -107, -107, - -107, -107, -107, -107, -107, -107, -107, -107, -107, -107, - -107, -107, -107, -107, -107, -107, -107, -107, -107, -107, - -107, -5, -107, -107, -107, -107, -107, 54, -107, -107, - 51, -107, -107, -107, -107, -107, -107, -107, -107, -107, - -107, -107, -107, -107, 114, -107, 113, 38, -107, -107, - 41, -107, 231, 63, 112, -107, -107, -107, -107, -107, - -107, -107, -107, 30, -107, -107, -107, 52, -107, -107, - -107, -107, -107, -107, -107, -107, -107, -107, -107, -107, - -107, -107, -107, -107, -107, -107, 36, -107, -107, 45, - -107, 42, -107, 40, -107, 80, -107, -107, 77, -107, - 88, -107, -107, -107, 83, 74, -107, -107, -107, -107, - -107, -10, -107, -107, -107, -107, -107, -107, -107, -107, - -107, -107, -107, -107, -107, -107, -107, -107, -107, -107, - -107, -107, 23, -107, -107, -107, -107, 100, -107, -107, - -107, -107, -107, -107, -107, -107, -107, -107, -107, -107, - -107, 4, 223, -107, 230, 236, 222, 205, -107, 127, - 125, 115, 96, 102, -107, -107, -107, -107, -107, -107, - -107, -107, 234, -107, 215, -107, 199, -107, -107, 197, - -107, 190, -107, -107, 163, -107, 90, -107, 0, -107, - -1, -107, 203, -107, 189, 211, -107, -107, 195, -107, - -107, -107, -107, -107, -107, 191, -107, 98, 119, -107, - -107, 95, -107, 81, -107, 79, -107, 82, -107, -107, - 101, -107, -107, -16, -107, -107, 53, -107, 46, -107, - 57, -107, 59, -107, -107, -107, -107, -107, -107, 35, - -107, 33, -107, 39, -107, 89, 67, -107, -107, 58, - -107, -107, 84, -107, -107, -107, 73, -107, -107, -107, - -107, 65, -107, 43, 93, -107, 109, -107, -107, 49, - -107, 47, -107, -107, -107, -107, -107, -107, -107, 50, - -107, -107, -107, -107, -107, -107, 108, -107, -107, 61, - -107, -107, -107, -107, 62, -107, 68, -107, -107, -107, - -107, -107, -23, -107, 69, -107, -19, -107, -107, -107, - -107, 97, -107, -107, 99, -107, -107, -107, -107, -107, - 60, -61, -107, -107, 34, -107, 37, -107, 29, -107, - -107, -107, -107, 32, -107, 76, -107, 44, -107, 56, - -107, -107, -107, -107, -107, -107, 31, -107, -107, 116, - -107, -107, -107, -107, -6, -107, -107, 70, -107, -107, - 64, -107, -107, -107, -107, -107, -107, -107, -107, -107, - -107, -107, -107, -107, -107, -107, -107, 193, -107, -107, - -107, -107, -107, 7, -107, -107, -107, -107, -107, -107, - -107, -20, -107, -107, -107, -7, -107, -107, 290, -107, - -107, -107, -107, -107, -107, -107, -107, -107, -107, -107, - -2, -25, -107, -15, -107, -107, -107, -107, 172, -107, - -107, -107, 287, -107, -107, 288, -107, -107, -107, 291, - -107, -107, -107, -107, 336, -107, -107, 20, -107, -107, - 15, 3, -107, 304, -107, -107, -107, 24, -107, -107, - -107, 28, 21, 26, -107, -107, -107, -107, -107, 320, - 104, -107, 13, 381, -3, -107, 6, -107, 10, -107, - 167, 22, -107, -107, 12, -107, -107, 87, -107, -107, - -107, 25, -107, -107, -107, -107, 11, -107, 14, 85, - -107, 121, -107, -107, -107, -107, -107, 27, -107, -107, - 17, -107, -107, 18, 91, -107, -107, -107, 16, -107, - -107, -107, -107, -107, -107, -4, -107, -107, -107, -107, - -107, -107, -107, -107, -107}; - -const short QDeclarativeJSGrammar::action_info [] = { - 416, 257, 533, -132, 403, -113, 346, -102, 575, 348, - 572, -121, 531, -103, -121, 545, 345, 430, 342, 348, - 340, 343, 440, 401, 391, 545, 563, 389, 538, 446, - 352, 444, -129, 416, -124, -102, 545, 453, 420, 408, - -124, 431, -132, 424, -126, 424, 424, 620, 440, 457, - -103, 440, -129, 457, -126, 440, 560, 453, -113, 257, - 565, 346, 545, 335, 272, 346, 466, 236, 448, 190, - 149, 164, 141, 170, 99, 511, 272, 409, 257, 312, - 296, 414, 348, 312, 189, 164, 187, 318, 325, 71, - 306, 252, 644, 416, 141, 453, 292, 457, 440, 147, - 304, 71, 443, 183, 179, 141, 0, 141, 0, 172, - 99, 427, 434, 141, 301, 477, 444, 0, 0, 0, - 0, 0, 141, 0, 0, 0, 0, 292, 173, 294, - 58, 294, 542, 251, 331, 542, 333, 141, 141, 101, - 141, 59, 0, 58, 62, 256, 255, 141, 247, 246, - 141, 399, 0, 177, 59, 63, 428, 327, 620, 254, - 314, 101, 141, 478, 315, 640, 639, 242, 241, 249, - 248, 58, 634, 633, 488, 58, 249, 248, 577, 576, - 615, 141, 59, 543, 166, 518, 59, 172, 167, 455, - 459, 85, 418, 86, 85, 142, 86, 249, 248, 413, - 412, 567, 337, 512, 87, 512, 173, 87, 174, 85, - 328, 86, 512, 0, 350, 85, 64, 86, 529, 85, - 512, 86, 87, 85, 512, 86, 568, 566, 87, 64, - 579, 64, 87, 310, 469, 85, 87, 86, 0, 519, - 517, 85, 141, 86, 554, 0, 172, 536, 87, 514, - 85, 514, 86, 141, 87, 85, 545, 86, 514, 0, - 513, 65, 513, 87, 514, 173, 514, 66, 87, 513, - 514, 103, 172, 0, 65, 513, 65, 513, 0, 0, - 66, 513, 66, 637, 636, 0, 0, 470, 468, 172, - 104, 173, 105, 406, 0, 235, 234, 630, 555, 553, - 172, 537, 535, 0, 274, 275, 438, 437, 173, 172, - 406, 631, 629, 635, 0, 580, 73, 74, -90, 173, - 34, 174, 73, 74, 274, 275, 34, -90, 173, 34, - 174, 276, 277, 85, 34, 86, 0, 0, 0, 0, - 0, 628, 0, 75, 76, 0, 87, 0, 0, 75, - 76, 276, 277, 0, 0, 0, 0, 48, 50, 49, - 0, 0, 0, 48, 50, 49, 48, 50, 49, 0, - 0, 48, 50, 49, 0, 0, 279, 280, 0, 0, - 0, 34, 0, 45, 0, 281, 279, 280, 282, 45, - 283, 34, 45, 279, 280, 281, 34, 45, 282, 0, - 283, 34, 281, 279, 280, 282, 0, 283, 0, 0, - 34, 0, 281, 78, 79, 282, 0, 283, 48, 50, - 49, 80, 81, 0, 34, 82, 0, 83, 48, 50, - 49, -345, 0, 48, 50, 49, 0, 0, 48, 50, - 49, 0, 0, 0, 45, 0, 0, 48, 50, 49, - 0, 0, 0, 0, 45, 0, 0, 78, 79, 45, - 0, 48, 50, 49, 45, 80, 81, 78, 79, 82, - 0, 83, 0, 45, 0, 80, 81, 78, 79, 82, - 0, 83, 34, 279, 280, 80, 81, 45, 0, 82, - 34, 83, 281, 34, 0, 282, 0, 283, 6, 5, - 4, 1, 3, 2, 34, 0, 0, 0, 0, 0, - 0, -345, 0, 0, 245, 244, 0, 0, 0, 48, - 50, 49, 245, 244, 0, 240, 239, 48, 50, 49, - 48, 50, 49, 0, 0, 0, 0, 0, 0, 0, - 34, 48, 50, 49, 0, 45, 0, 0, 34, 0, - 0, 34, 0, 45, 0, 0, 45, 0, 0, 0, - 0, 0, 78, 79, 0, 0, 0, 45, 0, 0, - 80, 81, 245, 244, 82, 0, 83, 48, 50, 49, - 240, 239, 151, 240, 239, 48, 50, 49, 48, 50, - 49, 0, 152, 0, 0, 0, 153, 0, 0, 0, - 0, 0, 0, 45, 0, 154, 0, 155, 0, 0, - 308, 45, 0, 0, 45, 0, 0, 0, 156, 0, - 157, 62, 0, 0, 0, 0, 0, 0, 158, 0, - 0, 159, 63, 0, 0, 0, 0, 160, 0, 30, - 31, 151, 0, 161, 0, 0, 0, 0, 0, 33, - 0, 152, 0, 0, 0, 153, 34, 0, 0, 162, - 35, 36, 0, 37, 154, 0, 155, 0, 0, 0, - 503, 0, 0, 0, 44, 0, 0, 156, 0, 157, - 62, 0, 0, 0, 0, 0, 0, 158, 0, 0, - 159, 63, 51, 48, 50, 49, 160, 52, 0, 0, - 0, 0, 161, 0, 0, 0, 0, 0, 43, 54, - 32, 0, 30, 31, 40, 0, 0, 0, 162, 45, - 0, 0, 33, 0, 0, 0, 0, 0, 0, 34, - 0, 0, 0, 35, 36, 0, 37, 0, 0, 0, - 30, 31, 0, 41, 0, 0, 0, 44, 0, 0, - 33, 0, 0, 0, 0, 0, 0, 34, 0, 0, - 0, 35, 36, 0, 37, 51, 48, 50, 49, 0, - 52, 503, 0, 0, 0, 44, 0, 0, 0, 0, - 0, 43, 54, 32, 0, 0, 0, 40, 0, 0, - 0, 0, 45, 51, 48, 50, 49, 0, 52, 0, - 0, 0, 30, 31, 0, 0, 0, 0, 0, 43, - 54, 32, 33, 0, 0, 40, 0, 0, 0, 34, - 45, 0, 0, 35, 36, 0, 37, 0, 0, 0, - 30, 31, 0, 41, 0, 0, 0, 44, 0, 0, - 33, 0, 0, 0, 0, 0, 0, 34, 0, 0, - 0, 35, 36, 0, 37, 51, 48, 50, 49, 0, - 52, 503, 0, 0, 0, 44, 0, 0, 0, 0, - 0, 43, 54, 32, 0, 0, 0, 40, 0, 0, - 0, 0, 45, 51, 48, 50, 49, 0, 52, 0, - 0, 0, 30, 31, 0, 0, 0, 0, 0, 43, - 54, 32, 33, 0, 0, 40, 0, 0, 0, 34, - 45, 0, 0, 35, 36, 0, 37, 0, 0, 0, - 30, 31, 0, 503, 0, 0, 0, 44, 0, 0, - 33, 0, 0, 0, 0, 0, 0, 34, 0, 0, - 0, 35, 36, 0, 37, 51, 48, 50, 49, 0, - 52, 41, 0, 0, 0, 44, 0, 0, 0, 0, - 0, 43, 54, 32, 0, 0, 0, 40, 0, 0, - 0, 0, 45, 51, 48, 50, 49, 0, 52, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, - 54, 32, 0, 0, 0, 40, 0, 0, 0, 0, - 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 502, 0, 30, 31, 0, 0, 0, 0, 0, 0, - 0, 0, 215, 0, 0, 0, 0, 0, 0, 34, - 0, 0, 0, 35, 36, 0, 37, 0, 0, 0, - 0, 0, 0, 503, 0, 0, 0, 44, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 51, 504, 506, 505, 0, - 52, 0, 0, 0, 0, 226, 0, 0, 0, 0, - 0, 43, 54, 32, 210, 0, 0, 40, 0, 0, - 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 502, 0, 30, 31, 0, 0, 0, 0, - 0, 0, 0, 0, 215, 0, 0, 0, 0, 0, - 0, 34, 0, 0, 0, 35, 36, 0, 37, 0, - 0, 0, 0, 0, 0, 503, 0, 0, 0, 44, - 0, 0, 0, 0, 0, 0, 0, 550, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 51, 504, 506, - 505, 0, 52, 0, 0, 0, 0, 226, 0, 0, - 0, 0, 0, 43, 54, 32, 210, 0, 0, 40, - 0, 0, 0, 0, 45, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 502, 0, 30, 31, 0, 0, - 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, - 0, 0, 0, 34, 0, 0, 0, 35, 36, 0, - 37, 0, 0, 0, 0, 0, 0, 503, 0, 0, - 0, 44, 0, 0, 0, 0, 0, 0, 0, 547, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, - 504, 506, 505, 0, 52, 0, 0, 0, 0, 226, - 0, 0, 0, 0, 0, 43, 54, 32, 210, 0, - 0, 40, 0, 0, 0, 0, 45, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 29, 30, 31, 0, - 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, - 0, 0, 0, 0, 34, 0, 0, 0, 35, 36, - 0, 37, 0, 0, 0, 38, 0, 39, 41, 42, - 0, 0, 44, 0, 0, 0, 46, 0, 47, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 51, 48, 50, 49, 0, 52, 0, 53, 0, 55, - 0, 56, 0, 0, 0, 0, 43, 54, 32, 0, - 0, 0, 40, 0, 0, 0, 0, 45, 0, 0, - 0, 0, 0, 0, 0, 0, 0, -122, 0, 0, - 0, 29, 30, 31, 0, 0, 0, 0, 0, 0, - 0, 0, 33, 0, 0, 0, 0, 0, 0, 34, - 0, 0, 0, 35, 36, 0, 37, 0, 0, 0, - 38, 0, 39, 41, 42, 0, 0, 44, 0, 0, - 0, 46, 0, 47, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 51, 48, 50, 49, 0, - 52, 0, 53, 0, 55, 0, 56, 0, 0, 0, - 0, 43, 54, 32, 0, 0, 0, 40, 0, 0, - 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 29, 30, 31, 0, 0, 0, 0, 0, - 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, - 34, 0, 0, 0, 35, 36, 0, 37, 0, 0, - 0, 38, 0, 39, 41, 42, 0, 0, 44, 0, - 0, 0, 46, 0, 47, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 51, 48, 50, 49, - 0, 52, 0, 53, 0, 55, 271, 56, 0, 0, - 0, 0, 43, 54, 32, 0, 0, 0, 40, 0, - 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 475, 0, 0, 29, 30, 31, 0, - 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, - 0, 0, 0, 0, 34, 0, 0, 0, 35, 36, - 0, 37, 0, 0, 0, 38, 0, 39, 41, 42, - 0, 0, 44, 0, 0, 0, 46, 0, 47, 0, - 0, 476, 0, 0, 0, 0, 0, 0, 0, 0, - 51, 48, 50, 49, 0, 52, 0, 53, 0, 55, - 0, 56, 0, 0, 0, 0, 43, 54, 32, 0, - 0, 0, 40, 0, 0, 0, 0, 45, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 475, 0, 0, - 29, 30, 31, 0, 0, 0, 0, 0, 0, 0, - 0, 33, 0, 0, 0, 0, 0, 0, 34, 0, - 0, 0, 35, 36, 0, 37, 0, 0, 0, 38, - 0, 39, 41, 42, 0, 0, 44, 0, 0, 0, - 46, 0, 47, 0, 0, 481, 0, 0, 0, 0, - 0, 0, 0, 0, 51, 48, 50, 49, 0, 52, - 0, 53, 0, 55, 0, 56, 0, 0, 0, 0, - 43, 54, 32, 0, 0, 0, 40, 0, 0, 0, - 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 483, 0, 0, 29, 30, 31, 0, 0, 0, - 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, - 0, 0, 34, 0, 0, 0, 35, 36, 0, 37, - 0, 0, 0, 38, 0, 39, 41, 42, 0, 0, - 44, 0, 0, 0, 46, 0, 47, 0, 0, 484, - 0, 0, 0, 0, 0, 0, 0, 0, 51, 48, - 50, 49, 0, 52, 0, 53, 0, 55, 0, 56, - 0, 0, 0, 0, 43, 54, 32, 0, 0, 0, - 40, 0, 0, 0, 0, 45, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 483, 0, 0, 29, 30, - 31, 0, 0, 0, 0, 0, 0, 0, 0, 33, - 0, 0, 0, 0, 0, 0, 34, 0, 0, 0, - 35, 36, 0, 37, 0, 0, 0, 38, 0, 39, - 41, 42, 0, 0, 44, 0, 0, 0, 46, 0, - 47, 0, 0, 486, 0, 0, 0, 0, 0, 0, - 0, 0, 51, 48, 50, 49, 0, 52, 0, 53, - 0, 55, 0, 56, 0, 0, 0, 0, 43, 54, - 32, 0, 0, 0, 40, 0, 0, 0, 0, 45, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, - 30, 31, 0, 0, 0, 0, 0, 0, 0, 0, - 33, 0, 0, 0, 0, 0, 0, 34, 217, 0, - 0, 218, 36, 0, 37, 0, 0, 0, 38, 0, - 39, 41, 42, 0, 0, 44, 0, 0, 0, 46, - 0, 47, 0, 0, 0, 0, 0, 0, 0, 221, - 0, 0, 0, 51, 48, 50, 49, 223, 52, 0, - 53, 225, 55, 0, 56, 0, 228, 0, 0, 43, - 54, 32, 0, 0, 0, 40, 0, 0, 0, 0, - 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 29, 30, 31, 0, 0, 0, 0, 0, 0, 0, - 0, 33, 0, 0, 0, 0, 0, 0, 34, 217, - 0, 0, 582, 583, 0, 37, 0, 0, 0, 38, - 0, 39, 41, 42, 0, 0, 44, 0, 0, 0, - 46, 0, 47, 0, 0, 0, 0, 0, 0, 0, - 221, 0, 0, 0, 51, 48, 50, 49, 223, 52, - 0, 53, 225, 55, 0, 56, 0, 228, 0, 0, - 43, 54, 32, 0, 0, 0, 40, 0, 0, 0, - 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 109, 110, 111, 0, 0, 113, 115, 116, 0, - 0, 117, 0, 118, 0, 0, 0, 120, 121, 122, - 0, 0, 0, 0, 0, 0, 34, 123, 124, 125, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 126, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 129, 0, 0, 0, - 0, 0, 0, 48, 50, 49, 130, 131, 132, 0, - 134, 135, 136, 137, 138, 139, 0, 0, 127, 133, - 119, 112, 114, 128, 0, 0, 0, 0, 0, 45, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, - 110, 111, 0, 0, 113, 115, 116, 0, 0, 117, - 0, 118, 0, 0, 0, 120, 121, 122, 0, 0, - 0, 0, 0, 0, 393, 123, 124, 125, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 126, 0, - 0, 0, 394, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 129, 0, 0, 0, 0, 0, - 398, 395, 397, 0, 130, 131, 132, 0, 134, 135, - 136, 137, 138, 139, 0, 0, 127, 133, 119, 112, - 114, 128, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 109, 110, 111, - 0, 0, 113, 115, 116, 0, 0, 117, 0, 118, - 0, 0, 0, 120, 121, 122, 0, 0, 0, 0, - 0, 0, 393, 123, 124, 125, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 126, 0, 0, 0, - 394, 0, 0, 0, 0, 0, 0, 0, 396, 0, - 0, 0, 129, 0, 0, 0, 0, 0, 398, 395, - 397, 0, 130, 131, 132, 0, 134, 135, 136, 137, - 138, 139, 0, 0, 127, 133, 119, 112, 114, 128, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 209, 0, 0, 0, 0, - 211, 0, 29, 30, 31, 213, 0, 0, 0, 0, - 0, 0, 214, 215, 0, 0, 0, 0, 0, 0, - 216, 217, 0, 0, 218, 36, 0, 37, 0, 0, - 0, 38, 0, 39, 41, 42, 0, 0, 44, 0, - 0, 0, 46, 0, 47, 0, 0, 0, 0, 0, - 220, 0, 221, 0, 0, 0, 51, 219, 222, 49, - 223, 52, 224, 53, 225, 55, 226, 56, 227, 228, - 0, 0, 43, 54, 32, 210, 212, 0, 40, 0, - 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 209, 0, 0, 0, 0, 211, 0, - 29, 30, 31, 213, 0, 0, 0, 0, 0, 0, - 214, 33, 0, 0, 0, 0, 0, 0, 216, 217, - 0, 0, 218, 36, 0, 37, 0, 0, 0, 38, - 0, 39, 41, 42, 0, 0, 44, 0, 0, 0, - 46, 0, 47, 0, 0, 0, 0, 0, 220, 0, - 221, 0, 0, 0, 51, 219, 222, 49, 223, 52, - 224, 53, 225, 55, 226, 56, 227, 228, 0, 0, - 43, 54, 32, 210, 212, 0, 40, 0, 0, 0, - 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 586, 110, 111, 0, 0, 588, 115, 590, 30, - 31, 591, 0, 118, 0, 0, 0, 120, 593, 594, - 0, 0, 0, 0, 0, 0, 595, 596, 124, 125, - 218, 36, 0, 37, 0, 0, 0, 38, 0, 39, - 597, 42, 0, 0, 599, 0, 0, 0, 46, 0, - 47, 0, 0, 0, 0, 0, 601, 0, 221, 0, - 0, 0, 603, 600, 602, 49, 604, 605, 606, 53, - 608, 609, 610, 611, 612, 613, 0, 0, 598, 607, - 592, 587, 589, 128, 40, 0, 0, 0, 0, 45, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 361, - 110, 111, 0, 0, 363, 115, 365, 30, 31, 366, - 0, 118, 0, 0, 0, 120, 368, 369, 0, 0, - 0, 0, 0, 0, 370, 371, 124, 125, 218, 36, - 0, 37, 0, 0, 0, 38, 0, 39, 372, 42, - 0, 0, 374, 0, 0, 0, 46, 0, 47, 0, - -268, 0, 0, 0, 376, 0, 221, 0, 0, 0, - 378, 375, 377, 49, 379, 380, 381, 53, 383, 384, - 385, 386, 387, 388, 0, 0, 373, 382, 367, 362, - 364, 128, 40, 0, 0, 0, 0, 45, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - - 534, 311, 497, 309, 532, 461, 498, 499, 516, 515, - 619, 638, 16, 552, 436, 358, 616, 472, 562, 320, - 528, 238, 487, 182, 250, 243, 253, 182, 302, 641, - 627, 632, 150, 485, 143, 454, 439, 402, 445, 559, - 237, 574, 250, 578, 561, 186, 618, 458, 238, 349, - 573, 449, 447, 571, 243, 347, 450, 243, 460, 351, - 238, 353, 358, 410, 415, 439, 176, 188, 436, 250, - 467, 417, 433, 182, 425, 429, 302, 169, 456, 358, - 171, 140, 336, 334, 338, 344, 436, 392, 390, 400, - 163, 302, 307, 148, 146, 339, 439, 404, 302, 358, - 404, 358, 0, 482, 501, 480, 0, 642, 0, 479, - 0, 0, 0, 320, 60, 0, 186, 501, 90, 60, - 60, 489, 302, 60, 617, 93, 0, 88, 0, 405, - 0, 461, 405, 60, 60, 451, 180, 60, 0, 180, - 60, 60, 60, 451, 60, 95, 89, 146, 266, 287, - 60, 146, 407, 270, 60, 288, 178, 60, 106, 452, - 0, 60, 60, 60, 102, 60, 302, 332, 286, 60, - 92, 452, 60, 60, 451, 60, 165, 168, 285, 432, - 284, 435, 60, 60, 108, 501, 329, 94, 540, 96, - 60, 330, 60, 302, 494, 60, 77, 237, 60, 404, - 452, 341, 471, 72, 60, 60, 67, 69, 60, 60, - 68, 0, 70, 60, 60, 60, 61, 180, 60, 60, - 98, 491, 60, 91, 490, 60, 60, 60, 493, 60, - 84, 405, 60, 97, 492, 305, 0, 60, 0, 298, - 0, 100, 270, 298, 270, 298, 106, 298, 270, 0, - 270, 60, 270, 60, 316, 0, 270, 0, 270, 298, - 291, 326, 303, 60, 270, 319, 313, 300, 270, 297, - 60, 60, 108, 175, 295, 270, 270, 290, 60, 501, - 273, 317, 60, 270, 60, 278, 509, 270, 0, 270, - 0, 289, 0, 548, 0, 293, 551, 0, 500, 510, - 501, 501, 0, 544, 501, 0, 0, 0, 509, 0, - 0, 509, 520, 521, 522, 523, 527, 524, 525, 0, - 500, 510, 0, 500, 510, 564, 520, 521, 522, 523, - 527, 524, 525, 581, 0, 0, 0, 0, 0, 0, - 584, 585, 520, 521, 522, 523, 527, 524, 525, 556, - 0, 0, 0, 0, 0, 0, 557, 558, 520, 521, - 522, 523, 527, 524, 525, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 556, 0, 0, 540, 0, 614, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 472, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0}; - -const short QDeclarativeJSGrammar::action_check [] = { - 36, 36, 24, 7, 55, 7, 7, 7, 60, 36, - 8, 7, 37, 7, 7, 33, 55, 55, 60, 36, - 36, 33, 33, 55, 8, 33, 7, 7, 34, 36, - 16, 20, 7, 36, 7, 7, 33, 36, 33, 60, - 7, 7, 7, 5, 7, 5, 5, 90, 33, 36, - 7, 33, 7, 36, 7, 33, 66, 36, 7, 36, - 29, 7, 33, 31, 1, 7, 17, 55, 60, 33, - 60, 2, 8, 7, 48, 66, 1, 7, 36, 2, - 8, 7, 36, 2, 60, 2, 8, 7, 17, 1, - 60, 36, 0, 36, 8, 36, 48, 36, 33, 8, - 61, 1, 6, 36, 60, 8, -1, 8, -1, 15, - 48, 10, 7, 8, 61, 8, 20, -1, -1, -1, - -1, -1, 8, -1, -1, -1, -1, 48, 34, 79, - 40, 79, 8, 77, 61, 8, 60, 8, 8, 79, - 8, 51, -1, 40, 42, 61, 62, 8, 61, 62, - 8, 7, -1, 56, 51, 53, 55, 8, 90, 60, - 50, 79, 8, 56, 54, 61, 62, 61, 62, 61, - 62, 40, 61, 62, 60, 40, 61, 62, 61, 62, - 56, 8, 51, 56, 50, 7, 51, 15, 54, 60, - 60, 25, 60, 27, 25, 56, 27, 61, 62, 61, - 62, 36, 60, 29, 38, 29, 34, 38, 36, 25, - 61, 27, 29, -1, 60, 25, 12, 27, 29, 25, - 29, 27, 38, 25, 29, 27, 61, 62, 38, 12, - 7, 12, 38, 60, 8, 25, 38, 27, -1, 61, - 62, 25, 8, 27, 7, -1, 15, 7, 38, 75, - 25, 75, 27, 8, 38, 25, 33, 27, 75, -1, - 86, 57, 86, 38, 75, 34, 75, 63, 38, 86, - 75, 15, 15, -1, 57, 86, 57, 86, -1, -1, - 63, 86, 63, 61, 62, -1, -1, 61, 62, 15, - 34, 34, 36, 36, -1, 61, 62, 47, 61, 62, - 15, 61, 62, -1, 18, 19, 61, 62, 34, 15, - 36, 61, 62, 91, -1, 92, 18, 19, 33, 34, - 29, 36, 18, 19, 18, 19, 29, 33, 34, 29, - 36, 45, 46, 25, 29, 27, -1, -1, -1, -1, - -1, 91, -1, 45, 46, -1, 38, -1, -1, 45, - 46, 45, 46, -1, -1, -1, -1, 66, 67, 68, - -1, -1, -1, 66, 67, 68, 66, 67, 68, -1, - -1, 66, 67, 68, -1, -1, 23, 24, -1, -1, - -1, 29, -1, 92, -1, 32, 23, 24, 35, 92, - 37, 29, 92, 23, 24, 32, 29, 92, 35, -1, - 37, 29, 32, 23, 24, 35, -1, 37, -1, -1, - 29, -1, 32, 23, 24, 35, -1, 37, 66, 67, - 68, 31, 32, -1, 29, 35, -1, 37, 66, 67, - 68, 36, -1, 66, 67, 68, -1, -1, 66, 67, - 68, -1, -1, -1, 92, -1, -1, 66, 67, 68, - -1, -1, -1, -1, 92, -1, -1, 23, 24, 92, - -1, 66, 67, 68, 92, 31, 32, 23, 24, 35, - -1, 37, -1, 92, -1, 31, 32, 23, 24, 35, - -1, 37, 29, 23, 24, 31, 32, 92, -1, 35, - 29, 37, 32, 29, -1, 35, -1, 37, 94, 95, - 96, 97, 98, 99, 29, -1, -1, -1, -1, -1, - -1, 36, -1, -1, 61, 62, -1, -1, -1, 66, - 67, 68, 61, 62, -1, 61, 62, 66, 67, 68, - 66, 67, 68, -1, -1, -1, -1, -1, -1, -1, - 29, 66, 67, 68, -1, 92, -1, -1, 29, -1, - -1, 29, -1, 92, -1, -1, 92, -1, -1, -1, - -1, -1, 23, 24, -1, -1, -1, 92, -1, -1, - 31, 32, 61, 62, 35, -1, 37, 66, 67, 68, - 61, 62, 3, 61, 62, 66, 67, 68, 66, 67, - 68, -1, 13, -1, -1, -1, 17, -1, -1, -1, - -1, -1, -1, 92, -1, 26, -1, 28, -1, -1, - 31, 92, -1, -1, 92, -1, -1, -1, 39, -1, - 41, 42, -1, -1, -1, -1, -1, -1, 49, -1, - -1, 52, 53, -1, -1, -1, -1, 58, -1, 12, - 13, 3, -1, 64, -1, -1, -1, -1, -1, 22, - -1, 13, -1, -1, -1, 17, 29, -1, -1, 80, - 33, 34, -1, 36, 26, -1, 28, -1, -1, -1, - 43, -1, -1, -1, 47, -1, -1, 39, -1, 41, - 42, -1, -1, -1, -1, -1, -1, 49, -1, -1, - 52, 53, 65, 66, 67, 68, 58, 70, -1, -1, - -1, -1, 64, -1, -1, -1, -1, -1, 81, 82, - 83, -1, 12, 13, 87, -1, -1, -1, 80, 92, - -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, - -1, -1, -1, 33, 34, -1, 36, -1, -1, -1, - 12, 13, -1, 43, -1, -1, -1, 47, -1, -1, - 22, -1, -1, -1, -1, -1, -1, 29, -1, -1, - -1, 33, 34, -1, 36, 65, 66, 67, 68, -1, - 70, 43, -1, -1, -1, 47, -1, -1, -1, -1, - -1, 81, 82, 83, -1, -1, -1, 87, -1, -1, - -1, -1, 92, 65, 66, 67, 68, -1, 70, -1, - -1, -1, 12, 13, -1, -1, -1, -1, -1, 81, - 82, 83, 22, -1, -1, 87, -1, -1, -1, 29, - 92, -1, -1, 33, 34, -1, 36, -1, -1, -1, - 12, 13, -1, 43, -1, -1, -1, 47, -1, -1, - 22, -1, -1, -1, -1, -1, -1, 29, -1, -1, - -1, 33, 34, -1, 36, 65, 66, 67, 68, -1, - 70, 43, -1, -1, -1, 47, -1, -1, -1, -1, - -1, 81, 82, 83, -1, -1, -1, 87, -1, -1, - -1, -1, 92, 65, 66, 67, 68, -1, 70, -1, - -1, -1, 12, 13, -1, -1, -1, -1, -1, 81, - 82, 83, 22, -1, -1, 87, -1, -1, -1, 29, - 92, -1, -1, 33, 34, -1, 36, -1, -1, -1, - 12, 13, -1, 43, -1, -1, -1, 47, -1, -1, - 22, -1, -1, -1, -1, -1, -1, 29, -1, -1, - -1, 33, 34, -1, 36, 65, 66, 67, 68, -1, - 70, 43, -1, -1, -1, 47, -1, -1, -1, -1, - -1, 81, 82, 83, -1, -1, -1, 87, -1, -1, - -1, -1, 92, 65, 66, 67, 68, -1, 70, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 81, - 82, 83, -1, -1, -1, 87, -1, -1, -1, -1, - 92, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 10, -1, 12, 13, -1, -1, -1, -1, -1, -1, - -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, - -1, -1, -1, 33, 34, -1, 36, -1, -1, -1, - -1, -1, -1, 43, -1, -1, -1, 47, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 65, 66, 67, 68, -1, - 70, -1, -1, -1, -1, 75, -1, -1, -1, -1, - -1, 81, 82, 83, 84, -1, -1, 87, -1, -1, - -1, -1, 92, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 10, -1, 12, 13, -1, -1, -1, -1, - -1, -1, -1, -1, 22, -1, -1, -1, -1, -1, - -1, 29, -1, -1, -1, 33, 34, -1, 36, -1, - -1, -1, -1, -1, -1, 43, -1, -1, -1, 47, - -1, -1, -1, -1, -1, -1, -1, 55, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 65, 66, 67, - 68, -1, 70, -1, -1, -1, -1, 75, -1, -1, - -1, -1, -1, 81, 82, 83, 84, -1, -1, 87, - -1, -1, -1, -1, 92, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 10, -1, 12, 13, -1, -1, - -1, -1, -1, -1, -1, -1, 22, -1, -1, -1, - -1, -1, -1, 29, -1, -1, -1, 33, 34, -1, - 36, -1, -1, -1, -1, -1, -1, 43, -1, -1, - -1, 47, -1, -1, -1, -1, -1, -1, -1, 55, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, - 66, 67, 68, -1, 70, -1, -1, -1, -1, 75, - -1, -1, -1, -1, -1, 81, 82, 83, 84, -1, - -1, 87, -1, -1, -1, -1, 92, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 11, 12, 13, -1, - -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, - -1, -1, -1, -1, 29, -1, -1, -1, 33, 34, - -1, 36, -1, -1, -1, 40, -1, 42, 43, 44, - -1, -1, 47, -1, -1, -1, 51, -1, 53, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 65, 66, 67, 68, -1, 70, -1, 72, -1, 74, - -1, 76, -1, -1, -1, -1, 81, 82, 83, -1, - -1, -1, 87, -1, -1, -1, -1, 92, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 7, -1, -1, - -1, 11, 12, 13, -1, -1, -1, -1, -1, -1, - -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, - -1, -1, -1, 33, 34, -1, 36, -1, -1, -1, - 40, -1, 42, 43, 44, -1, -1, 47, -1, -1, - -1, 51, -1, 53, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 65, 66, 67, 68, -1, - 70, -1, 72, -1, 74, -1, 76, -1, -1, -1, - -1, 81, 82, 83, -1, -1, -1, 87, -1, -1, - -1, -1, 92, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 11, 12, 13, -1, -1, -1, -1, -1, - -1, -1, -1, 22, -1, -1, -1, -1, -1, -1, - 29, -1, -1, -1, 33, 34, -1, 36, -1, -1, - -1, 40, -1, 42, 43, 44, -1, -1, 47, -1, - -1, -1, 51, -1, 53, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 65, 66, 67, 68, - -1, 70, -1, 72, -1, 74, 75, 76, -1, -1, - -1, -1, 81, 82, 83, -1, -1, -1, 87, -1, - -1, -1, -1, 92, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 8, -1, -1, 11, 12, 13, -1, - -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, - -1, -1, -1, -1, 29, -1, -1, -1, 33, 34, - -1, 36, -1, -1, -1, 40, -1, 42, 43, 44, - -1, -1, 47, -1, -1, -1, 51, -1, 53, -1, - -1, 56, -1, -1, -1, -1, -1, -1, -1, -1, - 65, 66, 67, 68, -1, 70, -1, 72, -1, 74, - -1, 76, -1, -1, -1, -1, 81, 82, 83, -1, - -1, -1, 87, -1, -1, -1, -1, 92, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 8, -1, -1, - 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, - -1, 22, -1, -1, -1, -1, -1, -1, 29, -1, - -1, -1, 33, 34, -1, 36, -1, -1, -1, 40, - -1, 42, 43, 44, -1, -1, 47, -1, -1, -1, - 51, -1, 53, -1, -1, 56, -1, -1, -1, -1, - -1, -1, -1, -1, 65, 66, 67, 68, -1, 70, - -1, 72, -1, 74, -1, 76, -1, -1, -1, -1, - 81, 82, 83, -1, -1, -1, 87, -1, -1, -1, - -1, 92, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 8, -1, -1, 11, 12, 13, -1, -1, -1, - -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, - -1, -1, 29, -1, -1, -1, 33, 34, -1, 36, - -1, -1, -1, 40, -1, 42, 43, 44, -1, -1, - 47, -1, -1, -1, 51, -1, 53, -1, -1, 56, - -1, -1, -1, -1, -1, -1, -1, -1, 65, 66, - 67, 68, -1, 70, -1, 72, -1, 74, -1, 76, - -1, -1, -1, -1, 81, 82, 83, -1, -1, -1, - 87, -1, -1, -1, -1, 92, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 8, -1, -1, 11, 12, - 13, -1, -1, -1, -1, -1, -1, -1, -1, 22, - -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, - 33, 34, -1, 36, -1, -1, -1, 40, -1, 42, - 43, 44, -1, -1, 47, -1, -1, -1, 51, -1, - 53, -1, -1, 56, -1, -1, -1, -1, -1, -1, - -1, -1, 65, 66, 67, 68, -1, 70, -1, 72, - -1, 74, -1, 76, -1, -1, -1, -1, 81, 82, - 83, -1, -1, -1, 87, -1, -1, -1, -1, 92, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, - 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, - 22, -1, -1, -1, -1, -1, -1, 29, 30, -1, - -1, 33, 34, -1, 36, -1, -1, -1, 40, -1, - 42, 43, 44, -1, -1, 47, -1, -1, -1, 51, - -1, 53, -1, -1, -1, -1, -1, -1, -1, 61, - -1, -1, -1, 65, 66, 67, 68, 69, 70, -1, - 72, 73, 74, -1, 76, -1, 78, -1, -1, 81, - 82, 83, -1, -1, -1, 87, -1, -1, -1, -1, - 92, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, - -1, 22, -1, -1, -1, -1, -1, -1, 29, 30, - -1, -1, 33, 34, -1, 36, -1, -1, -1, 40, - -1, 42, 43, 44, -1, -1, 47, -1, -1, -1, - 51, -1, 53, -1, -1, -1, -1, -1, -1, -1, - 61, -1, -1, -1, 65, 66, 67, 68, 69, 70, - -1, 72, 73, 74, -1, 76, -1, 78, -1, -1, - 81, 82, 83, -1, -1, -1, 87, -1, -1, -1, - -1, 92, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 4, 5, 6, -1, -1, 9, 10, 11, -1, - -1, 14, -1, 16, -1, -1, -1, 20, 21, 22, - -1, -1, -1, -1, -1, -1, 29, 30, 31, 32, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 43, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 59, -1, -1, -1, - -1, -1, -1, 66, 67, 68, 69, 70, 71, -1, - 73, 74, 75, 76, 77, 78, -1, -1, 81, 82, - 83, 84, 85, 86, -1, -1, -1, -1, -1, 92, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, - 5, 6, -1, -1, 9, 10, 11, -1, -1, 14, - -1, 16, -1, -1, -1, 20, 21, 22, -1, -1, - -1, -1, -1, -1, 29, 30, 31, 32, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 43, -1, - -1, -1, 47, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 59, -1, -1, -1, -1, -1, - 65, 66, 67, -1, 69, 70, 71, -1, 73, 74, - 75, 76, 77, 78, -1, -1, 81, 82, 83, 84, - 85, 86, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 4, 5, 6, - -1, -1, 9, 10, 11, -1, -1, 14, -1, 16, - -1, -1, -1, 20, 21, 22, -1, -1, -1, -1, - -1, -1, 29, 30, 31, 32, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 43, -1, -1, -1, - 47, -1, -1, -1, -1, -1, -1, -1, 55, -1, - -1, -1, 59, -1, -1, -1, -1, -1, 65, 66, - 67, -1, 69, 70, 71, -1, 73, 74, 75, 76, - 77, 78, -1, -1, 81, 82, 83, 84, 85, 86, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 4, -1, -1, -1, -1, - 9, -1, 11, 12, 13, 14, -1, -1, -1, -1, - -1, -1, 21, 22, -1, -1, -1, -1, -1, -1, - 29, 30, -1, -1, 33, 34, -1, 36, -1, -1, - -1, 40, -1, 42, 43, 44, -1, -1, 47, -1, - -1, -1, 51, -1, 53, -1, -1, -1, -1, -1, - 59, -1, 61, -1, -1, -1, 65, 66, 67, 68, - 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, - -1, -1, 81, 82, 83, 84, 85, -1, 87, -1, - -1, -1, -1, 92, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 4, -1, -1, -1, -1, 9, -1, - 11, 12, 13, 14, -1, -1, -1, -1, -1, -1, - 21, 22, -1, -1, -1, -1, -1, -1, 29, 30, - -1, -1, 33, 34, -1, 36, -1, -1, -1, 40, - -1, 42, 43, 44, -1, -1, 47, -1, -1, -1, - 51, -1, 53, -1, -1, -1, -1, -1, 59, -1, - 61, -1, -1, -1, 65, 66, 67, 68, 69, 70, - 71, 72, 73, 74, 75, 76, 77, 78, -1, -1, - 81, 82, 83, 84, 85, -1, 87, -1, -1, -1, - -1, 92, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 4, 5, 6, -1, -1, 9, 10, 11, 12, - 13, 14, -1, 16, -1, -1, -1, 20, 21, 22, - -1, -1, -1, -1, -1, -1, 29, 30, 31, 32, - 33, 34, -1, 36, -1, -1, -1, 40, -1, 42, - 43, 44, -1, -1, 47, -1, -1, -1, 51, -1, - 53, -1, -1, -1, -1, -1, 59, -1, 61, -1, - -1, -1, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, 78, -1, -1, 81, 82, - 83, 84, 85, 86, 87, -1, -1, -1, -1, 92, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, - 5, 6, -1, -1, 9, 10, 11, 12, 13, 14, - -1, 16, -1, -1, -1, 20, 21, 22, -1, -1, - -1, -1, -1, -1, 29, 30, 31, 32, 33, 34, - -1, 36, -1, -1, -1, 40, -1, 42, 43, 44, - -1, -1, 47, -1, -1, -1, 51, -1, 53, -1, - 55, -1, -1, -1, 59, -1, 61, -1, -1, -1, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 78, -1, -1, 81, 82, 83, 84, - 85, 86, 87, -1, -1, -1, -1, 92, -1, -1, - -1, -1, -1, -1, -1, -1, -1, - - 15, 2, 105, 3, 29, 15, 4, 2, 15, 29, - 9, 15, 3, 15, 3, 2, 19, 39, 15, 15, - 13, 15, 3, 15, 2, 15, 3, 15, 3, 11, - 13, 15, 71, 39, 39, 3, 22, 2, 99, 19, - 4, 15, 2, 15, 29, 15, 19, 3, 15, 3, - 29, 22, 15, 29, 15, 2, 22, 15, 2, 2, - 15, 2, 2, 2, 2, 22, 3, 15, 3, 2, - 39, 3, 3, 15, 97, 94, 3, 39, 2, 2, - 39, 3, 3, 2, 2, 101, 3, 40, 39, 39, - 39, 3, 2, 39, 39, 15, 22, 13, 3, 2, - 13, 2, -1, 39, 13, 35, -1, 16, -1, 39, - -1, -1, -1, 15, 48, -1, 15, 13, 52, 48, - 48, 50, 3, 48, 20, 53, -1, 52, -1, 45, - -1, 15, 45, 48, 48, 50, 50, 48, -1, 50, - 48, 48, 48, 50, 48, 53, 52, 39, 48, 53, - 48, 39, 44, 53, 48, 53, 44, 48, 15, 50, - -1, 48, 48, 48, 58, 48, 3, 72, 53, 48, - 53, 50, 48, 48, 50, 48, 62, 64, 53, 82, - 53, 82, 48, 48, 41, 13, 88, 53, 16, 54, - 48, 72, 48, 3, 50, 48, 54, 4, 48, 13, - 50, 100, 86, 56, 48, 48, 50, 50, 48, 48, - 50, -1, 51, 48, 48, 48, 51, 50, 48, 48, - 54, 50, 48, 53, 50, 48, 48, 48, 50, 48, - 53, 45, 48, 54, 50, 72, -1, 48, -1, 48, - -1, 60, 53, 48, 53, 48, 15, 48, 53, -1, - 53, 48, 53, 48, 65, -1, 53, -1, 53, 48, - 55, 70, 72, 48, 53, 70, 63, 70, 53, 70, - 48, 48, 41, 42, 59, 53, 53, 55, 48, 13, - 57, 70, 48, 53, 48, 55, 20, 53, -1, 53, - -1, 55, -1, 5, -1, 61, 5, -1, 32, 33, - 13, 13, -1, 16, 13, -1, -1, -1, 20, -1, - -1, 20, 22, 23, 24, 25, 26, 27, 28, -1, - 32, 33, -1, 32, 33, 21, 22, 23, 24, 25, - 26, 27, 28, 13, -1, -1, -1, -1, -1, -1, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 13, - -1, -1, -1, -1, -1, -1, 20, 21, 22, 23, - 24, 25, 26, 27, 28, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 13, -1, -1, 16, -1, 18, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 39, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1}; - -QT_END_NAMESPACE diff --git a/src/declarative/qml/parser/qdeclarativejsgrammar_p.h b/src/declarative/qml/parser/qdeclarativejsgrammar_p.h deleted file mode 100644 index 5503ff763f..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsgrammar_p.h +++ /dev/null @@ -1,211 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -// This file was generated by qlalr - DO NOT EDIT! -#ifndef QDECLARATIVEJSGRAMMAR_P_H -#define QDECLARATIVEJSGRAMMAR_P_H - -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeJSGrammar -{ -public: - enum VariousConstants { - EOF_SYMBOL = 0, - REDUCE_HERE = 101, - SHIFT_THERE = 100, - T_AND = 1, - T_AND_AND = 2, - T_AND_EQ = 3, - T_AS = 91, - T_AUTOMATIC_SEMICOLON = 62, - T_BREAK = 4, - T_CASE = 5, - T_CATCH = 6, - T_COLON = 7, - T_COMMA = 8, - T_COMMENT = 88, - T_CONST = 84, - T_CONTINUE = 9, - T_DEBUGGER = 85, - T_DEFAULT = 10, - T_DELETE = 11, - T_DIVIDE_ = 12, - T_DIVIDE_EQ = 13, - T_DO = 14, - T_DOT = 15, - T_ELSE = 16, - T_EQ = 17, - T_EQ_EQ = 18, - T_EQ_EQ_EQ = 19, - T_ERROR = 93, - T_FALSE = 83, - T_FEED_JS_EXPRESSION = 97, - T_FEED_JS_PROGRAM = 99, - T_FEED_JS_SOURCE_ELEMENT = 98, - T_FEED_JS_STATEMENT = 96, - T_FEED_UI_OBJECT_MEMBER = 95, - T_FEED_UI_PROGRAM = 94, - T_FINALLY = 20, - T_FOR = 21, - T_FUNCTION = 22, - T_GE = 23, - T_GT = 24, - T_GT_GT = 25, - T_GT_GT_EQ = 26, - T_GT_GT_GT = 27, - T_GT_GT_GT_EQ = 28, - T_IDENTIFIER = 29, - T_IF = 30, - T_IMPORT = 90, - T_IN = 31, - T_INSTANCEOF = 32, - T_LBRACE = 33, - T_LBRACKET = 34, - T_LE = 35, - T_LPAREN = 36, - T_LT = 37, - T_LT_LT = 38, - T_LT_LT_EQ = 39, - T_MINUS = 40, - T_MINUS_EQ = 41, - T_MINUS_MINUS = 42, - T_MULTILINE_STRING_LITERAL = 87, - T_NEW = 43, - T_NOT = 44, - T_NOT_EQ = 45, - T_NOT_EQ_EQ = 46, - T_NULL = 81, - T_NUMERIC_LITERAL = 47, - T_ON = 92, - T_OR = 48, - T_OR_EQ = 49, - T_OR_OR = 50, - T_PLUS = 51, - T_PLUS_EQ = 52, - T_PLUS_PLUS = 53, - T_PROPERTY = 66, - T_PUBLIC = 89, - T_QUESTION = 54, - T_RBRACE = 55, - T_RBRACKET = 56, - T_READONLY = 68, - T_REMAINDER = 57, - T_REMAINDER_EQ = 58, - T_RESERVED_WORD = 86, - T_RETURN = 59, - T_RPAREN = 60, - T_SEMICOLON = 61, - T_SIGNAL = 67, - T_STAR = 63, - T_STAR_EQ = 64, - T_STRING_LITERAL = 65, - T_SWITCH = 69, - T_THIS = 70, - T_THROW = 71, - T_TILDE = 72, - T_TRUE = 82, - T_TRY = 73, - T_TYPEOF = 74, - T_VAR = 75, - T_VOID = 76, - T_WHILE = 77, - T_WITH = 78, - T_XOR = 79, - T_XOR_EQ = 80, - - ACCEPT_STATE = 644, - RULE_COUNT = 349, - STATE_COUNT = 645, - TERMINAL_COUNT = 102, - NON_TERMINAL_COUNT = 107, - - GOTO_INDEX_OFFSET = 645, - GOTO_INFO_OFFSET = 2807, - GOTO_CHECK_OFFSET = 2807 - }; - - static const char *const spell []; - static const short lhs []; - static const short rhs []; - static const short goto_default []; - static const short action_default []; - static const short action_index []; - static const short action_info []; - static const short action_check []; - - static inline int nt_action (int state, int nt) - { - const int yyn = action_index [GOTO_INDEX_OFFSET + state] + nt; - if (yyn < 0 || action_check [GOTO_CHECK_OFFSET + yyn] != nt) - return goto_default [nt]; - - return action_info [GOTO_INFO_OFFSET + yyn]; - } - - static inline int t_action (int state, int token) - { - const int yyn = action_index [state] + token; - - if (yyn < 0 || action_check [yyn] != token) - return - action_default [state]; - - return action_info [yyn]; - } -}; - - -QT_END_NAMESPACE -#endif // QDECLARATIVEJSGRAMMAR_P_H - diff --git a/src/declarative/qml/parser/qdeclarativejskeywords_p.h b/src/declarative/qml/parser/qdeclarativejskeywords_p.h deleted file mode 100644 index fac5b7b5f6..0000000000 --- a/src/declarative/qml/parser/qdeclarativejskeywords_p.h +++ /dev/null @@ -1,860 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEJSKEYWORDS_P_H -#define QDECLARATIVEJSKEYWORDS_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. -// - -static inline int classify2(const QChar *s, bool qmlMode) { - if (s[0].unicode() == 'a') { - if (s[1].unicode() == 's') { - return qmlMode ? Lexer::T_AS : Lexer::T_RESERVED_WORD; - } - } - else if (s[0].unicode() == 'd') { - if (s[1].unicode() == 'o') { - return Lexer::T_DO; - } - } - else if (s[0].unicode() == 'i') { - if (s[1].unicode() == 'f') { - return Lexer::T_IF; - } - else if (s[1].unicode() == 'n') { - return Lexer::T_IN; - } - } - else if (qmlMode && s[0].unicode() == 'o') { - if (s[1].unicode() == 'n') { - return Lexer::T_ON; - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify3(const QChar *s, bool /*qmlMode*/) { - if (s[0].unicode() == 'f') { - if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'r') { - return Lexer::T_FOR; - } - } - } - else if (s[0].unicode() == 'i') { - if (s[1].unicode() == 'n') { - if (s[2].unicode() == 't') { - return Lexer::T_INT; - } - } - } - else if (s[0].unicode() == 'n') { - if (s[1].unicode() == 'e') { - if (s[2].unicode() == 'w') { - return Lexer::T_NEW; - } - } - } - else if (s[0].unicode() == 't') { - if (s[1].unicode() == 'r') { - if (s[2].unicode() == 'y') { - return Lexer::T_TRY; - } - } - } - else if (s[0].unicode() == 'v') { - if (s[1].unicode() == 'a') { - if (s[2].unicode() == 'r') { - return Lexer::T_VAR; - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify4(const QChar *s, bool /*qmlMode*/) { - if (s[0].unicode() == 'b') { - if (s[1].unicode() == 'y') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'e') { - return Lexer::T_BYTE; - } - } - } - } - else if (s[0].unicode() == 'c') { - if (s[1].unicode() == 'a') { - if (s[2].unicode() == 's') { - if (s[3].unicode() == 'e') { - return Lexer::T_CASE; - } - } - } - else if (s[1].unicode() == 'h') { - if (s[2].unicode() == 'a') { - if (s[3].unicode() == 'r') { - return Lexer::T_CHAR; - } - } - } - } - else if (s[0].unicode() == 'e') { - if (s[1].unicode() == 'l') { - if (s[2].unicode() == 's') { - if (s[3].unicode() == 'e') { - return Lexer::T_ELSE; - } - } - } - else if (s[1].unicode() == 'n') { - if (s[2].unicode() == 'u') { - if (s[3].unicode() == 'm') { - return Lexer::T_ENUM; - } - } - } - } - else if (s[0].unicode() == 'g') { - if (s[1].unicode() == 'o') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'o') { - return Lexer::T_GOTO; - } - } - } - } - else if (s[0].unicode() == 'l') { - if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'n') { - if (s[3].unicode() == 'g') { - return Lexer::T_LONG; - } - } - } - } - else if (s[0].unicode() == 'n') { - if (s[1].unicode() == 'u') { - if (s[2].unicode() == 'l') { - if (s[3].unicode() == 'l') { - return Lexer::T_NULL; - } - } - } - } - else if (s[0].unicode() == 't') { - if (s[1].unicode() == 'h') { - if (s[2].unicode() == 'i') { - if (s[3].unicode() == 's') { - return Lexer::T_THIS; - } - } - } - else if (s[1].unicode() == 'r') { - if (s[2].unicode() == 'u') { - if (s[3].unicode() == 'e') { - return Lexer::T_TRUE; - } - } - } - } - else if (s[0].unicode() == 'v') { - if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'i') { - if (s[3].unicode() == 'd') { - return Lexer::T_VOID; - } - } - } - } - else if (s[0].unicode() == 'w') { - if (s[1].unicode() == 'i') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'h') { - return Lexer::T_WITH; - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify5(const QChar *s, bool /*qmlMode*/) { - if (s[0].unicode() == 'b') { - if (s[1].unicode() == 'r') { - if (s[2].unicode() == 'e') { - if (s[3].unicode() == 'a') { - if (s[4].unicode() == 'k') { - return Lexer::T_BREAK; - } - } - } - } - } - else if (s[0].unicode() == 'c') { - if (s[1].unicode() == 'a') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'c') { - if (s[4].unicode() == 'h') { - return Lexer::T_CATCH; - } - } - } - } - else if (s[1].unicode() == 'l') { - if (s[2].unicode() == 'a') { - if (s[3].unicode() == 's') { - if (s[4].unicode() == 's') { - return Lexer::T_CLASS; - } - } - } - } - else if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'n') { - if (s[3].unicode() == 's') { - if (s[4].unicode() == 't') { - return Lexer::T_CONST; - } - } - } - } - } - else if (s[0].unicode() == 'f') { - if (s[1].unicode() == 'a') { - if (s[2].unicode() == 'l') { - if (s[3].unicode() == 's') { - if (s[4].unicode() == 'e') { - return Lexer::T_FALSE; - } - } - } - } - else if (s[1].unicode() == 'i') { - if (s[2].unicode() == 'n') { - if (s[3].unicode() == 'a') { - if (s[4].unicode() == 'l') { - return Lexer::T_FINAL; - } - } - } - } - else if (s[1].unicode() == 'l') { - if (s[2].unicode() == 'o') { - if (s[3].unicode() == 'a') { - if (s[4].unicode() == 't') { - return Lexer::T_FLOAT; - } - } - } - } - } - else if (s[0].unicode() == 's') { - if (s[1].unicode() == 'h') { - if (s[2].unicode() == 'o') { - if (s[3].unicode() == 'r') { - if (s[4].unicode() == 't') { - return Lexer::T_SHORT; - } - } - } - } - else if (s[1].unicode() == 'u') { - if (s[2].unicode() == 'p') { - if (s[3].unicode() == 'e') { - if (s[4].unicode() == 'r') { - return Lexer::T_SUPER; - } - } - } - } - } - else if (s[0].unicode() == 't') { - if (s[1].unicode() == 'h') { - if (s[2].unicode() == 'r') { - if (s[3].unicode() == 'o') { - if (s[4].unicode() == 'w') { - return Lexer::T_THROW; - } - } - } - } - } - else if (s[0].unicode() == 'w') { - if (s[1].unicode() == 'h') { - if (s[2].unicode() == 'i') { - if (s[3].unicode() == 'l') { - if (s[4].unicode() == 'e') { - return Lexer::T_WHILE; - } - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify6(const QChar *s, bool qmlMode) { - if (s[0].unicode() == 'd') { - if (s[1].unicode() == 'e') { - if (s[2].unicode() == 'l') { - if (s[3].unicode() == 'e') { - if (s[4].unicode() == 't') { - if (s[5].unicode() == 'e') { - return Lexer::T_DELETE; - } - } - } - } - } - else if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'u') { - if (s[3].unicode() == 'b') { - if (s[4].unicode() == 'l') { - if (s[5].unicode() == 'e') { - return Lexer::T_DOUBLE; - } - } - } - } - } - } - else if (s[0].unicode() == 'e') { - if (s[1].unicode() == 'x') { - if (s[2].unicode() == 'p') { - if (s[3].unicode() == 'o') { - if (s[4].unicode() == 'r') { - if (s[5].unicode() == 't') { - return Lexer::T_EXPORT; - } - } - } - } - } - } - else if (s[0].unicode() == 'i') { - if (s[1].unicode() == 'm') { - if (s[2].unicode() == 'p') { - if (s[3].unicode() == 'o') { - if (s[4].unicode() == 'r') { - if (s[5].unicode() == 't') { - return qmlMode ? Lexer::T_IMPORT : Lexer::T_RESERVED_WORD; - } - } - } - } - } - } - else if (s[0].unicode() == 'n') { - if (s[1].unicode() == 'a') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'i') { - if (s[4].unicode() == 'v') { - if (s[5].unicode() == 'e') { - return Lexer::T_NATIVE; - } - } - } - } - } - } - else if (s[0].unicode() == 'p') { - if (s[1].unicode() == 'u') { - if (s[2].unicode() == 'b') { - if (s[3].unicode() == 'l') { - if (s[4].unicode() == 'i') { - if (s[5].unicode() == 'c') { - return qmlMode ? Lexer::T_PUBLIC : Lexer::T_RESERVED_WORD; - } - } - } - } - } - } - else if (s[0].unicode() == 'r') { - if (s[1].unicode() == 'e') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'u') { - if (s[4].unicode() == 'r') { - if (s[5].unicode() == 'n') { - return Lexer::T_RETURN; - } - } - } - } - } - } - else if (s[0].unicode() == 's') { - if (qmlMode && s[1].unicode() == 'i') { - if (s[2].unicode() == 'g') { - if (s[3].unicode() == 'n') { - if (s[4].unicode() == 'a') { - if (s[5].unicode() == 'l') { - return Lexer::T_SIGNAL; - } - } - } - } - } - else if (s[1].unicode() == 't') { - if (s[2].unicode() == 'a') { - if (s[3].unicode() == 't') { - if (s[4].unicode() == 'i') { - if (s[5].unicode() == 'c') { - return Lexer::T_STATIC; - } - } - } - } - } - else if (s[1].unicode() == 'w') { - if (s[2].unicode() == 'i') { - if (s[3].unicode() == 't') { - if (s[4].unicode() == 'c') { - if (s[5].unicode() == 'h') { - return Lexer::T_SWITCH; - } - } - } - } - } - } - else if (s[0].unicode() == 't') { - if (s[1].unicode() == 'h') { - if (s[2].unicode() == 'r') { - if (s[3].unicode() == 'o') { - if (s[4].unicode() == 'w') { - if (s[5].unicode() == 's') { - return Lexer::T_THROWS; - } - } - } - } - } - else if (s[1].unicode() == 'y') { - if (s[2].unicode() == 'p') { - if (s[3].unicode() == 'e') { - if (s[4].unicode() == 'o') { - if (s[5].unicode() == 'f') { - return Lexer::T_TYPEOF; - } - } - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify7(const QChar *s, bool /*qmlMode*/) { - if (s[0].unicode() == 'b') { - if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'o') { - if (s[3].unicode() == 'l') { - if (s[4].unicode() == 'e') { - if (s[5].unicode() == 'a') { - if (s[6].unicode() == 'n') { - return Lexer::T_BOOLEAN; - } - } - } - } - } - } - } - else if (s[0].unicode() == 'd') { - if (s[1].unicode() == 'e') { - if (s[2].unicode() == 'f') { - if (s[3].unicode() == 'a') { - if (s[4].unicode() == 'u') { - if (s[5].unicode() == 'l') { - if (s[6].unicode() == 't') { - return Lexer::T_DEFAULT; - } - } - } - } - } - } - } - else if (s[0].unicode() == 'e') { - if (s[1].unicode() == 'x') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'e') { - if (s[4].unicode() == 'n') { - if (s[5].unicode() == 'd') { - if (s[6].unicode() == 's') { - return Lexer::T_EXTENDS; - } - } - } - } - } - } - } - else if (s[0].unicode() == 'f') { - if (s[1].unicode() == 'i') { - if (s[2].unicode() == 'n') { - if (s[3].unicode() == 'a') { - if (s[4].unicode() == 'l') { - if (s[5].unicode() == 'l') { - if (s[6].unicode() == 'y') { - return Lexer::T_FINALLY; - } - } - } - } - } - } - } - else if (s[0].unicode() == 'p') { - if (s[1].unicode() == 'a') { - if (s[2].unicode() == 'c') { - if (s[3].unicode() == 'k') { - if (s[4].unicode() == 'a') { - if (s[5].unicode() == 'g') { - if (s[6].unicode() == 'e') { - return Lexer::T_PACKAGE; - } - } - } - } - } - } - else if (s[1].unicode() == 'r') { - if (s[2].unicode() == 'i') { - if (s[3].unicode() == 'v') { - if (s[4].unicode() == 'a') { - if (s[5].unicode() == 't') { - if (s[6].unicode() == 'e') { - return Lexer::T_PRIVATE; - } - } - } - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify8(const QChar *s, bool qmlMode) { - if (s[0].unicode() == 'a') { - if (s[1].unicode() == 'b') { - if (s[2].unicode() == 's') { - if (s[3].unicode() == 't') { - if (s[4].unicode() == 'r') { - if (s[5].unicode() == 'a') { - if (s[6].unicode() == 'c') { - if (s[7].unicode() == 't') { - return Lexer::T_ABSTRACT; - } - } - } - } - } - } - } - } - else if (s[0].unicode() == 'c') { - if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'n') { - if (s[3].unicode() == 't') { - if (s[4].unicode() == 'i') { - if (s[5].unicode() == 'n') { - if (s[6].unicode() == 'u') { - if (s[7].unicode() == 'e') { - return Lexer::T_CONTINUE; - } - } - } - } - } - } - } - } - else if (s[0].unicode() == 'd') { - if (s[1].unicode() == 'e') { - if (s[2].unicode() == 'b') { - if (s[3].unicode() == 'u') { - if (s[4].unicode() == 'g') { - if (s[5].unicode() == 'g') { - if (s[6].unicode() == 'e') { - if (s[7].unicode() == 'r') { - return Lexer::T_DEBUGGER; - } - } - } - } - } - } - } - } - else if (s[0].unicode() == 'f') { - if (s[1].unicode() == 'u') { - if (s[2].unicode() == 'n') { - if (s[3].unicode() == 'c') { - if (s[4].unicode() == 't') { - if (s[5].unicode() == 'i') { - if (s[6].unicode() == 'o') { - if (s[7].unicode() == 'n') { - return Lexer::T_FUNCTION; - } - } - } - } - } - } - } - } - else if (qmlMode && s[0].unicode() == 'p') { - if (s[1].unicode() == 'r') { - if (s[2].unicode() == 'o') { - if (s[3].unicode() == 'p') { - if (s[4].unicode() == 'e') { - if (s[5].unicode() == 'r') { - if (s[6].unicode() == 't') { - if (s[7].unicode() == 'y') { - return Lexer::T_PROPERTY; - } - } - } - } - } - } - } - } - else if (qmlMode && s[0].unicode() == 'r') { - if (s[1].unicode() == 'e') { - if (s[2].unicode() == 'a') { - if (s[3].unicode() == 'd') { - if (s[4].unicode() == 'o') { - if (s[5].unicode() == 'n') { - if (s[6].unicode() == 'l') { - if (s[7].unicode() == 'y') { - return Lexer::T_READONLY; - } - } - } - } - } - } - } - } - else if (s[0].unicode() == 'v') { - if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'l') { - if (s[3].unicode() == 'a') { - if (s[4].unicode() == 't') { - if (s[5].unicode() == 'i') { - if (s[6].unicode() == 'l') { - if (s[7].unicode() == 'e') { - return Lexer::T_VOLATILE; - } - } - } - } - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify9(const QChar *s, bool /*qmlMode*/) { - if (s[0].unicode() == 'i') { - if (s[1].unicode() == 'n') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'e') { - if (s[4].unicode() == 'r') { - if (s[5].unicode() == 'f') { - if (s[6].unicode() == 'a') { - if (s[7].unicode() == 'c') { - if (s[8].unicode() == 'e') { - return Lexer::T_INTERFACE; - } - } - } - } - } - } - } - } - } - else if (s[0].unicode() == 'p') { - if (s[1].unicode() == 'r') { - if (s[2].unicode() == 'o') { - if (s[3].unicode() == 't') { - if (s[4].unicode() == 'e') { - if (s[5].unicode() == 'c') { - if (s[6].unicode() == 't') { - if (s[7].unicode() == 'e') { - if (s[8].unicode() == 'd') { - return Lexer::T_PROTECTED; - } - } - } - } - } - } - } - } - } - else if (s[0].unicode() == 't') { - if (s[1].unicode() == 'r') { - if (s[2].unicode() == 'a') { - if (s[3].unicode() == 'n') { - if (s[4].unicode() == 's') { - if (s[5].unicode() == 'i') { - if (s[6].unicode() == 'e') { - if (s[7].unicode() == 'n') { - if (s[8].unicode() == 't') { - return Lexer::T_TRANSIENT; - } - } - } - } - } - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify10(const QChar *s, bool /*qmlMode*/) { - if (s[0].unicode() == 'i') { - if (s[1].unicode() == 'm') { - if (s[2].unicode() == 'p') { - if (s[3].unicode() == 'l') { - if (s[4].unicode() == 'e') { - if (s[5].unicode() == 'm') { - if (s[6].unicode() == 'e') { - if (s[7].unicode() == 'n') { - if (s[8].unicode() == 't') { - if (s[9].unicode() == 's') { - return Lexer::T_IMPLEMENTS; - } - } - } - } - } - } - } - } - } - else if (s[1].unicode() == 'n') { - if (s[2].unicode() == 's') { - if (s[3].unicode() == 't') { - if (s[4].unicode() == 'a') { - if (s[5].unicode() == 'n') { - if (s[6].unicode() == 'c') { - if (s[7].unicode() == 'e') { - if (s[8].unicode() == 'o') { - if (s[9].unicode() == 'f') { - return Lexer::T_INSTANCEOF; - } - } - } - } - } - } - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify12(const QChar *s, bool /*qmlMode*/) { - if (s[0].unicode() == 's') { - if (s[1].unicode() == 'y') { - if (s[2].unicode() == 'n') { - if (s[3].unicode() == 'c') { - if (s[4].unicode() == 'h') { - if (s[5].unicode() == 'r') { - if (s[6].unicode() == 'o') { - if (s[7].unicode() == 'n') { - if (s[8].unicode() == 'i') { - if (s[9].unicode() == 'z') { - if (s[10].unicode() == 'e') { - if (s[11].unicode() == 'd') { - return Lexer::T_SYNCHRONIZED; - } - } - } - } - } - } - } - } - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -int Lexer::classify(const QChar *s, int n, bool qmlMode) { - switch (n) { - case 2: return classify2(s, qmlMode); - case 3: return classify3(s, qmlMode); - case 4: return classify4(s, qmlMode); - case 5: return classify5(s, qmlMode); - case 6: return classify6(s, qmlMode); - case 7: return classify7(s, qmlMode); - case 8: return classify8(s, qmlMode); - case 9: return classify9(s, qmlMode); - case 10: return classify10(s, qmlMode); - case 12: return classify12(s, qmlMode); - default: return Lexer::T_IDENTIFIER; - } // switch -} - -#endif // QDECLARATIVEJSKEYWORDS_P_H diff --git a/src/declarative/qml/parser/qdeclarativejslexer.cpp b/src/declarative/qml/parser/qdeclarativejslexer.cpp deleted file mode 100644 index e292490499..0000000000 --- a/src/declarative/qml/parser/qdeclarativejslexer.cpp +++ /dev/null @@ -1,1166 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativejslexer_p.h" -#include "qdeclarativejsengine_p.h" -#include "qdeclarativejsmemorypool_p.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE -Q_CORE_EXPORT double qstrtod(const char *s00, char const **se, bool *ok); -QT_END_NAMESPACE - -using namespace QDeclarativeJS; - -static int regExpFlagFromChar(const QChar &ch) -{ - switch (ch.unicode()) { - case 'g': return Lexer::RegExp_Global; - case 'i': return Lexer::RegExp_IgnoreCase; - case 'm': return Lexer::RegExp_Multiline; - } - return 0; -} - -static unsigned char convertHex(ushort c) -{ - if (c >= '0' && c <= '9') - return (c - '0'); - else if (c >= 'a' && c <= 'f') - return (c - 'a' + 10); - else - return (c - 'A' + 10); -} - -static QChar convertHex(QChar c1, QChar c2) -{ - return QChar((convertHex(c1.unicode()) << 4) + convertHex(c2.unicode())); -} - -static QChar convertUnicode(QChar c1, QChar c2, QChar c3, QChar c4) -{ - return QChar((convertHex(c3.unicode()) << 4) + convertHex(c4.unicode()), - (convertHex(c1.unicode()) << 4) + convertHex(c2.unicode())); -} - -Lexer::Lexer(Engine *engine) - : _engine(engine) - , _codePtr(0) - , _lastLinePtr(0) - , _tokenLinePtr(0) - , _tokenStartPtr(0) - , _char(QLatin1Char('\n')) - , _errorCode(NoError) - , _currentLineNumber(0) - , _tokenValue(0) - , _parenthesesState(IgnoreParentheses) - , _parenthesesCount(0) - , _stackToken(-1) - , _patternFlags(0) - , _tokenKind(0) - , _tokenLength(0) - , _tokenLine(0) - , _validTokenText(false) - , _prohibitAutomaticSemicolon(false) - , _restrictedKeyword(false) - , _terminator(false) - , _followsClosingBrace(false) - , _delimited(true) - , _qmlMode(true) -{ - if (engine) - engine->setLexer(this); -} - -bool Lexer::qmlMode() const -{ - return _qmlMode; -} - -QString Lexer::code() const -{ - return _code; -} - -void Lexer::setCode(const QString &code, int lineno, bool qmlMode) -{ - if (_engine) - _engine->setCode(code); - - _qmlMode = qmlMode; - _code = code; - _tokenText.clear(); - _tokenText.reserve(1024); - _errorMessage.clear(); - _tokenSpell = QStringRef(); - - _codePtr = code.unicode(); - _lastLinePtr = _codePtr; - _tokenLinePtr = _codePtr; - _tokenStartPtr = _codePtr; - - _char = QLatin1Char('\n'); - _errorCode = NoError; - - _currentLineNumber = lineno; - _tokenValue = 0; - - // parentheses state - _parenthesesState = IgnoreParentheses; - _parenthesesCount = 0; - - _stackToken = -1; - - _patternFlags = 0; - _tokenLength = 0; - _tokenLine = lineno; - - _validTokenText = false; - _prohibitAutomaticSemicolon = false; - _restrictedKeyword = false; - _terminator = false; - _followsClosingBrace = false; - _delimited = true; -} - -void Lexer::scanChar() -{ - _char = *_codePtr++; - - if (_char == QLatin1Char('\n')) { - _lastLinePtr = _codePtr; // points to the first character after the newline - ++_currentLineNumber; - } -} - -int Lexer::lex() -{ - const int previousTokenKind = _tokenKind; - - _tokenSpell = QStringRef(); - _tokenKind = scanToken(); - _tokenLength = _codePtr - _tokenStartPtr - 1; - - _delimited = false; - _restrictedKeyword = false; - _followsClosingBrace = (previousTokenKind == T_RBRACE); - - // update the flags - switch (_tokenKind) { - case T_LBRACE: - case T_SEMICOLON: - case T_COLON: - _delimited = true; - break; - - case T_IF: - case T_FOR: - case T_WHILE: - case T_WITH: - _parenthesesState = CountParentheses; - _parenthesesCount = 0; - break; - - case T_DO: - _parenthesesState = BalancedParentheses; - break; - - case T_CONTINUE: - case T_BREAK: - case T_RETURN: - case T_THROW: - _restrictedKeyword = true; - break; - } // switch - - // update the parentheses state - switch (_parenthesesState) { - case IgnoreParentheses: - break; - - case CountParentheses: - if (_tokenKind == T_RPAREN) { - --_parenthesesCount; - if (_parenthesesCount == 0) - _parenthesesState = BalancedParentheses; - } else if (_tokenKind == T_LPAREN) { - ++_parenthesesCount; - } - break; - - case BalancedParentheses: - _parenthesesState = IgnoreParentheses; - break; - } // switch - - return _tokenKind; -} - -bool Lexer::isUnicodeEscapeSequence(const QChar *chars) -{ - if (isHexDigit(chars[0]) && isHexDigit(chars[1]) && isHexDigit(chars[2]) && isHexDigit(chars[3])) - return true; - - return false; -} - -QChar Lexer::decodeUnicodeEscapeCharacter(bool *ok) -{ - if (_char == QLatin1Char('u') && isUnicodeEscapeSequence(&_codePtr[0])) { - scanChar(); // skip u - - const QChar c1 = _char; - scanChar(); - - const QChar c2 = _char; - scanChar(); - - const QChar c3 = _char; - scanChar(); - - const QChar c4 = _char; - scanChar(); - - if (ok) - *ok = true; - - return convertUnicode(c1, c2, c3, c4); - } - - *ok = false; - return QChar(); -} - -int Lexer::scanToken() -{ - if (_stackToken != -1) { - int tk = _stackToken; - _stackToken = -1; - return tk; - } - - _terminator = false; - -again: - _validTokenText = false; - _tokenLinePtr = _lastLinePtr; - - while (_char.isSpace()) { - if (_char == QLatin1Char('\n')) { - _tokenLinePtr = _codePtr; - - if (_restrictedKeyword) { - // automatic semicolon insertion - _tokenLine = _currentLineNumber; - _tokenStartPtr = _codePtr - 1; // ### TODO: insert it before the optional \r sequence. - return T_SEMICOLON; - } else { - _terminator = true; - syncProhibitAutomaticSemicolon(); - } - } - - scanChar(); - } - - _tokenStartPtr = _codePtr - 1; - _tokenLine = _currentLineNumber; - - if (_char.isNull()) - return EOF_SYMBOL; - - const QChar ch = _char; - scanChar(); - - switch (ch.unicode()) { - case '~': return T_TILDE; - case '}': return T_RBRACE; - - case '|': - if (_char == QLatin1Char('|')) { - scanChar(); - return T_OR_OR; - } else if (_char == QLatin1Char('=')) { - scanChar(); - return T_OR_EQ; - } - return T_OR; - - case '{': return T_LBRACE; - - case '^': - if (_char == QLatin1Char('=')) { - scanChar(); - return T_XOR_EQ; - } - return T_XOR; - - case ']': return T_RBRACKET; - case '[': return T_LBRACKET; - case '?': return T_QUESTION; - - case '>': - if (_char == QLatin1Char('>')) { - scanChar(); - if (_char == QLatin1Char('>')) { - scanChar(); - if (_char == QLatin1Char('=')) { - scanChar(); - return T_GT_GT_GT_EQ; - } - return T_GT_GT_GT; - } else if (_char == QLatin1Char('=')) { - scanChar(); - return T_GT_GT_EQ; - } - return T_GT_GT; - } else if (_char == QLatin1Char('=')) { - scanChar(); - return T_GE; - } - return T_GT; - - case '=': - if (_char == QLatin1Char('=')) { - scanChar(); - if (_char == QLatin1Char('=')) { - scanChar(); - return T_EQ_EQ_EQ; - } - return T_EQ_EQ; - } - return T_EQ; - - case '<': - if (_char == QLatin1Char('=')) { - scanChar(); - return T_LE; - } else if (_char == QLatin1Char('<')) { - scanChar(); - if (_char == QLatin1Char('=')) { - scanChar(); - return T_LT_LT_EQ; - } - return T_LT_LT; - } - return T_LT; - - case ';': return T_SEMICOLON; - case ':': return T_COLON; - - case '/': - if (_char == QLatin1Char('*')) { - scanChar(); - while (!_char.isNull()) { - if (_char == QLatin1Char('*')) { - scanChar(); - if (_char == QLatin1Char('/')) { - scanChar(); - - if (_engine) { - _engine->addComment(tokenOffset() + 2, _codePtr - _tokenStartPtr - 1 - 4, - tokenStartLine(), tokenStartColumn() + 2); - } - - goto again; - } - } else { - scanChar(); - } - } - } else if (_char == QLatin1Char('/')) { - while (!_char.isNull() && _char != QLatin1Char('\n')) { - scanChar(); - } - if (_engine) { - _engine->addComment(tokenOffset() + 2, _codePtr - _tokenStartPtr - 1 - 2, - tokenStartLine(), tokenStartColumn() + 2); - } - goto again; - } if (_char == QLatin1Char('=')) { - scanChar(); - return T_DIVIDE_EQ; - } - return T_DIVIDE_; - - case '.': - if (_char.isDigit()) { - QVarLengthArray chars; - - chars.append(ch.unicode()); // append the `.' - - while (_char.isDigit()) { - chars.append(_char.unicode()); - scanChar(); - } - - if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) { - if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) && - _codePtr[1].isDigit())) { - - chars.append(_char.unicode()); - scanChar(); // consume `e' - - if (_char == QLatin1Char('+') || _char == QLatin1Char('-')) { - chars.append(_char.unicode()); - scanChar(); // consume the sign - } - - while (_char.isDigit()) { - chars.append(_char.unicode()); - scanChar(); - } - } - } - - chars.append('\0'); - - const char *begin = chars.constData(); - const char *end = 0; - bool ok = false; - - _tokenValue = qstrtod(begin, &end, &ok); - - if (end - begin != chars.size() - 1) { - _errorCode = IllegalExponentIndicator; - _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Illegal syntax for exponential number"); - return T_ERROR; - } - - return T_NUMERIC_LITERAL; - } - return T_DOT; - - case '-': - if (_char == QLatin1Char('=')) { - scanChar(); - return T_MINUS_EQ; - } else if (_char == QLatin1Char('-')) { - scanChar(); - - if (_terminator && !_delimited && !_prohibitAutomaticSemicolon) { - _stackToken = T_MINUS_MINUS; - return T_SEMICOLON; - } - - return T_MINUS_MINUS; - } - return T_MINUS; - - case ',': return T_COMMA; - - case '+': - if (_char == QLatin1Char('=')) { - scanChar(); - return T_PLUS_EQ; - } else if (_char == QLatin1Char('+')) { - scanChar(); - - if (_terminator && !_delimited && !_prohibitAutomaticSemicolon) { - _stackToken = T_PLUS_PLUS; - return T_SEMICOLON; - } - - return T_PLUS_PLUS; - } - return T_PLUS; - - case '*': - if (_char == QLatin1Char('=')) { - scanChar(); - return T_STAR_EQ; - } - return T_STAR; - - case ')': return T_RPAREN; - case '(': return T_LPAREN; - - case '&': - if (_char == QLatin1Char('=')) { - scanChar(); - return T_AND_EQ; - } else if (_char == QLatin1Char('&')) { - scanChar(); - return T_AND_AND; - } - return T_AND; - - case '%': - if (_char == QLatin1Char('=')) { - scanChar(); - return T_REMAINDER_EQ; - } - return T_REMAINDER; - - case '!': - if (_char == QLatin1Char('=')) { - scanChar(); - if (_char == QLatin1Char('=')) { - scanChar(); - return T_NOT_EQ_EQ; - } - return T_NOT_EQ; - } - return T_NOT; - - case '\'': - case '"': { - const QChar quote = ch; - bool multilineStringLiteral = false; - - const QChar *startCode = _codePtr; - - if (_engine) { - while (!_char.isNull()) { - if (_char == QLatin1Char('\n') || _char == QLatin1Char('\\')) { - break; - } else if (_char == quote) { - _tokenSpell = _engine->midRef(startCode - _code.unicode() - 1, _codePtr - startCode); - scanChar(); - - return T_STRING_LITERAL; - } - scanChar(); - } - } - - _validTokenText = true; - _tokenText.resize(0); - startCode--; - while (startCode != _codePtr - 1) - _tokenText += *startCode++; - - while (! _char.isNull()) { - if (_char == QLatin1Char('\n')) { - multilineStringLiteral = true; - _tokenText += _char; - scanChar(); - } else if (_char == quote) { - scanChar(); - - if (_engine) - _tokenSpell = _engine->newStringRef(_tokenText); - - return multilineStringLiteral ? T_MULTILINE_STRING_LITERAL : T_STRING_LITERAL; - } else if (_char == QLatin1Char('\\')) { - scanChar(); - - QChar u; - bool ok = false; - - switch (_char.unicode()) { - // unicode escape sequence - case 'u': - u = decodeUnicodeEscapeCharacter(&ok); - if (! ok) - u = _char; - break; - - // hex escape sequence - case 'x': - case 'X': - if (isHexDigit(_codePtr[0]) && isHexDigit(_codePtr[1])) { - scanChar(); - - const QChar c1 = _char; - scanChar(); - - const QChar c2 = _char; - scanChar(); - - u = convertHex(c1, c2); - } else { - u = _char; - } - break; - - // single character escape sequence - case '\\': u = QLatin1Char('\\'); scanChar(); break; - case '\'': u = QLatin1Char('\''); scanChar(); break; - case '\"': u = QLatin1Char('\"'); scanChar(); break; - case 'b': u = QLatin1Char('\b'); scanChar(); break; - case 'f': u = QLatin1Char('\f'); scanChar(); break; - case 'n': u = QLatin1Char('\n'); scanChar(); break; - case 'r': u = QLatin1Char('\r'); scanChar(); break; - case 't': u = QLatin1Char('\t'); scanChar(); break; - case 'v': u = QLatin1Char('\v'); scanChar(); break; - - case '0': - if (! _codePtr[1].isDigit()) { - scanChar(); - u = QLatin1Char('\0'); - } else { - // ### parse deprecated octal escape sequence ? - u = _char; - } - break; - - case '\r': - while (_char == QLatin1Char('\r')) - scanChar(); - - if (_char == QLatin1Char('\n')) { - u = _char; - scanChar(); - } else { - u = QLatin1Char('\n'); - } - - break; - - case '\n': - u = _char; - scanChar(); - break; - - default: - // non escape character - u = _char; - scanChar(); - } - - _tokenText += u; - } else { - _tokenText += _char; - scanChar(); - } - } - - _errorCode = UnclosedStringLiteral; - _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Unclosed string at end of line"); - return T_ERROR; - } - - default: - if (ch.isLetter() || ch == QLatin1Char('$') || ch == QLatin1Char('_') || (ch == QLatin1Char('\\') && _char == QLatin1Char('u'))) { - bool identifierWithEscapeChars = false; - if (ch == QLatin1Char('\\')) { - identifierWithEscapeChars = true; - _tokenText.resize(0); - bool ok = false; - _tokenText += decodeUnicodeEscapeCharacter(&ok); - _validTokenText = true; - if (! ok) { - _errorCode = IllegalUnicodeEscapeSequence; - _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Illegal unicode escape sequence"); - return T_ERROR; - } - } - while (true) { - if (_char.isLetterOrNumber() || _char == QLatin1Char('$') || _char == QLatin1Char('_')) { - if (identifierWithEscapeChars) - _tokenText += _char; - - scanChar(); - } else if (_char == QLatin1Char('\\') && _codePtr[0] == QLatin1Char('u')) { - if (! identifierWithEscapeChars) { - identifierWithEscapeChars = true; - _tokenText.resize(0); - _tokenText.insert(0, _tokenStartPtr, _codePtr - _tokenStartPtr - 1); - _validTokenText = true; - } - - scanChar(); // skip '\\' - bool ok = false; - _tokenText += decodeUnicodeEscapeCharacter(&ok); - if (! ok) { - _errorCode = IllegalUnicodeEscapeSequence; - _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Illegal unicode escape sequence"); - return T_ERROR; - } - } else { - _tokenLength = _codePtr - _tokenStartPtr - 1; - - int kind = T_IDENTIFIER; - - if (! identifierWithEscapeChars) - kind = classify(_tokenStartPtr, _tokenLength, _qmlMode); - - if (_engine) { - if (kind == T_IDENTIFIER && identifierWithEscapeChars) - _tokenSpell = _engine->newStringRef(_tokenText); - else - _tokenSpell = _engine->midRef(_tokenStartPtr - _code.unicode(), _tokenLength); - } - - return kind; - } - } - } else if (ch.isDigit()) { - if (ch != QLatin1Char('0')) { - double integer = ch.unicode() - '0'; - - QChar n = _char; - const QChar *code = _codePtr; - while (n.isDigit()) { - integer = integer * 10 + (n.unicode() - '0'); - n = *code++; - } - - if (n != QLatin1Char('.') && n != QLatin1Char('e') && n != QLatin1Char('E')) { - if (code != _codePtr) { - _codePtr = code - 1; - scanChar(); - } - _tokenValue = integer; - return T_NUMERIC_LITERAL; - } - } - - QVarLengthArray chars; - chars.append(ch.unicode()); - - if (ch == QLatin1Char('0') && (_char == QLatin1Char('x') || _char == QLatin1Char('X'))) { - // parse hex integer literal - - chars.append(_char.unicode()); - scanChar(); // consume `x' - - while (isHexDigit(_char)) { - chars.append(_char.unicode()); - scanChar(); - } - - _tokenValue = integerFromString(chars.constData(), chars.size(), 16); - return T_NUMERIC_LITERAL; - } - - // decimal integer literal - while (_char.isDigit()) { - chars.append(_char.unicode()); - scanChar(); // consume the digit - } - - if (_char == QLatin1Char('.')) { - chars.append(_char.unicode()); - scanChar(); // consume `.' - - while (_char.isDigit()) { - chars.append(_char.unicode()); - scanChar(); - } - - if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) { - if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) && - _codePtr[1].isDigit())) { - - chars.append(_char.unicode()); - scanChar(); // consume `e' - - if (_char == QLatin1Char('+') || _char == QLatin1Char('-')) { - chars.append(_char.unicode()); - scanChar(); // consume the sign - } - - while (_char.isDigit()) { - chars.append(_char.unicode()); - scanChar(); - } - } - } - } else if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) { - if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) && - _codePtr[1].isDigit())) { - - chars.append(_char.unicode()); - scanChar(); // consume `e' - - if (_char == QLatin1Char('+') || _char == QLatin1Char('-')) { - chars.append(_char.unicode()); - scanChar(); // consume the sign - } - - while (_char.isDigit()) { - chars.append(_char.unicode()); - scanChar(); - } - } - } - - chars.append('\0'); - - const char *begin = chars.constData(); - const char *end = 0; - bool ok = false; - - _tokenValue = qstrtod(begin, &end, &ok); - - if (end - begin != chars.size() - 1) { - _errorCode = IllegalExponentIndicator; - _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Illegal syntax for exponential number"); - return T_ERROR; - } - - return T_NUMERIC_LITERAL; - } - - break; - } - - return T_ERROR; -} - -bool Lexer::scanRegExp(RegExpBodyPrefix prefix) -{ - _tokenText.resize(0); - _validTokenText = true; - _patternFlags = 0; - - if (prefix == EqualPrefix) - _tokenText += QLatin1Char('='); - - while (true) { - switch (_char.unicode()) { - case 0: // eof - case '\n': case '\r': // line terminator - _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Unterminated regular expression literal"); - return false; - - case '/': - scanChar(); - - // scan the flags - _patternFlags = 0; - while (isIdentLetter(_char)) { - int flag = regExpFlagFromChar(_char); - if (flag == 0) { - _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Invalid regular expression flag '%0'") - .arg(QChar(_char)); - return false; - } - _patternFlags |= flag; - scanChar(); - } - - _tokenLength = _codePtr - _tokenStartPtr - 1; - return true; - - case '\\': - // regular expression backslash sequence - _tokenText += _char; - scanChar(); - - if (_char.isNull() || isLineTerminator()) { - _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Unterminated regular expression backslash sequence"); - return false; - } - - _tokenText += _char; - scanChar(); - break; - - case '[': - // regular expression class - _tokenText += _char; - scanChar(); - - while (! _char.isNull() && ! isLineTerminator()) { - if (_char == QLatin1Char(']')) - break; - else if (_char == QLatin1Char('\\')) { - // regular expression backslash sequence - _tokenText += _char; - scanChar(); - - if (_char.isNull() || isLineTerminator()) { - _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Unterminated regular expression backslash sequence"); - return false; - } - - _tokenText += _char; - scanChar(); - } else { - _tokenText += _char; - scanChar(); - } - } - - if (_char != QLatin1Char(']')) { - _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Unterminated regular expression class"); - return false; - } - - _tokenText += _char; - scanChar(); // skip ] - break; - - default: - _tokenText += _char; - scanChar(); - } // switch - } // while - - return false; -} - -bool Lexer::isLineTerminator() const -{ - return (_char == QLatin1Char('\n') || _char == QLatin1Char('\r')); -} - -bool Lexer::isIdentLetter(QChar ch) -{ - // ASCII-biased, since all reserved words are ASCII, aand hence the - // bulk of content to be parsed. - if ((ch >= QLatin1Char('a') && ch <= QLatin1Char('z')) - || (ch >= QLatin1Char('A') && ch <= QLatin1Char('Z')) - || ch == QLatin1Char('$') - || ch == QLatin1Char('_')) - return true; - if (ch.unicode() < 128) - return false; - return ch.isLetterOrNumber(); -} - -bool Lexer::isDecimalDigit(ushort c) -{ - return (c >= '0' && c <= '9'); -} - -bool Lexer::isHexDigit(QChar c) -{ - return ((c >= QLatin1Char('0') && c <= QLatin1Char('9')) - || (c >= QLatin1Char('a') && c <= QLatin1Char('f')) - || (c >= QLatin1Char('A') && c <= QLatin1Char('F'))); -} - -bool Lexer::isOctalDigit(ushort c) -{ - return (c >= '0' && c <= '7'); -} - -int Lexer::tokenKind() const -{ - return _tokenKind; -} - -int Lexer::tokenOffset() const -{ - return _tokenStartPtr - _code.unicode(); -} - -int Lexer::tokenLength() const -{ - return _tokenLength; -} - -int Lexer::tokenStartLine() const -{ - return _tokenLine; -} - -int Lexer::tokenStartColumn() const -{ - return _tokenStartPtr - _tokenLinePtr + 1; -} - -int Lexer::tokenEndLine() const -{ - return _currentLineNumber; -} - -int Lexer::tokenEndColumn() const -{ - return _codePtr - _lastLinePtr; -} - -QStringRef Lexer::tokenSpell() const -{ - return _tokenSpell; -} - -double Lexer::tokenValue() const -{ - return _tokenValue; -} - -QString Lexer::tokenText() const -{ - if (_validTokenText) - return _tokenText; - - if (_tokenKind == T_STRING_LITERAL) - return QString(_tokenStartPtr + 1, _tokenLength - 2); - - return QString(_tokenStartPtr, _tokenLength); -} - -Lexer::Error Lexer::errorCode() const -{ - return _errorCode; -} - -QString Lexer::errorMessage() const -{ - return _errorMessage; -} - -void Lexer::syncProhibitAutomaticSemicolon() -{ - if (_parenthesesState == BalancedParentheses) { - // we have seen something like "if (foo)", which means we should - // never insert an automatic semicolon at this point, since it would - // then be expanded into an empty statement (ECMA-262 7.9.1) - _prohibitAutomaticSemicolon = true; - _parenthesesState = IgnoreParentheses; - } else { - _prohibitAutomaticSemicolon = false; - } -} - -bool Lexer::prevTerminator() const -{ - return _terminator; -} - -bool Lexer::followsClosingBrace() const -{ - return _followsClosingBrace; -} - -bool Lexer::canInsertAutomaticSemicolon(int token) const -{ - return token == T_RBRACE - || token == EOF_SYMBOL - || _terminator - || _followsClosingBrace; -} - -bool Lexer::scanDirectives(Directives *directives) -{ - if (_qmlMode) { - // the directives are a Javascript-only extension. - return false; - } - - lex(); // fetch the first token - - if (_tokenKind != T_DOT) - return true; - - do { - lex(); // skip T_DOT - - const int lineNumber = tokenStartLine(); - - if (! (_tokenKind == T_IDENTIFIER || _tokenKind == T_RESERVED_WORD)) - return false; // expected a valid QML/JS directive - - const QString directiveName = tokenText(); - - if (! (directiveName == QLatin1String("pragma") || - directiveName == QLatin1String("import"))) - return false; // not a valid directive name - - // it must be a pragma or an import directive. - if (directiveName == QLatin1String("pragma")) { - // .pragma library - if (! (lex() == T_IDENTIFIER && tokenText() == QLatin1String("library"))) - return false; // expected `library - - // we found a .pragma library directive - directives->pragmaLibrary(); - - } else { - Q_ASSERT(directiveName == QLatin1String("import")); - lex(); // skip .import - - QString pathOrUri; - QString version; - bool fileImport = false; // file or uri import - - if (_tokenKind == T_STRING_LITERAL) { - // .import T_STRING_LITERAL as T_IDENTIFIER - - fileImport = true; - pathOrUri = tokenText(); - - } else if (_tokenKind == T_IDENTIFIER) { - // .import T_IDENTIFIER (. T_IDENTIFIER)* T_NUMERIC_LITERAL as T_IDENTIFIER - - pathOrUri = tokenText(); - - lex(); // skip the first T_IDENTIFIER - for (; _tokenKind == T_DOT; lex()) { - if (lex() != T_IDENTIFIER) - return false; - - pathOrUri += QLatin1Char('.'); - pathOrUri += tokenText(); - } - - if (_tokenKind != T_NUMERIC_LITERAL) - return false; // expected the module version number - - version = tokenText(); - } - - // - // recognize the mandatory `as' followed by the module name - // - if (! (lex() == T_RESERVED_WORD && tokenText() == QLatin1String("as"))) - return false; // expected `as' - - if (lex() != T_IDENTIFIER) - return false; // expected module name - - const QString module = tokenText(); - - if (fileImport) - directives->importFile(pathOrUri, module); - else - directives->importModule(pathOrUri, version, module); - } - - if (tokenStartLine() != lineNumber) - return false; // the directives cannot span over multiple lines - - // fetch the first token after the .pragma/.import directive - lex(); - } while (_tokenKind == T_DOT); - - return true; -} - -#include "qdeclarativejskeywords_p.h" diff --git a/src/declarative/qml/parser/qdeclarativejslexer_p.h b/src/declarative/qml/parser/qdeclarativejslexer_p.h deleted file mode 100644 index 806603e022..0000000000 --- a/src/declarative/qml/parser/qdeclarativejslexer_p.h +++ /dev/null @@ -1,248 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEJSLEXER_P_H -#define QDECLARATIVEJSLEXER_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 "qdeclarativejsglobal_p.h" -#include "qdeclarativejsgrammar_p.h" -#include - -QT_QML_BEGIN_NAMESPACE - -namespace QDeclarativeJS { - -class Engine; - -class QML_PARSER_EXPORT Directives { -public: - virtual ~Directives() {} - - virtual void pragmaLibrary() - { - } - - virtual void importFile(const QString &jsfile, const QString &module) - { - Q_UNUSED(jsfile); - Q_UNUSED(module); - } - - virtual void importModule(const QString &uri, const QString &version, const QString &module) - { - Q_UNUSED(uri); - Q_UNUSED(version); - Q_UNUSED(module); - } -}; - -class QML_PARSER_EXPORT Lexer: public QDeclarativeJSGrammar -{ -public: - enum { - T_ABSTRACT = T_RESERVED_WORD, - T_BOOLEAN = T_RESERVED_WORD, - T_BYTE = T_RESERVED_WORD, - T_CHAR = T_RESERVED_WORD, - T_CLASS = T_RESERVED_WORD, - T_DOUBLE = T_RESERVED_WORD, - T_ENUM = T_RESERVED_WORD, - T_EXPORT = T_RESERVED_WORD, - T_EXTENDS = T_RESERVED_WORD, - T_FINAL = T_RESERVED_WORD, - T_FLOAT = T_RESERVED_WORD, - T_GOTO = T_RESERVED_WORD, - T_IMPLEMENTS = T_RESERVED_WORD, - T_INT = T_RESERVED_WORD, - T_INTERFACE = T_RESERVED_WORD, - T_LET = T_RESERVED_WORD, - T_LONG = T_RESERVED_WORD, - T_NATIVE = T_RESERVED_WORD, - T_PACKAGE = T_RESERVED_WORD, - T_PRIVATE = T_RESERVED_WORD, - T_PROTECTED = T_RESERVED_WORD, - T_SHORT = T_RESERVED_WORD, - T_STATIC = T_RESERVED_WORD, - T_SUPER = T_RESERVED_WORD, - T_SYNCHRONIZED = T_RESERVED_WORD, - T_THROWS = T_RESERVED_WORD, - T_TRANSIENT = T_RESERVED_WORD, - T_VOLATILE = T_RESERVED_WORD, - T_YIELD = T_RESERVED_WORD - }; - - enum Error { - NoError, - IllegalCharacter, - UnclosedStringLiteral, - IllegalEscapeSequence, - IllegalUnicodeEscapeSequence, - UnclosedComment, - IllegalExponentIndicator, - IllegalIdentifier - }; - - enum RegExpBodyPrefix { - NoPrefix, - EqualPrefix - }; - - enum RegExpFlag { - RegExp_Global = 0x01, - RegExp_IgnoreCase = 0x02, - RegExp_Multiline = 0x04 - }; - -public: - Lexer(Engine *engine); - - bool qmlMode() const; - - QString code() const; - void setCode(const QString &code, int lineno, bool qmlMode = true); - - int lex(); - - bool scanRegExp(RegExpBodyPrefix prefix = NoPrefix); - bool scanDirectives(Directives *directives); - - int regExpFlags() const { return _patternFlags; } - QString regExpPattern() const { return _tokenText; } - - int tokenKind() const; - int tokenOffset() const; - int tokenLength() const; - - int tokenStartLine() const; - int tokenStartColumn() const; - - int tokenEndLine() const; - int tokenEndColumn() const; - - QStringRef tokenSpell() const; - double tokenValue() const; - QString tokenText() const; - - Error errorCode() const; - QString errorMessage() const; - - bool prevTerminator() const; - bool followsClosingBrace() const; - bool canInsertAutomaticSemicolon(int token) const; - - enum ParenthesesState { - IgnoreParentheses, - CountParentheses, - BalancedParentheses - }; - -protected: - int classify(const QChar *s, int n, bool qmlMode); - -private: - inline void scanChar(); - int scanToken(); - - bool isLineTerminator() const; - static bool isIdentLetter(QChar c); - static bool isDecimalDigit(ushort c); - static bool isHexDigit(QChar c); - static bool isOctalDigit(ushort c); - static bool isUnicodeEscapeSequence(const QChar *chars); - - void syncProhibitAutomaticSemicolon(); - QChar decodeUnicodeEscapeCharacter(bool *ok); - -private: - Engine *_engine; - - QString _code; - QString _tokenText; - QString _errorMessage; - QStringRef _tokenSpell; - - const QChar *_codePtr; - const QChar *_lastLinePtr; - const QChar *_tokenLinePtr; - const QChar *_tokenStartPtr; - - QChar _char; - Error _errorCode; - - int _currentLineNumber; - double _tokenValue; - - // parentheses state - ParenthesesState _parenthesesState; - int _parenthesesCount; - - int _stackToken; - - int _patternFlags; - int _tokenKind; - int _tokenLength; - int _tokenLine; - - bool _validTokenText; - bool _prohibitAutomaticSemicolon; - bool _restrictedKeyword; - bool _terminator; - bool _followsClosingBrace; - bool _delimited; - bool _qmlMode; -}; - -} // end of namespace QDeclarativeJS - -QT_QML_END_NAMESPACE - -#endif // LEXER_H diff --git a/src/declarative/qml/parser/qdeclarativejsmemorypool_p.h b/src/declarative/qml/parser/qdeclarativejsmemorypool_p.h deleted file mode 100644 index 22baff2254..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsmemorypool_p.h +++ /dev/null @@ -1,173 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEJSMEMORYPOOL_P_H -#define QDECLARATIVEJSMEMORYPOOL_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 "qdeclarativejsglobal_p.h" - -#include -#include -#include - -#include - -QT_QML_BEGIN_NAMESPACE - -namespace QDeclarativeJS { - -class QML_PARSER_EXPORT MemoryPool : public QSharedData -{ - MemoryPool(const MemoryPool &other); - void operator =(const MemoryPool &other); - -public: - MemoryPool() - : _blocks(0), - _allocatedBlocks(0), - _blockCount(-1), - _ptr(0), - _end(0) - { } - - ~MemoryPool() - { - if (_blocks) { - for (int i = 0; i < _allocatedBlocks; ++i) { - if (char *b = _blocks[i]) - qFree(b); - } - - qFree(_blocks); - } - } - - inline void *allocate(size_t size) - { - size = (size + 7) & ~7; - if (_ptr && (_ptr + size < _end)) { - void *addr = _ptr; - _ptr += size; - return addr; - } - return allocate_helper(size); - } - - void reset() - { - _blockCount = -1; - _ptr = _end = 0; - } - -private: - void *allocate_helper(size_t size) - { - Q_ASSERT(size < BLOCK_SIZE); - - if (++_blockCount == _allocatedBlocks) { - if (! _allocatedBlocks) - _allocatedBlocks = DEFAULT_BLOCK_COUNT; - else - _allocatedBlocks *= 2; - - _blocks = (char **) qRealloc(_blocks, sizeof(char *) * _allocatedBlocks); - - for (int index = _blockCount; index < _allocatedBlocks; ++index) - _blocks[index] = 0; - } - - char *&block = _blocks[_blockCount]; - - if (! block) - block = (char *) qMalloc(BLOCK_SIZE); - - _ptr = block; - _end = _ptr + BLOCK_SIZE; - - void *addr = _ptr; - _ptr += size; - return addr; - } - -private: - char **_blocks; - int _allocatedBlocks; - int _blockCount; - char *_ptr; - char *_end; - - enum - { - BLOCK_SIZE = 8 * 1024, - DEFAULT_BLOCK_COUNT = 8 - }; -}; - -class QML_PARSER_EXPORT Managed -{ - Managed(const Managed &other); - void operator = (const Managed &other); - -public: - Managed() {} - ~Managed() {} - - void *operator new(size_t size, MemoryPool *pool) { return pool->allocate(size); } - void operator delete(void *) {} - void operator delete(void *, MemoryPool *) {} -}; - -} // namespace QDeclarativeJS - -QT_QML_END_NAMESPACE - -#endif diff --git a/src/declarative/qml/parser/qdeclarativejsparser.cpp b/src/declarative/qml/parser/qdeclarativejsparser.cpp deleted file mode 100644 index 384544afe4..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsparser.cpp +++ /dev/null @@ -1,1812 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include - -#include "qdeclarativejsengine_p.h" -#include "qdeclarativejslexer_p.h" -#include "qdeclarativejsast_p.h" -#include "qdeclarativejsmemorypool_p.h" - - - -#include "qdeclarativejsparser_p.h" -#include - -// -// This file is automatically generated from qmljs.g. -// Changes will be lost. -// - -using namespace QDeclarativeJS; - -QT_QML_BEGIN_NAMESPACE - -void Parser::reallocateStack() -{ - if (! stack_size) - stack_size = 128; - else - stack_size <<= 1; - - sym_stack = reinterpret_cast (realloc(sym_stack, stack_size * sizeof(Value))); - state_stack = reinterpret_cast (realloc(state_stack, stack_size * sizeof(int))); - location_stack = reinterpret_cast (realloc(location_stack, stack_size * sizeof(AST::SourceLocation))); - string_stack = reinterpret_cast (realloc(string_stack, stack_size * sizeof(QStringRef))); -} - -Parser::Parser(Engine *engine): - driver(engine), - pool(engine->pool()), - tos(0), - stack_size(0), - sym_stack(0), - state_stack(0), - location_stack(0), - string_stack(0), - first_token(0), - last_token(0) -{ -} - -Parser::~Parser() -{ - if (stack_size) { - free(sym_stack); - free(state_stack); - free(location_stack); - free(string_stack); - } -} - -static inline AST::SourceLocation location(Lexer *lexer) -{ - AST::SourceLocation loc; - loc.offset = lexer->tokenOffset(); - loc.length = lexer->tokenLength(); - loc.startLine = lexer->tokenStartLine(); - loc.startColumn = lexer->tokenStartColumn(); - return loc; -} - -AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr) -{ - QVarLengthArray nameIds; - QVarLengthArray locations; - - AST::ExpressionNode *it = expr; - while (AST::FieldMemberExpression *m = AST::cast(it)) { - nameIds.append(m->name); - locations.append(m->identifierToken); - it = m->base; - } - - if (AST::IdentifierExpression *idExpr = AST::cast(it)) { - AST::UiQualifiedId *q = new (pool) AST::UiQualifiedId(idExpr->name); - q->identifierToken = idExpr->identifierToken; - - AST::UiQualifiedId *currentId = q; - for (int i = nameIds.size() - 1; i != -1; --i) { - currentId = new (pool) AST::UiQualifiedId(currentId, nameIds[i]); - currentId->identifierToken = locations[i]; - } - - return currentId->finish(); - } - - return 0; -} - -bool Parser::parse(int startToken) -{ - Lexer *lexer = driver->lexer(); - bool hadErrors = false; - int yytoken = -1; - int action = 0; - - token_buffer[0].token = startToken; - first_token = &token_buffer[0]; - last_token = &token_buffer[1]; - - tos = -1; - program = 0; - - do { - if (++tos == stack_size) - reallocateStack(); - - state_stack[tos] = action; - - _Lcheck_token: - if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) { - yyprevlloc = yylloc; - - if (first_token == last_token) { - yytoken = lexer->lex(); - yylval = lexer->tokenValue(); - yytokenspell = lexer->tokenSpell(); - yylloc = location(lexer); - } else { - yytoken = first_token->token; - yylval = first_token->dval; - yytokenspell = first_token->spell; - yylloc = first_token->loc; - ++first_token; - } - } - - action = t_action(action, yytoken); - if (action > 0) { - if (action != ACCEPT_STATE) { - yytoken = -1; - sym(1).dval = yylval; - stringRef(1) = yytokenspell; - loc(1) = yylloc; - } else { - --tos; - return ! hadErrors; - } - } else if (action < 0) { - const int r = -action - 1; - tos -= rhs[r]; - - switch (r) { - -case 0: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; - -case 1: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; - -case 2: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; - -case 3: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; - -case 4: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; - -case 5: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; - -case 6: { - sym(1).UiProgram = new (pool) AST::UiProgram(sym(1).UiImportList, - sym(2).UiObjectMemberList->finish()); -} break; - -case 8: { - sym(1).Node = sym(1).UiImportList->finish(); -} break; - -case 9: { - sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImport); -} break; - -case 10: { - sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImportList, sym(2).UiImport); -} break; - -case 13: { - sym(1).UiImport->semicolonToken = loc(2); -} break; - -case 15: { - sym(1).UiImport->versionToken = loc(2); - sym(1).UiImport->semicolonToken = loc(3); -} break; - -case 17: { - sym(1).UiImport->versionToken = loc(2); - sym(1).UiImport->asToken = loc(3); - sym(1).UiImport->importIdToken = loc(4); - sym(1).UiImport->importId = stringRef(4); - sym(1).UiImport->semicolonToken = loc(5); -} break; - -case 19: { - sym(1).UiImport->asToken = loc(2); - sym(1).UiImport->importIdToken = loc(3); - sym(1).UiImport->importId = stringRef(3); - sym(1).UiImport->semicolonToken = loc(4); -} break; - -case 20: { - AST::UiImport *node = 0; - - if (AST::StringLiteral *importIdLiteral = AST::cast(sym(2).Expression)) { - node = new (pool) AST::UiImport(importIdLiteral->value); - node->fileNameToken = loc(2); - } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) { - node = new (pool) AST::UiImport(qualifiedId); - node->fileNameToken = loc(2); - } - - sym(1).Node = node; - - if (node) { - node->importToken = loc(1); - } else { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1), - QLatin1String("Expected a qualified name id or a string literal"))); - - return false; // ### remove me - } -} break; - -case 21: { - sym(1).Node = 0; -} break; - -case 22: { - sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember); -} break; - -case 23: { - sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember); -} break; - -case 24: { - AST::UiObjectMemberList *node = new (pool) AST:: UiObjectMemberList( - sym(1).UiObjectMemberList, sym(2).UiObjectMember); - sym(1).Node = node; -} break; - -case 25: { - sym(1).Node = new (pool) AST::UiArrayMemberList(sym(1).UiObjectMember); -} break; - -case 26: { - AST::UiArrayMemberList *node = new (pool) AST::UiArrayMemberList( - sym(1).UiArrayMemberList, sym(3).UiObjectMember); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 27: { - AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer((AST::UiObjectMemberList*)0); - node->lbraceToken = loc(1); - node->rbraceToken = loc(2); - sym(1).Node = node; -} break; - -case 28: { - AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer(sym(2).UiObjectMemberList->finish()); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; - -case 29: { - AST::UiObjectDefinition *node = new (pool) AST::UiObjectDefinition(sym(1).UiQualifiedId, - sym(2).UiObjectInitializer); - sym(1).Node = node; -} break; - -case 31: { - AST::UiArrayBinding *node = new (pool) AST::UiArrayBinding( - sym(1).UiQualifiedId, sym(4).UiArrayMemberList->finish()); - node->colonToken = loc(2); - node->lbracketToken = loc(3); - node->rbracketToken = loc(5); - sym(1).Node = node; -} break; - -case 32: { - AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding( - sym(1).UiQualifiedId, sym(3).UiQualifiedId, sym(4).UiObjectInitializer); - node->colonToken = loc(2); - sym(1).Node = node; -} break; - -case 33: { - AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding( - sym(3).UiQualifiedId, sym(1).UiQualifiedId, sym(4).UiObjectInitializer); - node->colonToken = loc(2); - node->hasOnToken = true; - sym(1).Node = node; -} break; - -case 41: -{ - AST::UiScriptBinding *node = new (pool) AST::UiScriptBinding( - sym(1).UiQualifiedId, sym(3).Statement); - node->colonToken = loc(2); - sym(1).Node = node; -} break; - -case 45: { - sym(1).Node = 0; -} break; - -case 46: { - sym(1).Node = sym(1).UiParameterList->finish (); -} break; - -case 47: { - AST::UiParameterList *node = new (pool) AST::UiParameterList(stringRef(1), stringRef(2)); - node->propertyTypeToken = loc(1); - node->identifierToken = loc(2); - sym(1).Node = node; -} break; - -case 48: { - AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, stringRef(3), stringRef(4)); - node->commaToken = loc(2); - node->identifierToken = loc(4); - sym(1).Node = node; -} break; - -case 50: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); - node->type = AST::UiPublicMember::Signal; - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(2); - node->parameters = sym(4).UiParameterList; - node->semicolonToken = loc(6); - sym(1).Node = node; -} break; - -case 52: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); - node->type = AST::UiPublicMember::Signal; - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(2); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; - -case 54: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); - node->typeModifier = stringRef(2); - node->propertyToken = loc(1); - node->typeModifierToken = loc(2); - node->typeToken = loc(4); - node->identifierToken = loc(6); - node->semicolonToken = loc(7); - sym(1).Node = node; -} break; - -case 56: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(3); - node->semicolonToken = loc(4); - sym(1).Node = node; -} break; - -case 58: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4)); - node->isDefaultMember = true; - node->defaultToken = loc(1); - node->propertyToken = loc(2); - node->typeToken = loc(3); - node->identifierToken = loc(4); - node->semicolonToken = loc(5); - sym(1).Node = node; -} break; - -case 59: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3), - sym(5).Statement); - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(3); - node->colonToken = loc(4); - sym(1).Node = node; -} break; - -case 60: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), - sym(6).Statement); - node->isReadonlyMember = true; - node->readonlyToken = loc(1); - node->propertyToken = loc(2); - node->typeToken = loc(3); - node->identifierToken = loc(4); - node->colonToken = loc(5); - sym(1).Node = node; -} break; - -case 61: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), - sym(6).Statement); - node->isDefaultMember = true; - node->defaultToken = loc(1); - node->propertyToken = loc(2); - node->typeToken = loc(3); - node->identifierToken = loc(4); - node->colonToken = loc(5); - sym(1).Node = node; -} break; - -case 62: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); - node->typeModifier = stringRef(2); - node->propertyToken = loc(1); - node->typeModifierToken = loc(2); - node->typeToken = loc(4); - node->identifierToken = loc(6); - node->semicolonToken = loc(7); // insert a fake ';' before ':' - - AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(6)); - propertyName->identifierToken = loc(6); - propertyName->next = 0; - - AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding( - propertyName, sym(9).UiArrayMemberList->finish()); - binding->colonToken = loc(7); - binding->lbracketToken = loc(8); - binding->rbracketToken = loc(10); - - node->binding = binding; - - sym(1).Node = node; -} break; - -case 63: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(3); - node->semicolonToken = loc(4); // insert a fake ';' before ':' - - AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(3)); - propertyName->identifierToken = loc(3); - propertyName->next = 0; - - AST::UiObjectBinding *binding = new (pool) AST::UiObjectBinding( - propertyName, sym(5).UiQualifiedId, sym(6).UiObjectInitializer); - binding->colonToken = loc(4); - - node->binding = binding; - - sym(1).Node = node; -} break; - -case 64: { - sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); -} break; - -case 65: { - sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); -} break; - -case 71: { - AST::ThisExpression *node = new (pool) AST::ThisExpression(); - node->thisToken = loc(1); - sym(1).Node = node; -} break; - -case 72: { - AST::IdentifierExpression *node = new (pool) AST::IdentifierExpression(stringRef(1)); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; - -case 73: { - AST::NullExpression *node = new (pool) AST::NullExpression(); - node->nullToken = loc(1); - sym(1).Node = node; -} break; - -case 74: { - AST::TrueLiteral *node = new (pool) AST::TrueLiteral(); - node->trueToken = loc(1); - sym(1).Node = node; -} break; - -case 75: { - AST::FalseLiteral *node = new (pool) AST::FalseLiteral(); - node->falseToken = loc(1); - sym(1).Node = node; -} break; - -case 76: { - AST::NumericLiteral *node = new (pool) AST::NumericLiteral(sym(1).dval); - node->literalToken = loc(1); - sym(1).Node = node; -} break; -case 77: -case 78: { - AST::StringLiteral *node = new (pool) AST::StringLiteral(stringRef(1)); - node->literalToken = loc(1); - sym(1).Node = node; -} break; - -case 79: { - bool rx = lexer->scanRegExp(Lexer::NoPrefix); - if (!rx) { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); - return false; // ### remove me - } - - loc(1).length = lexer->tokenLength(); - yylloc = loc(1); // adjust the location of the current token - - AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral( - driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags()); - node->literalToken = loc(1); - sym(1).Node = node; -} break; - -case 80: { - bool rx = lexer->scanRegExp(Lexer::EqualPrefix); - if (!rx) { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); - return false; - } - - loc(1).length = lexer->tokenLength(); - yylloc = loc(1); // adjust the location of the current token - - AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral( - driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags()); - node->literalToken = loc(1); - sym(1).Node = node; -} break; - -case 81: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral((AST::Elision *) 0); - node->lbracketToken = loc(1); - node->rbracketToken = loc(2); - sym(1).Node = node; -} break; - -case 82: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).Elision->finish()); - node->lbracketToken = loc(1); - node->rbracketToken = loc(3); - sym(1).Node = node; -} break; - -case 83: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish ()); - node->lbracketToken = loc(1); - node->rbracketToken = loc(3); - sym(1).Node = node; -} break; - -case 84: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), - (AST::Elision *) 0); - node->lbracketToken = loc(1); - node->commaToken = loc(3); - node->rbracketToken = loc(4); - sym(1).Node = node; -} break; - -case 85: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), - sym(4).Elision->finish()); - node->lbracketToken = loc(1); - node->commaToken = loc(3); - node->rbracketToken = loc(5); - sym(1).Node = node; -} break; - -case 86: { - AST::ObjectLiteral *node = 0; - if (sym(2).Node) - node = new (pool) AST::ObjectLiteral( - sym(2).PropertyNameAndValueList->finish ()); - else - node = new (pool) AST::ObjectLiteral(); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; - -case 87: { - AST::ObjectLiteral *node = new (pool) AST::ObjectLiteral( - sym(2).PropertyNameAndValueList->finish ()); - node->lbraceToken = loc(1); - node->rbraceToken = loc(4); - sym(1).Node = node; -} break; - -case 88: { - AST::NestedExpression *node = new (pool) AST::NestedExpression(sym(2).Expression); - node->lparenToken = loc(1); - node->rparenToken = loc(3); - sym(1).Node = node; -} break; - -case 89: { - if (AST::ArrayMemberExpression *mem = AST::cast(sym(1).Expression)) { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken, - QLatin1String("Ignored annotation"))); - - sym(1).Expression = mem->base; - } - - if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(1).Expression)) { - sym(1).UiQualifiedId = qualifiedId; - } else { - sym(1).UiQualifiedId = 0; - - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1), - QLatin1String("Expected a qualified name id"))); - - return false; // ### recover - } -} break; - -case 90: { - sym(1).Node = new (pool) AST::ElementList((AST::Elision *) 0, sym(1).Expression); -} break; - -case 91: { - sym(1).Node = new (pool) AST::ElementList(sym(1).Elision->finish(), sym(2).Expression); -} break; - -case 92: { - AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, - (AST::Elision *) 0, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 93: { - AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, sym(3).Elision->finish(), - sym(4).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 94: { - AST::Elision *node = new (pool) AST::Elision(); - node->commaToken = loc(1); - sym(1).Node = node; -} break; - -case 95: { - AST::Elision *node = new (pool) AST::Elision(sym(1).Elision); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 96: { - AST::PropertyNameAndValueList *node = new (pool) AST::PropertyNameAndValueList( - sym(1).PropertyName, sym(3).Expression); - node->colonToken = loc(2); - sym(1).Node = node; -} break; - -case 97: { - AST::PropertyNameAndValueList *node = new (pool) AST::PropertyNameAndValueList( - sym(1).PropertyNameAndValueList, sym(3).PropertyName, sym(5).Expression); - node->commaToken = loc(2); - node->colonToken = loc(4); - sym(1).Node = node; -} break; - -case 98: { - AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; -case 99: -case 100: { - AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; - -case 101: { - AST::StringLiteralPropertyName *node = new (pool) AST::StringLiteralPropertyName(stringRef(1)); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; - -case 102: { - AST::NumericLiteralPropertyName *node = new (pool) AST::NumericLiteralPropertyName(sym(1).dval); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; - -case 103: { - AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; - -case 139: { - AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression); - node->lbracketToken = loc(2); - node->rbracketToken = loc(4); - sym(1).Node = node; -} break; - -case 140: { - AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3)); - node->dotToken = loc(2); - node->identifierToken = loc(3); - sym(1).Node = node; -} break; - -case 141: { - AST::NewMemberExpression *node = new (pool) AST::NewMemberExpression(sym(2).Expression, sym(4).ArgumentList); - node->newToken = loc(1); - node->lparenToken = loc(3); - node->rparenToken = loc(5); - sym(1).Node = node; -} break; - -case 143: { - AST::NewExpression *node = new (pool) AST::NewExpression(sym(2).Expression); - node->newToken = loc(1); - sym(1).Node = node; -} break; - -case 144: { - AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; - -case 145: { - AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; - -case 146: { - AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression); - node->lbracketToken = loc(2); - node->rbracketToken = loc(4); - sym(1).Node = node; -} break; - -case 147: { - AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3)); - node->dotToken = loc(2); - node->identifierToken = loc(3); - sym(1).Node = node; -} break; - -case 148: { - sym(1).Node = 0; -} break; - -case 149: { - sym(1).Node = sym(1).ArgumentList->finish(); -} break; - -case 150: { - sym(1).Node = new (pool) AST::ArgumentList(sym(1).Expression); -} break; - -case 151: { - AST::ArgumentList *node = new (pool) AST::ArgumentList(sym(1).ArgumentList, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 155: { - AST::PostIncrementExpression *node = new (pool) AST::PostIncrementExpression(sym(1).Expression); - node->incrementToken = loc(2); - sym(1).Node = node; -} break; - -case 156: { - AST::PostDecrementExpression *node = new (pool) AST::PostDecrementExpression(sym(1).Expression); - node->decrementToken = loc(2); - sym(1).Node = node; -} break; - -case 158: { - AST::DeleteExpression *node = new (pool) AST::DeleteExpression(sym(2).Expression); - node->deleteToken = loc(1); - sym(1).Node = node; -} break; - -case 159: { - AST::VoidExpression *node = new (pool) AST::VoidExpression(sym(2).Expression); - node->voidToken = loc(1); - sym(1).Node = node; -} break; - -case 160: { - AST::TypeOfExpression *node = new (pool) AST::TypeOfExpression(sym(2).Expression); - node->typeofToken = loc(1); - sym(1).Node = node; -} break; - -case 161: { - AST::PreIncrementExpression *node = new (pool) AST::PreIncrementExpression(sym(2).Expression); - node->incrementToken = loc(1); - sym(1).Node = node; -} break; - -case 162: { - AST::PreDecrementExpression *node = new (pool) AST::PreDecrementExpression(sym(2).Expression); - node->decrementToken = loc(1); - sym(1).Node = node; -} break; - -case 163: { - AST::UnaryPlusExpression *node = new (pool) AST::UnaryPlusExpression(sym(2).Expression); - node->plusToken = loc(1); - sym(1).Node = node; -} break; - -case 164: { - AST::UnaryMinusExpression *node = new (pool) AST::UnaryMinusExpression(sym(2).Expression); - node->minusToken = loc(1); - sym(1).Node = node; -} break; - -case 165: { - AST::TildeExpression *node = new (pool) AST::TildeExpression(sym(2).Expression); - node->tildeToken = loc(1); - sym(1).Node = node; -} break; - -case 166: { - AST::NotExpression *node = new (pool) AST::NotExpression(sym(2).Expression); - node->notToken = loc(1); - sym(1).Node = node; -} break; - -case 168: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Mul, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 169: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Div, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 170: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Mod, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 172: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Add, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 173: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Sub, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 175: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::LShift, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 176: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::RShift, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 177: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::URShift, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 179: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Lt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 180: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Gt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 181: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Le, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 182: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Ge, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 183: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::InstanceOf, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 184: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::In, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 186: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Lt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 187: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Gt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 188: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Le, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 189: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Ge, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 190: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::InstanceOf, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 192: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Equal, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 193: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::NotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 194: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 195: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictNotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 197: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Equal, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 198: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::NotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 199: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 200: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictNotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 202: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitAnd, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 204: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitAnd, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 206: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitXor, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 208: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitXor, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 210: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitOr, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 212: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitOr, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 214: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::And, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 216: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::And, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 218: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Or, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 220: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Or, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 222: { - AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression, - sym(3).Expression, sym(5).Expression); - node->questionToken = loc(2); - node->colonToken = loc(4); - sym(1).Node = node; -} break; - -case 224: { - AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression, - sym(3).Expression, sym(5).Expression); - node->questionToken = loc(2); - node->colonToken = loc(4); - sym(1).Node = node; -} break; - -case 226: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - sym(2).ival, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 228: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - sym(2).ival, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 229: { - sym(1).ival = QSOperator::Assign; -} break; - -case 230: { - sym(1).ival = QSOperator::InplaceMul; -} break; - -case 231: { - sym(1).ival = QSOperator::InplaceDiv; -} break; - -case 232: { - sym(1).ival = QSOperator::InplaceMod; -} break; - -case 233: { - sym(1).ival = QSOperator::InplaceAdd; -} break; - -case 234: { - sym(1).ival = QSOperator::InplaceSub; -} break; - -case 235: { - sym(1).ival = QSOperator::InplaceLeftShift; -} break; - -case 236: { - sym(1).ival = QSOperator::InplaceRightShift; -} break; - -case 237: { - sym(1).ival = QSOperator::InplaceURightShift; -} break; - -case 238: { - sym(1).ival = QSOperator::InplaceAnd; -} break; - -case 239: { - sym(1).ival = QSOperator::InplaceXor; -} break; - -case 240: { - sym(1).ival = QSOperator::InplaceOr; -} break; - -case 242: { - AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 243: { - sym(1).Node = 0; -} break; - -case 246: { - AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 247: { - sym(1).Node = 0; -} break; - -case 264: { - AST::Block *node = new (pool) AST::Block(sym(2).StatementList); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; - -case 265: { - sym(1).Node = new (pool) AST::StatementList(sym(1).Statement); -} break; - -case 266: { - sym(1).Node = new (pool) AST::StatementList(sym(1).StatementList, sym(2).Statement); -} break; - -case 267: { - sym(1).Node = 0; -} break; - -case 268: { - sym(1).Node = sym(1).StatementList->finish (); -} break; - -case 270: { - AST::VariableStatement *node = new (pool) AST::VariableStatement( - sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST)); - node->declarationKindToken = loc(1); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; - -case 271: { - sym(1).ival = T_CONST; -} break; - -case 272: { - sym(1).ival = T_VAR; -} break; - -case 273: { - sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); -} break; - -case 274: { - AST::VariableDeclarationList *node = new (pool) AST::VariableDeclarationList( - sym(1).VariableDeclarationList, sym(3).VariableDeclaration); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 275: { - sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); -} break; - -case 276: { - sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclarationList, sym(3).VariableDeclaration); -} break; - -case 277: { - AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; - -case 278: { - AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; - -case 279: { - // ### TODO: AST for initializer - sym(1) = sym(2); -} break; - -case 280: { - sym(1).Node = 0; -} break; - -case 282: { - // ### TODO: AST for initializer - sym(1) = sym(2); -} break; - -case 283: { - sym(1).Node = 0; -} break; - -case 285: { - AST::EmptyStatement *node = new (pool) AST::EmptyStatement(); - node->semicolonToken = loc(1); - sym(1).Node = node; -} break; - -case 287: { - AST::ExpressionStatement *node = new (pool) AST::ExpressionStatement(sym(1).Expression); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; - -case 288: { - AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement, sym(7).Statement); - node->ifToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - node->elseToken = loc(6); - sym(1).Node = node; -} break; - -case 289: { - AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement); - node->ifToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; - -case 291: { - AST::DoWhileStatement *node = new (pool) AST::DoWhileStatement(sym(2).Statement, sym(5).Expression); - node->doToken = loc(1); - node->whileToken = loc(3); - node->lparenToken = loc(4); - node->rparenToken = loc(6); - node->semicolonToken = loc(7); - sym(1).Node = node; -} break; - -case 292: { - AST::WhileStatement *node = new (pool) AST::WhileStatement(sym(3).Expression, sym(5).Statement); - node->whileToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; - -case 293: { - AST::ForStatement *node = new (pool) AST::ForStatement(sym(3).Expression, - sym(5).Expression, sym(7).Expression, sym(9).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->firstSemicolonToken = loc(4); - node->secondSemicolonToken = loc(6); - node->rparenToken = loc(8); - sym(1).Node = node; -} break; - -case 294: { - AST::LocalForStatement *node = new (pool) AST::LocalForStatement( - sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression, - sym(8).Expression, sym(10).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->varToken = loc(3); - node->firstSemicolonToken = loc(5); - node->secondSemicolonToken = loc(7); - node->rparenToken = loc(9); - sym(1).Node = node; -} break; - -case 295: { - AST:: ForEachStatement *node = new (pool) AST::ForEachStatement(sym(3).Expression, - sym(5).Expression, sym(7).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->inToken = loc(4); - node->rparenToken = loc(6); - sym(1).Node = node; -} break; - -case 296: { - AST::LocalForEachStatement *node = new (pool) AST::LocalForEachStatement( - sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->varToken = loc(3); - node->inToken = loc(5); - node->rparenToken = loc(7); - sym(1).Node = node; -} break; - -case 298: { - AST::ContinueStatement *node = new (pool) AST::ContinueStatement(); - node->continueToken = loc(1); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; - -case 300: { - AST::ContinueStatement *node = new (pool) AST::ContinueStatement(stringRef(2)); - node->continueToken = loc(1); - node->identifierToken = loc(2); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; - -case 302: { - AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringRef()); - node->breakToken = loc(1); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; - -case 304: { - AST::BreakStatement *node = new (pool) AST::BreakStatement(stringRef(2)); - node->breakToken = loc(1); - node->identifierToken = loc(2); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; - -case 306: { - AST::ReturnStatement *node = new (pool) AST::ReturnStatement(sym(2).Expression); - node->returnToken = loc(1); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; - -case 307: { - AST::WithStatement *node = new (pool) AST::WithStatement(sym(3).Expression, sym(5).Statement); - node->withToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; - -case 308: { - AST::SwitchStatement *node = new (pool) AST::SwitchStatement(sym(3).Expression, sym(5).CaseBlock); - node->switchToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; - -case 309: { - AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; - -case 310: { - AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses); - node->lbraceToken = loc(1); - node->rbraceToken = loc(5); - sym(1).Node = node; -} break; - -case 311: { - sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClause); -} break; - -case 312: { - sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClauses, sym(2).CaseClause); -} break; - -case 313: { - sym(1).Node = 0; -} break; - -case 314: { - sym(1).Node = sym(1).CaseClauses->finish (); -} break; - -case 315: { - AST::CaseClause *node = new (pool) AST::CaseClause(sym(2).Expression, sym(4).StatementList); - node->caseToken = loc(1); - node->colonToken = loc(3); - sym(1).Node = node; -} break; - -case 316: { - AST::DefaultClause *node = new (pool) AST::DefaultClause(sym(3).StatementList); - node->defaultToken = loc(1); - node->colonToken = loc(2); - sym(1).Node = node; -} break; -case 317: -case 318: { - AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement); - node->identifierToken = loc(1); - node->colonToken = loc(2); - sym(1).Node = node; -} break; - -case 319: { - AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement); - node->identifierToken = loc(1); - node->colonToken = loc(2); - sym(1).Node = node; -} break; - -case 321: { - AST::ThrowStatement *node = new (pool) AST::ThrowStatement(sym(2).Expression); - node->throwToken = loc(1); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; - -case 322: { - AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch); - node->tryToken = loc(1); - sym(1).Node = node; -} break; - -case 323: { - AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Finally); - node->tryToken = loc(1); - sym(1).Node = node; -} break; - -case 324: { - AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch, sym(4).Finally); - node->tryToken = loc(1); - sym(1).Node = node; -} break; - -case 325: { - AST::Catch *node = new (pool) AST::Catch(stringRef(3), sym(5).Block); - node->catchToken = loc(1); - node->lparenToken = loc(2); - node->identifierToken = loc(3); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; - -case 326: { - AST::Finally *node = new (pool) AST::Finally(sym(2).Block); - node->finallyToken = loc(1); - sym(1).Node = node; -} break; - -case 328: { - AST::DebuggerStatement *node = new (pool) AST::DebuggerStatement(); - node->debuggerToken = loc(1); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; - -case 329: { - AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); - node->functionToken = loc(1); - node->identifierToken = loc(2); - node->lparenToken = loc(3); - node->rparenToken = loc(5); - node->lbraceToken = loc(6); - node->rbraceToken = loc(8); - sym(1).Node = node; -} break; - -case 330: { - AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); - node->functionToken = loc(1); - if (! stringRef(2).isNull()) - node->identifierToken = loc(2); - node->lparenToken = loc(3); - node->rparenToken = loc(5); - node->lbraceToken = loc(6); - node->rbraceToken = loc(8); - sym(1).Node = node; -} break; - -case 331: { - AST::FormalParameterList *node = new (pool) AST::FormalParameterList(stringRef(1)); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; - -case 332: { - AST::FormalParameterList *node = new (pool) AST::FormalParameterList(sym(1).FormalParameterList, stringRef(3)); - node->commaToken = loc(2); - node->identifierToken = loc(3); - sym(1).Node = node; -} break; - -case 333: { - sym(1).Node = 0; -} break; - -case 334: { - sym(1).Node = sym(1).FormalParameterList->finish (); -} break; - -case 335: { - sym(1).Node = 0; -} break; - -case 337: { - sym(1).Node = new (pool) AST::FunctionBody(sym(1).SourceElements->finish ()); -} break; - -case 339: { - sym(1).Node = new (pool) AST::Program(sym(1).SourceElements->finish ()); -} break; - -case 340: { - sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElement); -} break; - -case 341: { - sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElements, sym(2).SourceElement); -} break; - -case 342: { - sym(1).Node = new (pool) AST::StatementSourceElement(sym(1).Statement); -} break; - -case 343: { - sym(1).Node = new (pool) AST::FunctionSourceElement(sym(1).FunctionDeclaration); -} break; - -case 344: { - stringRef(1) = QStringRef(); -} break; - -case 346: { - sym(1).Node = 0; -} break; - - } // switch - action = nt_action(state_stack[tos], lhs[r] - TERMINAL_COUNT); - } // if - } while (action != 0); - - if (first_token == last_token) { - const int errorState = state_stack[tos]; - - // automatic insertion of `;' - if (yytoken != -1 && t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken)) { - SavedToken &tk = token_buffer[0]; - tk.token = yytoken; - tk.dval = yylval; - tk.spell = yytokenspell; - tk.loc = yylloc; - - yylloc = yyprevlloc; - yylloc.offset += yylloc.length; - yylloc.startColumn += yylloc.length; - yylloc.length = 0; - - //const QString msg = qApp->translate("QDeclarativeParser", "Missing `;'"); - //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg)); - - first_token = &token_buffer[0]; - last_token = &token_buffer[1]; - - yytoken = T_SEMICOLON; - yylval = 0; - - action = errorState; - - goto _Lcheck_token; - } - - hadErrors = true; - - token_buffer[0].token = yytoken; - token_buffer[0].dval = yylval; - token_buffer[0].spell = yytokenspell; - token_buffer[0].loc = yylloc; - - token_buffer[1].token = yytoken = lexer->lex(); - token_buffer[1].dval = yylval = lexer->tokenValue(); - token_buffer[1].spell = yytokenspell = lexer->tokenSpell(); - token_buffer[1].loc = yylloc = location(lexer); - - if (t_action(errorState, yytoken)) { - QString msg; - int token = token_buffer[0].token; - if (token < 0 || token >= TERMINAL_COUNT) - msg = qApp->translate("QDeclarativeParser", "Syntax error"); - else - msg = qApp->translate("QDeclarativeParser", "Unexpected token `%1'").arg(QLatin1String(spell[token])); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - - action = errorState; - goto _Lcheck_token; - } - - static int tokens[] = { - T_PLUS, - T_EQ, - - T_COMMA, - T_COLON, - T_SEMICOLON, - - T_RPAREN, T_RBRACKET, T_RBRACE, - - T_NUMERIC_LITERAL, - T_IDENTIFIER, - - T_LPAREN, T_LBRACKET, T_LBRACE, - - EOF_SYMBOL - }; - - for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) { - int a = t_action(errorState, *tk); - if (a > 0 && t_action(a, yytoken)) { - const QString msg = qApp->translate("QDeclarativeParser", "Expected token `%1'").arg(QLatin1String(spell[*tk])); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - - yytoken = *tk; - yylval = 0; - yylloc = token_buffer[0].loc; - yylloc.length = 0; - - first_token = &token_buffer[0]; - last_token = &token_buffer[2]; - - action = errorState; - goto _Lcheck_token; - } - } - - for (int tk = 1; tk < TERMINAL_COUNT; ++tk) { - if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM || - tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION || - tk == T_FEED_JS_SOURCE_ELEMENT) - continue; - - int a = t_action(errorState, tk); - if (a > 0 && t_action(a, yytoken)) { - const QString msg = qApp->translate("QDeclarativeParser", "Expected token `%1'").arg(QLatin1String(spell[tk])); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - - yytoken = tk; - yylval = 0; - yylloc = token_buffer[0].loc; - yylloc.length = 0; - - action = errorState; - goto _Lcheck_token; - } - } - - const QString msg = qApp->translate("QDeclarativeParser", "Syntax error"); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - } - - return false; -} - -QT_QML_END_NAMESPACE - - diff --git a/src/declarative/qml/parser/qdeclarativejsparser_p.h b/src/declarative/qml/parser/qdeclarativejsparser_p.h deleted file mode 100644 index 1e6da5944b..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsparser_p.h +++ /dev/null @@ -1,248 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -// -// 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. -// - -// -// This file is automatically generated from qmljs.g. -// Changes will be lost. -// - -#ifndef QDECLARATIVEJSPARSER_P_H -#define QDECLARATIVEJSPARSER_P_H - -#include "qdeclarativejsglobal_p.h" -#include "qdeclarativejsgrammar_p.h" -#include "qdeclarativejsast_p.h" -#include "qdeclarativejsengine_p.h" - -#include -#include - -QT_QML_BEGIN_NAMESPACE - -namespace QDeclarativeJS { - -class Engine; - -class QML_PARSER_EXPORT Parser: protected QDeclarativeJSGrammar -{ -public: - union Value { - int ival; - double dval; - AST::ArgumentList *ArgumentList; - AST::CaseBlock *CaseBlock; - AST::CaseClause *CaseClause; - AST::CaseClauses *CaseClauses; - AST::Catch *Catch; - AST::DefaultClause *DefaultClause; - AST::ElementList *ElementList; - AST::Elision *Elision; - AST::ExpressionNode *Expression; - AST::Finally *Finally; - AST::FormalParameterList *FormalParameterList; - AST::FunctionBody *FunctionBody; - AST::FunctionDeclaration *FunctionDeclaration; - AST::Node *Node; - AST::PropertyName *PropertyName; - AST::PropertyNameAndValueList *PropertyNameAndValueList; - AST::SourceElement *SourceElement; - AST::SourceElements *SourceElements; - AST::Statement *Statement; - AST::StatementList *StatementList; - AST::Block *Block; - AST::VariableDeclaration *VariableDeclaration; - AST::VariableDeclarationList *VariableDeclarationList; - - AST::UiProgram *UiProgram; - AST::UiImportList *UiImportList; - AST::UiImport *UiImport; - AST::UiParameterList *UiParameterList; - AST::UiPublicMember *UiPublicMember; - AST::UiObjectDefinition *UiObjectDefinition; - AST::UiObjectInitializer *UiObjectInitializer; - AST::UiObjectBinding *UiObjectBinding; - AST::UiScriptBinding *UiScriptBinding; - AST::UiArrayBinding *UiArrayBinding; - AST::UiObjectMember *UiObjectMember; - AST::UiObjectMemberList *UiObjectMemberList; - AST::UiArrayMemberList *UiArrayMemberList; - AST::UiQualifiedId *UiQualifiedId; - }; - -public: - Parser(Engine *engine); - ~Parser(); - - // parse a UI program - bool parse() { return parse(T_FEED_UI_PROGRAM); } - bool parseStatement() { return parse(T_FEED_JS_STATEMENT); } - bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); } - bool parseSourceElement() { return parse(T_FEED_JS_SOURCE_ELEMENT); } - bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); } - bool parseProgram() { return parse(T_FEED_JS_PROGRAM); } - - AST::UiProgram *ast() const - { return AST::cast(program); } - - AST::Statement *statement() const - { - if (! program) - return 0; - - return program->statementCast(); - } - - AST::ExpressionNode *expression() const - { - if (! program) - return 0; - - return program->expressionCast(); - } - - AST::UiObjectMember *uiObjectMember() const - { - if (! program) - return 0; - - return program->uiObjectMemberCast(); - } - - AST::Node *rootNode() const - { return program; } - - QList diagnosticMessages() const - { return diagnostic_messages; } - - inline DiagnosticMessage diagnosticMessage() const - { - foreach (const DiagnosticMessage &d, diagnostic_messages) { - if (! d.kind == DiagnosticMessage::Warning) - return d; - } - - return DiagnosticMessage(); - } - - inline QString errorMessage() const - { return diagnosticMessage().message; } - - inline int errorLineNumber() const - { return diagnosticMessage().loc.startLine; } - - inline int errorColumnNumber() const - { return diagnosticMessage().loc.startColumn; } - -protected: - bool parse(int startToken); - - void reallocateStack(); - - inline Value &sym(int index) - { return sym_stack [tos + index - 1]; } - - inline QStringRef &stringRef(int index) - { return string_stack [tos + index - 1]; } - - inline AST::SourceLocation &loc(int index) - { return location_stack [tos + index - 1]; } - - AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr); - -protected: - Engine *driver; - MemoryPool *pool; - int tos; - int stack_size; - Value *sym_stack; - int *state_stack; - AST::SourceLocation *location_stack; - QStringRef *string_stack; - - AST::Node *program; - - // error recovery - enum { TOKEN_BUFFER_SIZE = 3 }; - - struct SavedToken { - int token; - double dval; - AST::SourceLocation loc; - QStringRef spell; - }; - - double yylval; - QStringRef yytokenspell; - AST::SourceLocation yylloc; - AST::SourceLocation yyprevlloc; - - SavedToken token_buffer[TOKEN_BUFFER_SIZE]; - SavedToken *first_token; - SavedToken *last_token; - - QList diagnostic_messages; -}; - -} // end of namespace QDeclarativeJS - - - -#define J_SCRIPT_REGEXPLITERAL_RULE1 79 - -#define J_SCRIPT_REGEXPLITERAL_RULE2 80 - -QT_QML_END_NAMESPACE - - - -#endif // QDECLARATIVEJSPARSER_P_H diff --git a/src/declarative/qml/qdeclarative.h b/src/declarative/qml/qdeclarative.h deleted file mode 100644 index 2d199b79e6..0000000000 --- a/src/declarative/qml/qdeclarative.h +++ /dev/null @@ -1,451 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVE_H -#define QDECLARATIVE_H - -#include -#include -#include -#include - -#include -#include - -QT_BEGIN_HEADER - -#define QML_VERSION 0x020000 -#define QML_VERSION_STR "2.0" - -#define QML_DECLARE_TYPE(TYPE) \ - Q_DECLARE_METATYPE(TYPE *) \ - Q_DECLARE_METATYPE(QDeclarativeListProperty) - -#define QML_DECLARE_TYPE_HASMETATYPE(TYPE) \ - Q_DECLARE_METATYPE(QDeclarativeListProperty) - -#define QML_DECLARE_INTERFACE(INTERFACE) \ - QML_DECLARE_TYPE(INTERFACE) - -#define QML_DECLARE_INTERFACE_HASMETATYPE(INTERFACE) \ - QML_DECLARE_TYPE_HASMETATYPE(INTERFACE) - -enum { /* TYPEINFO flags */ - QML_HAS_ATTACHED_PROPERTIES = 0x01 -}; - -#define QML_DECLARE_TYPEINFO(TYPE, FLAGS) \ -QT_BEGIN_NAMESPACE \ -template <> \ -class QDeclarativeTypeInfo \ -{ \ -public: \ - enum { \ - hasAttachedProperties = (((FLAGS) & QML_HAS_ATTACHED_PROPERTIES) == QML_HAS_ATTACHED_PROPERTIES) \ - }; \ -}; \ -QT_END_NAMESPACE - -QT_BEGIN_NAMESPACE - - -class QDeclarativePropertyValueInterceptor; - -template -int qmlRegisterType() -{ - QByteArray name(T::staticMetaObject.className()); - - QByteArray pointerName(name + '*'); - QByteArray listName("QDeclarativeListProperty<" + name + ">"); - - QDeclarativePrivate::RegisterType type = { - 0, - - qRegisterMetaType(pointerName.constData()), - qRegisterMetaType >(listName.constData()), - 0, 0, - QString(), - - 0, 0, 0, 0, &T::staticMetaObject, - - QDeclarativePrivate::attachedPropertiesFunc(), - QDeclarativePrivate::attachedPropertiesMetaObject(), - - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - - 0, 0, - - 0, - 0 - }; - - return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type); -} - -int Q_DECLARATIVE_EXPORT qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message); - -template -int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason) -{ - QByteArray name(T::staticMetaObject.className()); - - QByteArray pointerName(name + '*'); - QByteArray listName("QDeclarativeListProperty<" + name + ">"); - - QDeclarativePrivate::RegisterType type = { - 0, - - qRegisterMetaType(pointerName.constData()), - qRegisterMetaType >(listName.constData()), - 0, 0, - reason, - - uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject, - - QDeclarativePrivate::attachedPropertiesFunc(), - QDeclarativePrivate::attachedPropertiesMetaObject(), - - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - - 0, 0, - - 0, - 0 - }; - - return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type); -} - -template -int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName) -{ - QByteArray name(T::staticMetaObject.className()); - - QByteArray pointerName(name + '*'); - QByteArray listName("QDeclarativeListProperty<" + name + ">"); - - QDeclarativePrivate::RegisterType type = { - 0, - - qRegisterMetaType(pointerName.constData()), - qRegisterMetaType >(listName.constData()), - sizeof(T), QDeclarativePrivate::createInto, - QString(), - - uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject, - - QDeclarativePrivate::attachedPropertiesFunc(), - QDeclarativePrivate::attachedPropertiesMetaObject(), - - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - - 0, 0, - - 0, - 0 - }; - - return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type); -} - -template -int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName) -{ - QByteArray name(T::staticMetaObject.className()); - - QByteArray pointerName(name + '*'); - QByteArray listName("QDeclarativeListProperty<" + name + ">"); - - QDeclarativePrivate::RegisterType type = { - 1, - - qRegisterMetaType(pointerName.constData()), - qRegisterMetaType >(listName.constData()), - sizeof(T), QDeclarativePrivate::createInto, - QString(), - - uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject, - - QDeclarativePrivate::attachedPropertiesFunc(), - QDeclarativePrivate::attachedPropertiesMetaObject(), - - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - - 0, 0, - - 0, - metaObjectRevision - }; - - return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type); -} - -template -int qmlRegisterRevision(const char *uri, int versionMajor, int versionMinor) -{ - QByteArray name(T::staticMetaObject.className()); - - QByteArray pointerName(name + '*'); - QByteArray listName("QDeclarativeListProperty<" + name + ">"); - - QDeclarativePrivate::RegisterType type = { - 1, - - qRegisterMetaType(pointerName.constData()), - qRegisterMetaType >(listName.constData()), - sizeof(T), QDeclarativePrivate::createInto, - QString(), - - uri, versionMajor, versionMinor, 0, &T::staticMetaObject, - - QDeclarativePrivate::attachedPropertiesFunc(), - QDeclarativePrivate::attachedPropertiesMetaObject(), - - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - - 0, 0, - - 0, - metaObjectRevision - }; - - return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type); -} - - -template -int qmlRegisterExtendedType() -{ - QByteArray name(T::staticMetaObject.className()); - - QByteArray pointerName(name + '*'); - QByteArray listName("QDeclarativeListProperty<" + name + ">"); - - QDeclarativePrivate::RegisterType type = { - 0, - - qRegisterMetaType(pointerName.constData()), - qRegisterMetaType >(listName.constData()), - 0, 0, - QString(), - - 0, 0, 0, 0, &T::staticMetaObject, - - QDeclarativePrivate::attachedPropertiesFunc(), - QDeclarativePrivate::attachedPropertiesMetaObject(), - - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - - QDeclarativePrivate::createParent, &E::staticMetaObject, - - 0, - 0 - }; - - return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type); -} - -template -int qmlRegisterExtendedType(const char *uri, int versionMajor, int versionMinor, - const char *qmlName) -{ - QByteArray name(T::staticMetaObject.className()); - - QByteArray pointerName(name + '*'); - QByteArray listName("QDeclarativeListProperty<" + name + ">"); - - QDeclarativeAttachedPropertiesFunc attached = QDeclarativePrivate::attachedPropertiesFunc(); - const QMetaObject * attachedMetaObject = QDeclarativePrivate::attachedPropertiesMetaObject(); - if (!attached) { - attached = QDeclarativePrivate::attachedPropertiesFunc(); - attachedMetaObject = QDeclarativePrivate::attachedPropertiesMetaObject(); - } - - QDeclarativePrivate::RegisterType type = { - 0, - - qRegisterMetaType(pointerName.constData()), - qRegisterMetaType >(listName.constData()), - sizeof(T), QDeclarativePrivate::createInto, - QString(), - - uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject, - - attached, - attachedMetaObject, - - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - - QDeclarativePrivate::createParent, &E::staticMetaObject, - - 0, - 0 - }; - - return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type); -} - -template -int qmlRegisterInterface(const char *typeName) -{ - QByteArray name(typeName); - - QByteArray pointerName(name + '*'); - QByteArray listName("QDeclarativeListProperty<" + name + ">"); - - QDeclarativePrivate::RegisterInterface qmlInterface = { - 0, - - qRegisterMetaType(pointerName.constData()), - qRegisterMetaType >(listName.constData()), - - qobject_interface_iid() - }; - - return QDeclarativePrivate::qmlregister(QDeclarativePrivate::InterfaceRegistration, &qmlInterface); -} - -template -int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor, - const char *qmlName, QDeclarativeCustomParser *parser) -{ - QByteArray name(T::staticMetaObject.className()); - - QByteArray pointerName(name + '*'); - QByteArray listName("QDeclarativeListProperty<" + name + ">"); - - QDeclarativePrivate::RegisterType type = { - 0, - - qRegisterMetaType(pointerName.constData()), - qRegisterMetaType >(listName.constData()), - sizeof(T), QDeclarativePrivate::createInto, - QString(), - - uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject, - - QDeclarativePrivate::attachedPropertiesFunc(), - QDeclarativePrivate::attachedPropertiesMetaObject(), - - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - - 0, 0, - - parser, - 0 - }; - - return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type); -} - -class QDeclarativeContext; -class QDeclarativeEngine; -class QJSValue; -class QJSEngine; -Q_DECLARATIVE_EXPORT void qmlExecuteDeferred(QObject *); -Q_DECLARATIVE_EXPORT QDeclarativeContext *qmlContext(const QObject *); -Q_DECLARATIVE_EXPORT QDeclarativeEngine *qmlEngine(const QObject *); -Q_DECLARATIVE_EXPORT QObject *qmlAttachedPropertiesObjectById(int, const QObject *, bool create = true); -Q_DECLARATIVE_EXPORT QObject *qmlAttachedPropertiesObject(int *, const QObject *, const QMetaObject *, bool create); - -template -QObject *qmlAttachedPropertiesObject(const QObject *obj, bool create = true) -{ - static int idx = -1; - return qmlAttachedPropertiesObject(&idx, obj, &T::staticMetaObject, create); -} - -// For the use of QtQuick1 module -Q_DECLARATIVE_EXPORT void qmlRegisterBaseTypes(const char *uri, int versionMajor, int versionMinor); - -inline int qmlRegisterModuleApi(const char *uri, int versionMajor, int versionMinor, - QJSValue (*callback)(QDeclarativeEngine *, QJSEngine *)) -{ - QDeclarativePrivate::RegisterModuleApi api = { - 0, - - uri, versionMajor, versionMinor, - - callback, 0 - }; - - return QDeclarativePrivate::qmlregister(QDeclarativePrivate::ModuleApiRegistration, &api); -} - -inline int qmlRegisterModuleApi(const char *uri, int versionMajor, int versionMinor, - QObject *(*callback)(QDeclarativeEngine *, QJSEngine *)) -{ - QDeclarativePrivate::RegisterModuleApi api = { - 0, - - uri, versionMajor, versionMinor, - - 0, callback - }; - - return QDeclarativePrivate::qmlregister(QDeclarativePrivate::ModuleApiRegistration, &api); -} - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QObject) -Q_DECLARE_METATYPE(QVariant) - -QT_END_HEADER - -#endif // QDECLARATIVE_H diff --git a/src/declarative/qml/qdeclarativeaccessors.cpp b/src/declarative/qml/qdeclarativeaccessors.cpp deleted file mode 100644 index 5659c2d550..0000000000 --- a/src/declarative/qml/qdeclarativeaccessors.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativeaccessors_p.h" - -#include "qdeclarativedata_p.h" -#include "qdeclarativenotifier_p.h" - -QT_BEGIN_NAMESPACE - -struct AccessorProperties { - AccessorProperties(); - - QReadWriteLock lock; - QHash properties; -}; - -Q_GLOBAL_STATIC(AccessorProperties, accessorProperties) - -QML_PRIVATE_ACCESSOR(QObject, QString, objectName, objectName) - -static void QObject_objectNameNotifier(QObject *object, intptr_t, QDeclarativeNotifier **notifier) -{ - *notifier = QDeclarativeData::get(object, true)->objectNameNotifier(); -} - -static QDeclarativeAccessors QObject_objectName = { QObject_objectNameRead, - QObject_objectNameNotifier }; - -QML_DECLARE_PROPERTIES(QObject) { - { QML_PROPERTY_NAME(objectName), 0, &QObject_objectName } -}; - -static void buildNameMask(QDeclarativeAccessorProperties::Properties &properties) -{ - quint32 mask = 0; - - for (int ii = 0; ii < properties.count; ++ii) { - Q_ASSERT(strlen(properties.properties[ii].name) == properties.properties[ii].nameLength); - Q_ASSERT(properties.properties[ii].nameLength > 0); - - mask |= (1 << qMin(31U, properties.properties[ii].nameLength - 1)); - } - - properties.nameMask = mask; -} - -AccessorProperties::AccessorProperties() -{ - // Pre-seed QObject::objectName accessor - typedef QDeclarativeAccessorProperties::Properties P; - properties.insert(&QObject::staticMetaObject, - P(qdeclarative_accessor_properties_QObject, - sizeof(qdeclarative_accessor_properties_QObject) / - sizeof(QDeclarativeAccessorProperties::Property))); -} - -QDeclarativeAccessorProperties::Properties::Properties(Property *properties, int count) -: count(count), properties(properties) -{ - buildNameMask(*this); -} - -QDeclarativeAccessorProperties::Properties -QDeclarativeAccessorProperties::properties(const QMetaObject *mo) -{ - AccessorProperties *This = accessorProperties(); - - QReadLocker lock(&This->lock); - return This->properties.value(mo); -} - -void QDeclarativeAccessorProperties::registerProperties(const QMetaObject *mo, int count, - Property *props) -{ - Q_ASSERT(count > 0); - - Properties properties(props, count); - - AccessorProperties *This = accessorProperties(); - - QWriteLocker lock(&This->lock); - - Q_ASSERT(!This->properties.contains(mo) || This->properties.value(mo) == properties); - - This->properties.insert(mo, properties); -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeaccessors_p.h b/src/declarative/qml/qdeclarativeaccessors_p.h deleted file mode 100644 index c52dc537ef..0000000000 --- a/src/declarative/qml/qdeclarativeaccessors_p.h +++ /dev/null @@ -1,165 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEACCESSORS_P_H -#define QDECLARATIVEACCESSORS_P_H - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QObject; -class QDeclarativeNotifier; - -// QML "accessor properties" allow V4 and V8 to bypass Qt's meta system to read and, more -// importantly, subscribe to properties directly. Any property that is primarily read -// from bindings is a candidate for inclusion as an accessor property. -// -// To define accessor properties, use the QML_DECLARE_PROPERTIES() and QML_DEFINE_PROPERTIES() -// macros. The QML_DECLARE_PROPERTIES() macro is used to specify the properties, and the -// QML_DEFINE_PROPERTIES() macro to register the properties with the -// QDeclarativeAccessorProperties singleton. -// -// A class with accessor properties must also add the Q_CLASSINFO("qt_HasQmlAccessors", "true") -// tag to its declaration. This is essential for QML to maintain internal consistency, -// and forgetting to do so will probably cause your application to qFatal() with a -// helpful reminder of this requirement. -// -// It is important that QML_DEFINE_PROPERTIES() has been called before QML ever sees -// the type with the accessor properties. As QML_DEFINE_PROPERTIES() is idempotent, it is -// recommended to call it in the type's constructor as well as when the type is registered -// as a QML element (if it ever is). QML_DEFINE_PROPERTIES() is a very cheap operation -// if registration has already occurred. - -#define QML_DECLARE_PROPERTIES(type) \ - static volatile bool qdeclarative_accessor_properties_isregistered_ ## type = false; \ - static QDeclarativeAccessorProperties::Property qdeclarative_accessor_properties_ ## type[] = - -#define QML_DEFINE_PROPERTIES(type) \ - do { \ - if (!qdeclarative_accessor_properties_isregistered_ ## type) { \ - int count = sizeof(qdeclarative_accessor_properties_ ## type) / \ - sizeof(QDeclarativeAccessorProperties::Property); \ - QDeclarativeAccessorProperties::registerProperties(&type::staticMetaObject, count, \ - qdeclarative_accessor_properties_ ## type);\ - qdeclarative_accessor_properties_isregistered_ ## type = true; \ - } \ - } while (false); - -#define QML_PRIVATE_ACCESSOR(clazz, cpptype, name, variable) \ - static void clazz ## _ ## name ## Read(QObject *o, intptr_t, void *rv) \ - { \ - clazz ## Private *d = clazz ## Private::get(static_cast(o)); \ - *static_cast(rv) = d->variable; \ - } - -#define QML_PROPERTY_NAME(name) #name, sizeof #name - 1 - -class QDeclarativeAccessors -{ -public: - void (*read)(QObject *object, intptr_t property, void *output); - void (*notifier)(QObject *object, intptr_t property, QDeclarativeNotifier **notifier); -}; - -namespace QDeclarativeAccessorProperties { - struct Property { - const char *name; - unsigned int nameLength; - intptr_t data; - QDeclarativeAccessors *accessors; - }; - - struct Properties { - inline Properties(); - Properties(Property *, int); - - bool operator==(const Properties &o) const { - return count == o.count && properties == o.properties; - } - - inline Property *property(const char *name); - - int count; - Property *properties; - quint32 nameMask; - }; - - Properties properties(const QMetaObject *); - void Q_DECLARATIVE_EXPORT registerProperties(const QMetaObject *, int, Property *); -}; - -QDeclarativeAccessorProperties::Property * -QDeclarativeAccessorProperties::Properties::property(const char *name) -{ - if (count == 0) - return 0; - - unsigned int length = strlen(name); - - Q_ASSERT(length); - - if (nameMask & (1 << qMin(31U, length - 1))) { - - for (int ii = 0; ii < count; ++ii) { - if (properties[ii].nameLength == length && 0 == qstrcmp(name, properties[ii].name)) - return &properties[ii]; - } - - } - - return 0; -} - -QDeclarativeAccessorProperties::Properties::Properties() -: count(0), properties(0), nameMask(0) -{ -} - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEACCESSORS_P_H diff --git a/src/declarative/qml/qdeclarativeapplication.cpp b/src/declarative/qml/qdeclarativeapplication.cpp deleted file mode 100644 index b5ceaf2550..0000000000 --- a/src/declarative/qml/qdeclarativeapplication.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativeapplication_p.h" -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeApplicationPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeApplication) -public: - QDeclarativeApplicationPrivate() : active(QGuiApplication::activeWindow() != 0), - layoutDirection(QGuiApplication::layoutDirection()) {} - bool active; - Qt::LayoutDirection layoutDirection; -}; - -/* - This object and its properties are documented as part of the Qt object, - in qdeclarativengine.cpp -*/ - -QDeclarativeApplication::QDeclarativeApplication(QObject *parent) : QObject(*new QDeclarativeApplicationPrivate(), parent) -{ - if (qApp) - qApp->installEventFilter(this); -} - -QDeclarativeApplication::~QDeclarativeApplication() -{ -} - -bool QDeclarativeApplication::active() const -{ - Q_D(const QDeclarativeApplication); - return d->active; -} - -Qt::LayoutDirection QDeclarativeApplication::layoutDirection() const -{ - Q_D(const QDeclarativeApplication); - return d->layoutDirection; -} - -QObject *QDeclarativeApplication::inputPanel() const -{ - static bool warned = false; - if (!warned) { - qWarning() << "Qt.application.inputPanel is deprecated, use Qt.inputMethod instead"; - warned = true; - } - return qApp ? qApp->inputMethod() : 0; -} - -bool QDeclarativeApplication::eventFilter(QObject *obj, QEvent *event) -{ - Q_UNUSED(obj) - Q_D(QDeclarativeApplication); - if (event->type() == QEvent::ApplicationActivate - || event->type() == QEvent::ApplicationDeactivate) { - bool active = d->active; - if (event->type() == QEvent::ApplicationActivate) - active = true; - else if (event->type() == QEvent::ApplicationDeactivate) - active = false; - - if (d->active != active) { - d->active = active; - emit activeChanged(); - } - } - if (event->type() == QEvent::LayoutDirectionChange) { - Qt::LayoutDirection direction = QGuiApplication::layoutDirection(); - if (d->layoutDirection != direction) { - d->layoutDirection = direction; - emit layoutDirectionChanged(); - } - } - return false; -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeapplication_p.h b/src/declarative/qml/qdeclarativeapplication_p.h deleted file mode 100644 index 4a0ff52d3e..0000000000 --- a/src/declarative/qml/qdeclarativeapplication_p.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEAPPLICATION_P_H -#define QDECLARATIVEAPPLICATION_P_H - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeApplicationPrivate; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeApplication : public QObject -{ - Q_OBJECT - Q_PROPERTY(bool active READ active NOTIFY activeChanged) - Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection NOTIFY layoutDirectionChanged) - Q_PROPERTY(QObject *inputPanel READ inputPanel CONSTANT) - -public: - explicit QDeclarativeApplication(QObject *parent = 0); - virtual ~QDeclarativeApplication(); - bool active() const; - Qt::LayoutDirection layoutDirection() const; - QT_DEPRECATED QObject *inputPanel() const; - -protected: - bool eventFilter(QObject *obj, QEvent *event); - -Q_SIGNALS: - void activeChanged(); - void layoutDirectionChanged(); - -private: - Q_DISABLE_COPY(QDeclarativeApplication) - Q_DECLARE_PRIVATE(QDeclarativeApplication) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativeApplication) - -QT_END_HEADER - -#endif // QDECLARATIVEAPPLICATION_P_H diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp deleted file mode 100644 index 39032e0ca6..0000000000 --- a/src/declarative/qml/qdeclarativebinding.cpp +++ /dev/null @@ -1,551 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativebinding_p.h" -#include "qdeclarativebinding_p_p.h" - -#include "qdeclarative.h" -#include "qdeclarativecontext.h" -#include "qdeclarativeinfo.h" -#include "qdeclarativecompiler_p.h" -#include "qdeclarativedata_p.h" -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -QDeclarativeAbstractBinding::QDeclarativeAbstractBinding() -: m_prevBinding(0), m_nextBinding(0) -{ -} - -QDeclarativeAbstractBinding::~QDeclarativeAbstractBinding() -{ - Q_ASSERT(m_prevBinding == 0); - Q_ASSERT(*m_mePtr == 0); -} - -/*! -Destroy the binding. Use this instead of calling delete. - -Bindings are free to implement their own memory management, so the delete operator is not -necessarily safe. The default implementation clears the binding, removes it from the object -and calls delete. -*/ -void QDeclarativeAbstractBinding::destroy() -{ - removeFromObject(); - clear(); - - delete this; -} - -/*! -Add this binding to \a object. - -This transfers ownership of the binding to the object, marks the object's property as -being bound. - -However, it does not enable the binding itself or call update() on it. -*/ -void QDeclarativeAbstractBinding::addToObject() -{ - Q_ASSERT(!m_prevBinding); - - QObject *obj = object(); - Q_ASSERT(obj); - - int index = propertyIndex(); - - QDeclarativeData *data = QDeclarativeData::get(obj, true); - - if (index & 0xFF000000) { - // Value type - - int coreIndex = index & 0xFFFFFF; - - // Find the value type proxy (if there is one) - QDeclarativeValueTypeProxyBinding *proxy = 0; - if (data->hasBindingBit(coreIndex)) { - QDeclarativeAbstractBinding *b = data->bindings; - while (b && b->propertyIndex() != coreIndex) - b = b->m_nextBinding; - Q_ASSERT(b && b->bindingType() == QDeclarativeAbstractBinding::ValueTypeProxy); - proxy = static_cast(b); - } - - if (!proxy) { - proxy = new QDeclarativeValueTypeProxyBinding(obj, coreIndex); - - Q_ASSERT(proxy->propertyIndex() == coreIndex); - Q_ASSERT(proxy->object() == obj); - - proxy->addToObject(); - } - - m_nextBinding = proxy->m_bindings; - if (m_nextBinding) m_nextBinding->m_prevBinding = &m_nextBinding; - m_prevBinding = &proxy->m_bindings; - proxy->m_bindings = this; - - } else { - m_nextBinding = data->bindings; - if (m_nextBinding) m_nextBinding->m_prevBinding = &m_nextBinding; - m_prevBinding = &data->bindings; - data->bindings = this; - - data->setBindingBit(obj, index); - } -} - -/*! -Remove the binding from the object. -*/ -void QDeclarativeAbstractBinding::removeFromObject() -{ - if (m_prevBinding) { - int index = propertyIndex(); - - *m_prevBinding = m_nextBinding; - if (m_nextBinding) m_nextBinding->m_prevBinding = m_prevBinding; - m_prevBinding = 0; - m_nextBinding = 0; - - if (index & 0xFF000000) { - // Value type - we don't remove the proxy from the object. It will sit their happily - // doing nothing until it is removed by a write, a binding change or it is reused - // to hold more sub-bindings. - } else if (QObject *obj = object()) { - QDeclarativeData *data = QDeclarativeData::get(obj, false); - if (data) data->clearBindingBit(index); - } - } -} - -static void bindingDummyDeleter(QDeclarativeAbstractBinding *) -{ -} - -QDeclarativeAbstractBinding::Pointer QDeclarativeAbstractBinding::weakPointer() -{ - if (m_mePtr.value().isNull()) - m_mePtr.value() = QSharedPointer(this, bindingDummyDeleter); - - return m_mePtr.value().toWeakRef(); -} - -void QDeclarativeAbstractBinding::clear() -{ - if (!m_mePtr.isNull()) { - **m_mePtr = 0; - m_mePtr = 0; - } -} - -void QDeclarativeAbstractBinding::retargetBinding(QObject *, int) -{ - qFatal("QDeclarativeAbstractBinding::retargetBinding() called on illegal binding."); -} - -QString QDeclarativeAbstractBinding::expression() const -{ - return QLatin1String(""); -} - -void QDeclarativeAbstractBinding::setEnabled(bool enabled, QDeclarativePropertyPrivate::WriteFlags flags) -{ - if (enabled) update(flags); -} - -QDeclarativeBinding::Identifier QDeclarativeBinding::Invalid = -1; - -void QDeclarativeBindingPrivate::refresh() -{ - Q_Q(QDeclarativeBinding); - q->update(); -} - -QDeclarativeBindingPrivate::QDeclarativeBindingPrivate() -: updating(false), enabled(false), target(), targetProperty(0) -{ -} - -QDeclarativeBindingPrivate::~QDeclarativeBindingPrivate() -{ -} - -QDeclarativeBinding * -QDeclarativeBinding::createBinding(Identifier id, QObject *obj, QDeclarativeContext *ctxt, - const QString &url, int lineNumber, QObject *parent) -{ - if (id < 0) - return 0; - - QDeclarativeContextData *ctxtdata = QDeclarativeContextData::get(ctxt); - - QDeclarativeEnginePrivate *engine = QDeclarativeEnginePrivate::get(ctxt->engine()); - QDeclarativeCompiledData *cdata = 0; - QDeclarativeTypeData *typeData = 0; - if (engine && ctxtdata && !ctxtdata->url.isEmpty()) { - typeData = engine->typeLoader.get(ctxtdata->url); - cdata = typeData->compiledData(); - } - QDeclarativeBinding *rv = cdata ? new QDeclarativeBinding(cdata->primitives.at(id), true, obj, ctxtdata, url, lineNumber, 0, parent) : 0; - if (cdata) - cdata->release(); - if (typeData) - typeData->release(); - return rv; -} - -QDeclarativeBinding::QDeclarativeBinding(const QString &str, QObject *obj, QDeclarativeContext *ctxt, - QObject *parent) -: QDeclarativeExpression(QDeclarativeContextData::get(ctxt), obj, str, *new QDeclarativeBindingPrivate) -{ - setParent(parent); - setNotifyOnValueChanged(true); -} - -QDeclarativeBinding::QDeclarativeBinding(const QString &str, QObject *obj, QDeclarativeContextData *ctxt, - QObject *parent) -: QDeclarativeExpression(ctxt, obj, str, *new QDeclarativeBindingPrivate) -{ - setParent(parent); - setNotifyOnValueChanged(true); -} - -QDeclarativeBinding::QDeclarativeBinding(const QString &str, bool isRewritten, QObject *obj, - QDeclarativeContextData *ctxt, - const QString &url, int lineNumber, int columnNumber, - QObject *parent) -: QDeclarativeExpression(ctxt, obj, str, isRewritten, url, lineNumber, columnNumber, *new QDeclarativeBindingPrivate) -{ - setParent(parent); - setNotifyOnValueChanged(true); -} - -/*! - \internal - - To avoid exposing v8 in the public API, functionPtr must be a pointer to a v8::Handle. - For example: - v8::Handle function; - new QDeclarativeBinding(&function, scope, ctxt); - */ -QDeclarativeBinding::QDeclarativeBinding(void *functionPtr, QObject *obj, QDeclarativeContextData *ctxt, - QObject *parent) -: QDeclarativeExpression(ctxt, obj, functionPtr, *new QDeclarativeBindingPrivate) -{ - setParent(parent); - setNotifyOnValueChanged(true); -} - -QDeclarativeBinding::~QDeclarativeBinding() -{ -} - -void QDeclarativeBinding::setTarget(const QDeclarativeProperty &prop) -{ - Q_D(QDeclarativeBinding); - d->property = prop; - d->target = d->property.object(); - d->targetProperty = QDeclarativePropertyPrivate::get(d->property)->core.encodedIndex(); - - update(); -} - -void QDeclarativeBinding::setTarget(QObject *object, - const QDeclarativePropertyData &core, - QDeclarativeContextData *ctxt) -{ - Q_D(QDeclarativeBinding); - d->property = QDeclarativePropertyPrivate::restore(object, core, ctxt); - d->target = d->property.object(); - d->targetProperty = QDeclarativePropertyPrivate::get(d->property)->core.encodedIndex(); - - update(); -} - -QDeclarativeProperty QDeclarativeBinding::property() const -{ - Q_D(const QDeclarativeBinding); - return d->property; -} - -void QDeclarativeBinding::setEvaluateFlags(EvaluateFlags flags) -{ - Q_D(QDeclarativeBinding); - d->setRequiresThisObject(flags & RequiresThisObject); -} - -QDeclarativeBinding::EvaluateFlags QDeclarativeBinding::evaluateFlags() const -{ - Q_D(const QDeclarativeBinding); - return d->requiresThisObject()?RequiresThisObject:None; -} - -void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags) -{ - Q_D(QDeclarativeBinding); - - if (!d->enabled || !d->context() || !d->context()->isValid()) - return; - - QDeclarativeTrace trace("General Binding Update"); - trace.addDetail("URL", d->url); - trace.addDetail("Line", d->line); - trace.addDetail("Column", d->columnNumber); - - if (!d->updating) { - QDeclarativeBindingProfiler prof(d->url, d->line, d->column); - prof.addDetail(expression()); - d->updating = true; - - QDeclarativeAbstractExpression::DeleteWatcher watcher(d); - - if (d->property.propertyType() == qMetaTypeId()) { - - int idx = d->property.index(); - Q_ASSERT(idx != -1); - - QDeclarativeBinding *t = this; - int status = -1; - void *a[] = { &t, 0, &status, &flags }; - QMetaObject::metacall(d->property.object(), - QMetaObject::WriteProperty, - idx, a); - - } else { - QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(d->context()->engine); - ep->referenceScarceResources(); - - bool isUndefined = false; - - v8::HandleScope handle_scope; - v8::Context::Scope scope(ep->v8engine()->context()); - v8::Local result = d->v8value(0, &isUndefined); - - trace.event("writing binding result"); - - bool needsErrorData = false; - if (!watcher.wasDeleted() && !d->hasError()) - needsErrorData = !QDeclarativePropertyPrivate::writeBinding(d->property, d->context(), - d, result, - isUndefined, flags); - - if (!watcher.wasDeleted()) { - - if (needsErrorData) { - QUrl url = QUrl(d->url); - int line = d->line; - if (url.isEmpty()) url = QUrl(QLatin1String("")); - - d->delayedError()->error.setUrl(url); - d->delayedError()->error.setLine(line); - d->delayedError()->error.setColumn(-1); - } - - if (d->hasError()) { - if (!d->delayedError()->addError(ep)) ep->warning(this->error()); - } else { - d->clearError(); - } - - } - - ep->dereferenceScarceResources(); - } - - if (!watcher.wasDeleted()) - d->updating = false; - } else { - QDeclarativeBindingPrivate::printBindingLoopError(d->property); - } -} - -void QDeclarativeBindingPrivate::printBindingLoopError(QDeclarativeProperty &prop) -{ - qmlInfo(prop.object()) << QDeclarativeBinding::tr("Binding loop detected for property \"%1\"").arg(prop.name()); -} - -void QDeclarativeBindingPrivate::expressionChanged() -{ - Q_Q(QDeclarativeBinding); - q->update(); -} - -void QDeclarativeBinding::setEnabled(bool e, QDeclarativePropertyPrivate::WriteFlags flags) -{ - Q_D(QDeclarativeBinding); - d->enabled = e; - setNotifyOnValueChanged(e); - - if (e) - update(flags); -} - -bool QDeclarativeBinding::enabled() const -{ - Q_D(const QDeclarativeBinding); - - return d->enabled; -} - -QString QDeclarativeBinding::expression() const -{ - return QDeclarativeExpression::expression(); -} - -int QDeclarativeBinding::propertyIndex() const -{ - Q_D(const QDeclarativeBinding); - return d->targetProperty; -} - -QObject *QDeclarativeBinding::object() const -{ - Q_D(const QDeclarativeBinding); - return d->target; -} - -void QDeclarativeBinding::retargetBinding(QObject *t, int i) -{ - Q_D(QDeclarativeBinding); - d->target = t; - d->targetProperty = i; -} - -QDeclarativeValueTypeProxyBinding::QDeclarativeValueTypeProxyBinding(QObject *o, int index) -: m_object(o), m_index(index), m_bindings(0) -{ -} - -QDeclarativeValueTypeProxyBinding::~QDeclarativeValueTypeProxyBinding() -{ - while (m_bindings) { - QDeclarativeAbstractBinding *binding = m_bindings; - binding->setEnabled(false, 0); - binding->destroy(); - } -} - -void QDeclarativeValueTypeProxyBinding::setEnabled(bool e, QDeclarativePropertyPrivate::WriteFlags flags) -{ - if (e) { - QDeclarativeAbstractBinding *bindings = m_bindings; - recursiveEnable(bindings, flags); - } else { - QDeclarativeAbstractBinding *bindings = m_bindings; - recursiveDisable(bindings); - } -} - -void QDeclarativeValueTypeProxyBinding::recursiveEnable(QDeclarativeAbstractBinding *b, QDeclarativePropertyPrivate::WriteFlags flags) -{ - if (!b) - return; - - recursiveEnable(b->m_nextBinding, flags); - - if (b) - b->setEnabled(true, flags); -} - -void QDeclarativeValueTypeProxyBinding::recursiveDisable(QDeclarativeAbstractBinding *b) -{ - if (!b) - return; - - recursiveDisable(b->m_nextBinding); - - if (b) - b->setEnabled(false, 0); -} - -void QDeclarativeValueTypeProxyBinding::update(QDeclarativePropertyPrivate::WriteFlags) -{ -} - -QDeclarativeAbstractBinding *QDeclarativeValueTypeProxyBinding::binding(int propertyIndex) -{ - QDeclarativeAbstractBinding *binding = m_bindings; - - while (binding && binding->propertyIndex() != propertyIndex) - binding = binding->m_nextBinding; - - return binding; -} - -/*! -Removes a collection of bindings, corresponding to the set bits in \a mask. -*/ -void QDeclarativeValueTypeProxyBinding::removeBindings(quint32 mask) -{ - QDeclarativeAbstractBinding *binding = m_bindings; - while (binding) { - if (mask & (1 << (binding->propertyIndex() >> 24))) { - QDeclarativeAbstractBinding *remove = binding; - binding = remove->m_nextBinding; - *remove->m_prevBinding = remove->m_nextBinding; - if (remove->m_nextBinding) remove->m_nextBinding->m_prevBinding = remove->m_prevBinding; - remove->m_prevBinding = 0; - remove->m_nextBinding = 0; - remove->destroy(); - } else { - binding = binding->m_nextBinding; - } - } -} - -int QDeclarativeValueTypeProxyBinding::propertyIndex() const -{ - return m_index; -} - -QObject *QDeclarativeValueTypeProxyBinding::object() const -{ - return m_object; -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativebinding_p.h b/src/declarative/qml/qdeclarativebinding_p.h deleted file mode 100644 index 61cf7dd550..0000000000 --- a/src/declarative/qml/qdeclarativebinding_p.h +++ /dev/null @@ -1,219 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEBINDING_P_H -#define QDECLARATIVEBINDING_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 "qdeclarative.h" -#include "qdeclarativepropertyvaluesource.h" -#include "qdeclarativeexpression.h" -#include "qdeclarativeproperty.h" -#include "qdeclarativeproperty_p.h" - -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeAbstractBinding -{ -public: - typedef QWeakPointer Pointer; - - QDeclarativeAbstractBinding(); - - virtual void destroy(); - - virtual QString expression() const; - - enum Type { PropertyBinding, ValueTypeProxy }; - virtual Type bindingType() const { return PropertyBinding; } - - // Should return the encoded property index for the binding. Should return this value - // even if the binding is not enabled or added to an object. - // Encoding is: coreIndex | (valueTypeIndex << 24) - virtual int propertyIndex() const = 0; - // Should return the object for the binding. Should return this object even if the - // binding is not enabled or added to the object. - virtual QObject *object() const = 0; - - void setEnabled(bool e) { setEnabled(e, QDeclarativePropertyPrivate::DontRemoveBinding); } - virtual void setEnabled(bool, QDeclarativePropertyPrivate::WriteFlags) = 0; - - void update() { update(QDeclarativePropertyPrivate::DontRemoveBinding); } - virtual void update(QDeclarativePropertyPrivate::WriteFlags) = 0; - - void addToObject(); - void removeFromObject(); - - static inline Pointer getPointer(QDeclarativeAbstractBinding *p); - -protected: - virtual ~QDeclarativeAbstractBinding(); - void clear(); - - // Called by QDeclarativePropertyPrivate to "move" a binding to a different property. - // This is only used for alias properties, and only used by QDeclarativeBinding not - // V8 or V4 bindings. The default implementation qFatal()'s to ensure that the - // method is never called for V4 or V8 bindings. - virtual void retargetBinding(QObject *, int); -private: - Pointer weakPointer(); - - friend class QDeclarativeData; - friend class QDeclarativeComponentPrivate; - friend class QDeclarativeValueTypeProxyBinding; - friend class QDeclarativePropertyPrivate; - friend class QDeclarativeVME; - friend class QtSharedPointer::ExternalRefCount; - - typedef QSharedPointer SharedPointer; - // To save memory, we also store the rarely used weakPointer() instance in here - QPointerValuePair m_mePtr; - - QDeclarativeAbstractBinding **m_prevBinding; - QDeclarativeAbstractBinding *m_nextBinding; -}; - -class QDeclarativeValueTypeProxyBinding : public QDeclarativeAbstractBinding -{ -public: - QDeclarativeValueTypeProxyBinding(QObject *o, int coreIndex); - - virtual Type bindingType() const { return ValueTypeProxy; } - - virtual void setEnabled(bool, QDeclarativePropertyPrivate::WriteFlags); - virtual void update(QDeclarativePropertyPrivate::WriteFlags); - virtual int propertyIndex() const; - virtual QObject *object() const; - - QDeclarativeAbstractBinding *binding(int propertyIndex); - - void removeBindings(quint32 mask); - -protected: - ~QDeclarativeValueTypeProxyBinding(); - -private: - void recursiveEnable(QDeclarativeAbstractBinding *, QDeclarativePropertyPrivate::WriteFlags); - void recursiveDisable(QDeclarativeAbstractBinding *); - - friend class QDeclarativeAbstractBinding; - QObject *m_object; - int m_index; - QDeclarativeAbstractBinding *m_bindings; -}; - -class QDeclarativeContext; -class QDeclarativeBindingPrivate; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeBinding : public QDeclarativeExpression, - public QDeclarativeAbstractBinding -{ -Q_OBJECT -public: - enum EvaluateFlag { None = 0x00, RequiresThisObject = 0x01 }; - Q_DECLARE_FLAGS(EvaluateFlags, EvaluateFlag) - - QDeclarativeBinding(const QString &, QObject *, QDeclarativeContext *, QObject *parent=0); - QDeclarativeBinding(const QString &, QObject *, QDeclarativeContextData *, QObject *parent=0); - QDeclarativeBinding(const QString &, bool isRewritten, QObject *, QDeclarativeContextData *, - const QString &url, int lineNumber, int columnNumber = 0, QObject *parent=0); - QDeclarativeBinding(void *, QObject *, QDeclarativeContextData *, QObject *parent=0); - - void setTarget(const QDeclarativeProperty &); - void setTarget(QObject *, const QDeclarativePropertyData &, QDeclarativeContextData *); - QDeclarativeProperty property() const; - - void setEvaluateFlags(EvaluateFlags flags); - EvaluateFlags evaluateFlags() const; - - bool enabled() const; - - // Inherited from QDeclarativeAbstractBinding - virtual void setEnabled(bool, QDeclarativePropertyPrivate::WriteFlags flags); - virtual void update(QDeclarativePropertyPrivate::WriteFlags flags); - virtual QString expression() const; - virtual int propertyIndex() const; - virtual QObject *object() const; - virtual void retargetBinding(QObject *, int); - - typedef int Identifier; - static Identifier Invalid; - static QDeclarativeBinding *createBinding(Identifier, QObject *, QDeclarativeContext *, - const QString &, int, QObject *parent=0); - - -public Q_SLOTS: - void update() { update(QDeclarativePropertyPrivate::DontRemoveBinding); } - -protected: - ~QDeclarativeBinding(); - -private: - Q_DECLARE_PRIVATE(QDeclarativeBinding) -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeBinding::EvaluateFlags) - -QDeclarativeAbstractBinding::Pointer -QDeclarativeAbstractBinding::getPointer(QDeclarativeAbstractBinding *p) -{ - return p ? p->weakPointer() : Pointer(); -} - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QDeclarativeBinding*) - -#endif // QDECLARATIVEBINDING_P_H diff --git a/src/declarative/qml/qdeclarativebinding_p_p.h b/src/declarative/qml/qdeclarativebinding_p_p.h deleted file mode 100644 index 030bd32ef3..0000000000 --- a/src/declarative/qml/qdeclarativebinding_p_p.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEBINDING_P_P_H -#define QDECLARATIVEBINDING_P_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 "qdeclarativebinding_p.h" - -#include "qdeclarativeproperty.h" -#include "qdeclarativeexpression_p.h" - -QT_BEGIN_NAMESPACE - -class QDeclarativeBindingPrivate : public QDeclarativeExpressionPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeBinding) -public: - QDeclarativeBindingPrivate(); - ~QDeclarativeBindingPrivate(); - - virtual void expressionChanged(); - - static void printBindingLoopError(QDeclarativeProperty &prop); - -protected: - virtual void refresh(); - -private: - bool updating:1; - bool enabled:1; - int columnNumber; - QDeclarativeProperty property; - - QObject *target; - int targetProperty; -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVEBINDING_P_P_H diff --git a/src/declarative/qml/qdeclarativeboundsignal.cpp b/src/declarative/qml/qdeclarativeboundsignal.cpp deleted file mode 100644 index bf96f03016..0000000000 --- a/src/declarative/qml/qdeclarativeboundsignal.cpp +++ /dev/null @@ -1,305 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativeboundsignal_p.h" - -#include -#include "qdeclarativeengine_p.h" -#include "qdeclarativeexpression_p.h" -#include "qdeclarativecontext_p.h" -#include "qdeclarativemetatype_p.h" -#include "qdeclarative.h" -#include "qdeclarativecontext.h" -#include "qdeclarativeglobal_p.h" -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeBoundSignalParameters : public QObject -{ -Q_OBJECT -public: - QDeclarativeBoundSignalParameters(const QMetaMethod &, QObject * = 0); - ~QDeclarativeBoundSignalParameters(); - - void setValues(void **); - void clearValues(); - -private: - friend class MetaObject; - int metaCall(QMetaObject::Call, int _id, void **); - struct MetaObject : public QAbstractDynamicMetaObject { - MetaObject(QDeclarativeBoundSignalParameters *b) - : parent(b) {} - - int metaCall(QMetaObject::Call c, int id, void **a) { - return parent->metaCall(c, id, a); - } - QDeclarativeBoundSignalParameters *parent; - }; - - int *types; - void **values; - QMetaObject *myMetaObject; -}; - -static int evaluateIdx = -1; - -QDeclarativeAbstractBoundSignal::QDeclarativeAbstractBoundSignal(QObject *parent) -: QObject(parent) -{ -} - -QDeclarativeAbstractBoundSignal::~QDeclarativeAbstractBoundSignal() -{ -} - -QDeclarativeBoundSignal::QDeclarativeBoundSignal(QObject *scope, const QMetaMethod &signal, - QObject *parent) -: m_expression(0), m_signal(signal), m_paramsValid(false), m_isEvaluating(false), m_params(0) -{ - // This is thread safe. Although it may be updated by two threads, they - // will both set it to the same value - so the worst thing that can happen - // is that they both do the work to figure it out. Boo hoo. - if (evaluateIdx == -1) evaluateIdx = metaObject()->methodCount(); - - QDeclarative_setParent_noEvent(this, parent); - QDeclarativePropertyPrivate::connect(scope, m_signal.methodIndex(), this, evaluateIdx); -} - -QDeclarativeBoundSignal::QDeclarativeBoundSignal(QDeclarativeContext *ctxt, const QString &val, - QObject *scope, const QMetaMethod &signal, - QObject *parent) -: m_expression(0), m_signal(signal), m_paramsValid(false), m_isEvaluating(false), m_params(0) -{ - // This is thread safe. Although it may be updated by two threads, they - // will both set it to the same value - so the worst thing that can happen - // is that they both do the work to figure it out. Boo hoo. - if (evaluateIdx == -1) evaluateIdx = metaObject()->methodCount(); - - QDeclarative_setParent_noEvent(this, parent); - QDeclarativePropertyPrivate::connect(scope, m_signal.methodIndex(), this, evaluateIdx); - - m_expression = new QDeclarativeExpression(ctxt, scope, val); -} - -QDeclarativeBoundSignal::~QDeclarativeBoundSignal() -{ - delete m_expression; - m_expression = 0; -} - -int QDeclarativeBoundSignal::index() const -{ - return m_signal.methodIndex(); -} - -/*! - Returns the signal expression. -*/ -QDeclarativeExpression *QDeclarativeBoundSignal::expression() const -{ - return m_expression; -} - -/*! - Sets the signal expression to \a e. Returns the current signal expression, - or null if there is no signal expression. - - The QDeclarativeBoundSignal instance takes ownership of \a e. The caller is - assumes ownership of the returned QDeclarativeExpression. -*/ -QDeclarativeExpression *QDeclarativeBoundSignal::setExpression(QDeclarativeExpression *e) -{ - QDeclarativeExpression *rv = m_expression; - m_expression = e; - if (m_expression) m_expression->setNotifyOnValueChanged(false); - return rv; -} - -QDeclarativeBoundSignal *QDeclarativeBoundSignal::cast(QObject *o) -{ - QDeclarativeAbstractBoundSignal *s = qobject_cast(o); - return static_cast(s); -} - -int QDeclarativeBoundSignal::qt_metacall(QMetaObject::Call c, int id, void **a) -{ - if (c == QMetaObject::InvokeMetaMethod && id == evaluateIdx) { - if (!m_expression) - return -1; - - if (QDeclarativeDebugService::isDebuggingEnabled()) - QV8DebugService::instance()->signalEmitted(QString::fromAscii(m_signal.signature())); - - QDeclarativeHandlingSignalProfiler prof; - if (prof.enabled) { - prof.setSignalInfo(QString::fromLatin1(m_signal.signature()), - m_expression->expression()); - prof.setLocation(m_expression->sourceFile(), m_expression->lineNumber(), - m_expression->columnNumber()); - } - - m_isEvaluating = true; - if (!m_paramsValid) { - if (!m_signal.parameterTypes().isEmpty()) - m_params = new QDeclarativeBoundSignalParameters(m_signal, this); - m_paramsValid = true; - } - - if (m_params) m_params->setValues(a); - if (m_expression && m_expression->engine()) { - QDeclarativeExpressionPrivate::get(m_expression)->value(m_params); - if (m_expression && m_expression->hasError()) - QDeclarativeEnginePrivate::warning(m_expression->engine(), m_expression->error()); - } - if (m_params) m_params->clearValues(); - m_isEvaluating = false; - return -1; - } else { - return QObject::qt_metacall(c, id, a); - } -} - -QDeclarativeBoundSignalParameters::QDeclarativeBoundSignalParameters(const QMetaMethod &method, - QObject *parent) -: QObject(parent), types(0), values(0) -{ - MetaObject *mo = new MetaObject(this); - - // ### Optimize! - QMetaObjectBuilder mob; - mob.setSuperClass(&QDeclarativeBoundSignalParameters::staticMetaObject); - mob.setClassName("QDeclarativeBoundSignalParameters"); - - QList paramTypes = method.parameterTypes(); - QList paramNames = method.parameterNames(); - types = new int[paramTypes.count()]; - for (int ii = 0; ii < paramTypes.count(); ++ii) { - const QByteArray &type = paramTypes.at(ii); - const QByteArray &name = paramNames.at(ii); - - if (name.isEmpty() || type.isEmpty()) { - types[ii] = 0; - continue; - } - - QVariant::Type t = (QVariant::Type)QMetaType::type(type.constData()); - if (QDeclarativeMetaType::isQObject(t)) { - types[ii] = QMetaType::QObjectStar; - QMetaPropertyBuilder prop = mob.addProperty(name, "QObject*"); - prop.setWritable(false); - } else { - QByteArray propType = type; - if (t >= QVariant::UserType || t == QVariant::Invalid) { - QByteArray scope; - QByteArray name; - int scopeIdx = propType.lastIndexOf("::"); - if (scopeIdx != -1) { - scope = propType.left(scopeIdx); - name = propType.mid(scopeIdx + 2); - } else { - name = propType; - } - const QMetaObject *meta; - if (scope == "Qt") - meta = &QObject::staticQtMetaObject; - else - meta = parent->parent()->metaObject(); //### assumes parent->parent() - for (int i = meta->enumeratorCount() - 1; i >= 0; --i) { - QMetaEnum m = meta->enumerator(i); - if ((m.name() == name) && (scope.isEmpty() || (m.scope() == scope))) { - t = QVariant::Int; - propType = "int"; - break; - } - } - } - types[ii] = t; - QMetaPropertyBuilder prop = mob.addProperty(name, propType); - prop.setWritable(false); - } - } - myMetaObject = mob.toMetaObject(); - *static_cast(mo) = *myMetaObject; - - d_ptr->metaObject = mo; -} - -QDeclarativeBoundSignalParameters::~QDeclarativeBoundSignalParameters() -{ - delete [] types; - free(myMetaObject); -} - -void QDeclarativeBoundSignalParameters::setValues(void **v) -{ - values = v; -} - -void QDeclarativeBoundSignalParameters::clearValues() -{ - values = 0; -} - -int QDeclarativeBoundSignalParameters::metaCall(QMetaObject::Call c, int id, void **a) -{ - if (!values) - return -1; - - if (c == QMetaObject::ReadProperty && id >= 1) { - int t = types[id - 1]; - void *p = a[0]; - QMetaType::destruct(t, p); - QMetaType::construct(t, p, values[id]); - return -1; - } else { - return qt_metacall(c, id, a); - } -} - -QT_END_NAMESPACE - -#include diff --git a/src/declarative/qml/qdeclarativeboundsignal_p.h b/src/declarative/qml/qdeclarativeboundsignal_p.h deleted file mode 100644 index b747d9d7a5..0000000000 --- a/src/declarative/qml/qdeclarativeboundsignal_p.h +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEBOUNDSIGNAL_P_H -#define QDECLARATIVEBOUNDSIGNAL_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 "qdeclarativeexpression.h" - -#include - -#include - -QT_BEGIN_NAMESPACE - -class Q_DECLARATIVE_EXPORT QDeclarativeAbstractBoundSignal : public QObject -{ - Q_OBJECT -public: - QDeclarativeAbstractBoundSignal(QObject *parent = 0); - virtual ~QDeclarativeAbstractBoundSignal() = 0; -}; - -class QDeclarativeBoundSignalParameters; -class Q_DECLARATIVE_EXPORT QDeclarativeBoundSignal : public QDeclarativeAbstractBoundSignal -{ -public: - QDeclarativeBoundSignal(QObject *scope, const QMetaMethod &signal, QObject *parent); - QDeclarativeBoundSignal(QDeclarativeContext *ctxt, const QString &val, QObject *scope, - const QMetaMethod &signal, QObject *parent); - virtual ~QDeclarativeBoundSignal(); - - int index() const; - - QDeclarativeExpression *expression() const; - QDeclarativeExpression *setExpression(QDeclarativeExpression *); - - bool isEvaluating() const { return m_isEvaluating; } - - static QDeclarativeBoundSignal *cast(QObject *); - -protected: - virtual int qt_metacall(QMetaObject::Call c, int id, void **a); - -private: - QDeclarativeExpression *m_expression; - QMetaMethod m_signal; - bool m_paramsValid : 1; - bool m_isEvaluating : 1; - QDeclarativeBoundSignalParameters *m_params; -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVEBOUNDSIGNAL_P_H diff --git a/src/declarative/qml/qdeclarativecleanup.cpp b/src/declarative/qml/qdeclarativecleanup.cpp deleted file mode 100644 index aa7a1e3254..0000000000 --- a/src/declarative/qml/qdeclarativecleanup.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativecleanup_p.h" - -#include "qdeclarativeengine_p.h" - -QT_BEGIN_NAMESPACE - -/*! -\internal -\class QDeclarativeCleanup -\brief The QDeclarativeCleanup provides a callback when a QDeclarativeEngine is deleted. - -Any object that needs cleanup to occur before the QDeclarativeEngine's V8 engine is -destroyed should inherit from QDeclarativeCleanup. The clear() virtual method will be -called by QDeclarativeEngine just before it destroys the context. -*/ - - -/* -Create a QDeclarativeCleanup that is not associated with any engine. -*/ -QDeclarativeCleanup::QDeclarativeCleanup() -: prev(0), next(0), engine(0) -{ -} - -/*! -Create a QDeclarativeCleanup for \a engine -*/ -QDeclarativeCleanup::QDeclarativeCleanup(QDeclarativeEngine *engine) -: prev(0), next(0), engine(0) -{ - if (!engine) - return; - - addToEngine(engine); -} - -/*! -Adds this object to \a engine's cleanup list. hasEngine() must be false -before calling this method. -*/ -void QDeclarativeCleanup::addToEngine(QDeclarativeEngine *engine) -{ - Q_ASSERT(engine); - Q_ASSERT(QDeclarativeEnginePrivate::isEngineThread(engine)); - - this->engine = engine; - - QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(engine); - - if (p->cleanup) next = p->cleanup; - p->cleanup = this; - prev = &p->cleanup; - if (next) next->prev = &next; -} - -/*! -\fn bool QDeclarativeCleanup::hasEngine() const - -Returns true if this QDeclarativeCleanup is associated with an engine, otherwise false. -*/ - -/*! -\internal -*/ -QDeclarativeCleanup::~QDeclarativeCleanup() -{ - Q_ASSERT(!prev || engine); - Q_ASSERT(!prev || QDeclarativeEnginePrivate::isEngineThread(engine)); - - if (prev) *prev = next; - if (next) next->prev = prev; - prev = 0; - next = 0; -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativecleanup_p.h b/src/declarative/qml/qdeclarativecleanup_p.h deleted file mode 100644 index bf84269698..0000000000 --- a/src/declarative/qml/qdeclarativecleanup_p.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVECLEANUP_P_H -#define QDECLARATIVECLEANUP_P_H - -#include - -// -// 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. -// - -QT_BEGIN_NAMESPACE - -class QDeclarativeEngine; - -// Exported for QtQuick1 -class Q_DECLARATIVE_EXPORT QDeclarativeCleanup -{ -public: - QDeclarativeCleanup(); - QDeclarativeCleanup(QDeclarativeEngine *); - virtual ~QDeclarativeCleanup(); - - bool hasEngine() const { return prev != 0; } - void addToEngine(QDeclarativeEngine *); -protected: - virtual void clear() = 0; - -private: - friend class QDeclarativeEnginePrivate; - QDeclarativeCleanup **prev; - QDeclarativeCleanup *next; - - // Only used for asserts - QDeclarativeEngine *engine; -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVECLEANUP_P_H - diff --git a/src/declarative/qml/qdeclarativecompileddata.cpp b/src/declarative/qml/qdeclarativecompileddata.cpp deleted file mode 100644 index 6ace1d3042..0000000000 --- a/src/declarative/qml/qdeclarativecompileddata.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativecompiler_p.h" -#include "qdeclarativeengine.h" -#include "qdeclarativecomponent.h" -#include "qdeclarativecomponent_p.h" -#include "qdeclarativecontext.h" -#include "qdeclarativecontext_p.h" -#ifdef QML_THREADED_VME_INTERPRETER -#include "qdeclarativevme_p.h" -#endif - -#include - -#include - -QT_BEGIN_NAMESPACE - -int QDeclarativeCompiledData::pack(const char *data, size_t size) -{ - const char *p = packData.constData(); - unsigned int ps = packData.size(); - - for (unsigned int ii = 0; (ii + size) <= ps; ii += sizeof(int)) { - if (0 == ::memcmp(p + ii, data, size)) - return ii; - } - - int rv = packData.size(); - packData.append(data, size); - return rv; -} - -int QDeclarativeCompiledData::indexForString(const QString &data) -{ - int idx = primitives.indexOf(data); - if (idx == -1) { - idx = primitives.count(); - primitives << data; - } - return idx; -} - -int QDeclarativeCompiledData::indexForByteArray(const QByteArray &data) -{ - int idx = datas.indexOf(data); - if (idx == -1) { - idx = datas.count(); - datas << data; - } - return idx; -} - -int QDeclarativeCompiledData::indexForUrl(const QUrl &data) -{ - int idx = urls.indexOf(data); - if (idx == -1) { - idx = urls.count(); - urls << data; - } - return idx; -} - -QDeclarativeCompiledData::QDeclarativeCompiledData(QDeclarativeEngine *engine) -: engine(engine), importCache(0), root(0), rootPropertyCache(0) -{ - Q_ASSERT(engine); - - bytecode.reserve(1024); -} - -void QDeclarativeCompiledData::destroy() -{ - if (engine && hasEngine()) - QDeclarativeEnginePrivate::deleteInEngineThread(engine, this); - else - delete this; -} - -QDeclarativeCompiledData::~QDeclarativeCompiledData() -{ - clear(); - - for (int ii = 0; ii < types.count(); ++ii) { - if (types.at(ii).component) - types.at(ii).component->release(); - if (types.at(ii).typePropertyCache) - types.at(ii).typePropertyCache->release(); - } - - for (int ii = 0; ii < propertyCaches.count(); ++ii) - propertyCaches.at(ii)->release(); - - for (int ii = 0; ii < contextCaches.count(); ++ii) - contextCaches.at(ii)->release(); - - for (int ii = 0; ii < scripts.count(); ++ii) - scripts.at(ii)->release(); - - if (importCache) - importCache->release(); - - if (rootPropertyCache) - rootPropertyCache->release(); -} - -void QDeclarativeCompiledData::clear() -{ - for (int ii = 0; ii < programs.count(); ++ii) - qPersistentDispose(programs[ii].bindings); -} - -const QMetaObject *QDeclarativeCompiledData::TypeReference::metaObject() const -{ - if (type) { - return type->metaObject(); - } else { - Q_ASSERT(component); - return component->root; - } -} - -/*! -Returns the property cache, if one alread exists. The cache is not referenced. -*/ -QDeclarativePropertyCache *QDeclarativeCompiledData::TypeReference::propertyCache() const -{ - if (type) - return typePropertyCache; - else - return component->rootPropertyCache; -} - -/*! -Returns the property cache, creating one if it doesn't already exist. The cache is not referenced. -*/ -QDeclarativePropertyCache *QDeclarativeCompiledData::TypeReference::createPropertyCache(QDeclarativeEngine *engine) -{ - if (typePropertyCache) { - return typePropertyCache; - } else if (type) { - typePropertyCache = QDeclarativeEnginePrivate::get(engine)->cache(type->metaObject()); - typePropertyCache->addref(); - return typePropertyCache; - } else { - return component->rootPropertyCache; - } -} - - -void QDeclarativeCompiledData::dumpInstructions() -{ - if (!name.isEmpty()) - qWarning() << name; - qWarning().nospace() << "Index\tOperation\t\tData1\tData2\tData3\tComments"; - qWarning().nospace() << "-------------------------------------------------------------------------------"; - - const char *instructionStream = bytecode.constData(); - const char *endInstructionStream = bytecode.constData() + bytecode.size(); - - int instructionCount = 0; - while (instructionStream < endInstructionStream) { - QDeclarativeInstruction *instr = (QDeclarativeInstruction *)instructionStream; - dump(instr, instructionCount); - instructionStream += QDeclarativeInstruction::size(instructionType(instr)); - instructionCount++; - } - - qWarning().nospace() << "-------------------------------------------------------------------------------"; -} - -int QDeclarativeCompiledData::addInstructionHelper(QDeclarativeInstruction::Type type, QDeclarativeInstruction &instr) -{ -#ifdef QML_THREADED_VME_INTERPRETER - instr.common.code = QDeclarativeVME::instructionJumpTable()[static_cast(type)]; -#else - instr.common.instructionType = type; -#endif - int ptrOffset = bytecode.size(); - int size = QDeclarativeInstruction::size(type); - if (bytecode.capacity() <= bytecode.size() + size) - bytecode.reserve(bytecode.size() + size + 512); - bytecode.append(reinterpret_cast(&instr), size); - return ptrOffset; -} - -int QDeclarativeCompiledData::nextInstructionIndex() -{ - return bytecode.size(); -} - -QDeclarativeInstruction *QDeclarativeCompiledData::instruction(int index) -{ - return (QDeclarativeInstruction *)(bytecode.constData() + index); -} - -QDeclarativeInstruction::Type QDeclarativeCompiledData::instructionType(const QDeclarativeInstruction *instr) -{ -#ifdef QML_THREADED_VME_INTERPRETER - void **jumpTable = QDeclarativeVME::instructionJumpTable(); - void *code = instr->common.code; - -# define QML_CHECK_INSTR_CODE(I, FMT) \ - if (jumpTable[static_cast(QDeclarativeInstruction::I)] == code) \ - return QDeclarativeInstruction::I; - - FOR_EACH_QML_INSTR(QML_CHECK_INSTR_CODE) - Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid instruction address"); - return static_cast(0); -# undef QML_CHECK_INSTR_CODE -#else - return static_cast(instr->common.instructionType); -#endif -} - -void QDeclarativeCompiledData::initialize(QDeclarativeEngine *engine) -{ - Q_ASSERT(!hasEngine()); - QDeclarativeCleanup::addToEngine(engine); -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp deleted file mode 100644 index aaa1acaaa3..0000000000 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ /dev/null @@ -1,3904 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativecompiler_p.h" - -#include "qdeclarativepropertyvaluesource.h" -#include "qdeclarativecomponent.h" -#include -#include -#include "qdeclarativestringconverters_p.h" -#include "qdeclarativeengine_p.h" -#include "qdeclarativeengine.h" -#include "qdeclarativecontext.h" -#include "qdeclarativemetatype_p.h" -#include "qdeclarativecustomparser_p_p.h" -#include "qdeclarativecontext_p.h" -#include "qdeclarativecomponent_p.h" -#include -#include "qdeclarativevmemetaobject_p.h" -#include "qdeclarativeexpression_p.h" -#include "qdeclarativeproperty_p.h" -#include "qdeclarativerewrite_p.h" -#include "qdeclarativescriptstring.h" -#include "qdeclarativeglobal_p.h" -#include "qdeclarativebinding_p.h" -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -Q_DECLARE_METATYPE(QList) -Q_DECLARE_METATYPE(QList) -Q_DECLARE_METATYPE(QList) -Q_DECLARE_METATYPE(QList) -Q_DECLARE_METATYPE(QList) - -QT_BEGIN_NAMESPACE - -DEFINE_BOOL_CONFIG_OPTION(compilerDump, QML_COMPILER_DUMP); -DEFINE_BOOL_CONFIG_OPTION(compilerStatDump, QML_COMPILER_STATS); - -using namespace QDeclarativeJS; -using namespace QDeclarativeScript; -using namespace QDeclarativeCompilerTypes; - -static QString id_string(QLatin1String("id")); -static QString on_string(QLatin1String("on")); -static QString Changed_string(QLatin1String("Changed")); -static QString Component_string(QLatin1String("Component")); -static QString Component_import_string(QLatin1String("QML/Component")); -static QString qsTr_string(QLatin1String("qsTr")); -static QString qsTrId_string(QLatin1String("qsTrId")); - -/*! - Instantiate a new QDeclarativeCompiler. -*/ -QDeclarativeCompiler::QDeclarativeCompiler(QDeclarativePool *pool) -: pool(pool), output(0), engine(0), unitRoot(0), unit(0), cachedComponentTypeRef(-1), - cachedTranslationContextIndex(-1), componentStats(0) -{ - if (compilerStatDump()) - componentStats = pool->New(); -} - -/*! - Returns true if the last call to compile() caused errors. - - \sa errors() -*/ -bool QDeclarativeCompiler::isError() const -{ - return !exceptions.isEmpty(); -} - -/*! - Return the list of errors from the last call to compile(), or an empty list - if there were no errors. -*/ -QList QDeclarativeCompiler::errors() const -{ - return exceptions; -} - -/*! - Returns true if \a name refers to an attached property, false otherwise. - - Attached property names are those that start with a capital letter. -*/ -bool QDeclarativeCompiler::isAttachedPropertyName(const QString &name) -{ - return isAttachedPropertyName(QHashedStringRef(&name)); -} - -bool QDeclarativeCompiler::isAttachedPropertyName(const QHashedStringRef &name) -{ - return !name.isEmpty() && name.at(0).isUpper(); -} - -/*! - Returns true if \a name refers to a signal property, false otherwise. - - Signal property names are those that start with "on", followed by a first - character which is either a capital letter or one or more underscores followed - by a capital letter, which is then followed by other allowed characters. - - Note that although ECMA-262r3 supports dollarsigns and escaped unicode - character codes in property names, for simplicity and performance reasons - QML only supports letters, numbers and underscores. -*/ -bool QDeclarativeCompiler::isSignalPropertyName(const QString &name) -{ - return isSignalPropertyName(QStringRef(&name)); -} - -bool QDeclarativeCompiler::isSignalPropertyName(const QHashedStringRef &name) -{ - if (name.length() < 3) return false; - if (!name.startsWith(on_string)) return false; - int ns = name.length(); - for (int i = 2; i < ns; ++i) { - const QChar curr = name.at(i); - if (curr.unicode() == '_') continue; - if (curr.isUpper()) return true; - return false; - } - return false; // consists solely of underscores - invalid. -} - -/*! - \macro COMPILE_EXCEPTION - \internal - Inserts an error into the QDeclarativeCompiler error list, and returns false - (failure). - - \a token is used to source the error line and column, and \a desc is the - error itself. \a desc can be an expression that can be piped into QDebug. - - For example: - - \code - COMPILE_EXCEPTION(property, tr("Error for property \"%1\"").arg(property->name)); - \endcode -*/ -#define COMPILE_EXCEPTION_LOCATION(line, column, desc) \ - { \ - QDeclarativeError error; \ - error.setUrl(output->url); \ - error.setLine(line); \ - error.setColumn(column); \ - error.setDescription(desc.trimmed()); \ - exceptions << error; \ - return false; \ - } - -#define COMPILE_EXCEPTION(token, desc) \ - COMPILE_EXCEPTION_LOCATION((token)->location.start.line, (token)->location.start.column, desc) - -/*! - \macro COMPILE_CHECK - \internal - Returns false if \a is false, otherwise does nothing. -*/ -#define COMPILE_CHECK(a) \ - { \ - if (!a) return false; \ - } - -/*! - Returns true if literal \a v can be assigned to property \a prop, otherwise - false. - - This test corresponds to action taken by genLiteralAssignment(). Any change - made here, must have a corresponding action in genLiteralAssigment(). -*/ -bool QDeclarativeCompiler::testLiteralAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Value *v) -{ - const QDeclarativeScript::Variant &value = v->value; - - if (!prop->core.isWritable() && !prop->isReadOnlyDeclaration) - COMPILE_EXCEPTION(v, tr("Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString())); - - if (prop->core.isEnum()) { - QMetaProperty p = prop->parent->metaObject()->property(prop->index); - int enumValue; - bool ok; - if (p.isFlagType()) { - enumValue = p.enumerator().keysToValue(value.asString().toUtf8().constData(), &ok); - } else - enumValue = p.enumerator().keyToValue(value.asString().toUtf8().constData(), &ok); - - if (!ok) - COMPILE_EXCEPTION(v, tr("Invalid property assignment: unknown enumeration")); - - v->value = QDeclarativeScript::Variant((double)enumValue); - return true; - } - - int type = prop->type; - - switch(type) { - case QMetaType::QVariant: - break; - case QVariant::String: - if (!v->value.isString()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: string expected")); - break; - case QVariant::StringList: // we expect a string literal. A string list is not a literal assignment. - if (!v->value.isString()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: string or string list expected")); - break; - case QVariant::ByteArray: - if (!v->value.isString()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: byte array expected")); - break; - case QVariant::Url: - if (!v->value.isString()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: url expected")); - break; - case QVariant::RegExp: - COMPILE_EXCEPTION(v, tr("Invalid property assignment: regular expression expected; use /pattern/ syntax")); - break; - case QVariant::UInt: - { - bool ok = v->value.isNumber(); - if (ok) { - double n = v->value.asNumber(); - if (double(uint(n)) != n) - ok = false; - } - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: unsigned int expected")); - } - break; - case QVariant::Int: - { - bool ok = v->value.isNumber(); - if (ok) { - double n = v->value.asNumber(); - if (double(int(n)) != n) - ok = false; - } - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: int expected")); - } - break; - case QMetaType::Float: - if (!v->value.isNumber()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: number expected")); - break; - case QVariant::Double: - if (!v->value.isNumber()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: number expected")); - break; - case QVariant::Color: - { - bool ok; - QDeclarativeStringConverters::colorFromString(value.asString(), &ok); - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: color expected")); - } - break; -#ifndef QT_NO_DATESTRING - case QVariant::Date: - { - bool ok; - QDeclarativeStringConverters::dateFromString(value.asString(), &ok); - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: date expected")); - } - break; - case QVariant::Time: - { - bool ok; - QDeclarativeStringConverters::timeFromString(value.asString(), &ok); - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: time expected")); - } - break; - case QVariant::DateTime: - { - bool ok; - QDeclarativeStringConverters::dateTimeFromString(value.asString(), &ok); - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: datetime expected")); - } - break; -#endif // QT_NO_DATESTRING - case QVariant::Point: - case QVariant::PointF: - { - bool ok; - QDeclarativeStringConverters::pointFFromString(value.asString(), &ok); - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: point expected")); - } - break; - case QVariant::Size: - case QVariant::SizeF: - { - bool ok; - QDeclarativeStringConverters::sizeFFromString(value.asString(), &ok); - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: size expected")); - } - break; - case QVariant::Rect: - case QVariant::RectF: - { - bool ok; - QDeclarativeStringConverters::rectFFromString(value.asString(), &ok); - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: rect expected")); - } - break; - case QVariant::Bool: - { - if (!v->value.isBoolean()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: boolean expected")); - } - break; - case QVariant::Vector3D: - { - bool ok; - QDeclarativeStringConverters::vector3DFromString(value.asString(), &ok); - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: 3D vector expected")); - } - break; - case QVariant::Vector4D: - { - bool ok; - QDeclarativeStringConverters::vector4DFromString(value.asString(), &ok); - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: 4D vector expected")); - } - break; - default: - { - // check if assigning a literal value to a list property. - // in each case, check the singular, since an Array of the specified type - // will not go via this literal assignment codepath. - if (type == qMetaTypeId >()) { - if (!v->value.isNumber()) { - COMPILE_EXCEPTION(v, tr("Invalid property assignment: real or array of reals expected")); - } - break; - } else if (type == qMetaTypeId >()) { - bool ok = v->value.isNumber(); - if (ok) { - double n = v->value.asNumber(); - if (double(int(n)) != n) - ok = false; - } - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: int or array of ints expected")); - break; - } else if (type == qMetaTypeId >()) { - if (!v->value.isBoolean()) { - COMPILE_EXCEPTION(v, tr("Invalid property assignment: bool or array of bools expected")); - } - break; - } else if (type == qMetaTypeId >()) { // we expect a string literal. A string list is not a literal assignment. - if (!v->value.isString()) { - COMPILE_EXCEPTION(v, tr("Invalid property assignment: string or array of strings expected")); - } - break; - } else if (type == qMetaTypeId >()) { - if (!v->value.isString()) { - COMPILE_EXCEPTION(v, tr("Invalid property assignment: url or array of urls expected")); - } - break; - } - - // otherwise, check for existence of string converter to custom type - QDeclarativeMetaType::StringConverter converter = QDeclarativeMetaType::customStringConverter(type); - if (!converter) - COMPILE_EXCEPTION(v, tr("Invalid property assignment: unsupported type \"%1\"").arg(QString::fromLatin1(QVariant::typeToName((QVariant::Type)type)))); - } - break; - } - return true; -} - -static QUrl urlFromUserString(const QString &data) -{ - QUrl u; - // Preserve any valid percent-encoded octets supplied by the source - u.setEncodedUrl(data.toUtf8(), QUrl::TolerantMode); - return u; -} - -/*! - Generate a store instruction for assigning literal \a v to property \a prop. - - Any literal assignment that is approved in testLiteralAssignment() must have - a corresponding action in this method. -*/ -void QDeclarativeCompiler::genLiteralAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Value *v) -{ - if (prop->core.isEnum()) { - Q_ASSERT(v->value.isNumber()); - // Preresolved value - int value = (int)v->value.asNumber(); - - Instruction::StoreInteger instr; - instr.propertyIndex = prop->index; - instr.value = value; - output->addInstruction(instr); - return; - } - - int type = prop->type; - switch(type) { - case QMetaType::QVariant: - { - if (v->value.isNumber()) { - double n = v->value.asNumber(); - if (double(int(n)) == n) { - if (prop->core.isVMEProperty()) { - Instruction::StoreVarInteger instr; - instr.propertyIndex = prop->index; - instr.value = int(n); - output->addInstruction(instr); - } else { - Instruction::StoreVariantInteger instr; - instr.propertyIndex = prop->index; - instr.value = int(n); - output->addInstruction(instr); - } - } else { - if (prop->core.isVMEProperty()) { - Instruction::StoreVarDouble instr; - instr.propertyIndex = prop->index; - instr.value = n; - output->addInstruction(instr); - } else { - Instruction::StoreVariantDouble instr; - instr.propertyIndex = prop->index; - instr.value = n; - output->addInstruction(instr); - } - } - } else if (v->value.isBoolean()) { - if (prop->core.isVMEProperty()) { - Instruction::StoreVarBool instr; - instr.propertyIndex = prop->index; - instr.value = v->value.asBoolean(); - output->addInstruction(instr); - } else { - Instruction::StoreVariantBool instr; - instr.propertyIndex = prop->index; - instr.value = v->value.asBoolean(); - output->addInstruction(instr); - } - } else { - if (prop->core.isVMEProperty()) { - Instruction::StoreVar instr; - instr.propertyIndex = prop->index; - instr.value = output->indexForString(v->value.asString()); - output->addInstruction(instr); - } else { - Instruction::StoreVariant instr; - instr.propertyIndex = prop->index; - instr.value = output->indexForString(v->value.asString()); - output->addInstruction(instr); - } - } - } - break; - case QVariant::String: - { - Instruction::StoreString instr; - instr.propertyIndex = prop->index; - instr.value = output->indexForString(v->value.asString()); - output->addInstruction(instr); - } - break; - case QVariant::StringList: - { - Instruction::StoreStringList instr; - instr.propertyIndex = prop->index; - instr.value = output->indexForString(v->value.asString()); - output->addInstruction(instr); - } - break; - case QVariant::ByteArray: - { - Instruction::StoreByteArray instr; - instr.propertyIndex = prop->index; - instr.value = output->indexForByteArray(v->value.asString().toLatin1()); - output->addInstruction(instr); - } - break; - case QVariant::Url: - { - Instruction::StoreUrl instr; - QString string = v->value.asString(); - QUrl u = string.isEmpty() ? QUrl() : output->url.resolved(urlFromUserString(string)); - instr.propertyIndex = prop->index; - instr.value = output->indexForUrl(u); - output->addInstruction(instr); - } - break; - case QVariant::UInt: - { - Instruction::StoreInteger instr; - instr.propertyIndex = prop->index; - instr.value = uint(v->value.asNumber()); - output->addInstruction(instr); - } - break; - case QVariant::Int: - { - Instruction::StoreInteger instr; - instr.propertyIndex = prop->index; - instr.value = int(v->value.asNumber()); - output->addInstruction(instr); - } - break; - case QMetaType::Float: - { - Instruction::StoreFloat instr; - instr.propertyIndex = prop->index; - instr.value = float(v->value.asNumber()); - output->addInstruction(instr); - } - break; - case QVariant::Double: - { - Instruction::StoreDouble instr; - instr.propertyIndex = prop->index; - instr.value = v->value.asNumber(); - output->addInstruction(instr); - } - break; - case QVariant::Color: - { - Instruction::StoreColor instr; - QColor c = QDeclarativeStringConverters::colorFromString(v->value.asString()); - instr.propertyIndex = prop->index; - instr.value = c.rgba(); - output->addInstruction(instr); - } - break; -#ifndef QT_NO_DATESTRING - case QVariant::Date: - { - Instruction::StoreDate instr; - QDate d = QDeclarativeStringConverters::dateFromString(v->value.asString()); - instr.propertyIndex = prop->index; - instr.value = d.toJulianDay(); - output->addInstruction(instr); - } - break; - case QVariant::Time: - { - Instruction::StoreTime instr; - QTime time = QDeclarativeStringConverters::timeFromString(v->value.asString()); - instr.propertyIndex = prop->index; - Q_ASSERT(sizeof(instr.time) == sizeof(QTime)); - ::memcpy(&instr.time, &time, sizeof(QTime)); - output->addInstruction(instr); - } - break; - case QVariant::DateTime: - { - Instruction::StoreDateTime instr; - QDateTime dateTime = QDeclarativeStringConverters::dateTimeFromString(v->value.asString()); - QTime time = dateTime.time(); - instr.propertyIndex = prop->index; - instr.date = dateTime.date().toJulianDay(); - Q_ASSERT(sizeof(instr.time) == sizeof(QTime)); - ::memcpy(&instr.time, &time, sizeof(QTime)); - output->addInstruction(instr); - } - break; -#endif // QT_NO_DATESTRING - case QVariant::Point: - { - Instruction::StorePoint instr; - bool ok; - QPoint point = QDeclarativeStringConverters::pointFFromString(v->value.asString(), &ok).toPoint(); - instr.propertyIndex = prop->index; - instr.point.xp = point.x(); - instr.point.yp = point.y(); - output->addInstruction(instr); - } - break; - case QVariant::PointF: - { - Instruction::StorePointF instr; - bool ok; - QPointF point = QDeclarativeStringConverters::pointFFromString(v->value.asString(), &ok); - instr.propertyIndex = prop->index; - instr.point.xp = point.x(); - instr.point.yp = point.y(); - output->addInstruction(instr); - } - break; - case QVariant::Size: - { - Instruction::StoreSize instr; - bool ok; - QSize size = QDeclarativeStringConverters::sizeFFromString(v->value.asString(), &ok).toSize(); - instr.propertyIndex = prop->index; - instr.size.wd = size.width(); - instr.size.ht = size.height(); - output->addInstruction(instr); - } - break; - case QVariant::SizeF: - { - Instruction::StoreSizeF instr; - bool ok; - QSizeF size = QDeclarativeStringConverters::sizeFFromString(v->value.asString(), &ok); - instr.propertyIndex = prop->index; - instr.size.wd = size.width(); - instr.size.ht = size.height(); - output->addInstruction(instr); - } - break; - case QVariant::Rect: - { - Instruction::StoreRect instr; - bool ok; - QRect rect = QDeclarativeStringConverters::rectFFromString(v->value.asString(), &ok).toRect(); - instr.propertyIndex = prop->index; - instr.rect.x1 = rect.left(); - instr.rect.y1 = rect.top(); - instr.rect.x2 = rect.right(); - instr.rect.y2 = rect.bottom(); - output->addInstruction(instr); - } - break; - case QVariant::RectF: - { - Instruction::StoreRectF instr; - bool ok; - QRectF rect = QDeclarativeStringConverters::rectFFromString(v->value.asString(), &ok); - instr.propertyIndex = prop->index; - instr.rect.xp = rect.left(); - instr.rect.yp = rect.top(); - instr.rect.w = rect.width(); - instr.rect.h = rect.height(); - output->addInstruction(instr); - } - break; - case QVariant::Bool: - { - Instruction::StoreBool instr; - bool b = v->value.asBoolean(); - instr.propertyIndex = prop->index; - instr.value = b; - output->addInstruction(instr); - } - break; - case QVariant::Vector3D: - { - Instruction::StoreVector3D instr; - bool ok; - QVector3D vector = QDeclarativeStringConverters::vector3DFromString(v->value.asString(), &ok); - instr.propertyIndex = prop->index; - instr.vector.xp = vector.x(); - instr.vector.yp = vector.y(); - instr.vector.zp = vector.z(); - output->addInstruction(instr); - } - break; - case QVariant::Vector4D: - { - Instruction::StoreVector4D instr; - bool ok; - QVector4D vector = QDeclarativeStringConverters::vector4DFromString(v->value.asString(), &ok); - instr.propertyIndex = prop->index; - instr.vector.xp = vector.x(); - instr.vector.yp = vector.y(); - instr.vector.zp = vector.z(); - instr.vector.wp = vector.w(); - output->addInstruction(instr); - } - break; - default: - { - // generate single literal value assignment to a list property if required - if (type == qMetaTypeId >()) { - Instruction::StoreDoubleQList instr; - instr.propertyIndex = prop->index; - instr.value = v->value.asNumber(); - output->addInstruction(instr); - break; - } else if (type == qMetaTypeId >()) { - Instruction::StoreIntegerQList instr; - instr.propertyIndex = prop->index; - instr.value = int(v->value.asNumber()); - output->addInstruction(instr); - break; - } else if (type == qMetaTypeId >()) { - Instruction::StoreBoolQList instr; - bool b = v->value.asBoolean(); - instr.propertyIndex = prop->index; - instr.value = b; - output->addInstruction(instr); - break; - } else if (type == qMetaTypeId >()) { - Instruction::StoreUrlQList instr; - QString string = v->value.asString(); - QUrl u = string.isEmpty() ? QUrl() : output->url.resolved(urlFromUserString(string)); - instr.propertyIndex = prop->index; - instr.value = output->indexForUrl(u); - output->addInstruction(instr); - break; - } else if (type == qMetaTypeId >()) { - Instruction::StoreStringQList instr; - instr.propertyIndex = prop->index; - instr.value = output->indexForString(v->value.asString()); - output->addInstruction(instr); - break; - } - - // otherwise, generate custom type literal assignment - Instruction::AssignCustomType instr; - instr.propertyIndex = prop->index; - instr.primitive = output->indexForString(v->value.asString()); - instr.type = type; - output->addInstruction(instr); - } - break; - } -} - -/*! - Resets data by clearing the lists that the QDeclarativeCompiler modifies. -*/ -void QDeclarativeCompiler::reset(QDeclarativeCompiledData *data) -{ - data->types.clear(); - data->primitives.clear(); - data->datas.clear(); - data->bytecode.resize(0); -} - -/*! - Compile \a unit, and store the output in \a out. \a engine is the QDeclarativeEngine - with which the QDeclarativeCompiledData will be associated. - - Returns true on success, false on failure. On failure, the compile errors - are available from errors(). - - If the environment variant QML_COMPILER_DUMP is set - (eg. QML_COMPILER_DUMP=1) the compiled instructions will be dumped to stderr - on a successful compiler. -*/ -bool QDeclarativeCompiler::compile(QDeclarativeEngine *engine, - QDeclarativeTypeData *unit, - QDeclarativeCompiledData *out) -{ - exceptions.clear(); - - Q_ASSERT(out); - reset(out); - - QDeclarativeScript::Object *root = unit->parser().tree(); - Q_ASSERT(root); - - this->engine = engine; - this->enginePrivate = QDeclarativeEnginePrivate::get(engine); - this->unit = unit; - this->unitRoot = root; - this->output = out; - - // Compile types - const QList &resolvedTypes = unit->resolvedTypes(); - QList referencedTypes = unit->parser().referencedTypes(); - - for (int ii = 0; ii < resolvedTypes.count(); ++ii) { - QDeclarativeCompiledData::TypeReference ref; - - const QDeclarativeTypeData::TypeReference &tref = resolvedTypes.at(ii); - QDeclarativeScript::TypeReference *parserRef = referencedTypes.at(ii); - - if (tref.type) { - ref.type = tref.type; - if (!ref.type->isCreatable()) { - QString err = ref.type->noCreationReason(); - if (err.isEmpty()) - err = tr( "Element is not creatable."); - COMPILE_EXCEPTION(parserRef->refObjects.first(), err); - } - - if (ref.type->containsRevisionedAttributes()) { - QDeclarativeError cacheError; - ref.typePropertyCache = enginePrivate->cache(ref.type, resolvedTypes.at(ii).minorVersion, - cacheError); - if (!ref.typePropertyCache) - COMPILE_EXCEPTION(parserRef->refObjects.first(), cacheError.description()); - ref.typePropertyCache->addref(); - } - - } else if (tref.typeData) { - ref.component = tref.typeData->compiledData(); - } - ref.className = parserRef->name; - out->types << ref; - } - - compileTree(root); - - if (!isError()) { - if (compilerDump()) - out->dumpInstructions(); - if (componentStats) - dumpStats(); - Q_ASSERT(out->rootPropertyCache); - } else { - reset(out); - } - - compileState = 0; - output = 0; - this->engine = 0; - this->enginePrivate = 0; - this->unit = 0; - this->cachedComponentTypeRef = -1; - this->cachedTranslationContextIndex = -1; - this->unitRoot = 0; - - return !isError(); -} - -void QDeclarativeCompiler::compileTree(QDeclarativeScript::Object *tree) -{ - compileState = pool->New(); - - compileState->root = tree; - if (componentStats) - componentStats->componentStat.lineNumber = tree->location.start.line; - - // We generate the importCache before we build the tree so that - // it can be used in the binding compiler. Given we "expect" the - // QML compilation to succeed, this isn't a waste. - output->importCache = new QDeclarativeTypeNameCache(); - foreach (const QString &ns, unit->namespaces()) { - output->importCache->add(ns); - } - - int scriptIndex = 0; - foreach (const QDeclarativeTypeData::ScriptReference &script, unit->resolvedScripts()) { - QString qualifier = script.qualifier; - QString enclosingNamespace; - - const int lastDotIndex = qualifier.lastIndexOf(QLatin1Char('.')); - if (lastDotIndex != -1) { - enclosingNamespace = qualifier.left(lastDotIndex); - qualifier = qualifier.mid(lastDotIndex+1); - } - - output->importCache->add(qualifier, scriptIndex++, enclosingNamespace); - } - - unit->imports().populateCache(output->importCache, engine); - - if (!buildObject(tree, BindingContext()) || !completeComponentBuild()) - return; - - Instruction::Init init; - init.bindingsSize = compileState->totalBindingsCount; - init.parserStatusSize = compileState->parserStatusCount; - init.contextCache = genContextCache(); - init.objectStackSize = compileState->objectDepth.maxDepth(); - init.listStackSize = compileState->listDepth.maxDepth(); - if (compileState->compiledBindingData.isEmpty()) - init.compiledBinding = -1; - else - init.compiledBinding = output->indexForByteArray(compileState->compiledBindingData); - output->addInstruction(init); - - foreach (const QDeclarativeTypeData::ScriptReference &script, unit->resolvedScripts()) { - Instruction::StoreImportedScript import; - import.value = output->scripts.count(); - - QDeclarativeScriptData *scriptData = script.script->scriptData(); - scriptData->addref(); - output->scripts << scriptData; - output->addInstruction(import); - } - - if (!compileState->v8BindingProgram.isEmpty()) { - Instruction::InitV8Bindings bindings; - int index = output->programs.count(); - - typedef QDeclarativeCompiledData::V8Program V8Program; - output->programs.append(V8Program(compileState->v8BindingProgram, output)); - - bindings.programIndex = index; - bindings.line = compileState->v8BindingProgramLine; - output->addInstruction(bindings); - } - - genObject(tree); - - Instruction::SetDefault def; - output->addInstruction(def); - - Instruction::Done done; - output->addInstruction(done); - - Q_ASSERT(tree->metatype); - - if (tree->metadata.isEmpty()) { - output->root = tree->metatype; - } else { - static_cast(output->rootData) = *tree->metaObject(); - output->root = &output->rootData; - } - if (!tree->metadata.isEmpty()) - enginePrivate->registerCompositeType(output); -} - -static bool QStringList_contains(const QStringList &list, const QHashedStringRef &string) -{ - for (int ii = 0; ii < list.count(); ++ii) - if (string == list.at(ii)) - return true; - - return false; -} - -bool QDeclarativeCompiler::buildObject(QDeclarativeScript::Object *obj, const BindingContext &ctxt) -{ - if (componentStats) - componentStats->componentStat.objects++; - - Q_ASSERT (obj->type != -1); - const QDeclarativeCompiledData::TypeReference &tr = output->types.at(obj->type); - obj->metatype = tr.metaObject(); - - if (tr.type) - obj->typeName = tr.type->qmlTypeName(); - - // This object is a "Component" element - if (tr.type && obj->metatype == &QDeclarativeComponent::staticMetaObject) { - COMPILE_CHECK(buildComponent(obj, ctxt)); - return true; - } - - if (tr.component) { - typedef QDeclarativeInstruction I; - const I *init = ((const I *)tr.component->bytecode.constData()); - Q_ASSERT(init && tr.component->instructionType(init) == QDeclarativeInstruction::Init); - - // Adjust stack depths to include nested components - compileState->objectDepth.pushPop(init->init.objectStackSize); - compileState->listDepth.pushPop(init->init.listStackSize); - compileState->parserStatusCount += init->init.parserStatusSize; - compileState->totalBindingsCount += init->init.bindingsSize; - } - - compileState->objectDepth.push(); - - // Object instantiations reset the binding context - BindingContext objCtxt(obj); - - // Create the synthesized meta object, ignoring aliases - COMPILE_CHECK(checkDynamicMeta(obj)); - COMPILE_CHECK(mergeDynamicMetaProperties(obj)); - COMPILE_CHECK(buildDynamicMeta(obj, IgnoreAliases)); - - // Find the native type and check for the QDeclarativeParserStatus interface - QDeclarativeType *type = toQmlType(obj); - Q_ASSERT(type); - obj->parserStatusCast = type->parserStatusCast(); - if (obj->parserStatusCast != -1) - compileState->parserStatusCount++; - - // Check if this is a custom parser type. Custom parser types allow - // assignments to non-existent properties. These assignments are then - // compiled by the type. - bool isCustomParser = output->types.at(obj->type).type && - output->types.at(obj->type).type->customParser() != 0; - QList customProps; - - // Fetch the list of deferred properties - QStringList deferredList = deferredProperties(obj); - - // Must do id property first. This is to ensure that the id given to any - // id reference created matches the order in which the objects are - // instantiated - for (Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) { - if (prop->name() == id_string) { - COMPILE_CHECK(buildProperty(prop, obj, objCtxt)); - break; - } - } - - // Merge - Property *defaultProperty = 0; - Property *skipProperty = 0; - if (obj->defaultProperty) { - defaultProperty = obj->defaultProperty; - - Property *explicitProperty = 0; - - const QMetaObject *mo = obj->metatype; - int idx = mo->indexOfClassInfo("DefaultProperty"); - if (idx != -1) { - QMetaClassInfo info = mo->classInfo(idx); - const char *p = info.value(); - if (p) { - int plen = 0; - char ord = 0; - while (char c = p[plen++]) { ord |= c; }; - --plen; - - if (ord & 0x80) { - // Utf8 - unoptimal, but seldom hit - QString *s = pool->NewString(QString::fromUtf8(p, plen)); - QHashedStringRef r(*s); - - if (obj->propertiesHashField.test(r.hash())) { - for (Property *ep = obj->properties.first(); ep; ep = obj->properties.next(ep)) { - if (ep->name() == r) { - explicitProperty = ep; - break; - } - } - } - - if (!explicitProperty) - defaultProperty->setName(r); - - } else { - QHashedCStringRef r(p, plen); - - if (obj->propertiesHashField.test(r.hash())) { - for (Property *ep = obj->properties.first(); ep; ep = obj->properties.next(ep)) { - if (ep->name() == r) { - explicitProperty = ep; - break; - } - } - } - - if (!explicitProperty) { - // Set the default property name - QChar *buffer = pool->NewRawArray(r.length()); - r.writeUtf16(buffer); - defaultProperty->setName(QHashedStringRef(buffer, r.length(), r.hash())); - } - } - } - } - - if (explicitProperty && !explicitProperty->value && !explicitProperty->values.isEmpty()) { - - skipProperty = explicitProperty; // We merge the values into defaultProperty - - // Find the correct insertion point - Value *insertPos = 0; - - for (Value *v = defaultProperty->values.first(); v; v = Property::ValueList::next(v)) { - if (!(v->location.start < explicitProperty->values.first()->location.start)) - break; - insertPos = v; - } - - defaultProperty->values.insertAfter(insertPos, explicitProperty->values); - } - } - - QDeclarativeCustomParser *cp = 0; - if (isCustomParser) - cp = output->types.at(obj->type).type->customParser(); - - // Build all explicit properties specified - for (Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) { - - if (prop == skipProperty) - continue; - if (prop->name() == id_string) - continue; - - bool canDefer = false; - if (isCustomParser) { - if (doesPropertyExist(prop, obj) && - (!(cp->flags() & QDeclarativeCustomParser::AcceptsAttachedProperties) || - !isAttachedPropertyName(prop->name()))) { - int ids = compileState->ids.count(); - COMPILE_CHECK(buildProperty(prop, obj, objCtxt)); - canDefer = ids == compileState->ids.count(); - } else if (isSignalPropertyName(prop->name()) && - (cp->flags() & QDeclarativeCustomParser::AcceptsSignalHandlers)) { - COMPILE_CHECK(buildSignal(prop,obj,objCtxt)); - } else { - customProps << QDeclarativeCustomParserNodePrivate::fromProperty(prop); - } - } else { - if (isSignalPropertyName(prop->name())) { - COMPILE_CHECK(buildSignal(prop,obj,objCtxt)); - } else { - int ids = compileState->ids.count(); - COMPILE_CHECK(buildProperty(prop, obj, objCtxt)); - canDefer = ids == compileState->ids.count(); - } - } - - if (canDefer && !deferredList.isEmpty() && QStringList_contains(deferredList, prop->name())) - prop->isDeferred = true; - - } - - // Build the default property - if (defaultProperty) { - Property *prop = defaultProperty; - - bool canDefer = false; - if (isCustomParser) { - if (doesPropertyExist(prop, obj)) { - int ids = compileState->ids.count(); - COMPILE_CHECK(buildProperty(prop, obj, objCtxt)); - canDefer = ids == compileState->ids.count(); - } else { - customProps << QDeclarativeCustomParserNodePrivate::fromProperty(prop); - } - } else { - int ids = compileState->ids.count(); - COMPILE_CHECK(buildProperty(prop, obj, objCtxt)); - canDefer = ids == compileState->ids.count(); - } - - if (canDefer && !deferredList.isEmpty() && QStringList_contains(deferredList, prop->name())) - prop->isDeferred = true; - } - - // Compile custom parser parts - if (isCustomParser && !customProps.isEmpty()) { - cp->clearErrors(); - cp->compiler = this; - cp->object = obj; - obj->custom = cp->compile(customProps); - cp->compiler = 0; - cp->object = 0; - foreach (QDeclarativeError err, cp->errors()) { - err.setUrl(output->url); - exceptions << err; - } - } - - compileState->objectDepth.pop(); - - return true; -} - -void QDeclarativeCompiler::genObject(QDeclarativeScript::Object *obj) -{ - QDeclarativeCompiledData::TypeReference &tr = output->types[obj->type]; - if (tr.type && obj->metatype == &QDeclarativeComponent::staticMetaObject) { - genComponent(obj); - return; - } - - // Create the object - if (obj->custom.isEmpty() && output->types.at(obj->type).type && - !output->types.at(obj->type).type->isExtendedType() && obj != compileState->root) { - - Instruction::CreateSimpleObject create; - create.create = output->types.at(obj->type).type->createFunction(); - create.typeSize = output->types.at(obj->type).type->createSize(); - create.type = obj->type; - create.line = obj->location.start.line; - create.column = obj->location.start.column; - output->addInstruction(create); - - } else { - - if (output->types.at(obj->type).type) { - Instruction::CreateCppObject create; - create.line = obj->location.start.line; - create.column = obj->location.start.column; - create.data = -1; - if (!obj->custom.isEmpty()) - create.data = output->indexForByteArray(obj->custom); - create.type = obj->type; - create.isRoot = (compileState->root == obj); - output->addInstruction(create); - } else { - Instruction::CreateQMLObject create; - create.type = obj->type; - create.isRoot = (compileState->root == obj); - - if (!obj->bindingBitmask.isEmpty()) { - Q_ASSERT(obj->bindingBitmask.size() % 4 == 0); - create.bindingBits = output->indexForByteArray(obj->bindingBitmask); - } else { - create.bindingBits = -1; - } - output->addInstruction(create); - - Instruction::CompleteQMLObject complete; - complete.line = obj->location.start.line; - complete.column = obj->location.start.column; - complete.isRoot = (compileState->root == obj); - output->addInstruction(complete); - } - } - - // Setup the synthesized meta object if necessary - if (!obj->metadata.isEmpty()) { - Instruction::StoreMetaObject meta; - meta.data = output->indexForByteArray(obj->metadata); - meta.aliasData = output->indexForByteArray(obj->synthdata); - meta.propertyCache = output->propertyCaches.count(); - - QDeclarativePropertyCache *propertyCache = obj->synthCache; - Q_ASSERT(propertyCache); - propertyCache->addref(); - - // Add flag for alias properties - if (!obj->synthdata.isEmpty()) { - const QDeclarativeVMEMetaData *vmeMetaData = - reinterpret_cast(obj->synthdata.constData()); - for (int ii = 0; ii < vmeMetaData->aliasCount; ++ii) { - int index = obj->metaObject()->propertyOffset() + vmeMetaData->propertyCount + ii; - QDeclarativePropertyData *data = propertyCache->property(index); - data->setFlags(data->getFlags() | QDeclarativePropertyData::IsAlias); - } - } - - if (obj == unitRoot) { - propertyCache->addref(); - output->rootPropertyCache = propertyCache; - } - - output->propertyCaches << propertyCache; - output->addInstruction(meta); - } else if (obj == unitRoot) { - output->rootPropertyCache = tr.createPropertyCache(engine); - output->rootPropertyCache->addref(); - } - - // Set the object id - if (!obj->id.isEmpty()) { - Instruction::SetId id; - id.value = output->indexForString(obj->id); - id.index = obj->idIndex; - output->addInstruction(id); - } - - // Begin the class - if (tr.type && obj->parserStatusCast != -1) { - Instruction::BeginObject begin; - begin.castValue = obj->parserStatusCast; - output->addInstruction(begin); - } - - genObjectBody(obj); -} - -void QDeclarativeCompiler::genObjectBody(QDeclarativeScript::Object *obj) -{ - for (Property *prop = obj->scriptStringProperties.first(); prop; prop = Object::PropertyList::next(prop)) { - Q_ASSERT(prop->scriptStringScope != -1); - const QString &script = prop->values.first()->value.asScript(); - Instruction::StoreScriptString ss; - ss.propertyIndex = prop->index; - ss.value = output->indexForString(script); - ss.scope = prop->scriptStringScope; -// ss.bindingId = rewriteBinding(script, prop->name()); - ss.bindingId = rewriteBinding(prop->values.first()->value, QString()); // XXX - ss.line = prop->location.start.line; - ss.column = prop->location.start.column; - output->addInstruction(ss); - } - - bool seenDefer = false; - for (Property *prop = obj->valueProperties.first(); prop; prop = Object::PropertyList::next(prop)) { - if (prop->isDeferred) { - seenDefer = true; - continue; - } - if (!prop->isAlias) - genValueProperty(prop, obj); - } - if (seenDefer) { - Instruction::Defer defer; - defer.deferCount = 0; - int deferIdx = output->addInstruction(defer); - int nextInstructionIndex = output->nextInstructionIndex(); - - Instruction::DeferInit dinit; - // XXX - these are now massive over allocations - dinit.bindingsSize = compileState->totalBindingsCount; - dinit.parserStatusSize = compileState->parserStatusCount; - dinit.objectStackSize = compileState->objectDepth.maxDepth(); - dinit.listStackSize = compileState->listDepth.maxDepth(); - output->addInstruction(dinit); - - for (Property *prop = obj->valueProperties.first(); prop; prop = Object::PropertyList::next(prop)) { - if (!prop->isDeferred) - continue; - genValueProperty(prop, obj); - } - - Instruction::Done done; - output->addInstruction(done); - - output->instruction(deferIdx)->defer.deferCount = output->nextInstructionIndex() - nextInstructionIndex; - } - - for (Property *prop = obj->signalProperties.first(); prop; prop = Object::PropertyList::next(prop)) { - - QDeclarativeScript::Value *v = prop->values.first(); - - if (v->type == Value::SignalObject) { - - genObject(v->object); - - Instruction::AssignSignalObject assign; - assign.line = v->location.start.line; - assign.signal = output->indexForString(prop->name().toString()); - output->addInstruction(assign); - - } else if (v->type == Value::SignalExpression) { - - Instruction::StoreSignal store; - store.signalIndex = prop->index; - const QString &rewrite = rewriteSignalHandler(v->value, prop->name().toString()); - store.value = output->indexForByteArray(rewrite.toUtf8()); - store.context = v->signalExpressionContextStack; - store.line = v->location.start.line; - store.column = v->location.start.column; - output->addInstruction(store); - - } - - } - - for (Property *prop = obj->attachedProperties.first(); prop; prop = Object::PropertyList::next(prop)) { - Instruction::FetchAttached fetch; - fetch.id = prop->index; - fetch.line = prop->location.start.line; - output->addInstruction(fetch); - - genObjectBody(prop->value); - - Instruction::PopFetchedObject pop; - output->addInstruction(pop); - } - - for (Property *prop = obj->groupedProperties.first(); prop; prop = Object::PropertyList::next(prop)) { - Instruction::FetchObject fetch; - fetch.property = prop->index; - fetch.line = prop->location.start.line; - output->addInstruction(fetch); - - if (!prop->value->metadata.isEmpty()) { - Instruction::StoreMetaObject meta; - meta.data = output->indexForByteArray(prop->value->metadata); - meta.aliasData = output->indexForByteArray(prop->value->synthdata); - meta.propertyCache = -1; - output->addInstruction(meta); - } - - genObjectBody(prop->value); - - Instruction::PopFetchedObject pop; - output->addInstruction(pop); - } - - for (Property *prop = obj->valueTypeProperties.first(); prop; prop = Object::PropertyList::next(prop)) { - if (!prop->isAlias) - genValueTypeProperty(obj, prop); - } - - for (Property *prop = obj->valueProperties.first(); prop; prop = Object::PropertyList::next(prop)) { - if (prop->isDeferred) - continue; - if (prop->isAlias) - genValueProperty(prop, obj); - } - - for (Property *prop = obj->valueTypeProperties.first(); prop; prop = Object::PropertyList::next(prop)) { - if (prop->isAlias) - genValueTypeProperty(obj, prop); - } -} - -void QDeclarativeCompiler::genValueTypeProperty(QDeclarativeScript::Object *obj,QDeclarativeScript::Property *prop) -{ - Instruction::FetchValueType fetch; - fetch.property = prop->index; - fetch.type = prop->type; - fetch.bindingSkipList = 0; - - if (obj->type == -1 || output->types.at(obj->type).component) { - // We only have to do this if this is a composite type. If it is a builtin - // type it can't possibly already have bindings that need to be cleared. - for (Property *vprop = prop->value->valueProperties.first(); vprop; vprop = Object::PropertyList::next(vprop)) { - if (!vprop->values.isEmpty()) { - Q_ASSERT(vprop->index >= 0 && vprop->index < 32); - fetch.bindingSkipList |= (1 << vprop->index); - } - } - } - - output->addInstruction(fetch); - - for (Property *vprop = prop->value->valueProperties.first(); vprop; vprop = Object::PropertyList::next(vprop)) { - genPropertyAssignment(vprop, prop->value, prop); - } - - Instruction::PopValueType pop; - pop.property = prop->index; - pop.type = prop->type; - pop.bindingSkipList = 0; - output->addInstruction(pop); -} - -void QDeclarativeCompiler::genComponent(QDeclarativeScript::Object *obj) -{ - QDeclarativeScript::Object *root = obj->defaultProperty->values.first()->object; - Q_ASSERT(root); - - Instruction::CreateComponent create; - create.line = root->location.start.line; - create.column = root->location.start.column; - create.endLine = root->location.end.line; - create.isRoot = (compileState->root == obj); - int createInstruction = output->addInstruction(create); - int nextInstructionIndex = output->nextInstructionIndex(); - - ComponentCompileState *oldCompileState = compileState; - compileState = componentState(root); - - Instruction::Init init; - init.bindingsSize = compileState->totalBindingsCount; - init.parserStatusSize = compileState->parserStatusCount; - init.contextCache = genContextCache(); - init.objectStackSize = compileState->objectDepth.maxDepth(); - init.listStackSize = compileState->listDepth.maxDepth(); - if (compileState->compiledBindingData.isEmpty()) - init.compiledBinding = -1; - else - init.compiledBinding = output->indexForByteArray(compileState->compiledBindingData); - output->addInstruction(init); - - if (!compileState->v8BindingProgram.isEmpty()) { - Instruction::InitV8Bindings bindings; - int index = output->programs.count(); - - typedef QDeclarativeCompiledData::V8Program V8Program; - output->programs.append(V8Program(compileState->v8BindingProgram, output)); - - bindings.programIndex = index; - bindings.line = compileState->v8BindingProgramLine; - output->addInstruction(bindings); - } - - genObject(root); - - Instruction::SetDefault def; - output->addInstruction(def); - - Instruction::Done done; - output->addInstruction(done); - - output->instruction(createInstruction)->createComponent.count = - output->nextInstructionIndex() - nextInstructionIndex; - - compileState = oldCompileState; - - if (!obj->id.isEmpty()) { - Instruction::SetId id; - id.value = output->indexForString(obj->id); - id.index = obj->idIndex; - output->addInstruction(id); - } - - if (obj == unitRoot) { - output->rootPropertyCache = output->types[obj->type].createPropertyCache(engine); - output->rootPropertyCache->addref(); - } -} - -bool QDeclarativeCompiler::buildComponent(QDeclarativeScript::Object *obj, - const BindingContext &ctxt) -{ - // The special "Component" element can only have the id property and a - // default property, that actually defines the component's tree - - compileState->objectDepth.push(); - - // Find, check and set the "id" property (if any) - Property *idProp = 0; - if (obj->properties.isMany() || - (obj->properties.isOne() && obj->properties.first()->name() != id_string)) - COMPILE_EXCEPTION(obj->properties.first(), tr("Component elements may not contain properties other than id")); - - if (!obj->properties.isEmpty()) - idProp = obj->properties.first(); - - if (idProp) { - if (idProp->value || idProp->values.isMany() || idProp->values.first()->object) - COMPILE_EXCEPTION(idProp, tr("Invalid component id specification")); - COMPILE_CHECK(checkValidId(idProp->values.first(), idProp->values.first()->primitive())) - - QString idVal = idProp->values.first()->primitive(); - - if (compileState->ids.value(idVal)) - COMPILE_EXCEPTION(idProp, tr("id is not unique")); - - obj->id = idVal; - addId(idVal, obj); - } - - // Check the Component tree is well formed - if (obj->defaultProperty && - (obj->defaultProperty->value || obj->defaultProperty->values.isMany() || - (obj->defaultProperty->values.isOne() && !obj->defaultProperty->values.first()->object))) - COMPILE_EXCEPTION(obj, tr("Invalid component body specification")); - - if (!obj->dynamicProperties.isEmpty()) - COMPILE_EXCEPTION(obj, tr("Component objects cannot declare new properties.")); - if (!obj->dynamicSignals.isEmpty()) - COMPILE_EXCEPTION(obj, tr("Component objects cannot declare new signals.")); - if (!obj->dynamicSlots.isEmpty()) - COMPILE_EXCEPTION(obj, tr("Component objects cannot declare new functions.")); - - QDeclarativeScript::Object *root = 0; - if (obj->defaultProperty && !obj->defaultProperty->values.isEmpty()) - root = obj->defaultProperty->values.first()->object; - - if (!root) - COMPILE_EXCEPTION(obj, tr("Cannot create empty component specification")); - - // Build the component tree - COMPILE_CHECK(buildComponentFromRoot(root, ctxt)); - - compileState->objectDepth.pop(); - - return true; -} - -bool QDeclarativeCompiler::buildComponentFromRoot(QDeclarativeScript::Object *obj, - const BindingContext &ctxt) -{ - ComponentCompileState *oldComponentCompileState = compileState; - compileState = pool->New(); - compileState->root = obj; - compileState->nested = true; - - if (componentStats) { - ComponentStat oldComponentStat = componentStats->componentStat; - - componentStats->componentStat = ComponentStat(); - componentStats->componentStat.lineNumber = obj->location.start.line; - - if (obj) - COMPILE_CHECK(buildObject(obj, ctxt)); - - COMPILE_CHECK(completeComponentBuild()); - - componentStats->componentStat = oldComponentStat; - } else { - if (obj) - COMPILE_CHECK(buildObject(obj, ctxt)); - - COMPILE_CHECK(completeComponentBuild()); - } - - compileState = oldComponentCompileState; - - return true; -} - - -// Build a sub-object. A sub-object is one that was not created directly by -// QML - such as a grouped property object, or an attached object. Sub-object's -// can't have an id, involve a custom parser, have attached properties etc. -bool QDeclarativeCompiler::buildSubObject(QDeclarativeScript::Object *obj, const BindingContext &ctxt) -{ - Q_ASSERT(obj->metatype); - Q_ASSERT(!obj->defaultProperty); - Q_ASSERT(ctxt.isSubContext()); // sub-objects must always be in a binding - // sub-context - - for (Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) { - if (isSignalPropertyName(prop->name())) { - COMPILE_CHECK(buildSignal(prop, obj, ctxt)); - } else { - COMPILE_CHECK(buildProperty(prop, obj, ctxt)); - } - } - - return true; -} - -int QDeclarativeCompiler::componentTypeRef() -{ - if (cachedComponentTypeRef == -1) { - QDeclarativeType *t = QDeclarativeMetaType::qmlType(Component_import_string,1,0); - for (int ii = output->types.count() - 1; ii >= 0; --ii) { - if (output->types.at(ii).type == t) { - cachedComponentTypeRef = ii; - return ii; - } - } - QDeclarativeCompiledData::TypeReference ref; - ref.className = Component_string; - ref.type = t; - output->types << ref; - cachedComponentTypeRef = output->types.count() - 1; - } - return cachedComponentTypeRef; -} - -int QDeclarativeCompiler::translationContextIndex() -{ - if (cachedTranslationContextIndex == -1) { - // This code must match that in the qsTr() implementation - const QString &path = output->name; - int lastSlash = path.lastIndexOf(QLatin1Char('/')); - QString context = (lastSlash > -1) ? path.mid(lastSlash + 1, path.length()-lastSlash-5) : - QString(); - QByteArray contextUtf8 = context.toUtf8(); - cachedTranslationContextIndex = output->indexForByteArray(contextUtf8); - } - return cachedTranslationContextIndex; -} - -bool QDeclarativeCompiler::buildSignal(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj, - const BindingContext &ctxt) -{ - Q_ASSERT(obj->metaObject()); - - const QHashedStringRef &propName = prop->name(); - - Q_ASSERT(propName.startsWith(on_string)); - QString name = propName.mid(2, -1).toString(); - - // Note that the property name could start with any alpha or '_' or '$' character, - // so we need to do the lower-casing of the first alpha character. - for (int firstAlphaIndex = 0; firstAlphaIndex < name.size(); ++firstAlphaIndex) { - if (name.at(firstAlphaIndex).isUpper()) { - name[firstAlphaIndex] = name.at(firstAlphaIndex).toLower(); - break; - } - } - - bool notInRevision = false; - - QDeclarativePropertyData *sig = signal(obj, QStringRef(&name), ¬InRevision); - - if (sig == 0) { - - if (notInRevision && 0 == property(obj, propName, 0)) { - Q_ASSERT(obj->type != -1); - const QList &resolvedTypes = unit->resolvedTypes(); - const QDeclarativeTypeData::TypeReference &type = resolvedTypes.at(obj->type); - if (type.type) { - COMPILE_EXCEPTION(prop, tr("\"%1.%2\" is not available in %3 %4.%5.").arg(elementName(obj)).arg(prop->name().toString()).arg(type.type->module()).arg(type.majorVersion).arg(type.minorVersion)); - } else { - COMPILE_EXCEPTION(prop, tr("\"%1.%2\" is not available due to component versioning.").arg(elementName(obj)).arg(prop->name().toString())); - } - } - - // If the "on" name doesn't resolve into a signal, try it as a - // property. - COMPILE_CHECK(buildProperty(prop, obj, ctxt)); - - } else { - - if (prop->value || !prop->values.isOne()) - COMPILE_EXCEPTION(prop, tr("Incorrectly specified signal assignment")); - - prop->index = sig->coreIndex; - prop->core = *sig; - - obj->addSignalProperty(prop); - - if (prop->values.first()->object) { - COMPILE_CHECK(buildObject(prop->values.first()->object, ctxt)); - prop->values.first()->type = Value::SignalObject; - } else { - prop->values.first()->type = Value::SignalExpression; - - if (!prop->values.first()->value.isScript()) - COMPILE_EXCEPTION(prop, tr("Cannot assign a value to a signal (expecting a script to be run)")); - - QString script = prop->values.first()->value.asScript().trimmed(); - if (script.isEmpty()) - COMPILE_EXCEPTION(prop, tr("Empty signal assignment")); - - prop->values.first()->signalExpressionContextStack = ctxt.stack; - } - } - - return true; -} - - -/*! - Returns true if (value) property \a prop exists on obj, false otherwise. -*/ -bool QDeclarativeCompiler::doesPropertyExist(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj) -{ - if (prop->name().isEmpty()) - return false; - if(isAttachedPropertyName(prop->name()) || prop->name() == id_string) - return true; - - return property(obj, prop->name()) != 0; -} - -bool QDeclarativeCompiler::buildProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const BindingContext &ctxt) -{ - if (prop->isEmpty()) - COMPILE_EXCEPTION(prop, tr("Empty property assignment")); - - const QMetaObject *metaObject = obj->metaObject(); - Q_ASSERT(metaObject); - - if (isAttachedPropertyName(prop->name())) { - // Setup attached property data - - if (ctxt.isSubContext()) { - // Attached properties cannot be used on sub-objects. Sub-objects - // always exist in a binding sub-context, which is what we test - // for here. - COMPILE_EXCEPTION(prop, tr("Attached properties cannot be used here")); - } - - QDeclarativeType *type = 0; - QDeclarativeImportedNamespace *typeNamespace = 0; - unit->imports().resolveType(prop->name().toString(), &type, 0, 0, 0, &typeNamespace); - - if (typeNamespace) { - COMPILE_CHECK(buildPropertyInNamespace(typeNamespace, prop, obj, - ctxt)); - return true; - } else if (!type || !type->attachedPropertiesType()) { - COMPILE_EXCEPTION(prop, tr("Non-existent attached object")); - } - - if (!prop->value) - COMPILE_EXCEPTION(prop, tr("Invalid attached object assignment")); - - Q_ASSERT(type->attachedPropertiesFunction()); - prop->index = type->attachedPropertiesId(); - prop->value->metatype = type->attachedPropertiesType(); - } else { - // Setup regular property data - bool notInRevision = false; - QDeclarativePropertyData *d = - prop->name().isEmpty()?0:property(obj, prop->name(), ¬InRevision); - - if (d == 0 && notInRevision) { - const QList &resolvedTypes = unit->resolvedTypes(); - const QDeclarativeTypeData::TypeReference &type = resolvedTypes.at(obj->type); - if (type.type) { - COMPILE_EXCEPTION(prop, tr("\"%1.%2\" is not available in %3 %4.%5.").arg(elementName(obj)).arg(prop->name().toString()).arg(type.type->module()).arg(type.majorVersion).arg(type.minorVersion)); - } else { - COMPILE_EXCEPTION(prop, tr("\"%1.%2\" is not available due to component versioning.").arg(elementName(obj)).arg(prop->name().toString())); - } - } else if (d) { - prop->index = d->coreIndex; - prop->core = *d; - } else if (prop->isDefault) { - QMetaProperty p = QDeclarativeMetaType::defaultProperty(metaObject); - QDeclarativePropertyData defaultPropertyData; - defaultPropertyData.load(p, engine); - if (p.name()) - prop->setName(QLatin1String(p.name())); - prop->core = defaultPropertyData; - prop->index = prop->core.coreIndex; - } - - // We can't error here as the "id" property does not require a - // successful index resolution - if (prop->index != -1) - prop->type = prop->core.propType; - - // Check if this is an alias - if (prop->index != -1 && - prop->parent && - prop->parent->type != -1 && - output->types.at(prop->parent->type).component) { - - QDeclarativePropertyCache *cache = output->types.at(prop->parent->type).component->rootPropertyCache; - if (cache && cache->property(prop->index) && cache->property(prop->index)->isAlias()) - prop->isAlias = true; - } - - if (prop->index != -1 && !prop->values.isEmpty()) - prop->parent->setBindingBit(prop->index); - } - - if (!prop->isDefault && prop->name() == id_string && !ctxt.isSubContext()) { - - // The magic "id" behavior doesn't apply when "id" is resolved as a - // default property or to sub-objects (which are always in binding - // sub-contexts) - COMPILE_CHECK(buildIdProperty(prop, obj)); - if (prop->type == QVariant::String && - prop->values.first()->value.isString()) - COMPILE_CHECK(buildPropertyAssignment(prop, obj, ctxt)); - - } else if (isAttachedPropertyName(prop->name())) { - - COMPILE_CHECK(buildAttachedProperty(prop, obj, ctxt)); - - } else if (prop->index == -1) { - - if (prop->isDefault) { - COMPILE_EXCEPTION(prop->values.first(), tr("Cannot assign to non-existent default property")); - } else { - COMPILE_EXCEPTION(prop, tr("Cannot assign to non-existent property \"%1\"").arg(prop->name().toString())); - } - - } else if (prop->value) { - - COMPILE_CHECK(buildGroupedProperty(prop, obj, ctxt)); - - } else if (prop->core.isQList()) { - - COMPILE_CHECK(buildListProperty(prop, obj, ctxt)); - - } else if (prop->type == qMetaTypeId()) { - - COMPILE_CHECK(buildScriptStringProperty(prop, obj, ctxt)); - - } else { - - COMPILE_CHECK(buildPropertyAssignment(prop, obj, ctxt)); - - } - - return true; -} - -bool QDeclarativeCompiler::buildPropertyInNamespace(QDeclarativeImportedNamespace *ns, - QDeclarativeScript::Property *nsProp, - QDeclarativeScript::Object *obj, - const BindingContext &ctxt) -{ - if (!nsProp->value) - COMPILE_EXCEPTION(nsProp, tr("Invalid use of namespace")); - - for (Property *prop = nsProp->value->properties.first(); prop; prop = nsProp->value->properties.next(prop)) { - - if (!isAttachedPropertyName(prop->name())) - COMPILE_EXCEPTION(prop, tr("Not an attached property name")); - - // Setup attached property data - - QDeclarativeType *type = 0; - unit->imports().resolveType(ns, prop->name().toString(), &type, 0, 0, 0); - - if (!type || !type->attachedPropertiesType()) - COMPILE_EXCEPTION(prop, tr("Non-existent attached object")); - - if (!prop->value) - COMPILE_EXCEPTION(prop, tr("Invalid attached object assignment")); - - Q_ASSERT(type->attachedPropertiesFunction()); - prop->index = type->index(); - prop->value->metatype = type->attachedPropertiesType(); - - COMPILE_CHECK(buildAttachedProperty(prop, obj, ctxt)); - } - - return true; -} - -void QDeclarativeCompiler::genValueProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj) -{ - if (prop->core.isQList()) { - genListProperty(prop, obj); - } else { - genPropertyAssignment(prop, obj); - } -} - -void QDeclarativeCompiler::genListProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj) -{ - int listType = enginePrivate->listType(prop->type); - - Instruction::FetchQList fetch; - fetch.property = prop->index; - bool listTypeIsInterface = QDeclarativeMetaType::isInterface(listType); - fetch.type = listType; - output->addInstruction(fetch); - - for (Value *v = prop->values.first(); v; v = Property::ValueList::next(v)) { - - if (v->type == Value::CreatedObject) { - - genObject(v->object); - if (listTypeIsInterface) { - Instruction::AssignObjectList assign; - assign.line = prop->location.start.line; - output->addInstruction(assign); - } else { - Instruction::StoreObjectQList store; - output->addInstruction(store); - } - - } else if (v->type == Value::PropertyBinding) { - - genBindingAssignment(v, prop, obj); - - } - - } - - Instruction::PopQList pop; - output->addInstruction(pop); -} - -void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Property *valueTypeProperty) -{ - for (Value *v = prop->values.first(); v; v = Property::ValueList::next(v)) { - - Q_ASSERT(v->type == Value::CreatedObject || - v->type == Value::PropertyBinding || - v->type == Value::Literal); - - if (v->type == Value::CreatedObject) { - - genObject(v->object); - - if (QDeclarativeMetaType::isInterface(prop->type)) { - - Instruction::StoreInterface store; - store.line = v->object->location.start.line; - store.propertyIndex = prop->index; - output->addInstruction(store); - - } else if (prop->type == QMetaType::QVariant) { - - if (prop->core.isVMEProperty()) { - Instruction::StoreVarObject store; - store.line = v->object->location.start.line; - store.propertyIndex = prop->index; - output->addInstruction(store); - } else { - Instruction::StoreVariantObject store; - store.line = v->object->location.start.line; - store.propertyIndex = prop->index; - output->addInstruction(store); - } - - - } else { - - Instruction::StoreObject store; - store.line = v->object->location.start.line; - store.propertyIndex = prop->index; - output->addInstruction(store); - - } - } else if (v->type == Value::PropertyBinding) { - - genBindingAssignment(v, prop, obj, valueTypeProperty); - - } else if (v->type == Value::Literal) { - - genLiteralAssignment(prop, v); - - } - - } - - for (Value *v = prop->onValues.first(); v; v = Property::ValueList::next(v)) { - - Q_ASSERT(v->type == Value::ValueSource || - v->type == Value::ValueInterceptor); - - if (v->type == Value::ValueSource) { - genObject(v->object); - - Instruction::StoreValueSource store; - if (valueTypeProperty) { - store.property = genValueTypeData(prop, valueTypeProperty); - store.owner = 1; - } else { - store.property = prop->core; - store.owner = 0; - } - QDeclarativeType *valueType = toQmlType(v->object); - store.castValue = valueType->propertyValueSourceCast(); - output->addInstruction(store); - - } else if (v->type == Value::ValueInterceptor) { - genObject(v->object); - - Instruction::StoreValueInterceptor store; - if (valueTypeProperty) { - store.property = genValueTypeData(prop, valueTypeProperty); - store.owner = 1; - } else { - store.property = prop->core; - store.owner = 0; - } - QDeclarativeType *valueType = toQmlType(v->object); - store.castValue = valueType->propertyValueInterceptorCast(); - output->addInstruction(store); - } - - } -} - -bool QDeclarativeCompiler::buildIdProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj) -{ - if (prop->value || - prop->values.isMany() || - prop->values.first()->object) - COMPILE_EXCEPTION(prop, tr("Invalid use of id property")); - - QDeclarativeScript::Value *idValue = prop->values.first(); - QString val = idValue->primitive(); - - COMPILE_CHECK(checkValidId(idValue, val)); - - if (compileState->ids.value(val)) - COMPILE_EXCEPTION(prop, tr("id is not unique")); - - prop->values.first()->type = Value::Id; - - obj->id = val; - addId(val, obj); - - return true; -} - -void QDeclarativeCompiler::addId(const QString &id, QDeclarativeScript::Object *obj) -{ - Q_UNUSED(id); - Q_ASSERT(!compileState->ids.value(id)); - Q_ASSERT(obj->id == id); - obj->idIndex = compileState->ids.count(); - compileState->ids.append(obj); -} - -void QDeclarativeCompiler::addBindingReference(JSBindingReference *ref) -{ - Q_ASSERT(ref->value && !ref->value->bindingReference); - ref->value->bindingReference = ref; - compileState->totalBindingsCount++; - compileState->bindings.prepend(ref); -} - -void QDeclarativeCompiler::saveComponentState() -{ - Q_ASSERT(compileState->root); - Q_ASSERT(compileState->root->componentCompileState == 0); - - compileState->root->componentCompileState = compileState; - - if (componentStats) - componentStats->savedComponentStats.append(componentStats->componentStat); -} - -QDeclarativeCompilerTypes::ComponentCompileState * -QDeclarativeCompiler::componentState(QDeclarativeScript::Object *obj) -{ - Q_ASSERT(obj->componentCompileState); - return obj->componentCompileState; -} - -// Build attached property object. In this example, -// Text { -// GridView.row: 10 -// } -// GridView is an attached property object. -bool QDeclarativeCompiler::buildAttachedProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const BindingContext &ctxt) -{ - Q_ASSERT(prop->value); - Q_ASSERT(prop->index != -1); // This is set in buildProperty() - - compileState->objectDepth.push(); - - obj->addAttachedProperty(prop); - - COMPILE_CHECK(buildSubObject(prop->value, ctxt.incr())); - - compileState->objectDepth.pop(); - - return true; -} - - -// Build "grouped" properties. In this example: -// Text { -// font.pointSize: 12 -// font.family: "Helvetica" -// } -// font is a nested property. pointSize and family are not. -bool QDeclarativeCompiler::buildGroupedProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const BindingContext &ctxt) -{ - Q_ASSERT(prop->type != 0); - Q_ASSERT(prop->index != -1); - - if (QDeclarativeValueTypeFactory::isValueType(prop->type)) { - if (prop->type >= 0 && enginePrivate->valueTypes[prop->type]) { - - if (!prop->values.isEmpty()) { - if (prop->values.first()->location < prop->value->location) { - COMPILE_EXCEPTION(prop->value, tr( "Property has already been assigned a value")); - } else { - COMPILE_EXCEPTION(prop->values.first(), tr( "Property has already been assigned a value")); - } - } - - if (!prop->core.isWritable() && !prop->isReadOnlyDeclaration) { - COMPILE_EXCEPTION(prop, tr( "Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString())); - } - - - if (prop->isAlias) { - for (Property *vtProp = prop->value->properties.first(); vtProp; vtProp = prop->value->properties.next(vtProp)) { - vtProp->isAlias = true; - } - } - - COMPILE_CHECK(buildValueTypeProperty(enginePrivate->valueTypes[prop->type], - prop->value, obj, ctxt.incr())); - obj->addValueTypeProperty(prop); - } else { - COMPILE_EXCEPTION(prop, tr("Invalid grouped property access")); - } - - } else { - // Load the nested property's meta type - prop->value->metatype = enginePrivate->metaObjectForType(prop->type); - if (!prop->value->metatype) - COMPILE_EXCEPTION(prop, tr("Invalid grouped property access")); - - if (!prop->values.isEmpty()) - COMPILE_EXCEPTION(prop->values.first(), tr( "Cannot assign a value directly to a grouped property")); - - obj->addGroupedProperty(prop); - - compileState->objectDepth.push(); - - COMPILE_CHECK(buildSubObject(prop->value, ctxt.incr())); - - compileState->objectDepth.pop(); - } - - return true; -} - -bool QDeclarativeCompiler::buildValueTypeProperty(QObject *type, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Object *baseObj, - const BindingContext &ctxt) -{ - compileState->objectDepth.push(); - - if (obj->defaultProperty) - COMPILE_EXCEPTION(obj, tr("Invalid property use")); - obj->metatype = type->metaObject(); - - for (Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) { - - QDeclarativePropertyData *d = property(obj, prop->name()); - if (d == 0) - COMPILE_EXCEPTION(prop, tr("Cannot assign to non-existent property \"%1\"").arg(prop->name().toString())); - - prop->index = d->coreIndex; - prop->type = d->propType; - prop->core = *d; - prop->isValueTypeSubProperty = true; - - if (prop->value) - COMPILE_EXCEPTION(prop, tr("Property assignment expected")); - - if (prop->values.isMany()) { - COMPILE_EXCEPTION(prop, tr("Single property assignment expected")); - } else if (!prop->values.isEmpty()) { - QDeclarativeScript::Value *value = prop->values.first(); - - if (value->object) { - COMPILE_EXCEPTION(prop, tr("Unexpected object assignment")); - } else if (value->value.isScript()) { - // ### Check for writability - - //optimization for . enum assignments - bool isEnumAssignment = false; - - if (prop->core.isEnum()) - COMPILE_CHECK(testQualifiedEnumAssignment(prop, obj, value, &isEnumAssignment)); - - if (isEnumAssignment) { - value->type = Value::Literal; - } else { - JSBindingReference *reference = pool->New(); - reference->expression = value->value; - reference->property = prop; - reference->value = value; - reference->bindingContext = ctxt; - reference->bindingContext.owner++; - addBindingReference(reference); - value->type = Value::PropertyBinding; - } - } else { - COMPILE_CHECK(testLiteralAssignment(prop, value)); - value->type = Value::Literal; - } - } - - for (Value *v = prop->onValues.first(); v; v = Property::ValueList::next(v)) { - Q_ASSERT(v->object); - - COMPILE_CHECK(buildPropertyOnAssignment(prop, obj, baseObj, v, ctxt)); - } - - obj->addValueProperty(prop); - } - - compileState->objectDepth.pop(); - - return true; -} - -// Build assignments to QML lists. QML lists are properties of type -// QDeclarativeListProperty. List properties can accept a list of -// objects, or a single binding. -bool QDeclarativeCompiler::buildListProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const BindingContext &ctxt) -{ - Q_ASSERT(prop->core.isQList()); - - compileState->listDepth.push(); - - int t = prop->type; - - obj->addValueProperty(prop); - - int listType = enginePrivate->listType(t); - bool listTypeIsInterface = QDeclarativeMetaType::isInterface(listType); - - bool assignedBinding = false; - for (Value *v = prop->values.first(); v; v = Property::ValueList::next(v)) { - if (v->object) { - v->type = Value::CreatedObject; - COMPILE_CHECK(buildObject(v->object, ctxt)); - - // We check object coercian here. We check interface assignment - // at runtime. - if (!listTypeIsInterface) { - if (!canCoerce(listType, v->object)) { - COMPILE_EXCEPTION(v, tr("Cannot assign object to list")); - } - } - - } else if (v->value.isScript()) { - if (assignedBinding) - COMPILE_EXCEPTION(v, tr("Can only assign one binding to lists")); - - assignedBinding = true; - COMPILE_CHECK(buildBinding(v, prop, ctxt)); - v->type = Value::PropertyBinding; - } else { - COMPILE_EXCEPTION(v, tr("Cannot assign primitives to lists")); - } - } - - compileState->listDepth.pop(); - - return true; -} - -// Compiles an assignment to a QDeclarativeScriptString property -bool QDeclarativeCompiler::buildScriptStringProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const BindingContext &ctxt) -{ - if (prop->values.isMany()) - COMPILE_EXCEPTION(prop->values.first()->nextValue, tr( "Cannot assign multiple values to a script property")); - - if (prop->values.first()->object) - COMPILE_EXCEPTION(prop->values.first(), tr( "Invalid property assignment: script expected")); - - prop->scriptStringScope = ctxt.stack; - obj->addScriptStringProperty(prop); - - return true; -} - -// Compile regular property assignments of the form "property: " -bool QDeclarativeCompiler::buildPropertyAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const BindingContext &ctxt) -{ - obj->addValueProperty(prop); - - if (prop->values.isMany()) - COMPILE_EXCEPTION(prop->values.first(), tr( "Cannot assign multiple values to a singular property") ); - - for (Value *v = prop->values.first(); v; v = Property::ValueList::next(v)) { - if (v->object) { - - COMPILE_CHECK(buildPropertyObjectAssignment(prop, obj, v, ctxt)); - - } else { - - COMPILE_CHECK(buildPropertyLiteralAssignment(prop, obj, v, ctxt)); - - } - } - - for (Value *v = prop->onValues.first(); v; v = Property::ValueList::next(v)) { - Q_ASSERT(v->object); - COMPILE_CHECK(buildPropertyOnAssignment(prop, obj, obj, v, ctxt)); - } - - return true; -} - -// Compile assigning a single object instance to a regular property -bool QDeclarativeCompiler::buildPropertyObjectAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Value *v, - const BindingContext &ctxt) -{ - Q_ASSERT(prop->index != -1); - Q_ASSERT(v->object->type != -1); - - if (!prop->core.isWritable() && !prop->isReadOnlyDeclaration) - COMPILE_EXCEPTION(v, tr("Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString())); - - if (QDeclarativeMetaType::isInterface(prop->type)) { - - // Assigning an object to an interface ptr property - COMPILE_CHECK(buildObject(v->object, ctxt)); - - v->type = Value::CreatedObject; - - } else if (prop->type == QMetaType::QVariant) { - - // Assigning an object to a QVariant - COMPILE_CHECK(buildObject(v->object, ctxt)); - - v->type = Value::CreatedObject; - } else { - // Normally buildObject() will set this up, but we need the static - // meta object earlier to test for assignability. It doesn't matter - // that there may still be outstanding synthesized meta object changes - // on this type, as they are not relevant for assignability testing - v->object->metatype = output->types.at(v->object->type).metaObject(); - Q_ASSERT(v->object->metaObject()); - - // We want to raw metaObject here as the raw metaobject is the - // actual property type before we applied any extensions that might - // effect the properties on the type, but don't effect assignability - const QMetaObject *propertyMetaObject = enginePrivate->rawMetaObjectForType(prop->type); - - // Will be true if the assgned type inherits propertyMetaObject - bool isAssignable = false; - // Determine isAssignable value - if (propertyMetaObject) { - const QMetaObject *c = v->object->metatype; - while(c) { - isAssignable |= (QDeclarativePropertyPrivate::equal(c, propertyMetaObject)); - c = c->superClass(); - } - } - - if (isAssignable) { - // Simple assignment - COMPILE_CHECK(buildObject(v->object, ctxt)); - - v->type = Value::CreatedObject; - } else if (propertyMetaObject == &QDeclarativeComponent::staticMetaObject) { - // Automatic "Component" insertion - QDeclarativeScript::Object *root = v->object; - QDeclarativeScript::Object *component = pool->New(); - component->type = componentTypeRef(); - component->typeName = QStringLiteral("Qt/Component"); - component->metatype = &QDeclarativeComponent::staticMetaObject; - component->location = root->location; - QDeclarativeScript::Value *componentValue = pool->New(); - componentValue->object = root; - component->getDefaultProperty()->addValue(componentValue); - v->object = component; - COMPILE_CHECK(buildPropertyObjectAssignment(prop, obj, v, ctxt)); - } else { - COMPILE_EXCEPTION(v->object, tr("Cannot assign object to property")); - } - } - - return true; -} - -// Compile assigning a single object instance to a regular property using the "on" syntax. -// -// For example: -// Item { -// NumberAnimation on x { } -// } -bool QDeclarativeCompiler::buildPropertyOnAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Object *baseObj, - QDeclarativeScript::Value *v, - const BindingContext &ctxt) -{ - Q_ASSERT(prop->index != -1); - Q_ASSERT(v->object->type != -1); - - Q_UNUSED(obj); - - if (!prop->core.isWritable()) - COMPILE_EXCEPTION(v, tr("Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString())); - - - // Normally buildObject() will set this up, but we need the static - // meta object earlier to test for assignability. It doesn't matter - // that there may still be outstanding synthesized meta object changes - // on this type, as they are not relevant for assignability testing - v->object->metatype = output->types.at(v->object->type).metaObject(); - Q_ASSERT(v->object->metaObject()); - - // Will be true if the assigned type inherits QDeclarativePropertyValueSource - bool isPropertyValue = false; - // Will be true if the assigned type inherits QDeclarativePropertyValueInterceptor - bool isPropertyInterceptor = false; - if (QDeclarativeType *valueType = toQmlType(v->object)) { - isPropertyValue = valueType->propertyValueSourceCast() != -1; - isPropertyInterceptor = valueType->propertyValueInterceptorCast() != -1; - } - - if (isPropertyValue || isPropertyInterceptor) { - // Assign as a property value source - COMPILE_CHECK(buildObject(v->object, ctxt)); - - if (isPropertyInterceptor && prop->parent->synthdata.isEmpty()) - buildDynamicMeta(baseObj, ForceCreation); - v->type = isPropertyValue ? Value::ValueSource : Value::ValueInterceptor; - } else { - COMPILE_EXCEPTION(v, tr("\"%1\" cannot operate on \"%2\"").arg(v->object->typeName).arg(prop->name().toString())); - } - - return true; -} - -// Compile assigning a literal or binding to a regular property -bool QDeclarativeCompiler::buildPropertyLiteralAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Value *v, - const BindingContext &ctxt) -{ - Q_ASSERT(prop->index != -1); - - if (v->value.isScript()) { - - //optimization for . enum assignments - if (prop->core.isEnum()) { - bool isEnumAssignment = false; - COMPILE_CHECK(testQualifiedEnumAssignment(prop, obj, v, &isEnumAssignment)); - if (isEnumAssignment) { - v->type = Value::Literal; - return true; - } - } - - // Test for other binding optimizations - if (!buildLiteralBinding(v, prop, ctxt)) - COMPILE_CHECK(buildBinding(v, prop, ctxt)); - - v->type = Value::PropertyBinding; - - } else { - - COMPILE_CHECK(testLiteralAssignment(prop, v)); - - v->type = Value::Literal; - } - - return true; -} - -bool QDeclarativeCompiler::testQualifiedEnumAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Value *v, - bool *isAssignment) -{ - *isAssignment = false; - if (!prop->core.isEnum()) - return true; - - QMetaProperty mprop = obj->metaObject()->property(prop->index); - - if (!prop->core.isWritable() && !prop->isReadOnlyDeclaration) - COMPILE_EXCEPTION(v, tr("Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString())); - - QString string = v->value.asString(); - if (!string.at(0).isUpper()) - return true; - - QStringList parts = string.split(QLatin1Char('.')); - if (parts.count() != 2) - return true; - - QString typeName = parts.at(0); - QDeclarativeType *type = 0; - unit->imports().resolveType(typeName, &type, 0, 0, 0, 0); - - //handle enums on value types (where obj->typeName is empty) - QString objTypeName = obj->typeName; - if (objTypeName.isEmpty()) { - QDeclarativeType *objType = toQmlType(obj); - if (objType) - objTypeName = objType->qmlTypeName(); - } - - if (!type) - return true; - - QString enumValue = parts.at(1); - int value; - bool ok; - - if (objTypeName == type->qmlTypeName()) { - // When these two match, we can short cut the search - if (mprop.isFlagType()) { - value = mprop.enumerator().keysToValue(enumValue.toUtf8().constData(), &ok); - } else { - value = mprop.enumerator().keyToValue(enumValue.toUtf8().constData(), &ok); - } - } else { - // Otherwise we have to search the whole type - // This matches the logic in QV8TypeWrapper - QByteArray enumName = enumValue.toUtf8(); - const QMetaObject *metaObject = type->baseMetaObject(); - ok = false; - for (int ii = metaObject->enumeratorCount() - 1; !ok && ii >= 0; --ii) { - QMetaEnum e = metaObject->enumerator(ii); - value = e.keyToValue(enumName.constData(), &ok); - } - } - - if (!ok) - return true; - - v->type = Value::Literal; - v->value = QDeclarativeScript::Variant((double)value); - *isAssignment = true; - - return true; -} - -struct StaticQtMetaObject : public QObject -{ - static const QMetaObject *get() - { return &static_cast (0)->staticQtMetaObject; } -}; - -// Similar logic to above, but not knowing target property. -int QDeclarativeCompiler::evaluateEnum(const QByteArray& script) const -{ - int dot = script.indexOf('.'); - if (dot > 0) { - const QByteArray &scope = script.left(dot); - QDeclarativeType *type = 0; - unit->imports().resolveType(QString::fromUtf8(script.left(dot)), &type, 0, 0, 0, 0); - if (!type && scope != "Qt") - return -1; - const QMetaObject *mo = type ? type->metaObject() : StaticQtMetaObject::get(); - const char *key = script.constData() + dot+1; - int i = mo->enumeratorCount(); - while (i--) { - bool ok; - int v = mo->enumerator(i).keyToValue(key, &ok); - if (ok) - return v; - } - } - return -1; -} - -const QMetaObject *QDeclarativeCompiler::resolveType(const QString& name) const -{ - QDeclarativeType *qmltype = 0; - if (!unit->imports().resolveType(name, &qmltype, 0, 0, 0, 0)) - return 0; - if (!qmltype) - return 0; - return qmltype->metaObject(); -} - -// similar to logic of completeComponentBuild, but also sticks data -// into primitives at the end -int QDeclarativeCompiler::rewriteBinding(const QDeclarativeScript::Variant& value, const QString& name) -{ - QDeclarativeRewrite::RewriteBinding rewriteBinding; - rewriteBinding.setName(QLatin1Char('$') + name.mid(name.lastIndexOf(QLatin1Char('.')) + 1)); - - QString rewrite = rewriteBinding(value.asAST(), value.asScript(), 0); - - return output->indexForString(rewrite); -} - -QString QDeclarativeCompiler::rewriteSignalHandler(const QDeclarativeScript::Variant& value, const QString &name) -{ - QDeclarativeRewrite::RewriteSignalHandler rewriteSignalHandler; - return rewriteSignalHandler(value.asAST(), value.asScript(), name); -} - -// Ensures that the dynamic meta specification on obj is valid -bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeScript::Object *obj) -{ - bool seenDefaultProperty = false; - - // We use a coarse grain, 31 bit hash to check if there are duplicates. - // Calculating the hash for the names is not a waste as we have to test - // them against the illegalNames set anyway. - QHashField propNames; - QHashField methodNames; - - // Check properties - for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) { - const QDeclarativeScript::Object::DynamicProperty &prop = *p; - - if (prop.isDefaultProperty) { - if (seenDefaultProperty) - COMPILE_EXCEPTION(&prop, tr("Duplicate default property")); - seenDefaultProperty = true; - } - - if (propNames.testAndSet(prop.name.hash())) { - for (Object::DynamicProperty *p2 = obj->dynamicProperties.first(); p2 != p; - p2 = obj->dynamicProperties.next(p2)) { - if (p2->name == prop.name) { - COMPILE_EXCEPTION_LOCATION(prop.nameLocation.line, - prop.nameLocation.column, - tr("Duplicate property name")); - } - } - } - - if (prop.name.at(0).isUpper()) { - COMPILE_EXCEPTION_LOCATION(prop.nameLocation.line, - prop.nameLocation.column, - tr("Property names cannot begin with an upper case letter")); - } - - if (enginePrivate->v8engine()->illegalNames().contains(prop.name)) { - COMPILE_EXCEPTION_LOCATION(prop.nameLocation.line, - prop.nameLocation.column, - tr("Illegal property name")); - } - } - - for (Object::DynamicSignal *s = obj->dynamicSignals.first(); s; s = obj->dynamicSignals.next(s)) { - const QDeclarativeScript::Object::DynamicSignal &currSig = *s; - - if (methodNames.testAndSet(currSig.name.hash())) { - for (Object::DynamicSignal *s2 = obj->dynamicSignals.first(); s2 != s; - s2 = obj->dynamicSignals.next(s2)) { - if (s2->name == currSig.name) - COMPILE_EXCEPTION(&currSig, tr("Duplicate signal name")); - } - } - - if (currSig.name.at(0).isUpper()) - COMPILE_EXCEPTION(&currSig, tr("Signal names cannot begin with an upper case letter")); - if (enginePrivate->v8engine()->illegalNames().contains(currSig.name)) - COMPILE_EXCEPTION(&currSig, tr("Illegal signal name")); - } - - for (Object::DynamicSlot *s = obj->dynamicSlots.first(); s; s = obj->dynamicSlots.next(s)) { - const QDeclarativeScript::Object::DynamicSlot &currSlot = *s; - - if (methodNames.testAndSet(currSlot.name.hash())) { - for (Object::DynamicSignal *s2 = obj->dynamicSignals.first(); s2; - s2 = obj->dynamicSignals.next(s2)) { - if (s2->name == currSlot.name) - COMPILE_EXCEPTION(&currSlot, tr("Duplicate method name")); - } - for (Object::DynamicSlot *s2 = obj->dynamicSlots.first(); s2 != s; - s2 = obj->dynamicSlots.next(s2)) { - if (s2->name == currSlot.name) - COMPILE_EXCEPTION(&currSlot, tr("Duplicate method name")); - } - } - - if (currSlot.name.at(0).isUpper()) - COMPILE_EXCEPTION(&currSlot, tr("Method names cannot begin with an upper case letter")); - if (enginePrivate->v8engine()->illegalNames().contains(currSlot.name)) - COMPILE_EXCEPTION(&currSlot, tr("Illegal method name")); - } - - return true; -} - -bool QDeclarativeCompiler::mergeDynamicMetaProperties(QDeclarativeScript::Object *obj) -{ - for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; - p = obj->dynamicProperties.next(p)) { - - if (!p->defaultValue || p->type == Object::DynamicProperty::Alias) - continue; - - Property *property = 0; - if (p->isDefaultProperty) { - property = obj->getDefaultProperty(); - } else { - property = obj->getProperty(p->name); - if (!property->values.isEmpty()) - COMPILE_EXCEPTION(property, tr("Property value set multiple times")); - } - - if (p->isReadOnly) - property->isReadOnlyDeclaration = true; - - if (property->value) - COMPILE_EXCEPTION(property, tr("Invalid property nesting")); - - property->values.append(p->defaultValue->values); - } - return true; -} - -Q_GLOBAL_STATIC(QAtomicInt, classIndexCounter) - -bool QDeclarativeCompiler::buildDynamicMeta(QDeclarativeScript::Object *obj, DynamicMetaMode mode) -{ - Q_ASSERT(obj); - Q_ASSERT(obj->metatype); - - if (mode != ForceCreation && - obj->dynamicProperties.isEmpty() && - obj->dynamicSignals.isEmpty() && - obj->dynamicSlots.isEmpty()) - return true; - - bool resolveAlias = (mode == ResolveAliases); - - const Object::DynamicProperty *defaultProperty = 0; - int aliasCount = 0; - int varPropCount = 0; - int totalPropCount = 0; - int firstPropertyVarIndex = 0; - - for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) { - - if (p->type == Object::DynamicProperty::Alias) - aliasCount++; - if (p->type == Object::DynamicProperty::Var) - varPropCount++; - - if (p->isDefaultProperty && - (resolveAlias || p->type != Object::DynamicProperty::Alias)) - defaultProperty = p; - - if (!resolveAlias) { - // No point doing this for both the alias and non alias cases - QDeclarativePropertyData *d = property(obj, p->name); - if (d && d->isFinal()) - COMPILE_EXCEPTION(p, tr("Cannot override FINAL property")); - } - } - - bool buildData = resolveAlias || aliasCount == 0; - - QByteArray dynamicData; - if (buildData) { - typedef QDeclarativeVMEMetaData VMD; - - dynamicData = QByteArray(sizeof(QDeclarativeVMEMetaData) + - (obj->dynamicProperties.count() - aliasCount) * sizeof(VMD::PropertyData) + - obj->dynamicSlots.count() * sizeof(VMD::MethodData) + - aliasCount * sizeof(VMD::AliasData), 0); - } - - int uniqueClassId = classIndexCounter()->fetchAndAddRelaxed(1); - - QByteArray newClassName = obj->metatype->className(); - newClassName.append("_QML_"); - newClassName.append(QByteArray::number(uniqueClassId)); - - if (compileState->root == obj && !compileState->nested) { - QString path = output->url.path(); - int lastSlash = path.lastIndexOf(QLatin1Char('/')); - if (lastSlash > -1) { - QString nameBase = path.mid(lastSlash + 1, path.length()-lastSlash-5); - if (!nameBase.isEmpty() && nameBase.at(0).isUpper()) - newClassName = nameBase.toUtf8() + "_QMLTYPE_" + QByteArray::number(uniqueClassId); - } - } - - QFastMetaBuilder builder; - QFastMetaBuilder::StringRef classNameRef = builder.init(newClassName.length(), - obj->dynamicProperties.count() - (resolveAlias?0:aliasCount), - obj->dynamicSlots.count(), - obj->dynamicSignals.count() + obj->dynamicProperties.count(), - defaultProperty?1:0); - - struct TypeData { - Object::DynamicProperty::Type dtype; - int metaType; - const char *cppType; - } builtinTypes[] = { - { Object::DynamicProperty::Var, QMetaType::QVariant, "QVariant" }, - { Object::DynamicProperty::Variant, QMetaType::QVariant, "QVariant" }, - { Object::DynamicProperty::Int, QMetaType::Int, "int" }, - { Object::DynamicProperty::Bool, QMetaType::Bool, "bool" }, - { Object::DynamicProperty::Real, QMetaType::Double, "double" }, - { Object::DynamicProperty::String, QMetaType::QString, "QString" }, - { Object::DynamicProperty::Url, QMetaType::QUrl, "QUrl" }, - { Object::DynamicProperty::Color, QMetaType::QColor, "QColor" }, - { Object::DynamicProperty::Time, QMetaType::QTime, "QTime" }, - { Object::DynamicProperty::Date, QMetaType::QDate, "QDate" }, - { Object::DynamicProperty::DateTime, QMetaType::QDateTime, "QDateTime" }, - }; - static const int builtinTypeCount = sizeof(builtinTypes) / sizeof(TypeData); - QFastMetaBuilder::StringRef typeRefs[builtinTypeCount]; - - // Reserve dynamic properties - if (obj->dynamicProperties.count()) { - typedef QDeclarativeVMEMetaData VMD; - - int effectivePropertyIndex = 0; - for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) { - - // Reserve space for name - p->nameRef = builder.newString(p->name.utf8length()); - - int propertyType = 0; - bool readonly = false; - QFastMetaBuilder::StringRef typeRef; - - if (p->type == Object::DynamicProperty::Alias) { - continue; - } else if (p->type < builtinTypeCount) { - Q_ASSERT(builtinTypes[p->type].dtype == p->type); - propertyType = builtinTypes[p->type].metaType; - if (typeRefs[p->type].isEmpty()) - typeRefs[p->type] = builder.newString(strlen(builtinTypes[p->type].cppType)); - typeRef = typeRefs[p->type]; - - } else { - Q_ASSERT(p->type == Object::DynamicProperty::CustomList || - p->type == Object::DynamicProperty::Custom); - - // XXX don't double resolve this in the case of an alias run - - QByteArray customTypeName; - QDeclarativeType *qmltype = 0; - QString url; - if (!unit->imports().resolveType(p->customType.toString(), &qmltype, &url, 0, 0, 0)) - COMPILE_EXCEPTION(p, tr("Invalid property type")); - - if (!qmltype) { - QDeclarativeTypeData *tdata = enginePrivate->typeLoader.get(QUrl(url)); - Q_ASSERT(tdata); - Q_ASSERT(tdata->isComplete()); - - QDeclarativeCompiledData *data = tdata->compiledData(); - customTypeName = data->root->className(); - data->release(); - tdata->release(); - } else { - customTypeName = qmltype->typeName(); - } - - if (p->type == Object::DynamicProperty::Custom) { - customTypeName += '*'; - propertyType = QMetaType::QObjectStar; - } else { - readonly = true; - customTypeName = QByteArray("QDeclarativeListProperty<") + customTypeName + QByteArray(">"); - propertyType = qMetaTypeId >(); - } - - p->resolvedCustomTypeName = pool->NewByteArray(customTypeName); - p->typeRef = builder.newString(customTypeName.length()); - typeRef = p->typeRef; - } - - if (p->type == Object::DynamicProperty::Var) - continue; - - if (p->isReadOnly) - readonly = true; - - if (buildData) { - VMD *vmd = (QDeclarativeVMEMetaData *)dynamicData.data(); - vmd->propertyCount++; - (vmd->propertyData() + effectivePropertyIndex)->propertyType = propertyType; - } - - if (p->type < builtinTypeCount) - builder.setProperty(effectivePropertyIndex, p->nameRef, typeRef, (QMetaType::Type)propertyType, - readonly?QFastMetaBuilder::None:QFastMetaBuilder::Writable, - effectivePropertyIndex); - else - builder.setProperty(effectivePropertyIndex, p->nameRef, typeRef, - readonly?QFastMetaBuilder::None:QFastMetaBuilder::Writable, - effectivePropertyIndex); - - p->changedSignatureRef = builder.newString(p->name.utf8length() + strlen("Changed()")); - builder.setSignal(effectivePropertyIndex, p->changedSignatureRef); - - effectivePropertyIndex++; - } - - if (varPropCount) { - VMD *vmd = (QDeclarativeVMEMetaData *)dynamicData.data(); - if (buildData) - vmd->varPropertyCount = varPropCount; - firstPropertyVarIndex = effectivePropertyIndex; - totalPropCount = varPropCount + effectivePropertyIndex; - for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) { - if (p->type == Object::DynamicProperty::Var) { - QFastMetaBuilder::StringRef typeRef = typeRefs[p->type]; - if (buildData) { - vmd->propertyCount++; - (vmd->propertyData() + effectivePropertyIndex)->propertyType = QMetaType::QVariant; - } - - builder.setProperty(effectivePropertyIndex, p->nameRef, typeRef, - QMetaType::QVariant, - p->isReadOnly?QFastMetaBuilder::None:QFastMetaBuilder::Writable, - effectivePropertyIndex); - - p->changedSignatureRef = builder.newString(p->name.utf8length() + strlen("Changed()")); - builder.setSignal(effectivePropertyIndex, p->changedSignatureRef); - - effectivePropertyIndex++; - } - } - } - - if (aliasCount) { - int aliasIndex = 0; - for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) { - if (p->type == Object::DynamicProperty::Alias) { - if (resolveAlias) { - Q_ASSERT(buildData); - ((QDeclarativeVMEMetaData *)dynamicData.data())->aliasCount++; - COMPILE_CHECK(compileAlias(builder, dynamicData, obj, effectivePropertyIndex, - aliasIndex, *p)); - } - // Even if we aren't resolving the alias, we need a fake signal so that the - // metaobject remains consistent across the resolve and non-resolve alias runs - p->changedSignatureRef = builder.newString(p->name.utf8length() + strlen("Changed()")); - builder.setSignal(effectivePropertyIndex, p->changedSignatureRef); - effectivePropertyIndex++; - aliasIndex++; - } - } - } - } - - // Reserve default property - QFastMetaBuilder::StringRef defPropRef; - if (defaultProperty) { - defPropRef = builder.newString(strlen("DefaultProperty")); - builder.setClassInfo(0, defPropRef, defaultProperty->nameRef); - } - - // Reserve dynamic signals - int signalIndex = 0; - for (Object::DynamicSignal *s = obj->dynamicSignals.first(); s; s = obj->dynamicSignals.next(s)) { - - int paramCount = s->parameterNames.count(); - - int signatureSize = s->name.utf8length() + 2 /* paren */; - int namesSize = 0; - if (paramCount) signatureSize += s->parameterTypesLength() + (paramCount - 1) /* commas */; - if (paramCount) namesSize += s->parameterNamesLength() + (paramCount - 1) /* commas */; - - s->signatureRef = builder.newString(signatureSize); - if (namesSize) s->parameterNamesRef = builder.newString(namesSize); - - if (buildData) - ((QDeclarativeVMEMetaData *)dynamicData.data())->signalCount++; - - builder.setSignal(signalIndex + obj->dynamicProperties.count(), s->signatureRef, s->parameterNamesRef); - ++signalIndex; - } - - // Reserve dynamic slots - if (obj->dynamicSlots.count()) { - - // Allocate QVariant string - if (typeRefs[0].isEmpty()) - typeRefs[0] = builder.newString(strlen(builtinTypes[0].cppType)); - - typedef QDeclarativeVMEMetaData VMD; - - int methodIndex = 0; - for (Object::DynamicSlot *s = obj->dynamicSlots.first(); s; s = obj->dynamicSlots.next(s)) { - int paramCount = s->parameterNames.count(); - - int signatureSize = s->name.utf8length() + 2 /* paren */; - int namesSize = 0; - if (paramCount) signatureSize += (paramCount * strlen("QVariant") + (paramCount - 1)); - if (paramCount) namesSize += s->parameterNamesLength() + (paramCount - 1 /* commas */); - - s->signatureRef = builder.newString(signatureSize); - if (namesSize) s->parameterNamesRef = builder.newString(namesSize); - - builder.setMethod(methodIndex, s->signatureRef, s->parameterNamesRef, typeRefs[0]); - - if (buildData) { - QString funcScript; - funcScript.reserve(strlen("(function ") + s->name.length() + 1 /* lparen */ + - namesSize + 1 /* rparen */ + s->body.length() + 1 /* rparen */); - funcScript = QLatin1String("(function ") + s->name.toString() + QLatin1Char('('); - for (int jj = 0; jj < paramCount; ++jj) { - if (jj) funcScript.append(QLatin1Char(',')); - funcScript.append(QLatin1String(s->parameterNames.at(jj))); - } - funcScript += QLatin1Char(')') + s->body + QLatin1Char(')'); - - QByteArray utf8 = funcScript.toUtf8(); - VMD::MethodData methodData = { s->parameterNames.count(), 0, - utf8.length(), - s->location.start.line }; - - VMD *vmd = (QDeclarativeVMEMetaData *)dynamicData.data(); - vmd->methodCount++; - - VMD::MethodData &md = *(vmd->methodData() + methodIndex); - md = methodData; - md.bodyOffset = dynamicData.size(); - - dynamicData.append((const char *)utf8.constData(), utf8.length()); - } - - - methodIndex++; - } - } - - // Now allocate used builtin types - for (int ii = 0; ii < builtinTypeCount; ++ii) { - if (!typeRefs[ii].isEmpty()) - typeRefs[ii].load(builtinTypes[ii].cppType); - } - - // Now allocate properties - for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) { - - char *d = p->changedSignatureRef.data(); - p->name.writeUtf8(d); - strcpy(d + p->name.utf8length(), "Changed()"); - - if (p->type == Object::DynamicProperty::Alias && !resolveAlias) - continue; - - p->nameRef.load(p->name); - - if (p->type >= builtinTypeCount) { - Q_ASSERT(p->resolvedCustomTypeName); - p->typeRef.load(*p->resolvedCustomTypeName); - } - } - - // Allocate default property if necessary - if (defaultProperty) - strcpy(defPropRef.data(), "DefaultProperty"); - - // Now allocate signals - for (Object::DynamicSignal *s = obj->dynamicSignals.first(); s; s = obj->dynamicSignals.next(s)) { - - char *d = s->signatureRef.data(); - char *d2 = s->parameterNamesRef.isEmpty()?0:s->parameterNamesRef.data(); - s->name.writeUtf8(d); d += s->name.utf8length(); - *d++ = '('; - - for (int jj = 0; jj < s->parameterNames.count(); ++jj) { - if (jj != 0) { *d++ = ','; *d2++ = ','; } - strcpy(d, s->parameterTypes.at(jj).constData()); - d += s->parameterTypes.at(jj).length(); - s->parameterNames.at(jj).writeUtf8(d2); - d2 += s->parameterNames.at(jj).utf8length(); - } - *d++ = ')'; - *d = 0; - if (d2) *d2 = 0; - } - - // Now allocate methods - for (Object::DynamicSlot *s = obj->dynamicSlots.first(); s; s = obj->dynamicSlots.next(s)) { - char *d = s->signatureRef.data(); - char *d2 = s->parameterNamesRef.isEmpty()?0:s->parameterNamesRef.data(); - s->name.writeUtf8(d); d += s->name.utf8length(); - *d++ = '('; - for (int jj = 0; jj < s->parameterNames.count(); ++jj) { - if (jj != 0) { *d++ = ','; *d2++ = ','; } - strcpy(d, "QVariant"); - d += strlen("QVariant"); - strcpy(d2, s->parameterNames.at(jj).constData()); - d2 += s->parameterNames.at(jj).length(); - } - *d++ = ')'; - *d = 0; - if (d2) *d2 = 0; - } - - // Now allocate class name - classNameRef.load(newClassName); - - obj->metadata = builder.toData(); - builder.fromData(&obj->extObject, obj->metatype, obj->metadata); - - if (mode == IgnoreAliases && aliasCount) - compileState->aliasingObjects.append(obj); - - obj->synthdata = dynamicData; - - if (obj->synthCache) { - obj->synthCache->release(); - obj->synthCache = 0; - } - - if (obj->type != -1) { - QDeclarativePropertyCache *superCache = output->types[obj->type].createPropertyCache(engine); - QDeclarativePropertyCache *cache = - superCache->copyAndAppend(engine, &obj->extObject, - QDeclarativePropertyData::NoFlags, - QDeclarativePropertyData::IsVMEFunction, - QDeclarativePropertyData::IsVMESignal); - - // now we modify the flags appropriately for var properties. - int propertyOffset = obj->extObject.propertyOffset(); - QDeclarativePropertyData *currPropData = 0; - for (int pvi = firstPropertyVarIndex; pvi < totalPropCount; ++pvi) { - currPropData = cache->property(pvi + propertyOffset); - currPropData->setFlags(currPropData->getFlags() | QDeclarativePropertyData::IsVMEProperty); - } - - obj->synthCache = cache; - } - - return true; -} - -bool QDeclarativeCompiler::checkValidId(QDeclarativeScript::Value *v, const QString &val) -{ - if (val.isEmpty()) - COMPILE_EXCEPTION(v, tr( "Invalid empty ID")); - - QChar ch = val.at(0); - if (ch.isLetter() && !ch.isLower()) - COMPILE_EXCEPTION(v, tr( "IDs cannot start with an uppercase letter")); - - QChar u(QLatin1Char('_')); - if (!ch.isLetter() && ch != u) - COMPILE_EXCEPTION(v, tr( "IDs must start with a letter or underscore")); - - for (int ii = 1; ii < val.count(); ++ii) { - ch = val.at(ii); - if (!ch.isLetterOrNumber() && ch != u) - COMPILE_EXCEPTION(v, tr( "IDs must contain only letters, numbers, and underscores")); - } - - if (enginePrivate->v8engine()->illegalNames().contains(val)) - COMPILE_EXCEPTION(v, tr( "ID illegally masks global JavaScript property")); - - return true; -} - -#include - -static QStringList astNodeToStringList(QDeclarativeJS::AST::Node *node) -{ - if (node->kind == QDeclarativeJS::AST::Node::Kind_IdentifierExpression) { - QString name = - static_cast(node)->name.toString(); - return QStringList() << name; - } else if (node->kind == QDeclarativeJS::AST::Node::Kind_FieldMemberExpression) { - QDeclarativeJS::AST::FieldMemberExpression *expr = static_cast(node); - - QStringList rv = astNodeToStringList(expr->base); - if (rv.isEmpty()) - return rv; - rv.append(expr->name.toString()); - return rv; - } - return QStringList(); -} - -bool QDeclarativeCompiler::compileAlias(QFastMetaBuilder &builder, - QByteArray &data, - QDeclarativeScript::Object *obj, - int propIndex, int aliasIndex, - Object::DynamicProperty &prop) -{ - if (!prop.defaultValue) - COMPILE_EXCEPTION(obj, tr("No property alias location")); - - if (!prop.defaultValue->values.isOne() || - prop.defaultValue->values.first()->object || - !prop.defaultValue->values.first()->value.isScript()) - COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location")); - - QDeclarativeJS::AST::Node *node = prop.defaultValue->values.first()->value.asAST(); - if (!node) - COMPILE_EXCEPTION(obj, tr("No property alias location")); // ### Can this happen? - - QStringList alias = astNodeToStringList(node); - - if (alias.count() < 1 || alias.count() > 3) - COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias reference. An alias reference must be specified as , . or ..")); - - QDeclarativeScript::Object *idObject = compileState->ids.value(alias.at(0)); - if (!idObject) - COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias reference. Unable to find id \"%1\"").arg(alias.at(0))); - - QByteArray typeName; - - int propIdx = -1; - int flags = 0; - int type = 0; - bool writable = false; - bool resettable = false; - if (alias.count() == 2 || alias.count() == 3) { - propIdx = indexOfProperty(idObject, alias.at(1)); - - if (-1 == propIdx) { - COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location")); - } else if (propIdx > 0xFFFF) { - COMPILE_EXCEPTION(prop.defaultValue, tr("Alias property exceeds alias bounds")); - } - - QMetaProperty aliasProperty = idObject->metaObject()->property(propIdx); - if (!aliasProperty.isScriptable()) - COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location")); - - writable = aliasProperty.isWritable() && !prop.isReadOnly; - resettable = aliasProperty.isResettable() && !prop.isReadOnly; - - if (aliasProperty.type() < QVariant::UserType - || uint(aliasProperty.type()) == QMetaType::QVariant) - type = aliasProperty.type(); - - if (alias.count() == 3) { - QDeclarativeValueType *valueType = enginePrivate->valueTypes[aliasProperty.type()]; - if (!valueType) - COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location")); - - propIdx |= ((unsigned int)aliasProperty.type()) << 24; - - int valueTypeIndex = valueType->metaObject()->indexOfProperty(alias.at(2).toUtf8().constData()); - if (valueTypeIndex == -1) - COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location")); - Q_ASSERT(valueTypeIndex <= 0xFF); - - aliasProperty = valueType->metaObject()->property(valueTypeIndex); - propIdx |= (valueTypeIndex << 16); - - // update the property type - type = aliasProperty.type(); - if (type >= (int)QVariant::UserType) - type = 0; - } - - if (aliasProperty.isEnumType()) - typeName = "int"; // Avoid introducing a dependency on the aliased metaobject - else - typeName = aliasProperty.typeName(); - } else { - Q_ASSERT(idObject->type != -1); // How else did it get an id? - - const QDeclarativeCompiledData::TypeReference &ref = output->types.at(idObject->type); - if (ref.type) - typeName = ref.type->typeName(); - else - typeName = ref.component->root->className(); - - typeName += '*'; - } - - if (typeName.endsWith('*')) - flags |= QML_ALIAS_FLAG_PTR; - - QDeclarativeVMEMetaData::AliasData aliasData = { idObject->idIndex, propIdx, flags }; - - typedef QDeclarativeVMEMetaData VMD; - VMD *vmd = (QDeclarativeVMEMetaData *)data.data(); - *(vmd->aliasData() + aliasIndex) = aliasData; - - prop.nameRef = builder.newString(prop.name.utf8length()); - prop.resolvedCustomTypeName = pool->NewByteArray(typeName); - prop.typeRef = builder.newString(typeName.length()); - - int propertyFlags = 0; - if (writable) - propertyFlags |= QFastMetaBuilder::Writable; - if (resettable) - propertyFlags |= QFastMetaBuilder::Resettable; - - builder.setProperty(propIndex, prop.nameRef, prop.typeRef, (QMetaType::Type)type, - (QFastMetaBuilder::PropertyFlag)propertyFlags, - propIndex); - - return true; -} - -bool QDeclarativeCompiler::buildBinding(QDeclarativeScript::Value *value, - QDeclarativeScript::Property *prop, - const BindingContext &ctxt) -{ - Q_ASSERT(prop->index != -1); - Q_ASSERT(prop->parent); - Q_ASSERT(prop->parent->metaObject()); - - if (!prop->core.isWritable() && !prop->core.isQList() && !prop->isReadOnlyDeclaration) - COMPILE_EXCEPTION(prop, tr("Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString())); - - JSBindingReference *reference = pool->New(); - reference->expression = value->value; - reference->property = prop; - reference->value = value; - reference->bindingContext = ctxt; - addBindingReference(reference); - - return true; -} - -bool QDeclarativeCompiler::buildLiteralBinding(QDeclarativeScript::Value *v, - QDeclarativeScript::Property *prop, - const QDeclarativeCompilerTypes::BindingContext &) -{ - Q_ASSERT(v->value.isScript()); - - if (!prop->core.isWritable()) - return false; - - AST::Node *binding = v->value.asAST(); - - if (prop->type == QVariant::String) { - if (AST::CallExpression *e = AST::cast(binding)) { - if (AST::IdentifierExpression *i = AST::cast(e->base)) { - if (i->name == qsTrId_string) { - AST::ArgumentList *arg1 = e->arguments?e->arguments:0; - AST::ArgumentList *arg2 = arg1?arg1->next:0; - - if (arg1 && arg1->expression->kind == AST::Node::Kind_StringLiteral && - (!arg2 || arg2->expression->kind == AST::Node::Kind_NumericLiteral) && - (!arg2 || !arg2->next)) { - - QStringRef text; - int n = -1; - - text = AST::cast(arg1->expression)->value; - if (arg2) n = (int)AST::cast(arg2->expression)->value; - - TrBindingReference *reference = pool->New(); - reference->dataType = BindingReference::TrId; - reference->text = text; - reference->n = n; - v->bindingReference = reference; - return true; - } - - } else if (i->name == qsTr_string) { - - AST::ArgumentList *arg1 = e->arguments?e->arguments:0; - AST::ArgumentList *arg2 = arg1?arg1->next:0; - AST::ArgumentList *arg3 = arg2?arg2->next:0; - - if (arg1 && arg1->expression->kind == AST::Node::Kind_StringLiteral && - (!arg2 || arg2->expression->kind == AST::Node::Kind_StringLiteral) && - (!arg3 || arg3->expression->kind == AST::Node::Kind_NumericLiteral) && - (!arg3 || !arg3->next)) { - - QStringRef text; - QStringRef comment; - int n = -1; - - text = AST::cast(arg1->expression)->value; - if (arg2) comment = AST::cast(arg2->expression)->value; - if (arg3) n = (int)AST::cast(arg3->expression)->value; - - TrBindingReference *reference = pool->New(); - reference->dataType = BindingReference::Tr; - reference->text = text; - reference->comment = comment; - reference->n = n; - v->bindingReference = reference; - return true; - } - - } - } - } - - } - - return false; -} - -void QDeclarativeCompiler::genBindingAssignment(QDeclarativeScript::Value *binding, - QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Property *valueTypeProperty) -{ - Q_UNUSED(obj); - Q_ASSERT(binding->bindingReference); - - const BindingReference &ref = *binding->bindingReference; - if (ref.dataType == BindingReference::TrId) { - const TrBindingReference &tr = static_cast(ref); - - Instruction::StoreTrIdString store; - store.propertyIndex = prop->core.coreIndex; - store.text = output->indexForByteArray(tr.text.toUtf8()); - store.n = tr.n; - output->addInstruction(store); - } else if (ref.dataType == BindingReference::Tr) { - const TrBindingReference &tr = static_cast(ref); - - Instruction::StoreTrString store; - store.propertyIndex = prop->core.coreIndex; - store.context = translationContextIndex(); - store.text = output->indexForByteArray(tr.text.toUtf8()); - store.comment = output->indexForByteArray(tr.comment.toUtf8()); - store.n = tr.n; - output->addInstruction(store); - } else if (ref.dataType == BindingReference::V4) { - const JSBindingReference &js = static_cast(ref); - - Instruction::StoreV4Binding store; - store.value = js.compiledIndex; - store.context = js.bindingContext.stack; - store.owner = js.bindingContext.owner; - if (valueTypeProperty) { - store.property = (valueTypeProperty->index & 0xFFFF) | - ((valueTypeProperty->type & 0xFF)) << 16 | - ((prop->index & 0xFF) << 24); - store.isRoot = (compileState->root == valueTypeProperty->parent); - } else { - store.property = prop->index; - store.isRoot = (compileState->root == obj); - } - store.line = binding->location.start.line; - store.column = binding->location.start.column; - output->addInstruction(store); - } else if (ref.dataType == BindingReference::V8) { - const JSBindingReference &js = static_cast(ref); - - Instruction::StoreV8Binding store; - store.value = js.compiledIndex; - store.context = js.bindingContext.stack; - store.owner = js.bindingContext.owner; - if (valueTypeProperty) { - store.isRoot = (compileState->root == valueTypeProperty->parent); - } else { - store.isRoot = (compileState->root == obj); - } - store.line = binding->location.start.line; - store.column = binding->location.start.column; - - Q_ASSERT(js.bindingContext.owner == 0 || - (js.bindingContext.owner != 0 && valueTypeProperty)); - if (js.bindingContext.owner) { - store.property = genValueTypeData(prop, valueTypeProperty); - } else { - store.property = prop->core; - } - - output->addInstruction(store); - } else if (ref.dataType == BindingReference::QtScript) { - const JSBindingReference &js = static_cast(ref); - - QDeclarativeInstruction store; - store.assignBinding.value = output->indexForString(js.rewrittenExpression); - store.assignBinding.context = js.bindingContext.stack; - store.assignBinding.owner = js.bindingContext.owner; - store.assignBinding.line = binding->location.start.line; - store.assignBinding.column = binding->location.start.column; - - if (valueTypeProperty) { - store.assignBinding.isRoot = (compileState->root == valueTypeProperty->parent); - } else { - store.assignBinding.isRoot = (compileState->root == obj); - } - - Q_ASSERT(js.bindingContext.owner == 0 || - (js.bindingContext.owner != 0 && valueTypeProperty)); - if (js.bindingContext.owner) { - store.assignBinding.property = genValueTypeData(prop, valueTypeProperty); - } else { - store.assignBinding.property = prop->core; - } - output->addInstructionHelper( - !prop->isAlias ? QDeclarativeInstruction::StoreBinding - : QDeclarativeInstruction::StoreBindingOnAlias - , store); - } else { - Q_ASSERT(!"Unhandled BindingReference::DataType type"); - } -} - -int QDeclarativeCompiler::genContextCache() -{ - if (compileState->ids.count() == 0) - return -1; - - QDeclarativeIntegerCache *cache = new QDeclarativeIntegerCache(); - cache->reserve(compileState->ids.count()); - for (Object *o = compileState->ids.first(); o; o = compileState->ids.next(o)) - cache->add(o->id, o->idIndex); - - output->contextCaches.append(cache); - return output->contextCaches.count() - 1; -} - -QDeclarativePropertyData -QDeclarativeCompiler::genValueTypeData(QDeclarativeScript::Property *valueTypeProp, - QDeclarativeScript::Property *prop) -{ - typedef QDeclarativePropertyPrivate QDPP; - return QDPP::saveValueType(prop->parent->metaObject(), prop->index, - enginePrivate->valueTypes[prop->type]->metaObject(), - valueTypeProp->index, engine); -} - -bool QDeclarativeCompiler::completeComponentBuild() -{ - if (componentStats) - componentStats->componentStat.ids = compileState->ids.count(); - - for (Object *aliasObject = compileState->aliasingObjects.first(); aliasObject; - aliasObject = compileState->aliasingObjects.next(aliasObject)) - COMPILE_CHECK(buildDynamicMeta(aliasObject, ResolveAliases)); - - QV4Compiler::Expression expr(unit->imports()); - expr.component = compileState->root; - expr.ids = &compileState->ids; - expr.importCache = output->importCache; - - QV4Compiler bindingCompiler; - - QList sharedBindings; - - for (JSBindingReference *b = compileState->bindings.first(); b; b = b->nextReference) { - - JSBindingReference &binding = *b; - - // ### We don't currently optimize for bindings on alias's - because - // of the solution to QTBUG-13719 - if (!binding.property->isAlias) { - expr.context = binding.bindingContext.object; - expr.property = binding.property; - expr.expression = binding.expression; - - int index = bindingCompiler.compile(expr, enginePrivate); - if (index != -1) { - binding.dataType = BindingReference::V4; - binding.compiledIndex = index; - if (componentStats) - componentStats->componentStat.optimizedBindings.append(b->value->location); - continue; - } - } - - // Pre-rewrite the expression - QString expression = binding.expression.asScript(); - - QDeclarativeRewrite::RewriteBinding rewriteBinding; - rewriteBinding.setName(QLatin1Char('$')+binding.property->name().toString()); - bool isSharable = false; - binding.rewrittenExpression = rewriteBinding(binding.expression.asAST(), expression, &isSharable); - - if (isSharable && !binding.property->isAlias /* See above re alias */ && - binding.property->type != qMetaTypeId()) { - binding.dataType = BindingReference::V8; - sharedBindings.append(b); - - if (componentStats) - componentStats->componentStat.sharedBindings.append(b->value->location); - } else { - binding.dataType = BindingReference::QtScript; - - if (componentStats) - componentStats->componentStat.scriptBindings.append(b->value->location); - } - } - - if (!sharedBindings.isEmpty()) { - struct Sort { - static bool lt(const JSBindingReference *lhs, const JSBindingReference *rhs) - { - return lhs->value->location.start.line < rhs->value->location.start.line; - } - }; - - qSort(sharedBindings.begin(), sharedBindings.end(), Sort::lt); - - int startLineNumber = sharedBindings.at(0)->value->location.start.line; - int lineNumber = startLineNumber; - - QByteArray functionArray("[", 1); - for (int ii = 0; ii < sharedBindings.count(); ++ii) { - - JSBindingReference *reference = sharedBindings.at(ii); - QDeclarativeScript::Value *value = reference->value; - const QString &expression = reference->rewrittenExpression; - - if (ii != 0) functionArray.append(",", 1); - - while (lineNumber < value->location.start.line) { - lineNumber++; - functionArray.append("\n", 1); - } - - functionArray += expression.toUtf8(); - lineNumber += expression.count(QLatin1Char('\n')); - reference->compiledIndex = ii; - } - functionArray.append("]", 1); - - compileState->v8BindingProgram = functionArray; - compileState->v8BindingProgramLine = startLineNumber; - } - - if (bindingCompiler.isValid()) - compileState->compiledBindingData = bindingCompiler.program(); - - // Check pop()'s matched push()'s - Q_ASSERT(compileState->objectDepth.depth() == 0); - Q_ASSERT(compileState->listDepth.depth() == 0); - - saveComponentState(); - - return true; -} - -void QDeclarativeCompiler::dumpStats() -{ - Q_ASSERT(componentStats); - qWarning().nospace() << "QML Document: " << output->url.toString(); - for (int ii = 0; ii < componentStats->savedComponentStats.count(); ++ii) { - const ComponentStat &stat = componentStats->savedComponentStats.at(ii); - qWarning().nospace() << " Component Line " << stat.lineNumber; - qWarning().nospace() << " Total Objects: " << stat.objects; - qWarning().nospace() << " IDs Used: " << stat.ids; - qWarning().nospace() << " Optimized Bindings: " << stat.optimizedBindings.count(); - - { - QByteArray output; - for (int ii = 0; ii < stat.optimizedBindings.count(); ++ii) { - if (0 == (ii % 10)) { - if (ii) output.append("\n"); - output.append(" "); - } - - output.append("("); - output.append(QByteArray::number(stat.optimizedBindings.at(ii).start.line)); - output.append(":"); - output.append(QByteArray::number(stat.optimizedBindings.at(ii).start.column)); - output.append(") "); - } - if (!output.isEmpty()) - qWarning().nospace() << output.constData(); - } - - qWarning().nospace() << " Shared Bindings: " << stat.sharedBindings.count(); - { - QByteArray output; - for (int ii = 0; ii < stat.sharedBindings.count(); ++ii) { - if (0 == (ii % 10)) { - if (ii) output.append("\n"); - output.append(" "); - } - - output.append("("); - output.append(QByteArray::number(stat.sharedBindings.at(ii).start.line)); - output.append(":"); - output.append(QByteArray::number(stat.sharedBindings.at(ii).start.column)); - output.append(") "); - } - if (!output.isEmpty()) - qWarning().nospace() << output.constData(); - } - - qWarning().nospace() << " QScript Bindings: " << stat.scriptBindings.count(); - { - QByteArray output; - for (int ii = 0; ii < stat.scriptBindings.count(); ++ii) { - if (0 == (ii % 10)) { - if (ii) output.append("\n"); - output.append(" "); - } - - output.append("("); - output.append(QByteArray::number(stat.scriptBindings.at(ii).start.line)); - output.append(":"); - output.append(QByteArray::number(stat.scriptBindings.at(ii).start.column)); - output.append(") "); - } - if (!output.isEmpty()) - qWarning().nospace() << output.constData(); - } - } -} - -/*! - Returns true if from can be assigned to a (QObject) property of type - to. -*/ -bool QDeclarativeCompiler::canCoerce(int to, QDeclarativeScript::Object *from) -{ - const QMetaObject *toMo = enginePrivate->rawMetaObjectForType(to); - const QMetaObject *fromMo = from->metaObject(); - - while (fromMo) { - if (QDeclarativePropertyPrivate::equal(fromMo, toMo)) - return true; - fromMo = fromMo->superClass(); - } - return false; -} - -/*! - Returns the element name, as written in the QML file, for o. -*/ -QString QDeclarativeCompiler::elementName(QDeclarativeScript::Object *o) -{ - Q_ASSERT(o); - if (o->type != -1) { - return output->types.at(o->type).className; - } else { - return QString(); - } -} - -QDeclarativeType *QDeclarativeCompiler::toQmlType(QDeclarativeScript::Object *from) -{ - // ### Optimize - const QMetaObject *mo = from->metatype; - QDeclarativeType *type = 0; - while (!type && mo) { - type = QDeclarativeMetaType::qmlType(mo); - mo = mo->superClass(); - } - return type; -} - -QStringList QDeclarativeCompiler::deferredProperties(QDeclarativeScript::Object *obj) -{ - const QMetaObject *mo = obj->metatype; - - int idx = mo->indexOfClassInfo("DeferredPropertyNames"); - if (idx == -1) - return QStringList(); - - QMetaClassInfo classInfo = mo->classInfo(idx); - QStringList rv = QString::fromUtf8(classInfo.value()).split(QLatin1Char(',')); - return rv; -} - -QDeclarativePropertyData * -QDeclarativeCompiler::property(QDeclarativeScript::Object *object, int index) -{ - QDeclarativePropertyCache *cache = 0; - - if (object->synthCache) - cache = object->synthCache; - else if (object->type != -1) - cache = output->types[object->type].createPropertyCache(engine); - else - cache = QDeclarativeEnginePrivate::get(engine)->cache(object->metaObject()); - - return cache->property(index); -} - -QDeclarativePropertyData * -QDeclarativeCompiler::property(QDeclarativeScript::Object *object, const QHashedStringRef &name, bool *notInRevision) -{ - if (notInRevision) *notInRevision = false; - - QDeclarativePropertyCache *cache = 0; - - if (object->synthCache) - cache = object->synthCache; - else if (object->type != -1) - cache = output->types[object->type].createPropertyCache(engine); - else - cache = QDeclarativeEnginePrivate::get(engine)->cache(object->metaObject()); - - QDeclarativePropertyData *d = cache->property(name); - - // Find the first property - while (d && d->isFunction()) - d = cache->overrideData(d); - - if (d && !cache->isAllowedInRevision(d)) { - if (notInRevision) *notInRevision = true; - return 0; - } else { - return d; - } -} - -// This code must match the semantics of QDeclarativePropertyPrivate::findSignalByName -QDeclarativePropertyData * -QDeclarativeCompiler::signal(QDeclarativeScript::Object *object, const QHashedStringRef &name, bool *notInRevision) -{ - if (notInRevision) *notInRevision = false; - - QDeclarativePropertyCache *cache = 0; - - if (object->synthCache) - cache = object->synthCache; - else if (object->type != -1) - cache = output->types[object->type].createPropertyCache(engine); - else - cache = QDeclarativeEnginePrivate::get(engine)->cache(object->metaObject()); - - - QDeclarativePropertyData *d = cache->property(name); - if (notInRevision) *notInRevision = false; - - while (d && !(d->isFunction())) - d = cache->overrideData(d); - - if (d && !cache->isAllowedInRevision(d)) { - if (notInRevision) *notInRevision = true; - return 0; - } else if (d) { - return d; - } - - if (name.endsWith(Changed_string)) { - QHashedStringRef propName = name.mid(0, name.length() - Changed_string.length()); - - d = property(object, propName, notInRevision); - if (d) - return cache->method(d->notifyIndex); - } - - return 0; -} - -// This code must match the semantics of QDeclarativePropertyPrivate::findSignalByName -int QDeclarativeCompiler::indexOfSignal(QDeclarativeScript::Object *object, const QString &name, - bool *notInRevision) -{ - QDeclarativePropertyData *d = signal(object, QStringRef(&name), notInRevision); - return d?d->coreIndex:-1; -} - -int QDeclarativeCompiler::indexOfProperty(QDeclarativeScript::Object *object, const QString &name, - bool *notInRevision) -{ - return indexOfProperty(object, QStringRef(&name), notInRevision); -} - -int QDeclarativeCompiler::indexOfProperty(QDeclarativeScript::Object *object, const QHashedStringRef &name, - bool *notInRevision) -{ - QDeclarativePropertyData *d = property(object, name, notInRevision); - return d?d->coreIndex:-1; -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h deleted file mode 100644 index 3ef4668b79..0000000000 --- a/src/declarative/qml/qdeclarativecompiler_p.h +++ /dev/null @@ -1,467 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVECOMPILER_P_H -#define QDECLARATIVECOMPILER_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 "qdeclarative.h" -#include "qdeclarativeerror.h" -#include -#include "qdeclarativeinstruction_p.h" -#include "qdeclarativescript_p.h" -#include "qdeclarativeengine_p.h" -#include -#include "qdeclarativepropertycache_p.h" -#include "qdeclarativeintegercache_p.h" -#include "qdeclarativetypenamecache_p.h" -#include "qdeclarativetypeloader_p.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeEngine; -class QDeclarativeComponent; -class QDeclarativeContext; -class QDeclarativeContextData; - -class Q_AUTOTEST_EXPORT QDeclarativeCompiledData : public QDeclarativeRefCount, - public QDeclarativeCleanup -{ -public: - QDeclarativeCompiledData(QDeclarativeEngine *engine); - virtual ~QDeclarativeCompiledData(); - - QDeclarativeEngine *engine; - - QString name; - QUrl url; - QDeclarativeTypeNameCache *importCache; - - struct TypeReference - { - TypeReference() - : type(0), typePropertyCache(0), component(0) {} - - QString className; - QDeclarativeType *type; - QDeclarativePropertyCache *typePropertyCache; - QDeclarativeCompiledData *component; - - const QMetaObject *metaObject() const; - QDeclarativePropertyCache *propertyCache() const; - QDeclarativePropertyCache *createPropertyCache(QDeclarativeEngine *); - }; - QList types; - - struct V8Program { - V8Program(const QByteArray &p, QDeclarativeCompiledData *c) - : program(p), cdata(c) {} - - QByteArray program; - v8::Persistent bindings; - QDeclarativeCompiledData *cdata; - }; - - QList programs; - - const QMetaObject *root; - QAbstractDynamicMetaObject rootData; - QDeclarativePropertyCache *rootPropertyCache; - QList primitives; - QList datas; - QByteArray bytecode; - QList propertyCaches; - QList contextCaches; - QList scripts; - QList urls; - - struct Instruction { -#define QML_INSTR_DATA_TYPEDEF(I, FMT) typedef QDeclarativeInstructionData I; - FOR_EACH_QML_INSTR(QML_INSTR_DATA_TYPEDEF) -#undef QML_INSTR_DATA_TYPEDEF - private: - Instruction(); - }; - - void dumpInstructions(); - - template - int addInstruction(const QDeclarativeInstructionData &data) - { - QDeclarativeInstruction genericInstr; - QDeclarativeInstructionMeta::setData(genericInstr, data); - return addInstructionHelper(static_cast(Instr), genericInstr); - } - int nextInstructionIndex(); - QDeclarativeInstruction *instruction(int index); - QDeclarativeInstruction::Type instructionType(const QDeclarativeInstruction *instr); - - bool isInitialized() const { return hasEngine(); } - void initialize(QDeclarativeEngine *); - -protected: - virtual void destroy(); // From QDeclarativeRefCount - virtual void clear(); // From QDeclarativeCleanup - -private: - friend class QDeclarativeCompiler; - - int addInstructionHelper(QDeclarativeInstruction::Type type, QDeclarativeInstruction &instr); - void dump(QDeclarativeInstruction *, int idx = -1); - QDeclarativeCompiledData(const QDeclarativeCompiledData &other); - QDeclarativeCompiledData &operator=(const QDeclarativeCompiledData &other); - QByteArray packData; - int pack(const char *, size_t); - - int indexForString(const QString &); - int indexForByteArray(const QByteArray &); - int indexForUrl(const QUrl &); -}; - -namespace QDeclarativeCompilerTypes { - struct BindingContext - { - BindingContext() - : stack(0), owner(0), object(0) {} - BindingContext(QDeclarativeScript::Object *o) - : stack(0), owner(0), object(o) {} - BindingContext incr() const { - BindingContext rv(object); - rv.stack = stack + 1; - return rv; - } - bool isSubContext() const { return stack != 0; } - int stack; - int owner; - QDeclarativeScript::Object *object; - }; - - struct BindingReference - { - enum DataType { QtScript, V4, V8, - Tr, TrId }; - DataType dataType; - }; - - struct JSBindingReference : public QDeclarativePool::Class, - public BindingReference - { - JSBindingReference() : nextReference(0) {} - - QDeclarativeScript::Variant expression; - QDeclarativeScript::Property *property; - QDeclarativeScript::Value *value; - - int compiledIndex; - - QString rewrittenExpression; - BindingContext bindingContext; - - JSBindingReference *nextReference; - }; - - struct TrBindingReference : public QDeclarativePool::POD, - public BindingReference - { - QStringRef text; - QStringRef comment; - int n; - }; - - struct IdList : public QFieldList - { - QDeclarativeScript::Object *value(const QString &id) const { - for (QDeclarativeScript::Object *o = first(); o; o = next(o)) { - if (o->id == id) - return o; - } - return 0; - } - }; - - struct DepthStack { - DepthStack() : _depth(0), _maxDepth(0) {} - DepthStack(const DepthStack &o) : _depth(o._depth), _maxDepth(o._maxDepth) {} - DepthStack &operator=(const DepthStack &o) { _depth = o._depth; _maxDepth = o._maxDepth; return *this; } - - int depth() const { return _depth; } - int maxDepth() const { return _maxDepth; } - - void push() { ++_depth; _maxDepth = qMax(_depth, _maxDepth); } - void pop() { --_depth; Q_ASSERT(_depth >= 0); Q_ASSERT(_maxDepth > _depth); } - - void pushPop(int count) { _maxDepth = qMax(_depth + count, _maxDepth); } - private: - int _depth; - int _maxDepth; - }; - - // Contains all the incremental compiler state about a component. As - // a single QML file can have multiple components defined, there may be - // more than one of these for each compile - struct ComponentCompileState : public QDeclarativePool::Class - { - ComponentCompileState() - : parserStatusCount(0), totalBindingsCount(0), pushedProperties(0), nested(false), - v8BindingProgramLine(-1), root(0) {} - - IdList ids; - int parserStatusCount; - int totalBindingsCount; - int pushedProperties; - bool nested; - - QByteArray compiledBindingData; - QByteArray v8BindingProgram; - int v8BindingProgramLine; - - DepthStack objectDepth; - DepthStack listDepth; - - typedef QDeclarativeCompilerTypes::JSBindingReference B; - typedef QFieldList JSBindingReferenceList; - JSBindingReferenceList bindings; - typedef QDeclarativeScript::Object O; - typedef QFieldList AliasingObjectsList; - AliasingObjectsList aliasingObjects; - QDeclarativeScript::Object *root; - }; -}; - -class QMetaObjectBuilder; -class Q_AUTOTEST_EXPORT QDeclarativeCompiler -{ - Q_DECLARE_TR_FUNCTIONS(QDeclarativeCompiler) -public: - QDeclarativeCompiler(QDeclarativePool *); - - bool compile(QDeclarativeEngine *, QDeclarativeTypeData *, QDeclarativeCompiledData *); - - bool isError() const; - QList errors() const; - - static bool isAttachedPropertyName(const QString &); - static bool isSignalPropertyName(const QString &); - static bool isAttachedPropertyName(const QHashedStringRef &); - static bool isSignalPropertyName(const QHashedStringRef &); - - int evaluateEnum(const QByteArray& script) const; // for QDeclarativeCustomParser::evaluateEnum - const QMetaObject *resolveType(const QString& name) const; // for QDeclarativeCustomParser::resolveType - int rewriteBinding(const QDeclarativeScript::Variant& value, const QString& name); // for QDeclarativeCustomParser::rewriteBinding - QString rewriteSignalHandler(const QDeclarativeScript::Variant& value, const QString &name); // for QDeclarativeCustomParser::rewriteSignalHandler - -private: - typedef QDeclarativeCompiledData::Instruction Instruction; - - static void reset(QDeclarativeCompiledData *); - - void compileTree(QDeclarativeScript::Object *tree); - - - bool buildObject(QDeclarativeScript::Object *obj, const QDeclarativeCompilerTypes::BindingContext &); - bool buildComponent(QDeclarativeScript::Object *obj, const QDeclarativeCompilerTypes::BindingContext &); - bool buildSubObject(QDeclarativeScript::Object *obj, const QDeclarativeCompilerTypes::BindingContext &); - bool buildSignal(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj, - const QDeclarativeCompilerTypes::BindingContext &); - bool buildProperty(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj, - const QDeclarativeCompilerTypes::BindingContext &); - bool buildPropertyInNamespace(QDeclarativeImportedNamespace *ns, - QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const QDeclarativeCompilerTypes::BindingContext &); - bool buildIdProperty(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj); - bool buildAttachedProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const QDeclarativeCompilerTypes::BindingContext &ctxt); - bool buildGroupedProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const QDeclarativeCompilerTypes::BindingContext &ctxt); - bool buildValueTypeProperty(QObject *type, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Object *baseObj, - const QDeclarativeCompilerTypes::BindingContext &ctxt); - bool buildListProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const QDeclarativeCompilerTypes::BindingContext &ctxt); - bool buildScriptStringProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const QDeclarativeCompilerTypes::BindingContext &ctxt); - bool buildPropertyAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const QDeclarativeCompilerTypes::BindingContext &ctxt); - bool buildPropertyObjectAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Value *value, - const QDeclarativeCompilerTypes::BindingContext &ctxt); - bool buildPropertyOnAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Object *baseObj, - QDeclarativeScript::Value *value, - const QDeclarativeCompilerTypes::BindingContext &ctxt); - bool buildPropertyLiteralAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Value *value, - const QDeclarativeCompilerTypes::BindingContext &ctxt); - bool doesPropertyExist(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj); - bool testLiteralAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Value *value); - bool testQualifiedEnumAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Value *value, - bool *isAssignment); - enum DynamicMetaMode { IgnoreAliases, ResolveAliases, ForceCreation }; - bool mergeDynamicMetaProperties(QDeclarativeScript::Object *obj); - bool buildDynamicMeta(QDeclarativeScript::Object *obj, DynamicMetaMode mode); - bool checkDynamicMeta(QDeclarativeScript::Object *obj); - bool buildBinding(QDeclarativeScript::Value *, QDeclarativeScript::Property *prop, - const QDeclarativeCompilerTypes::BindingContext &ctxt); - bool buildLiteralBinding(QDeclarativeScript::Value *, QDeclarativeScript::Property *prop, - const QDeclarativeCompilerTypes::BindingContext &ctxt); - bool buildComponentFromRoot(QDeclarativeScript::Object *obj, const QDeclarativeCompilerTypes::BindingContext &); - bool compileAlias(QFastMetaBuilder &, - QByteArray &data, - QDeclarativeScript::Object *obj, - int propIndex, int aliasIndex, - QDeclarativeScript::Object::DynamicProperty &); - bool completeComponentBuild(); - bool checkValidId(QDeclarativeScript::Value *, const QString &); - - - void genObject(QDeclarativeScript::Object *obj); - void genObjectBody(QDeclarativeScript::Object *obj); - void genValueTypeProperty(QDeclarativeScript::Object *obj,QDeclarativeScript::Property *); - void genComponent(QDeclarativeScript::Object *obj); - void genValueProperty(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj); - void genListProperty(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj); - void genPropertyAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Property *valueTypeProperty = 0); - void genLiteralAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Value *value); - void genBindingAssignment(QDeclarativeScript::Value *binding, - QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Property *valueTypeProperty = 0); - int genContextCache(); - - QDeclarativePropertyData genValueTypeData(QDeclarativeScript::Property *prop, - QDeclarativeScript::Property *valueTypeProp); - - int componentTypeRef(); - int translationContextIndex(); - - static QDeclarativeType *toQmlType(QDeclarativeScript::Object *from); - bool canCoerce(int to, QDeclarativeScript::Object *from); - - QString elementName(QDeclarativeScript::Object *); - - QStringList deferredProperties(QDeclarativeScript::Object *); - - QDeclarativePropertyData *property(QDeclarativeScript::Object *, int); - QDeclarativePropertyData *property(QDeclarativeScript::Object *, const QHashedStringRef &, - bool *notInRevision = 0); - QDeclarativePropertyData *signal(QDeclarativeScript::Object *, const QHashedStringRef &, - bool *notInRevision = 0); - int indexOfProperty(QDeclarativeScript::Object *, const QHashedStringRef &, bool *notInRevision = 0); - int indexOfProperty(QDeclarativeScript::Object *, const QString &, bool *notInRevision = 0); - int indexOfSignal(QDeclarativeScript::Object *, const QString &, bool *notInRevision = 0); - - void addId(const QString &, QDeclarativeScript::Object *); - - void dumpStats(); - - void addBindingReference(QDeclarativeCompilerTypes::JSBindingReference *); - - QDeclarativeCompilerTypes::ComponentCompileState *compileState; - - QDeclarativePool *pool; - - QDeclarativeCompilerTypes::ComponentCompileState *componentState(QDeclarativeScript::Object *); - void saveComponentState(); - - QList exceptions; - QDeclarativeCompiledData *output; - QDeclarativeEngine *engine; - QDeclarativeEnginePrivate *enginePrivate; - QDeclarativeScript::Object *unitRoot; - QDeclarativeTypeData *unit; - int cachedComponentTypeRef; - int cachedTranslationContextIndex; - - // Compiler component statistics. Only collected if QML_COMPILER_STATS=1 - struct ComponentStat - { - ComponentStat() : ids(0), objects(0) {} - - int lineNumber; - - int ids; - QList scriptBindings; - QList sharedBindings; - QList optimizedBindings; - int objects; - }; - struct ComponentStats : public QDeclarativePool::Class - { - ComponentStat componentStat; - QList savedComponentStats; - }; - ComponentStats *componentStats; -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVECOMPILER_P_H diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp deleted file mode 100644 index 57c30748f3..0000000000 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ /dev/null @@ -1,1352 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativecomponent.h" -#include "qdeclarativecomponent_p.h" -#include "qdeclarativecomponentattached_p.h" - -#include "qdeclarativecompiler_p.h" -#include "qdeclarativecontext_p.h" -#include "qdeclarativeengine_p.h" -#include "qdeclarativevme_p.h" -#include "qdeclarative.h" -#include "qdeclarativeengine.h" -#include "qdeclarativebinding_p.h" -#include "qdeclarativebinding_p_p.h" -#include "qdeclarativeglobal_p.h" -#include "qdeclarativescript_p.h" -#include -#include -#include "qdeclarativeincubator.h" -#include "qdeclarativeincubator_p.h" - -#include -#include - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeComponentExtension : public QV8Engine::Deletable -{ -public: - QDeclarativeComponentExtension(QV8Engine *); - virtual ~QDeclarativeComponentExtension(); - - v8::Persistent incubationConstructor; - v8::Persistent initialProperties; - v8::Persistent forceCompletion; -}; -V8_DEFINE_EXTENSION(QDeclarativeComponentExtension, componentExtension); - -/* - Try to do what's necessary for a reasonable display of the type - name, but no more (just enough for the client to do more extensive cleanup). - - Should only be called when debugging is enabled. -*/ -static inline QString buildTypeNameForDebug(const QMetaObject *metaObject) -{ - static const QString qmlMarker(QLatin1String("_QML")); - static const QChar underscore(QLatin1Char('_')); - static const QChar asterisk(QLatin1Char('*')); - QDeclarativeType *type = QDeclarativeMetaType::qmlType(metaObject); - QString typeName = type ? type->qmlTypeName() : QString::fromUtf8(metaObject->className()); - if (!type) { - //### optimize further? - int marker = typeName.indexOf(qmlMarker); - if (marker != -1 && marker < typeName.count() - 1) { - if (typeName[marker + 1] == underscore) { - const QString className = typeName.left(marker) + asterisk; - type = QDeclarativeMetaType::qmlType(QMetaType::type(className.toUtf8())); - if (type) - typeName = type->qmlTypeName(); - } - } - } - return typeName; -} - -/*! - \class QDeclarativeComponent - \since 4.7 - \brief The QDeclarativeComponent class encapsulates a QML component definition. - \mainclass - - Components are reusable, encapsulated QML elements with well-defined interfaces. - They are often defined in \l {qdeclarativedocuments.html}{Component Files}. - - A QDeclarativeComponent instance can be created from a QML file. - For example, if there is a \c main.qml file like this: - - \qml - import QtQuick 2.0 - - Item { - width: 200 - height: 200 - } - \endqml - - The following code loads this QML file as a component, creates an instance of - this component using create(), and then queries the \l Item's \l {Item::}{width} - value: - - \code - QDeclarativeEngine *engine = new QDeclarativeEngine; - QDeclarativeComponent component(engine, QUrl::fromLocalFile("main.qml")); - - QObject *myObject = component.create(); - QDeclarativeItem *item = qobject_cast(myObject); - int width = item->width(); // width = 200 - \endcode - - - \section2 Network Components - - If the URL passed to QDeclarativeComponent is a network resource, or if the QML document references a - network resource, the QDeclarativeComponent has to fetch the network data before it is able to create - objects. In this case, the QDeclarativeComponent will have a \l {QDeclarativeComponent::Loading}{Loading} - \l {QDeclarativeComponent::status()}{status}. An application will have to wait until the component - is \l {QDeclarativeComponent::Ready}{Ready} before calling \l {QDeclarativeComponent::create()}. - - The following example shows how to load a QML file from a network resource. After creating - the QDeclarativeComponent, it tests whether the component is loading. If it is, it connects to the - QDeclarativeComponent::statusChanged() signal and otherwise calls the \c {continueLoading()} method - directly. Note that QDeclarativeComponent::isLoading() may be false for a network component if the - component has been cached and is ready immediately. - - \code - MyApplication::MyApplication() - { - // ... - component = new QDeclarativeComponent(engine, QUrl("http://www.example.com/main.qml")); - if (component->isLoading()) - QObject::connect(component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), - this, SLOT(continueLoading())); - else - continueLoading(); - } - - void MyApplication::continueLoading() - { - if (component->isError()) { - qWarning() << component->errors(); - } else { - QObject *myObject = component->create(); - } - } - \endcode - - \sa {Using QML Bindings in C++ Applications}, {Integrating QML Code with Existing Qt UI Code} -*/ - -/*! - \qmlclass Component QDeclarativeComponent - \ingroup qml-utility-elements - \since 4.7 - \brief The Component element encapsulates a QML component definition. - - Components are reusable, encapsulated QML elements with well-defined interfaces. - - Components are often defined by \l {qdeclarativedocuments.html}{component files} - - that is, \c .qml files. The \e Component element essentially allows QML components - to be defined inline, within a \l {QML Document}{QML document}, rather than as a separate QML file. - This may be useful for reusing a small component within a QML file, or for defining - a component that logically belongs with other QML components within a file. - - For example, here is a component that is used by multiple \l Loader objects. - It contains a single item, a \l Rectangle: - - \snippet doc/src/snippets/declarative/component.qml 0 - - Notice that while a \l Rectangle by itself would be automatically - rendered and displayed, this is not the case for the above rectangle - because it is defined inside a \c Component. The component encapsulates the - QML elements within, as if they were defined in a separate QML - file, and is not loaded until requested (in this case, by the - two \l Loader objects). - - Defining a \c Component is similar to defining a \l {QML Document}{QML document}. - A QML document has a single top-level item that defines the behaviors and - properties of that component, and cannot define properties or behaviors outside - of that top-level item. In the same way, a \c Component definition contains a single - top level item (which in the above example is a \l Rectangle) and cannot define any - data outside of this item, with the exception of an \e id (which in the above example - is \e redSquare). - - The \c Component element is commonly used to provide graphical components - for views. For example, the ListView::delegate property requires a \c Component - to specify how each list item is to be displayed. - - \c Component objects can also be created dynamically using - \l{QML:Qt::createComponent()}{Qt.createComponent()}. -*/ - -/*! - \qmlattachedsignal Component::onCompleted() - - Emitted after component "startup" has completed. This can be used to - execute script code at startup, once the full QML environment has been - established. - - The \c {Component::onCompleted} attached property can be applied to - any element. The order of running the \c onCompleted scripts is - undefined. - - \qml - Rectangle { - Component.onCompleted: console.log("Completed Running!") - Rectangle { - Component.onCompleted: console.log("Nested Completed Running!") - } - } - \endqml -*/ - -/*! - \qmlattachedsignal Component::onDestruction() - - Emitted as the component begins destruction. This can be used to undo - work done in the onCompleted signal, or other imperative code in your - application. - - The \c {Component::onDestruction} attached property can be applied to - any element. However, it applies to the destruction of the component as - a whole, and not the destruction of the specific object. The order of - running the \c onDestruction scripts is undefined. - - \qml - Rectangle { - Component.onDestruction: console.log("Destruction Beginning!") - Rectangle { - Component.onDestruction: console.log("Nested Destruction Beginning!") - } - } - \endqml - - \sa QtDeclarative -*/ - -/*! - \enum QDeclarativeComponent::Status - - Specifies the loading status of the QDeclarativeComponent. - - \value Null This QDeclarativeComponent has no data. Call loadUrl() or setData() to add QML content. - \value Ready This QDeclarativeComponent is ready and create() may be called. - \value Loading This QDeclarativeComponent is loading network data. - \value Error An error has occurred. Call errors() to retrieve a list of \{QDeclarativeError}{errors}. -*/ - -void QDeclarativeComponentPrivate::typeDataReady(QDeclarativeTypeData *) -{ - Q_Q(QDeclarativeComponent); - - Q_ASSERT(typeData); - - fromTypeData(typeData); - typeData = 0; - - emit q->statusChanged(q->status()); -} - -void QDeclarativeComponentPrivate::typeDataProgress(QDeclarativeTypeData *, qreal p) -{ - Q_Q(QDeclarativeComponent); - - progress = p; - - emit q->progressChanged(p); -} - -void QDeclarativeComponentPrivate::fromTypeData(QDeclarativeTypeData *data) -{ - url = data->finalUrl(); - QDeclarativeCompiledData *c = data->compiledData(); - - if (!c) { - Q_ASSERT(data->isError()); - state.errors = data->errors(); - } else { - cc = c; - } - - data->release(); -} - -void QDeclarativeComponentPrivate::clear() -{ - if (typeData) { - typeData->unregisterCallback(this); - typeData->release(); - typeData = 0; - } - - if (cc) { - cc->release(); - cc = 0; - } -} - -/*! - \internal -*/ -QDeclarativeComponent::QDeclarativeComponent(QObject *parent) - : QObject(*(new QDeclarativeComponentPrivate), parent) -{ -} - -/*! - Destruct the QDeclarativeComponent. -*/ -QDeclarativeComponent::~QDeclarativeComponent() -{ - Q_D(QDeclarativeComponent); - - if (d->state.completePending) { - qWarning("QDeclarativeComponent: Component destroyed while completion pending"); - d->completeCreate(); - } - - if (d->typeData) { - d->typeData->unregisterCallback(d); - d->typeData->release(); - } - if (d->cc) - d->cc->release(); -} - -/*! - \qmlproperty enumeration Component::status - This property holds the status of component loading. It can be one of: - \list - \o Component.Null - no data is available for the component - \o Component.Ready - the component has been loaded, and can be used to create instances. - \o Component.Loading - the component is currently being loaded - \o Component.Error - an error occurred while loading the component. - Calling errorString() will provide a human-readable description of any errors. - \endlist - */ - -/*! - \property QDeclarativeComponent::status - The component's current \l{QDeclarativeComponent::Status} {status}. - */ -QDeclarativeComponent::Status QDeclarativeComponent::status() const -{ - Q_D(const QDeclarativeComponent); - - if (d->typeData) - return Loading; - else if (!d->state.errors.isEmpty()) - return Error; - else if (d->engine && d->cc) - return Ready; - else - return Null; -} - -/*! - Returns true if status() == QDeclarativeComponent::Null. -*/ -bool QDeclarativeComponent::isNull() const -{ - return status() == Null; -} - -/*! - Returns true if status() == QDeclarativeComponent::Ready. -*/ -bool QDeclarativeComponent::isReady() const -{ - return status() == Ready; -} - -/*! - Returns true if status() == QDeclarativeComponent::Error. -*/ -bool QDeclarativeComponent::isError() const -{ - return status() == Error; -} - -/*! - Returns true if status() == QDeclarativeComponent::Loading. -*/ -bool QDeclarativeComponent::isLoading() const -{ - return status() == Loading; -} - -/*! - \qmlproperty real Component::progress - The progress of loading the component, from 0.0 (nothing loaded) - to 1.0 (finished). -*/ - -/*! - \property QDeclarativeComponent::progress - The progress of loading the component, from 0.0 (nothing loaded) - to 1.0 (finished). -*/ -qreal QDeclarativeComponent::progress() const -{ - Q_D(const QDeclarativeComponent); - return d->progress; -} - -/*! - \fn void QDeclarativeComponent::progressChanged(qreal progress) - - Emitted whenever the component's loading progress changes. \a progress will be the - current progress between 0.0 (nothing loaded) and 1.0 (finished). -*/ - -/*! - \fn void QDeclarativeComponent::statusChanged(QDeclarativeComponent::Status status) - - Emitted whenever the component's status changes. \a status will be the - new status. -*/ - -/*! - Create a QDeclarativeComponent with no data and give it the specified - \a engine and \a parent. Set the data with setData(). -*/ -QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine *engine, QObject *parent) - : QObject(*(new QDeclarativeComponentPrivate), parent) -{ - Q_D(QDeclarativeComponent); - d->engine = engine; -} - -/*! - Create a QDeclarativeComponent from the given \a url and give it the - specified \a parent and \a engine. - - Ensure that the URL provided is full and correct, in particular, use - \l QUrl::fromLocalFile() when loading a file from the local filesystem. - - \sa loadUrl() -*/ -QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine *engine, const QUrl &url, QObject *parent) -: QObject(*(new QDeclarativeComponentPrivate), parent) -{ - Q_D(QDeclarativeComponent); - d->engine = engine; - loadUrl(url); -} - -/*! - Create a QDeclarativeComponent from the given \a fileName and give it the specified - \a parent and \a engine. - - \sa loadUrl() -*/ -QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine *engine, const QString &fileName, - QObject *parent) -: QObject(*(new QDeclarativeComponentPrivate), parent) -{ - Q_D(QDeclarativeComponent); - d->engine = engine; - loadUrl(d->engine->baseUrl().resolved(QUrl::fromLocalFile(fileName))); -} - -/*! - \internal -*/ -QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine *engine, QDeclarativeCompiledData *cc, int start, QObject *parent) - : QObject(*(new QDeclarativeComponentPrivate), parent) -{ - Q_D(QDeclarativeComponent); - d->engine = engine; - d->cc = cc; - cc->addref(); - d->start = start; - d->url = cc->url; - d->progress = 1.0; -} - -/*! - Sets the QDeclarativeComponent to use the given QML \a data. If \a url - is provided, it is used to set the component name and to provide - a base path for items resolved by this component. -*/ -void QDeclarativeComponent::setData(const QByteArray &data, const QUrl &url) -{ - Q_D(QDeclarativeComponent); - - d->clear(); - - d->url = url; - - QDeclarativeTypeData *typeData = QDeclarativeEnginePrivate::get(d->engine)->typeLoader.get(data, url); - - if (typeData->isCompleteOrError()) { - d->fromTypeData(typeData); - } else { - d->typeData = typeData; - d->typeData->registerCallback(d); - } - - d->progress = 1.0; - emit statusChanged(status()); - emit progressChanged(d->progress); -} - -/*! -Returns the QDeclarativeContext the component was created in. This is only -valid for components created directly from QML. -*/ -QDeclarativeContext *QDeclarativeComponent::creationContext() const -{ - Q_D(const QDeclarativeComponent); - if(d->creationContext) - return d->creationContext->asQDeclarativeContext(); - - return qmlContext(this); -} - -/*! - Load the QDeclarativeComponent from the provided \a url. - - Ensure that the URL provided is full and correct, in particular, use - \l QUrl::fromLocalFile() when loading a file from the local filesystem. -*/ -void QDeclarativeComponent::loadUrl(const QUrl &url) -{ - Q_D(QDeclarativeComponent); - - d->clear(); - - if ((url.isRelative() && !url.isEmpty()) - || url.scheme() == QLatin1String("file")) // Workaround QTBUG-11929 - d->url = d->engine->baseUrl().resolved(url); - else - d->url = url; - - if (url.isEmpty()) { - QDeclarativeError error; - error.setDescription(tr("Invalid empty URL")); - d->state.errors << error; - return; - } - - QDeclarativeTypeData *data = QDeclarativeEnginePrivate::get(d->engine)->typeLoader.get(d->url); - - if (data->isCompleteOrError()) { - d->fromTypeData(data); - d->progress = 1.0; - } else { - d->typeData = data; - d->typeData->registerCallback(d); - d->progress = data->progress(); - } - - emit statusChanged(status()); - emit progressChanged(d->progress); -} - -/*! - Return the list of errors that occurred during the last compile or create - operation. An empty list is returned if isError() is not set. -*/ -QList QDeclarativeComponent::errors() const -{ - Q_D(const QDeclarativeComponent); - if (isError()) - return d->state.errors; - else - return QList(); -} - -/*! - \qmlmethod string Component::errorString() - - Returns a human-readable description of any errors. - - The string includes the file, location, and description of each error. - If multiple errors are present they are separated by a newline character. - - If no errors are present, an empty string is returned. -*/ - -/*! - \internal - errorString is only meant as a way to get the errors in script -*/ -QString QDeclarativeComponent::errorString() const -{ - Q_D(const QDeclarativeComponent); - QString ret; - if(!isError()) - return ret; - foreach(const QDeclarativeError &e, d->state.errors) { - ret += e.url().toString() + QLatin1Char(':') + - QString::number(e.line()) + QLatin1Char(' ') + - e.description() + QLatin1Char('\n'); - } - return ret; -} - -/*! - \qmlproperty url Component::url - The component URL. This is the URL that was used to construct the component. -*/ - -/*! - \property QDeclarativeComponent::url - The component URL. This is the URL passed to either the constructor, - or the loadUrl() or setData() methods. -*/ -QUrl QDeclarativeComponent::url() const -{ - Q_D(const QDeclarativeComponent); - return d->url; -} - -/*! - \internal -*/ -QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, QObject *parent) - : QObject(dd, parent) -{ -} - -/*! - Create an object instance from this component. Returns 0 if creation - failed. \a context specifies the context within which to create the object - instance. - - If \a context is 0 (the default), it will create the instance in the - engine' s \l {QDeclarativeEngine::rootContext()}{root context}. -*/ -QObject *QDeclarativeComponent::create(QDeclarativeContext *context) -{ - Q_D(QDeclarativeComponent); - - if (!context) - context = d->engine->rootContext(); - - QObject *rv = beginCreate(context); - completeCreate(); - return rv; -} - -/*! - This method provides more advanced control over component instance creation. - In general, programmers should use QDeclarativeComponent::create() to create a - component. - - Create an object instance from this component. Returns 0 if creation - failed. \a publicContext specifies the context within which to create the object - instance. - - When QDeclarativeComponent constructs an instance, it occurs in three steps: - \list 1 - \i The object hierarchy is created, and constant values are assigned. - \i Property bindings are evaluated for the the first time. - \i If applicable, QDeclarativeParserStatus::componentComplete() is called on objects. - \endlist - QDeclarativeComponent::beginCreate() differs from QDeclarativeComponent::create() in that it - only performs step 1. QDeclarativeComponent::completeCreate() must be called to - complete steps 2 and 3. - - This breaking point is sometimes useful when using attached properties to - communicate information to an instantiated component, as it allows their - initial values to be configured before property bindings take effect. -*/ -QObject *QDeclarativeComponent::beginCreate(QDeclarativeContext *publicContext) -{ - Q_D(QDeclarativeComponent); - - Q_ASSERT(publicContext); - QDeclarativeContextData *context = QDeclarativeContextData::get(publicContext); - - return d->beginCreate(context); -} - -QObject * -QDeclarativeComponentPrivate::beginCreate(QDeclarativeContextData *context) -{ - Q_Q(QDeclarativeComponent); - if (!context) { - qWarning("QDeclarativeComponent: Cannot create a component in a null context"); - return 0; - } - - if (!context->isValid()) { - qWarning("QDeclarativeComponent: Cannot create a component in an invalid context"); - return 0; - } - - if (context->engine != engine) { - qWarning("QDeclarativeComponent: Must create component in context from the same QDeclarativeEngine"); - return 0; - } - - if (state.completePending) { - qWarning("QDeclarativeComponent: Cannot create new component instance before completing the previous"); - return 0; - } - - if (!q->isReady()) { - qWarning("QDeclarativeComponent: Component is not ready"); - return 0; - } - - QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine); - - if (enginePriv->inProgressCreations == 0) { - // only track root, since further ones might not be properly nested - profiler = new QDeclarativeObjectCreatingProfiler(); - } - - enginePriv->inProgressCreations++; - state.errors.clear(); - state.completePending = true; - - enginePriv->referenceScarceResources(); - state.vme.init(context, cc, start, creationContext); - QObject *rv = state.vme.execute(&state.errors); - enginePriv->dereferenceScarceResources(); - - if (rv) { - QDeclarativeData *ddata = QDeclarativeData::get(rv); - Q_ASSERT(ddata); - ddata->indestructible = true; - } - - if (enginePriv->isDebugging && rv) { - if (!context->isInternal) - context->asQDeclarativeContextPrivate()->instances.append(rv); - QDeclarativeEngineDebugService::instance()->objectCreated(engine, rv); - - if (profiler && profiler->enabled) { - profiler->setTypeName(buildTypeNameForDebug(rv->metaObject())); - QDeclarativeData *data = QDeclarativeData::get(rv); - Q_ASSERT(data); - profiler->setLocation(cc->url, data->lineNumber, data->columnNumber); - } - } - - return rv; -} - -void QDeclarativeComponentPrivate::beginDeferred(QDeclarativeEnginePrivate *enginePriv, - QObject *object, ConstructionState *state) -{ - enginePriv->inProgressCreations++; - state->errors.clear(); - state->completePending = true; - - state->vme.initDeferred(object); - state->vme.execute(&state->errors); -} - -void QDeclarativeComponentPrivate::complete(QDeclarativeEnginePrivate *enginePriv, ConstructionState *state) -{ - if (state->completePending) { - state->vme.complete(); - - state->completePending = false; - - enginePriv->inProgressCreations--; - - if (0 == enginePriv->inProgressCreations) { - while (enginePriv->erroredBindings) { - enginePriv->warning(enginePriv->erroredBindings->error); - enginePriv->erroredBindings->removeError(); - } - } - } -} - -/*! - This method provides more advanced control over component instance creation. - In general, programmers should use QDeclarativeComponent::create() to create a - component. - - Complete a component creation begin with QDeclarativeComponent::beginCreate(). -*/ -void QDeclarativeComponent::completeCreate() -{ - Q_D(QDeclarativeComponent); - - d->completeCreate(); -} - -void QDeclarativeComponentPrivate::completeCreate() -{ - if (state.completePending) { - QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); - complete(ep, &state); - - delete profiler; - profiler = 0; - } -} - -QDeclarativeComponentAttached::QDeclarativeComponentAttached(QObject *parent) -: QObject(parent), prev(0), next(0) -{ -} - -QDeclarativeComponentAttached::~QDeclarativeComponentAttached() -{ - if (prev) *prev = next; - if (next) next->prev = prev; - prev = 0; - next = 0; -} - -/*! - \internal -*/ -QDeclarativeComponentAttached *QDeclarativeComponent::qmlAttachedProperties(QObject *obj) -{ - QDeclarativeComponentAttached *a = new QDeclarativeComponentAttached(obj); - - QDeclarativeEngine *engine = qmlEngine(obj); - if (!engine) - return a; - - if (QDeclarativeEnginePrivate::get(engine)->activeVME) { // XXX should only be allowed during begin - QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(engine); - a->add(&p->activeVME->componentAttached); - } else { - QDeclarativeData *d = QDeclarativeData::get(obj); - Q_ASSERT(d); - Q_ASSERT(d->context); - a->add(&d->context->componentAttached); - } - - return a; -} - -void QDeclarativeComponent::create(QDeclarativeIncubator &i, QDeclarativeContext *context, - QDeclarativeContext *forContext) -{ - Q_D(QDeclarativeComponent); - - if (!context) - context = d->engine->rootContext(); - - QDeclarativeContextData *contextData = QDeclarativeContextData::get(context); - QDeclarativeContextData *forContextData = contextData; - if (forContext) forContextData = QDeclarativeContextData::get(forContext); - - if (!contextData->isValid()) { - qWarning("QDeclarativeComponent: Cannot create a component in an invalid context"); - return; - } - - if (contextData->engine != d->engine) { - qWarning("QDeclarativeComponent: Must create component in context from the same QDeclarativeEngine"); - return; - } - - if (!isReady()) { - qWarning("QDeclarativeComponent: Component is not ready"); - return; - } - - i.clear(); - QDeclarativeIncubatorPrivate *p = i.d; - - QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(d->engine); - - p->component = d->cc; p->component->addref(); - p->vme.init(contextData, d->cc, d->start, d->creationContext); - - enginePriv->incubate(i, forContextData); -} - -class QV8IncubatorResource : public QV8ObjectResource, - public QDeclarativeIncubator -{ -V8_RESOURCE_TYPE(IncubatorType) -public: - QV8IncubatorResource(QV8Engine *engine, IncubationMode = Asynchronous); - - static v8::Handle StatusChangedGetter(v8::Local, - const v8::AccessorInfo& info); - static v8::Handle StatusGetter(v8::Local, - const v8::AccessorInfo& info); - static v8::Handle ObjectGetter(v8::Local, - const v8::AccessorInfo& info); - static v8::Handle ForceCompletionGetter(v8::Local, - const v8::AccessorInfo& info); - static v8::Handle ForceCompletion(const v8::Arguments &args); - - static void StatusChangedSetter(v8::Local, v8::Local value, - const v8::AccessorInfo& info); - - void dispose(); - - v8::Persistent me; - QDeclarativeGuard parent; - v8::Persistent valuemap; - v8::Persistent qmlGlobal; -protected: - virtual void statusChanged(Status); - virtual void setInitialState(QObject *); -}; - -static void QDeclarativeComponent_setQmlParent(QObject *me, QObject *parent) -{ - if (parent) { - me->setParent(parent); - typedef QDeclarativePrivate::AutoParentFunction APF; - QList functions = QDeclarativeMetaType::parentFunctions(); - - bool needParent = false; - for (int ii = 0; ii < functions.count(); ++ii) { - QDeclarativePrivate::AutoParentResult res = functions.at(ii)(me, parent); - if (res == QDeclarativePrivate::Parented) { - needParent = false; - break; - } else if (res == QDeclarativePrivate::IncompatibleParent) { - needParent = true; - } - } - if (needParent) - qWarning("QDeclarativeComponent: Created graphical object was not " - "placed in the graphics scene."); - } -} - -/*! - \qmlmethod object Component::createObject(Item parent, object properties) - - Creates and returns an object instance of this component that will have - the given \a parent and \a properties. The \a properties argument is optional. - Returns null if object creation fails. - - The object will be created in the same context as the one in which the component - was created. This function will always return null when called on components - which were not created in QML. - - If you wish to create an object without setting a parent, specify \c null for - the \a parent value. Note that if the returned object is to be displayed, you - must provide a valid \a parent value or set the returned object's \l{Item::parent}{parent} - property, or else the object will not be visible. - - If a \a parent is not provided to createObject(), a reference to the returned object must be held so that - it is not destroyed by the garbage collector. This is true regardless of whether \l{Item::parent} is set afterwards, - since setting the Item parent does not change object ownership; only the graphical parent is changed. - - As of QtQuick 1.1, this method accepts an optional \a properties argument that specifies a - map of initial property values for the created object. These values are applied before object - creation is finalized. (This is more efficient than setting property values after object creation, - particularly where large sets of property values are defined, and also allows property bindings - to be set up before the object is created.) - - The \a properties argument is specified as a map of property-value items. For example, the code - below creates an object with initial \c x and \c y values of 100 and 200, respectively: - - \js - var component = Qt.createComponent("Button.qml"); - if (component.status == Component.Ready) - component.createObject(parent, {"x": 100, "y": 100}); - \endjs - - Dynamically created instances can be deleted with the \c destroy() method. - See \l {Dynamic Object Management in QML} for more information. -*/ -void QDeclarativeComponent::createObject(QDeclarativeV8Function *args) -{ - Q_D(QDeclarativeComponent); - Q_ASSERT(d->engine); - Q_ASSERT(args); - - QObject *parent = 0; - v8::Local valuemap; - - if (args->Length() >= 1) - parent = args->engine()->toQObject((*args)[0]); - - if (args->Length() >= 2) { - v8::Local v = (*args)[1]; - if (!v->IsObject() || v->IsArray()) { - qmlInfo(this) << tr("createObject: value is not an object"); - args->returnValue(v8::Null()); - return; - } - valuemap = v8::Local::Cast(v); - } - - QV8Engine *v8engine = args->engine(); - - QDeclarativeContext *ctxt = creationContext(); - if (!ctxt) ctxt = d->engine->rootContext(); - - QObject *rv = beginCreate(ctxt); - - if (!rv) { - args->returnValue(v8::Null()); - return; - } - - QDeclarativeComponent_setQmlParent(rv, parent); - - v8::Handle ov = v8engine->newQObject(rv); - Q_ASSERT(ov->IsObject()); - v8::Handle object = v8::Handle::Cast(ov); - - if (!valuemap.IsEmpty()) { - QDeclarativeComponentExtension *e = componentExtension(v8engine); - // Try catch isn't needed as the function itself is loaded with try/catch - v8::Handle function = e->initialProperties->Run(args->qmlGlobal()); - v8::Handle args[] = { object, valuemap }; - v8::Handle::Cast(function)->Call(v8engine->global(), 2, args); - } - - d->completeCreate(); - - Q_ASSERT(QDeclarativeData::get(rv)); - QDeclarativeData::get(rv)->setImplicitDestructible(); - - if (!rv) - args->returnValue(v8::Null()); - else - args->returnValue(object); -} - -/*! - \qmlmethod object Component::incubateObject(Item parent, object properties, enum mode) - - Creates an incubator for instance of this component. Incubators allow new component - instances to be instantiated asynchronously and not cause freezes in the UI. - - The \a parent argument specifies the parent the created instance will have. Omitting the - parameter or passing null will create anobject with no parent. In this case, a reference - to the created object must be maintained by the application of the object will eventually - be garbage collected. - - The \a properties argument is specified as a map of property-value items which will be - set on the created object during its construction. \a mode may be Qt.Synchronous or - Qt.Asynchronous and controls whether the instance is created synchronously or asynchronously. - The default is asynchronously. In some circumstances, even if Qt.Synchronous is specified, - the incubator may create the object asynchronously. This happens if the component calling - incubateObject() is itself being created asynchronously. - - All three arguments are optional. - - If successful, the method returns an incubator, otherwise null. The incubator has the following - properties: - - \list - \i status The status of the incubator. Valid values are Component.Ready, Component.Loading and - Component.Error. - \i object The created object instance. Will only be available once the incubator is in the - Ready status. - \i onStatusChanged Specifies a callback function to be invoked when the status changes. The - status is passed as a parameter to the callback. - \i forceCompletion() Call to complete incubation synchronously. - \endlist - - The following example demonstrates how to use an incubator: - - \js - var component = Qt.createComponent("Button.qml"); - - var incubator = component.incubateObject(parent, { x: 10, y: 10 }); - if (incubator.status != Component.Ready) { - incubator.onStatusChanged = function(status) { - if (status == Component.Ready) { - print ("Object", incubator.object, "is now ready!"); - } - } - } else { - print ("Object", incubator.object, "is ready immediately!"); - } - \endjs -*/ - -void QDeclarativeComponent::incubateObject(QDeclarativeV8Function *args) -{ - Q_D(QDeclarativeComponent); - Q_ASSERT(d->engine); - Q_UNUSED(d); - Q_ASSERT(args); - - QObject *parent = 0; - v8::Local valuemap; - QDeclarativeIncubator::IncubationMode mode = QDeclarativeIncubator::Asynchronous; - - if (args->Length() >= 1) - parent = args->engine()->toQObject((*args)[0]); - - if (args->Length() >= 2) { - v8::Local v = (*args)[1]; - if (v->IsNull()) { - } else if (!v->IsObject() || v->IsArray()) { - qmlInfo(this) << tr("createObject: value is not an object"); - args->returnValue(v8::Null()); - return; - } else { - valuemap = v8::Local::Cast(v); - } - } - - if (args->Length() >= 3) { - quint32 v = (*args)[2]->Uint32Value(); - if (v == 0) - mode = QDeclarativeIncubator::Asynchronous; - else if (v == 1) - mode = QDeclarativeIncubator::AsynchronousIfNested; - } - - QDeclarativeComponentExtension *e = componentExtension(args->engine()); - - QV8IncubatorResource *r = new QV8IncubatorResource(args->engine(), mode); - v8::Local o = e->incubationConstructor->NewInstance(); - o->SetExternalResource(r); - - if (!valuemap.IsEmpty()) { - r->valuemap = qPersistentNew(valuemap); - r->qmlGlobal = qPersistentNew(args->qmlGlobal()); - } - r->parent = parent; - r->me = qPersistentNew(o); - - create(*r, creationContext()); - - if (r->status() == QDeclarativeIncubator::Null) { - r->dispose(); - args->returnValue(v8::Null()); - } else { - args->returnValue(o); - } -} - -// XXX used by QSGLoader -void QDeclarativeComponentPrivate::initializeObjectWithInitialProperties(v8::Handle qmlGlobal, v8::Handle valuemap, QObject *toCreate) -{ - QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); - QV8Engine *v8engine = ep->v8engine(); - - v8::HandleScope handle_scope; - v8::Context::Scope scope(v8engine->context()); - v8::Handle ov = v8engine->newQObject(toCreate); - Q_ASSERT(ov->IsObject()); - v8::Handle object = v8::Handle::Cast(ov); - - if (!valuemap.IsEmpty()) { - QDeclarativeComponentExtension *e = componentExtension(v8engine); - // Try catch isn't needed as the function itself is loaded with try/catch - v8::Handle function = e->initialProperties->Run(qmlGlobal); - v8::Handle args[] = { object, valuemap }; - v8::Handle::Cast(function)->Call(v8engine->global(), 2, args); - } - - QDeclarativeData *ddata = QDeclarativeData::get(toCreate); - Q_ASSERT(ddata); - ddata->setImplicitDestructible(); -} - - -QDeclarativeComponentExtension::QDeclarativeComponentExtension(QV8Engine *engine) -{ - v8::HandleScope handle_scope; - v8::Context::Scope scope(engine->context()); - - forceCompletion = qPersistentNew(V8FUNCTION(QV8IncubatorResource::ForceCompletion, engine)); - - { - v8::Local ft = v8::FunctionTemplate::New(); - ft->InstanceTemplate()->SetHasExternalResource(true); - ft->InstanceTemplate()->SetInternalFieldCount(1); - ft->InstanceTemplate()->SetAccessor(v8::String::New("onStatusChanged"), - QV8IncubatorResource::StatusChangedGetter, - QV8IncubatorResource::StatusChangedSetter); - ft->InstanceTemplate()->SetAccessor(v8::String::New("status"), - QV8IncubatorResource::StatusGetter); - ft->InstanceTemplate()->SetAccessor(v8::String::New("object"), - QV8IncubatorResource::ObjectGetter); - ft->InstanceTemplate()->SetAccessor(v8::String::New("forceCompletion"), - QV8IncubatorResource::ForceCompletionGetter); - incubationConstructor = qPersistentNew(ft->GetFunction()); - } - - { -#define INITIALPROPERTIES_SOURCE \ - "(function(object, values) {"\ - "try {"\ - "for(var property in values) {" \ - "try {"\ - "var properties = property.split(\".\");"\ - "var o = object;"\ - "for (var ii = 0; ii < properties.length - 1; ++ii) {"\ - "o = o[properties[ii]];"\ - "}"\ - "o[properties[properties.length - 1]] = values[property];"\ - "} catch(e) {}"\ - "}"\ - "} catch(e) {}"\ - "})" - initialProperties = qPersistentNew(engine->qmlModeCompile(QLatin1String(INITIALPROPERTIES_SOURCE))); -#undef INITIALPROPERTIES_SOURCE - } -} - -v8::Handle QV8IncubatorResource::ObjectGetter(v8::Local, - const v8::AccessorInfo& info) -{ - QV8IncubatorResource *r = v8_resource_check(info.This()); - return r->engine->newQObject(r->object()); -} - -v8::Handle QV8IncubatorResource::ForceCompletionGetter(v8::Local, - const v8::AccessorInfo& info) -{ - QV8IncubatorResource *r = v8_resource_check(info.This()); - return componentExtension(r->engine)->forceCompletion; -} - -v8::Handle QV8IncubatorResource::ForceCompletion(const v8::Arguments &args) -{ - QV8IncubatorResource *r = v8_resource_cast(args.This()); - if (!r) - V8THROW_TYPE("Not an incubator object"); - - r->forceCompletion(); - - return v8::Undefined(); -} - -v8::Handle QV8IncubatorResource::StatusGetter(v8::Local, - const v8::AccessorInfo& info) -{ - QV8IncubatorResource *r = v8_resource_check(info.This()); - return v8::Integer::NewFromUnsigned(r->status()); -} - -v8::Handle QV8IncubatorResource::StatusChangedGetter(v8::Local, - const v8::AccessorInfo& info) -{ - return info.This()->GetInternalField(0); -} - -void QV8IncubatorResource::StatusChangedSetter(v8::Local, v8::Local value, - const v8::AccessorInfo& info) -{ - info.This()->SetInternalField(0, value); -} - -QDeclarativeComponentExtension::~QDeclarativeComponentExtension() -{ - qPersistentDispose(incubationConstructor); - qPersistentDispose(initialProperties); - qPersistentDispose(forceCompletion); -} - -QV8IncubatorResource::QV8IncubatorResource(QV8Engine *engine, IncubationMode m) -: QV8ObjectResource(engine), QDeclarativeIncubator(m) -{ -} - -void QV8IncubatorResource::setInitialState(QObject *o) -{ - QDeclarativeComponent_setQmlParent(o, parent); - - if (!valuemap.IsEmpty()) { - QDeclarativeComponentExtension *e = componentExtension(engine); - - v8::HandleScope handle_scope; - v8::Context::Scope scope(engine->context()); - - v8::Handle function = e->initialProperties->Run(qmlGlobal); - v8::Handle args[] = { engine->newQObject(o), valuemap }; - v8::Handle::Cast(function)->Call(engine->global(), 2, args); - - qPersistentDispose(valuemap); - qPersistentDispose(qmlGlobal); - } -} - -void QV8IncubatorResource::dispose() -{ - qPersistentDispose(valuemap); - qPersistentDispose(qmlGlobal); - // No further status changes are forthcoming, so we no long need a self reference - qPersistentDispose(me); -} - -void QV8IncubatorResource::statusChanged(Status s) -{ - if (s == Ready) { - Q_ASSERT(QDeclarativeData::get(object())); - QDeclarativeData::get(object())->setImplicitDestructible(); - } - - if (!me.IsEmpty()) { // Will be false in synchronous mode - v8::HandleScope scope; - v8::Local callback = me->GetInternalField(0); - - if (!callback.IsEmpty() && !callback->IsUndefined()) { - - if (callback->IsFunction()) { - v8::Context::Scope context_scope(engine->context()); - v8::Local f = v8::Local::Cast(callback); - v8::Handle args[] = { v8::Integer::NewFromUnsigned(s) }; - v8::TryCatch tc; - f->Call(me, 1, args); - if (tc.HasCaught()) { - QDeclarativeError error; - QDeclarativeExpressionPrivate::exceptionToError(tc.Message(), error); - QDeclarativeEnginePrivate::warning(QDeclarativeEnginePrivate::get(engine->engine()), - error); - } - } - } - } - - if (s == Ready || s == Error) - dispose(); -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativecomponent.h b/src/declarative/qml/qdeclarativecomponent.h deleted file mode 100644 index 2bd292081c..0000000000 --- a/src/declarative/qml/qdeclarativecomponent.h +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVECOMPONENT_H -#define QDECLARATIVECOMPONENT_H - -#include -#include - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QByteArray; -class QDeclarativeEngine; -class QDeclarativeComponent; -class QDeclarativeIncubator; -class QDeclarativeV8Function; -class QDeclarativeCompiledData; -class QDeclarativeComponentPrivate; -class QDeclarativeComponentAttached; - -class Q_DECLARATIVE_EXPORT QDeclarativeComponent : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarativeComponent) - - Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) - Q_PROPERTY(Status status READ status NOTIFY statusChanged) - Q_PROPERTY(QUrl url READ url CONSTANT) - -public: - QDeclarativeComponent(QObject *parent = 0); - QDeclarativeComponent(QDeclarativeEngine *, QObject *parent=0); - QDeclarativeComponent(QDeclarativeEngine *, const QString &fileName, QObject *parent = 0); - QDeclarativeComponent(QDeclarativeEngine *, const QUrl &url, QObject *parent = 0); - virtual ~QDeclarativeComponent(); - - Q_ENUMS(Status) - enum Status { Null, Ready, Loading, Error }; - Status status() const; - - bool isNull() const; - bool isReady() const; - bool isError() const; - bool isLoading() const; - - QList errors() const; - Q_INVOKABLE QString errorString() const; - - qreal progress() const; - - QUrl url() const; - - virtual QObject *create(QDeclarativeContext *context = 0); - virtual QObject *beginCreate(QDeclarativeContext *); - virtual void completeCreate(); - - void create(QDeclarativeIncubator &, QDeclarativeContext *context = 0, - QDeclarativeContext *forContext = 0); - - QDeclarativeContext *creationContext() const; - - static QDeclarativeComponentAttached *qmlAttachedProperties(QObject *); - -public Q_SLOTS: - void loadUrl(const QUrl &url); - void setData(const QByteArray &, const QUrl &baseUrl); - -Q_SIGNALS: - void statusChanged(QDeclarativeComponent::Status); - void progressChanged(qreal); - -protected: - QDeclarativeComponent(QDeclarativeComponentPrivate &dd, QObject* parent); - Q_INVOKABLE void createObject(QDeclarativeV8Function *); - Q_INVOKABLE void incubateObject(QDeclarativeV8Function *); - -private: - QDeclarativeComponent(QDeclarativeEngine *, QDeclarativeCompiledData *, int, QObject *parent); - - Q_DISABLE_COPY(QDeclarativeComponent) - friend class QDeclarativeVME; - friend class QDeclarativeTypeData; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QDeclarativeComponent::Status) -QML_DECLARE_TYPE(QDeclarativeComponent) -QML_DECLARE_TYPEINFO(QDeclarativeComponent, QML_HAS_ATTACHED_PROPERTIES) - -QT_END_HEADER - -#endif // QDECLARATIVECOMPONENT_H diff --git a/src/declarative/qml/qdeclarativecomponent_p.h b/src/declarative/qml/qdeclarativecomponent_p.h deleted file mode 100644 index 6824bd2927..0000000000 --- a/src/declarative/qml/qdeclarativecomponent_p.h +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVECOMPONENT_P_H -#define QDECLARATIVECOMPONENT_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 "qdeclarativecomponent.h" - -#include -#include "qdeclarativeengine_p.h" -#include "qdeclarativetypeloader_p.h" -#include -#include "qdeclarativevme_p.h" -#include "qdeclarativeerror.h" -#include "qdeclarative.h" -#include "../debugger/qdeclarativeprofilerservice_p.h" - -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -class QV8Engine; - -class QDeclarativeComponent; -class QDeclarativeEngine; -class QDeclarativeCompiledData; - -class QDeclarativeComponentAttached; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeComponentPrivate : public QObjectPrivate, public QDeclarativeTypeData::TypeDataCallback -{ - Q_DECLARE_PUBLIC(QDeclarativeComponent) - -public: - QDeclarativeComponentPrivate() : typeData(0), progress(0.), start(-1), cc(0), engine(0), creationContext(0), profiler(0) {} - - QObject *beginCreate(QDeclarativeContextData *); - void completeCreate(); - void initializeObjectWithInitialProperties(v8::Handle qmlGlobal, v8::Handle valuemap, QObject *toCreate); - - QDeclarativeTypeData *typeData; - virtual void typeDataReady(QDeclarativeTypeData *); - virtual void typeDataProgress(QDeclarativeTypeData *, qreal); - - void fromTypeData(QDeclarativeTypeData *data); - - QUrl url; - qreal progress; - - int start; - QDeclarativeCompiledData *cc; - - struct ConstructionState { - ConstructionState() : completePending(false) {} - - QDeclarativeVME vme; - QList errors; - bool completePending; - }; - ConstructionState state; - - static void beginDeferred(QDeclarativeEnginePrivate *enginePriv, QObject *object, - ConstructionState *state); - static void complete(QDeclarativeEnginePrivate *enginePriv, ConstructionState *state); - - QDeclarativeEngine *engine; - QDeclarativeGuardedContextData creationContext; - QDeclarativeObjectCreatingProfiler *profiler; - - void clear(); - - static QDeclarativeComponentPrivate *get(QDeclarativeComponent *c) { - return static_cast(QObjectPrivate::get(c)); - } -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVECOMPONENT_P_H diff --git a/src/declarative/qml/qdeclarativecomponentattached_p.h b/src/declarative/qml/qdeclarativecomponentattached_p.h deleted file mode 100644 index cd21ea1dcb..0000000000 --- a/src/declarative/qml/qdeclarativecomponentattached_p.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVECOMPONENTATTACHED_P_H -#define QDECLARATIVECOMPONENTATTACHED_P_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class Q_AUTOTEST_EXPORT QDeclarativeComponentAttached : public QObject -{ - Q_OBJECT -public: - QDeclarativeComponentAttached(QObject *parent = 0); - ~QDeclarativeComponentAttached(); - - void add(QDeclarativeComponentAttached **a) { - prev = a; next = *a; *a = this; - if (next) next->prev = &next; - } - void rem() { - if (next) next->prev = prev; - *prev = next; - next = 0; prev = 0; - } - QDeclarativeComponentAttached **prev; - QDeclarativeComponentAttached *next; - -Q_SIGNALS: - void completed(); - void destruction(); - -private: - friend class QDeclarativeVME; - friend class QDeclarativeContextData; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVECOMPONENTATTACHED_P_H diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp deleted file mode 100644 index 102992947e..0000000000 --- a/src/declarative/qml/qdeclarativecontext.cpp +++ /dev/null @@ -1,811 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativecontext.h" -#include "qdeclarativecontext_p.h" -#include "qdeclarativecomponentattached_p.h" - -#include "qdeclarativecomponent_p.h" -#include "qdeclarativeexpression_p.h" -#include "qdeclarativeengine_p.h" -#include "qdeclarativeengine.h" -#include "qdeclarativeinfo.h" -#include -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -QDeclarativeContextPrivate::QDeclarativeContextPrivate() -: data(0), notifyIndex(-1) -{ -} - -/*! - \class QDeclarativeContext - \since 4.7 - \brief The QDeclarativeContext class defines a context within a QML engine. - \mainclass - - Contexts allow data to be exposed to the QML components instantiated by the - QML engine. - - Each QDeclarativeContext contains a set of properties, distinct from its QObject - properties, that allow data to be explicitly bound to a context by name. The - context properties are defined and updated by calling - QDeclarativeContext::setContextProperty(). The following example shows a Qt model - being bound to a context and then accessed from a QML file. - - \code - QDeclarativeEngine engine; - QStringListModel modelData; - QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext()); - context->setContextProperty("myModel", &modelData); - - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0\nListView { model: myModel }", QUrl()); - QObject *window = component.create(context); - \endcode - - Note it is the responsibility of the creator to delete any QDeclarativeContext it - constructs. If the \c context object in the example is no longer needed when the - \c window component instance is destroyed, the \c context must be destroyed explicitly. - The simplest way to ensure this is to set \c window as the parent of \c context. - - To simplify binding and maintaining larger data sets, a context object can be set - on a QDeclarativeContext. All the properties of the context object are available - by name in the context, as though they were all individually added through calls - to QDeclarativeContext::setContextProperty(). Changes to the property's values are - detected through the property's notify signal. Setting a context object is both - faster and easier than manually adding and maintaing context property values. - - The following example has the same effect as the previous one, but it uses a context - object. - - \code - class MyDataSet : ... { - ... - Q_PROPERTY(QAbstractItemModel *myModel READ model NOTIFY modelChanged) - ... - }; - - MyDataSet myDataSet; - QDeclarativeEngine engine; - QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext()); - context->setContextObject(&myDataSet); - - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0\nListView { model: myModel }", QUrl()); - component.create(context); - \endcode - - All properties added explicitly by QDeclarativeContext::setContextProperty() take - precedence over the context object's properties. - - \section2 The Context Hierarchy - - Contexts form a hierarchy. The root of this hierarchy is the QML engine's - \l {QDeclarativeEngine::rootContext()}{root context}. Child contexts inherit - the context properties of their parents; if a child context sets a context property - that already exists in its parent, the new context property overrides that of the - parent. - - The following example defines two contexts - \c context1 and \c context2. The - second context overrides the "b" context property inherited from the first with a - new value. - - \code - QDeclarativeEngine engine; - QDeclarativeContext *context1 = new QDeclarativeContext(engine.rootContext()); - QDeclarativeContext *context2 = new QDeclarativeContext(context1); - - context1->setContextProperty("a", 12); - context1->setContextProperty("b", 12); - - context2->setContextProperty("b", 15); - \endcode - - While QML objects instantiated in a context are not strictly owned by that - context, their bindings are. If a context is destroyed, the property bindings of - outstanding QML objects will stop evaluating. - - \warning Setting the context object or adding new context properties after an object - has been created in that context is an expensive operation (essentially forcing all bindings - to reevaluate). Thus whenever possible you should complete "setup" of the context - before using it to create any objects. - - \sa {Using QML Bindings in C++ Applications} -*/ - -/*! \internal */ -QDeclarativeContext::QDeclarativeContext(QDeclarativeEngine *e, bool) -: QObject(*(new QDeclarativeContextPrivate)) -{ - Q_D(QDeclarativeContext); - d->data = new QDeclarativeContextData(this); - - d->data->engine = e; -} - -/*! - Create a new QDeclarativeContext as a child of \a engine's root context, and the - QObject \a parent. -*/ -QDeclarativeContext::QDeclarativeContext(QDeclarativeEngine *engine, QObject *parent) -: QObject(*(new QDeclarativeContextPrivate), parent) -{ - Q_D(QDeclarativeContext); - d->data = new QDeclarativeContextData(this); - - d->data->setParent(engine?QDeclarativeContextData::get(engine->rootContext()):0); -} - -/*! - Create a new QDeclarativeContext with the given \a parentContext, and the - QObject \a parent. -*/ -QDeclarativeContext::QDeclarativeContext(QDeclarativeContext *parentContext, QObject *parent) -: QObject(*(new QDeclarativeContextPrivate), parent) -{ - Q_D(QDeclarativeContext); - d->data = new QDeclarativeContextData(this); - - d->data->setParent(parentContext?QDeclarativeContextData::get(parentContext):0); -} - -/*! - \internal -*/ -QDeclarativeContext::QDeclarativeContext(QDeclarativeContextData *data) -: QObject(*(new QDeclarativeContextPrivate), 0) -{ - Q_D(QDeclarativeContext); - d->data = data; -} - -/*! - Destroys the QDeclarativeContext. - - Any expressions, or sub-contexts dependent on this context will be - invalidated, but not destroyed (unless they are parented to the QDeclarativeContext - object). - */ -QDeclarativeContext::~QDeclarativeContext() -{ - Q_D(QDeclarativeContext); - - if (!d->data->isInternal) - d->data->destroy(); -} - -/*! - Returns whether the context is valid. - - To be valid, a context must have a engine, and it's contextObject(), if any, - must not have been deleted. -*/ -bool QDeclarativeContext::isValid() const -{ - Q_D(const QDeclarativeContext); - return d->data && d->data->isValid(); -} - -/*! - Return the context's QDeclarativeEngine, or 0 if the context has no QDeclarativeEngine or the - QDeclarativeEngine was destroyed. -*/ -QDeclarativeEngine *QDeclarativeContext::engine() const -{ - Q_D(const QDeclarativeContext); - return d->data->engine; -} - -/*! - Return the context's parent QDeclarativeContext, or 0 if this context has no - parent or if the parent has been destroyed. -*/ -QDeclarativeContext *QDeclarativeContext::parentContext() const -{ - Q_D(const QDeclarativeContext); - return d->data->parent?d->data->parent->asQDeclarativeContext():0; -} - -/*! - Return the context object, or 0 if there is no context object. -*/ -QObject *QDeclarativeContext::contextObject() const -{ - Q_D(const QDeclarativeContext); - return d->data->contextObject; -} - -/*! - Set the context \a object. -*/ -void QDeclarativeContext::setContextObject(QObject *object) -{ - Q_D(QDeclarativeContext); - - QDeclarativeContextData *data = d->data; - - if (data->isInternal) { - qWarning("QDeclarativeContext: Cannot set context object for internal context."); - return; - } - - if (!isValid()) { - qWarning("QDeclarativeContext: Cannot set context object on invalid context."); - return; - } - - data->contextObject = object; -} - -/*! - Set a the \a value of the \a name property on this context. -*/ -void QDeclarativeContext::setContextProperty(const QString &name, const QVariant &value) -{ - Q_D(QDeclarativeContext); - if (d->notifyIndex == -1) - d->notifyIndex = this->metaObject()->methodCount(); - - QDeclarativeContextData *data = d->data; - - if (data->isInternal) { - qWarning("QDeclarativeContext: Cannot set property on internal context."); - return; - } - - if (!isValid()) { - qWarning("QDeclarativeContext: Cannot set property on invalid context."); - return; - } - - if (data->engine) { - bool ok; - QObject *o = QDeclarativeEnginePrivate::get(data->engine)->toQObject(value, &ok); - if (ok) { - setContextProperty(name, o); - return; - } - } - - if (!data->propertyNames) data->propertyNames = new QDeclarativeIntegerCache(); - - int idx = data->propertyNames->value(name); - if (idx == -1) { - data->propertyNames->add(name, data->idValueCount + d->propertyValues.count()); - d->propertyValues.append(value); - - data->refreshExpressions(); - } else { - d->propertyValues[idx] = value; - QMetaObject::activate(this, idx + d->notifyIndex, 0); - } -} - -/*! - Set the \a value of the \a name property on this context. - - QDeclarativeContext does \bold not take ownership of \a value. -*/ -void QDeclarativeContext::setContextProperty(const QString &name, QObject *value) -{ - Q_D(QDeclarativeContext); - if (d->notifyIndex == -1) - d->notifyIndex = this->metaObject()->methodCount(); - - QDeclarativeContextData *data = d->data; - - if (data->isInternal) { - qWarning("QDeclarativeContext: Cannot set property on internal context."); - return; - } - - if (!isValid()) { - qWarning("QDeclarativeContext: Cannot set property on invalid context."); - return; - } - - if (!data->propertyNames) data->propertyNames = new QDeclarativeIntegerCache(); - int idx = data->propertyNames->value(name); - - if (idx == -1) { - data->propertyNames->add(name, data->idValueCount + d->propertyValues.count()); - d->propertyValues.append(QVariant::fromValue(value)); - - data->refreshExpressions(); - } else { - d->propertyValues[idx] = QVariant::fromValue(value); - QMetaObject::activate(this, idx + d->notifyIndex, 0); - } -} - -/*! - Returns the value of the \a name property for this context - as a QVariant. - */ -QVariant QDeclarativeContext::contextProperty(const QString &name) const -{ - Q_D(const QDeclarativeContext); - QVariant value; - int idx = -1; - - QDeclarativeContextData *data = d->data; - - if (data->propertyNames) - idx = data->propertyNames->value(name); - - if (idx == -1) { - QByteArray utf8Name = name.toUtf8(); - if (data->contextObject) { - QObject *obj = data->contextObject; - QDeclarativePropertyData local; - QDeclarativePropertyData *property = - QDeclarativePropertyCache::property(data->engine, obj, name, local); - - if (property) value = obj->metaObject()->property(property->coreIndex).read(obj); - } - if (!value.isValid() && parentContext()) - value = parentContext()->contextProperty(name); - } else { - if (idx >= d->propertyValues.count()) - value = QVariant::fromValue(data->idValues[idx - d->propertyValues.count()].data()); - else - value = d->propertyValues[idx]; - } - - return value; -} - -/*! -Returns the name of \a object in this context, or an empty string if \a object -is not named in the context. Objects are named by setContextProperty(), or by ids in -the case of QML created contexts. - -If the object has multiple names, the first is returned. -*/ -QString QDeclarativeContext::nameForObject(QObject *object) const -{ - Q_D(const QDeclarativeContext); - - return d->data->findObjectId(object); -} - -/*! - Resolves the URL \a src relative to the URL of the - containing component. - - \sa QDeclarativeEngine::baseUrl(), setBaseUrl() -*/ -QUrl QDeclarativeContext::resolvedUrl(const QUrl &src) -{ - Q_D(QDeclarativeContext); - return d->data->resolvedUrl(src); -} - -QUrl QDeclarativeContextData::resolvedUrl(const QUrl &src) -{ - QDeclarativeContextData *ctxt = this; - - if (src.isRelative() && !src.isEmpty()) { - if (ctxt) { - while(ctxt) { - if(ctxt->url.isValid()) - break; - else - ctxt = ctxt->parent; - } - - if (ctxt) - return ctxt->url.resolved(src); - else if (engine) - return engine->baseUrl().resolved(src); - } - return QUrl(); - } else { - return src; - } -} - - -/*! - Explicitly sets the url resolvedUrl() will use for relative references to \a baseUrl. - - Calling this function will override the url of the containing - component used by default. - - \sa resolvedUrl() -*/ -void QDeclarativeContext::setBaseUrl(const QUrl &baseUrl) -{ - Q_D(QDeclarativeContext); - - d->data->url = baseUrl; - d->data->urlString = baseUrl.toString(); -} - -/*! - Returns the base url of the component, or the containing component - if none is set. -*/ -QUrl QDeclarativeContext::baseUrl() const -{ - Q_D(const QDeclarativeContext); - const QDeclarativeContextData* data = d->data; - while (data && data->url.isEmpty()) - data = data->parent; - - if (data) - return data->url; - else - return QUrl(); -} - -int QDeclarativeContextPrivate::context_count(QDeclarativeListProperty *prop) -{ - QDeclarativeContext *context = static_cast(prop->object); - QDeclarativeContextPrivate *d = QDeclarativeContextPrivate::get(context); - int contextProperty = (int)(quintptr)prop->data; - - if (d->propertyValues.at(contextProperty).userType() != qMetaTypeId >()) { - return 0; - } else { - return ((const QList *)d->propertyValues.at(contextProperty).constData())->count(); - } -} - -QObject *QDeclarativeContextPrivate::context_at(QDeclarativeListProperty *prop, int index) -{ - QDeclarativeContext *context = static_cast(prop->object); - QDeclarativeContextPrivate *d = QDeclarativeContextPrivate::get(context); - int contextProperty = (int)(quintptr)prop->data; - - if (d->propertyValues.at(contextProperty).userType() != qMetaTypeId >()) { - return 0; - } else { - return ((const QList *)d->propertyValues.at(contextProperty).constData())->at(index); - } -} - - -QDeclarativeContextData::QDeclarativeContextData() -: parent(0), engine(0), isInternal(false), ownedByParent(false), isJSContext(false), - isPragmaLibraryContext(false), unresolvedNames(false), publicContext(0), activeVMEData(0), - propertyNames(0), contextObject(0), imports(0), childContexts(0), nextChild(0), prevChild(0), - expressions(0), contextObjects(0), contextGuards(0), idValues(0), idValueCount(0), linkedContext(0), - componentAttached(0), v4bindings(0), v8bindings(0) -{ -} - -QDeclarativeContextData::QDeclarativeContextData(QDeclarativeContext *ctxt) -: parent(0), engine(0), isInternal(false), ownedByParent(false), isJSContext(false), - isPragmaLibraryContext(false), unresolvedNames(false), publicContext(ctxt), activeVMEData(0), - propertyNames(0), contextObject(0), imports(0), childContexts(0), nextChild(0), prevChild(0), - expressions(0), contextObjects(0), contextGuards(0), idValues(0), idValueCount(0), linkedContext(0), - componentAttached(0), v4bindings(0), v8bindings(0) -{ -} - -void QDeclarativeContextData::invalidate() -{ - while (componentAttached) { - QDeclarativeComponentAttached *a = componentAttached; - componentAttached = a->next; - if (componentAttached) componentAttached->prev = &componentAttached; - - a->next = 0; - a->prev = 0; - - emit a->destruction(); - } - - while (childContexts) { - if (childContexts->ownedByParent) { - childContexts->destroy(); - } else { - childContexts->invalidate(); - } - } - - if (prevChild) { - *prevChild = nextChild; - if (nextChild) nextChild->prevChild = prevChild; - nextChild = 0; - prevChild = 0; - } - - engine = 0; - parent = 0; -} - -void QDeclarativeContextData::clearContext() -{ - if (engine) { - while (componentAttached) { - QDeclarativeComponentAttached *a = componentAttached; - componentAttached = a->next; - if (componentAttached) componentAttached->prev = &componentAttached; - - a->next = 0; - a->prev = 0; - - emit a->destruction(); - } - } - - QDeclarativeAbstractExpression *expression = expressions; - while (expression) { - QDeclarativeAbstractExpression *nextExpression = expression->m_nextExpression; - - expression->m_prevExpression = 0; - expression->m_nextExpression = 0; - - expression->setContext(0); - - expression = nextExpression; - } - expressions = 0; -} - -void QDeclarativeContextData::destroy() -{ - if (linkedContext) - linkedContext->destroy(); - - if (engine) invalidate(); - - clearContext(); - - while (contextObjects) { - QDeclarativeData *co = contextObjects; - contextObjects = contextObjects->nextContextObject; - - co->context = 0; - co->outerContext = 0; - co->nextContextObject = 0; - co->prevContextObject = 0; - } - - QDeclarativeGuardedContextData *contextGuard = contextGuards; - while (contextGuard) { - QDeclarativeGuardedContextData *next = contextGuard->m_next; - contextGuard->m_next = 0; - contextGuard->m_prev = 0; - contextGuard->m_contextData = 0; - contextGuard = next; - } - contextGuards = 0; - - if (propertyNames) - propertyNames->release(); - - if (imports) - imports->release(); - - if (v4bindings) - v4bindings->release(); - - if (v8bindings) - v8bindings->release(); - - for (int ii = 0; ii < importedScripts.count(); ++ii) { - qPersistentDispose(importedScripts[ii]); - } - - delete [] idValues; - - if (isInternal) - delete publicContext; - - delete this; -} - -void QDeclarativeContextData::setParent(QDeclarativeContextData *p, bool parentTakesOwnership) -{ - if (p) { - parent = p; - engine = p->engine; - nextChild = p->childContexts; - if (nextChild) nextChild->prevChild = &nextChild; - prevChild = &p->childContexts; - p->childContexts = this; - ownedByParent = parentTakesOwnership; - } -} - -void QDeclarativeContextData::refreshExpressionsRecursive(QDeclarativeAbstractExpression *expression) -{ - QDeclarativeAbstractExpression::DeleteWatcher w(expression); - - if (expression->m_nextExpression) - refreshExpressionsRecursive(expression->m_nextExpression); - - if (!w.wasDeleted()) - expression->refresh(); -} - -static inline bool expressions_to_run(QDeclarativeContextData *ctxt, bool isGlobalRefresh) -{ - return ctxt->expressions && (!isGlobalRefresh || ctxt->unresolvedNames); -} - -void QDeclarativeContextData::refreshExpressionsRecursive(bool isGlobal) -{ - // For efficiency, we try and minimize the number of guards we have to create - if (expressions_to_run(this, isGlobal) && (nextChild || childContexts)) { - QDeclarativeGuardedContextData guard(this); - - if (childContexts) - childContexts->refreshExpressionsRecursive(isGlobal); - - if (guard.isNull()) return; - - if (nextChild) - nextChild->refreshExpressionsRecursive(isGlobal); - - if (guard.isNull()) return; - - if (expressions_to_run(this, isGlobal)) - refreshExpressionsRecursive(expressions); - - } else if (expressions_to_run(this, isGlobal)) { - - refreshExpressionsRecursive(expressions); - - } else if (nextChild && childContexts) { - - QDeclarativeGuardedContextData guard(this); - - childContexts->refreshExpressionsRecursive(isGlobal); - - if (!guard.isNull() && nextChild) - nextChild->refreshExpressionsRecursive(isGlobal); - - } else if (nextChild) { - - nextChild->refreshExpressionsRecursive(isGlobal); - - } else if (childContexts) { - - childContexts->refreshExpressionsRecursive(isGlobal); - - } -} - -// Refreshes all expressions that could possibly depend on this context. Refreshing flushes all -// context-tree dependent caches in the expressions, and should occur every time the context tree -// *structure* (not values) changes. -void QDeclarativeContextData::refreshExpressions() -{ - bool isGlobal = (parent == 0); - - // For efficiency, we try and minimize the number of guards we have to create - if (expressions_to_run(this, isGlobal) && childContexts) { - QDeclarativeGuardedContextData guard(this); - - childContexts->refreshExpressionsRecursive(isGlobal); - - if (!guard.isNull() && expressions_to_run(this, isGlobal)) - refreshExpressionsRecursive(expressions); - - } else if (expressions_to_run(this, isGlobal)) { - - refreshExpressionsRecursive(expressions); - - } else if (childContexts) { - - childContexts->refreshExpressionsRecursive(isGlobal); - - } -} - -void QDeclarativeContextData::addObject(QObject *o) -{ - QDeclarativeData *data = QDeclarativeData::get(o, true); - - Q_ASSERT(data->context == 0); - - data->context = this; - data->outerContext = this; - - data->nextContextObject = contextObjects; - if (data->nextContextObject) - data->nextContextObject->prevContextObject = &data->nextContextObject; - data->prevContextObject = &contextObjects; - contextObjects = data; -} - -void QDeclarativeContextData::setIdProperty(int idx, QObject *obj) -{ - idValues[idx] = obj; - idValues[idx].context = this; -} - -void QDeclarativeContextData::setIdPropertyData(QDeclarativeIntegerCache *data) -{ - Q_ASSERT(!propertyNames); - propertyNames = data; - propertyNames->addref(); - - idValueCount = data->count(); - idValues = new ContextGuard[idValueCount]; -} - -QString QDeclarativeContextData::findObjectId(const QObject *obj) const -{ - if (!propertyNames) - return QString(); - - for (int ii = 0; ii < idValueCount; ii++) { - if (idValues[ii] == obj) - return propertyNames->findId(ii); - } - - if (publicContext) { - QDeclarativeContextPrivate *p = QDeclarativeContextPrivate::get(publicContext); - for (int ii = 0; ii < p->propertyValues.count(); ++ii) - if (p->propertyValues.at(ii) == QVariant::fromValue((QObject *)obj)) - return propertyNames->findId(ii); - } - - if (linkedContext) - return linkedContext->findObjectId(obj); - return QString(); -} - -QDeclarativeContext *QDeclarativeContextData::asQDeclarativeContext() -{ - if (!publicContext) - publicContext = new QDeclarativeContext(this); - return publicContext; -} - -QDeclarativeContextPrivate *QDeclarativeContextData::asQDeclarativeContextPrivate() -{ - return QDeclarativeContextPrivate::get(asQDeclarativeContext()); -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativecontext.h b/src/declarative/qml/qdeclarativecontext.h deleted file mode 100644 index b1a8362a3b..0000000000 --- a/src/declarative/qml/qdeclarativecontext.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVECONTEXT_H -#define QDECLARATIVECONTEXT_H - -#include -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QString; -class QDeclarativeEngine; -class QDeclarativeRefCount; -class QDeclarativeContextPrivate; -class QDeclarativeCompositeTypeData; -class QDeclarativeContextData; - -class Q_DECLARATIVE_EXPORT QDeclarativeContext : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarativeContext) - -public: - QDeclarativeContext(QDeclarativeEngine *parent, QObject *objParent=0); - QDeclarativeContext(QDeclarativeContext *parent, QObject *objParent=0); - virtual ~QDeclarativeContext(); - - bool isValid() const; - - QDeclarativeEngine *engine() const; - QDeclarativeContext *parentContext() const; - - QObject *contextObject() const; - void setContextObject(QObject *); - - QVariant contextProperty(const QString &) const; - void setContextProperty(const QString &, QObject *); - void setContextProperty(const QString &, const QVariant &); - - QString nameForObject(QObject *) const; - - QUrl resolvedUrl(const QUrl &); - - void setBaseUrl(const QUrl &); - QUrl baseUrl() const; - -private: - friend class QDeclarativeVME; - friend class QDeclarativeEngine; - friend class QDeclarativeEnginePrivate; - friend class QDeclarativeExpression; - friend class QDeclarativeExpressionPrivate; - friend class QDeclarativeComponent; - friend class QDeclarativeComponentPrivate; - friend class QDeclarativeScriptPrivate; - friend class QDeclarativeBoundSignalProxy; - friend class QDeclarativeContextData; - QDeclarativeContext(QDeclarativeContextData *); - QDeclarativeContext(QDeclarativeEngine *, bool); - Q_DISABLE_COPY(QDeclarativeContext) -}; -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QList) - -QT_END_HEADER - -#endif // QDECLARATIVECONTEXT_H diff --git a/src/declarative/qml/qdeclarativecontext_p.h b/src/declarative/qml/qdeclarativecontext_p.h deleted file mode 100644 index c53fc9cc21..0000000000 --- a/src/declarative/qml/qdeclarativecontext_p.h +++ /dev/null @@ -1,334 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVECONTEXT_P_H -#define QDECLARATIVECONTEXT_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 "qdeclarativecontext.h" - -#include "qdeclarativedata_p.h" -#include "qdeclarativeintegercache_p.h" -#include "qdeclarativetypenamecache_p.h" -#include "qdeclarativenotifier_p.h" -#include "qdeclarativelist.h" -#include "qdeclarativescript_p.h" - -#include -#include -#include - -#include -#include -#include - -#include - - -QT_BEGIN_NAMESPACE - -class QV8Bindings; -class QDeclarativeContext; -class QDeclarativeExpression; -class QDeclarativeEngine; -class QDeclarativeExpression; -class QDeclarativeExpressionPrivate; -class QDeclarativeAbstractExpression; -class QV4Bindings; -class QDeclarativeContextData; - -class QDeclarativeContextPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeContext) -public: - QDeclarativeContextPrivate(); - - QDeclarativeContextData *data; - - QList propertyValues; - int notifyIndex; - - static QDeclarativeContextPrivate *get(QDeclarativeContext *context) { - return static_cast(QObjectPrivate::get(context)); - } - static QDeclarativeContext *get(QDeclarativeContextPrivate *context) { - return static_cast(context->q_func()); - } - - // Only used for debugging - QList > instances; - - static int context_count(QDeclarativeListProperty *); - static QObject *context_at(QDeclarativeListProperty *, int); -}; - -class QDeclarativeVME; -class QDeclarativeComponentAttached; -class QDeclarativeGuardedContextData; -class Q_DECLARATIVE_EXPORT QDeclarativeContextData -{ -public: - QDeclarativeContextData(); - QDeclarativeContextData(QDeclarativeContext *); - void clearContext(); - void destroy(); - void invalidate(); - - inline bool isValid() const { - return engine && (!isInternal || !contextObject || !QObjectPrivate::get(contextObject)->wasDeleted); - } - - // My parent context and engine - QDeclarativeContextData *parent; - QDeclarativeEngine *engine; - - void setParent(QDeclarativeContextData *, bool parentTakesOwnership = false); - void refreshExpressions(); - - void addObject(QObject *); - - QUrl resolvedUrl(const QUrl &); - - // My containing QDeclarativeContext. If isInternal is true this owns publicContext. - // If internal is false publicContext owns this. - QDeclarativeContext *asQDeclarativeContext(); - QDeclarativeContextPrivate *asQDeclarativeContextPrivate(); - quint32 isInternal:1; - quint32 ownedByParent:1; // unrelated to isInternal; parent context deletes children if true. - quint32 isJSContext:1; - quint32 isPragmaLibraryContext:1; - quint32 unresolvedNames:1; // True if expressions in this context failed to resolve a toplevel name - quint32 dummy:28; - QDeclarativeContext *publicContext; - - // VME data that is constructing this context if any - void *activeVMEData; - - // Property name cache - QDeclarativeIntegerCache *propertyNames; - - // Context object - QObject *contextObject; - - // Any script blocks that exist on this context - QList > importedScripts; - - // Context base url - QUrl url; - QString urlString; - - // List of imports that apply to this context - QDeclarativeTypeNameCache *imports; - - // My children - QDeclarativeContextData *childContexts; - - // My peers in parent's childContexts list - QDeclarativeContextData *nextChild; - QDeclarativeContextData **prevChild; - - // Expressions that use this context - QDeclarativeAbstractExpression *expressions; - - // Doubly-linked list of objects that are owned by this context - QDeclarativeData *contextObjects; - - // Doubly-linked list of context guards (XXX merge with contextObjects) - QDeclarativeGuardedContextData *contextGuards; - - // id guards - struct ContextGuard : public QDeclarativeGuard - { - inline ContextGuard(); - inline ContextGuard &operator=(QObject *obj); - inline void objectDestroyed(QObject *); - - inline bool wasSet() const; - - QFlagPointer context; - QDeclarativeNotifier bindings; - }; - ContextGuard *idValues; - int idValueCount; - void setIdProperty(int, QObject *); - void setIdPropertyData(QDeclarativeIntegerCache *); - - // Linked contexts. this owns linkedContext. - QDeclarativeContextData *linkedContext; - - // Linked list of uses of the Component attached property in this - // context - QDeclarativeComponentAttached *componentAttached; - - // Optimized binding objects. Needed for deferred properties. - QV4Bindings *v4bindings; - QV8Bindings *v8bindings; - - // Return the outermost id for obj, if any. - QString findObjectId(const QObject *obj) const; - - static QDeclarativeContextData *get(QDeclarativeContext *context) { - return QDeclarativeContextPrivate::get(context)->data; - } - -private: - void refreshExpressionsRecursive(bool isGlobal); - void refreshExpressionsRecursive(QDeclarativeAbstractExpression *); - ~QDeclarativeContextData() {} -}; - -class QDeclarativeGuardedContextData -{ -public: - inline QDeclarativeGuardedContextData(); - inline QDeclarativeGuardedContextData(QDeclarativeContextData *); - inline ~QDeclarativeGuardedContextData(); - - inline QDeclarativeContextData *contextData(); - inline void setContextData(QDeclarativeContextData *); - - inline bool isNull() const { return !m_contextData; } - - inline operator QDeclarativeContextData*() const { return m_contextData; } - inline QDeclarativeContextData* operator->() const { return m_contextData; } - inline QDeclarativeGuardedContextData &operator=(QDeclarativeContextData *d); - -private: - QDeclarativeGuardedContextData &operator=(const QDeclarativeGuardedContextData &); - QDeclarativeGuardedContextData(const QDeclarativeGuardedContextData &); - friend class QDeclarativeContextData; - - inline void clear(); - - QDeclarativeContextData *m_contextData; - QDeclarativeGuardedContextData *m_next; - QDeclarativeGuardedContextData **m_prev; -}; - -QDeclarativeGuardedContextData::QDeclarativeGuardedContextData() -: m_contextData(0), m_next(0), m_prev(0) -{ -} - -QDeclarativeGuardedContextData::QDeclarativeGuardedContextData(QDeclarativeContextData *data) -: m_contextData(0), m_next(0), m_prev(0) -{ - setContextData(data); -} - -QDeclarativeGuardedContextData::~QDeclarativeGuardedContextData() -{ - clear(); -} - -void QDeclarativeGuardedContextData::setContextData(QDeclarativeContextData *contextData) -{ - clear(); - - if (contextData) { - m_contextData = contextData; - m_next = contextData->contextGuards; - if (m_next) m_next->m_prev = &m_next; - m_prev = &contextData->contextGuards; - contextData->contextGuards = this; - } -} - -QDeclarativeContextData *QDeclarativeGuardedContextData::contextData() -{ - return m_contextData; -} - -void QDeclarativeGuardedContextData::clear() -{ - if (m_prev) { - *m_prev = m_next; - if (m_next) m_next->m_prev = m_prev; - m_contextData = 0; - m_next = 0; - m_prev = 0; - } -} - -QDeclarativeGuardedContextData & -QDeclarativeGuardedContextData::operator=(QDeclarativeContextData *d) -{ - setContextData(d); - return *this; -} - -QDeclarativeContextData::ContextGuard::ContextGuard() -: context(0) -{ -} - -QDeclarativeContextData::ContextGuard &QDeclarativeContextData::ContextGuard::operator=(QObject *obj) -{ - QDeclarativeGuard::operator=(obj); - context.setFlag(); - bindings.notify(); // For alias connections - return *this; -} - -void QDeclarativeContextData::ContextGuard::objectDestroyed(QObject *) -{ - if (context->contextObject && !QObjectPrivate::get(context->contextObject)->wasDeleted) - bindings.notify(); -} - -bool QDeclarativeContextData::ContextGuard::wasSet() const -{ - return context.flag(); -} - -QT_END_NAMESPACE - -#endif // QDECLARATIVECONTEXT_P_H diff --git a/src/declarative/qml/qdeclarativecustomparser.cpp b/src/declarative/qml/qdeclarativecustomparser.cpp deleted file mode 100644 index a746700aa6..0000000000 --- a/src/declarative/qml/qdeclarativecustomparser.cpp +++ /dev/null @@ -1,319 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativecustomparser_p.h" -#include "qdeclarativecustomparser_p_p.h" - -#include "qdeclarativecompiler_p.h" - -#include - -QT_BEGIN_NAMESPACE - -using namespace QDeclarativeScript; - -/*! - \class QDeclarativeCustomParser - \brief The QDeclarativeCustomParser class allows you to add new arbitrary types to QML. - \internal - - By subclassing QDeclarativeCustomParser, you can add a parser for - building a particular type. - - The subclass must implement compile() and setCustomData(), and register - itself in the meta type system by calling the macro: - - \code - QML_REGISTER_CUSTOM_TYPE(Module, MajorVersion, MinorVersion, Name, TypeClass, ParserClass) - \endcode -*/ - -/* - \fn QByteArray QDeclarativeCustomParser::compile(const QList & properties) - - The custom parser processes \a properties, and returns - a QByteArray containing data meaningful only to the - custom parser; the type engine will pass this same data to - setCustomData() when making an instance of the data. - - Errors must be reported via the error() functions. - - The QByteArray may be cached between executions of the system, so - it must contain correctly-serialized data (not, for example, - pointers to stack objects). -*/ - -/* - \fn void QDeclarativeCustomParser::setCustomData(QObject *object, const QByteArray &data) - - This function sets \a object to have the properties defined - by \a data, which is a block of data previously returned by a call - to compile(). - - Errors should be reported using qmlInfo(object). - - The \a object will be an instance of the TypeClass specified by QML_REGISTER_CUSTOM_TYPE. -*/ - -QDeclarativeCustomParserNode -QDeclarativeCustomParserNodePrivate::fromObject(QDeclarativeScript::Object *root) -{ - QDeclarativeCustomParserNode rootNode; - rootNode.d->name = root->typeName; - rootNode.d->location = root->location.start; - - for (Property *p = root->properties.first(); p; p = root->properties.next(p)) { - rootNode.d->properties << fromProperty(p); - } - - if (root->defaultProperty) - rootNode.d->properties << fromProperty(root->defaultProperty); - - return rootNode; -} - -QDeclarativeCustomParserProperty -QDeclarativeCustomParserNodePrivate::fromProperty(QDeclarativeScript::Property *p) -{ - QDeclarativeCustomParserProperty prop; - prop.d->name = p->name().toString(); - prop.d->isList = p->values.isMany(); - prop.d->location = p->location.start; - - if (p->value) { - QDeclarativeCustomParserNode node = fromObject(p->value); - QList props = node.properties(); - for (int ii = 0; ii < props.count(); ++ii) - prop.d->values << QVariant::fromValue(props.at(ii)); - } else { - for (QDeclarativeScript::Value *v = p->values.first(); v; v = p->values.next(v)) { - v->type = QDeclarativeScript::Value::Literal; - - if(v->object) { - QDeclarativeCustomParserNode node = fromObject(v->object); - prop.d->values << QVariant::fromValue(node); - } else { - prop.d->values << QVariant::fromValue(v->value); - } - - } - } - - return prop; -} - -QDeclarativeCustomParserNode::QDeclarativeCustomParserNode() -: d(new QDeclarativeCustomParserNodePrivate) -{ -} - -QDeclarativeCustomParserNode::QDeclarativeCustomParserNode(const QDeclarativeCustomParserNode &other) -: d(new QDeclarativeCustomParserNodePrivate) -{ - *this = other; -} - -QDeclarativeCustomParserNode &QDeclarativeCustomParserNode::operator=(const QDeclarativeCustomParserNode &other) -{ - d->name = other.d->name; - d->properties = other.d->properties; - d->location = other.d->location; - return *this; -} - -QDeclarativeCustomParserNode::~QDeclarativeCustomParserNode() -{ - delete d; d = 0; -} - -QString QDeclarativeCustomParserNode::name() const -{ - return d->name; -} - -QList QDeclarativeCustomParserNode::properties() const -{ - return d->properties; -} - -QDeclarativeScript::Location QDeclarativeCustomParserNode::location() const -{ - return d->location; -} - -QDeclarativeCustomParserProperty::QDeclarativeCustomParserProperty() -: d(new QDeclarativeCustomParserPropertyPrivate) -{ -} - -QDeclarativeCustomParserProperty::QDeclarativeCustomParserProperty(const QDeclarativeCustomParserProperty &other) -: d(new QDeclarativeCustomParserPropertyPrivate) -{ - *this = other; -} - -QDeclarativeCustomParserProperty &QDeclarativeCustomParserProperty::operator=(const QDeclarativeCustomParserProperty &other) -{ - d->name = other.d->name; - d->isList = other.d->isList; - d->values = other.d->values; - d->location = other.d->location; - return *this; -} - -QDeclarativeCustomParserProperty::~QDeclarativeCustomParserProperty() -{ - delete d; d = 0; -} - -QString QDeclarativeCustomParserProperty::name() const -{ - return d->name; -} - -bool QDeclarativeCustomParserProperty::isList() const -{ - return d->isList; -} - -QDeclarativeScript::Location QDeclarativeCustomParserProperty::location() const -{ - return d->location; -} - -QList QDeclarativeCustomParserProperty::assignedValues() const -{ - return d->values; -} - -void QDeclarativeCustomParser::clearErrors() -{ - exceptions.clear(); -} - -/*! - Reports an error with the given \a description. - - This can only be used during the compile() step. For errors during setCustomData(), use qmlInfo(). - - An error is generated referring to the position of the element in the source file. -*/ -void QDeclarativeCustomParser::error(const QString& description) -{ - Q_ASSERT(object); - QDeclarativeError error; - QString exceptionDescription; - error.setLine(object->location.start.line); - error.setColumn(object->location.start.column); - error.setDescription(description); - exceptions << error; -} - -/*! - Reports an error in parsing \a prop, with the given \a description. - - An error is generated referring to the position of \a node in the source file. -*/ -void QDeclarativeCustomParser::error(const QDeclarativeCustomParserProperty& prop, const QString& description) -{ - QDeclarativeError error; - QString exceptionDescription; - error.setLine(prop.location().line); - error.setColumn(prop.location().column); - error.setDescription(description); - exceptions << error; -} - -/*! - Reports an error in parsing \a node, with the given \a description. - - An error is generated referring to the position of \a node in the source file. -*/ -void QDeclarativeCustomParser::error(const QDeclarativeCustomParserNode& node, const QString& description) -{ - QDeclarativeError error; - QString exceptionDescription; - error.setLine(node.location().line); - error.setColumn(node.location().column); - error.setDescription(description); - exceptions << error; -} - -/*! - If \a script is a simply enum expression (eg. Text.AlignLeft), - returns the integer equivalent (eg. 1). - - Otherwise, returns -1. -*/ -int QDeclarativeCustomParser::evaluateEnum(const QByteArray& script) const -{ - return compiler->evaluateEnum(script); -} - -/*! - Resolves \a name to a type, or 0 if it is not a type. This can be used - to type-check object nodes. -*/ -const QMetaObject *QDeclarativeCustomParser::resolveType(const QString& name) const -{ - return compiler->resolveType(name); -} - -/*! - Rewrites \a value and returns an identifier that can be - used to construct the binding later. \a name - is used as the name of the rewritten function. -*/ -QDeclarativeBinding::Identifier QDeclarativeCustomParser::rewriteBinding(const QDeclarativeScript::Variant &value, const QString& name) -{ - return compiler->rewriteBinding(value, name); -} - -/*! - Returns a rewritten \a handler. \a name - is used as the name of the rewritten function. -*/ -QString QDeclarativeCustomParser::rewriteSignalHandler(const QDeclarativeScript::Variant &value, const QString &name) -{ - return compiler->rewriteSignalHandler(value , name); -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativecustomparser_p.h b/src/declarative/qml/qdeclarativecustomparser_p.h deleted file mode 100644 index 92d1ca7af2..0000000000 --- a/src/declarative/qml/qdeclarativecustomparser_p.h +++ /dev/null @@ -1,168 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVECUSTOMPARSER_H -#define QDECLARATIVECUSTOMPARSER_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 "qdeclarativemetatype_p.h" -#include "qdeclarativeerror.h" -#include "qdeclarativescript_p.h" -#include "qdeclarativebinding_p.h" - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeCompiler; - -class QDeclarativeCustomParserPropertyPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeCustomParserProperty -{ -public: - QDeclarativeCustomParserProperty(); - QDeclarativeCustomParserProperty(const QDeclarativeCustomParserProperty &); - QDeclarativeCustomParserProperty &operator=(const QDeclarativeCustomParserProperty &); - ~QDeclarativeCustomParserProperty(); - - QString name() const; - QDeclarativeScript::Location location() const; - - bool isList() const; - // Will be one of QDeclarativeScript::Variant, QDeclarativeCustomParserProperty or - // QDeclarativeCustomParserNode - QList assignedValues() const; - -private: - friend class QDeclarativeCustomParserNodePrivate; - friend class QDeclarativeCustomParserPropertyPrivate; - QDeclarativeCustomParserPropertyPrivate *d; -}; - -class QDeclarativeCustomParserNodePrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeCustomParserNode -{ -public: - QDeclarativeCustomParserNode(); - QDeclarativeCustomParserNode(const QDeclarativeCustomParserNode &); - QDeclarativeCustomParserNode &operator=(const QDeclarativeCustomParserNode &); - ~QDeclarativeCustomParserNode(); - - QString name() const; - QDeclarativeScript::Location location() const; - - QList properties() const; - -private: - friend class QDeclarativeCustomParserNodePrivate; - QDeclarativeCustomParserNodePrivate *d; -}; - -class Q_DECLARATIVE_EXPORT QDeclarativeCustomParser -{ -public: - enum Flag { - NoFlag = 0x00000000, - AcceptsAttachedProperties = 0x00000001, - AcceptsSignalHandlers = 0x00000002 - }; - Q_DECLARE_FLAGS(Flags, Flag) - - QDeclarativeCustomParser() : compiler(0), object(0), m_flags(NoFlag) {} - QDeclarativeCustomParser(Flags f) : compiler(0), object(0), m_flags(f) {} - virtual ~QDeclarativeCustomParser() {} - - void clearErrors(); - Flags flags() const { return m_flags; } - - virtual QByteArray compile(const QList &)=0; - virtual void setCustomData(QObject *, const QByteArray &)=0; - - QList errors() const { return exceptions; } - -protected: - void error(const QString& description); - void error(const QDeclarativeCustomParserProperty&, const QString& description); - void error(const QDeclarativeCustomParserNode&, const QString& description); - - int evaluateEnum(const QByteArray&) const; - - const QMetaObject *resolveType(const QString&) const; - - QDeclarativeBinding::Identifier rewriteBinding(const QDeclarativeScript::Variant&, const QString&); - QString rewriteSignalHandler(const QDeclarativeScript::Variant&, const QString&); - -private: - QList exceptions; - QDeclarativeCompiler *compiler; - QDeclarativeScript::Object *object; - Flags m_flags; - friend class QDeclarativeCompiler; -}; -Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeCustomParser::Flags); - -#if 0 -#define QML_REGISTER_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, CUSTOMTYPE) \ - qmlRegisterCustomType(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE, new CUSTOMTYPE) -#endif - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QDeclarativeCustomParserProperty) -Q_DECLARE_METATYPE(QDeclarativeCustomParserNode) - -QT_END_HEADER - -#endif diff --git a/src/declarative/qml/qdeclarativecustomparser_p_p.h b/src/declarative/qml/qdeclarativecustomparser_p_p.h deleted file mode 100644 index e7228f07f0..0000000000 --- a/src/declarative/qml/qdeclarativecustomparser_p_p.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVECUSTOMPARSER_P_H -#define QDECLARATIVECUSTOMPARSER_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 "qdeclarativecustomparser_p.h" - -#include "qdeclarativescript_p.h" - -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeCustomParserNodePrivate -{ -public: - QString name; - QList properties; - QDeclarativeScript::Location location; - - static QDeclarativeCustomParserNode fromObject(QDeclarativeScript::Object *); - static QDeclarativeCustomParserProperty fromProperty(QDeclarativeScript::Property *); -}; - -class QDeclarativeCustomParserPropertyPrivate -{ -public: - QDeclarativeCustomParserPropertyPrivate() - : isList(false) {} - - QString name; - bool isList; - QDeclarativeScript::Location location; - QList values; -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVECUSTOMPARSER_P_H diff --git a/src/declarative/qml/qdeclarativedata_p.h b/src/declarative/qml/qdeclarativedata_p.h deleted file mode 100644 index 0f75d620b8..0000000000 --- a/src/declarative/qml/qdeclarativedata_p.h +++ /dev/null @@ -1,207 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEDATA_P_H -#define QDECLARATIVEDATA_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 - -QT_BEGIN_NAMESPACE - -template class QHash; -class QDeclarativeGuardImpl; -class QDeclarativeCompiledData; -class QDeclarativeAbstractBinding; -class QDeclarativeContext; -class QDeclarativePropertyCache; -class QDeclarativeContextData; -class QDeclarativeNotifier; -class QDeclarativeDataExtended; -class QDeclarativeNotifierEndpoint; -// This class is structured in such a way, that simply zero'ing it is the -// default state for elemental object allocations. This is crucial in the -// workings of the QDeclarativeInstruction::CreateSimpleObject instruction. -// Don't change anything here without first considering that case! -class Q_DECLARATIVE_EXPORT QDeclarativeData : public QAbstractDeclarativeData -{ -public: - QDeclarativeData() - : ownMemory(true), ownContext(false), indestructible(true), explicitIndestructibleSet(false), - hasTaintedV8Object(false), notifyList(0), context(0), outerContext(0), bindings(0), - nextContextObject(0), prevContextObject(0), bindingBitsSize(0), bindingBits(0), - lineNumber(0), columnNumber(0), deferredComponent(0), deferredIdx(0), v8objectid(0), - propertyCache(0), guards(0), extendedData(0) { - init(); - } - - static inline void init() { - QAbstractDeclarativeData::destroyed = destroyed; - QAbstractDeclarativeData::parentChanged = parentChanged; - QAbstractDeclarativeData::objectNameChanged = objectNameChanged; - QAbstractDeclarativeData::signalEmitted = signalEmitted; - } - - static void destroyed(QAbstractDeclarativeData *, QObject *); - static void parentChanged(QAbstractDeclarativeData *, QObject *, QObject *); - static void objectNameChanged(QAbstractDeclarativeData *, QObject *); - static void signalEmitted(QAbstractDeclarativeData *, QObject *, int, void **); - - void destroyed(QObject *); - void parentChanged(QObject *, QObject *); - void objectNameChanged(QObject *); - - void setImplicitDestructible() { - if (!explicitIndestructibleSet) indestructible = false; - } - - quint32 ownMemory:1; - quint32 ownContext:1; - quint32 indestructible:1; - quint32 explicitIndestructibleSet:1; - quint32 hasTaintedV8Object:1; - quint32 dummy:27; - - struct NotifyList { - quint64 connectionMask; - - quint16 maximumTodoIndex; - quint16 notifiesSize; - - QDeclarativeNotifierEndpoint *todo; - QDeclarativeNotifierEndpoint**notifies; - void layout(); - private: - void layout(QDeclarativeNotifierEndpoint*); - }; - NotifyList *notifyList; - - inline QDeclarativeNotifierEndpoint *notify(int index); - void addNotify(int index, QDeclarativeNotifierEndpoint *); - - // The context that created the C++ object - QDeclarativeContextData *context; - // The outermost context in which this object lives - QDeclarativeContextData *outerContext; - - QDeclarativeAbstractBinding *bindings; - - // Linked list for QDeclarativeContext::contextObjects - QDeclarativeData *nextContextObject; - QDeclarativeData**prevContextObject; - - int bindingBitsSize; - quint32 *bindingBits; - bool hasBindingBit(int) const; - void clearBindingBit(int); - void setBindingBit(QObject *obj, int); - - ushort lineNumber; - ushort columnNumber; - - QDeclarativeCompiledData *deferredComponent; // Can't this be found from the context? - unsigned int deferredIdx; - - quint32 v8objectid; - v8::Persistent v8object; - - QDeclarativePropertyCache *propertyCache; - - QDeclarativeGuardImpl *guards; - - static QDeclarativeData *get(const QObject *object, bool create = false) { - QObjectPrivate *priv = QObjectPrivate::get(const_cast(object)); - if (priv->wasDeleted) { - Q_ASSERT(!create); - return 0; - } else if (priv->declarativeData) { - return static_cast(priv->declarativeData); - } else if (create) { - priv->declarativeData = new QDeclarativeData; - return static_cast(priv->declarativeData); - } else { - return 0; - } - } - - bool hasExtendedData() const { return extendedData != 0; } - QDeclarativeNotifier *objectNameNotifier() const; - QHash *attachedProperties() const; - -private: - // For objectNameNotifier and attachedProperties - mutable QDeclarativeDataExtended *extendedData; -}; - -QDeclarativeNotifierEndpoint *QDeclarativeData::notify(int index) -{ - Q_ASSERT(index <= 0xFFFF); - - if (!notifyList || !(notifyList->connectionMask & (1ULL << quint64(index % 64)))) { - return 0; - } else if (index < notifyList->notifiesSize) { - return notifyList->notifies[index]; - } else if (index <= notifyList->maximumTodoIndex) { - notifyList->layout(); - } - - if (index < notifyList->notifiesSize) { - return notifyList->notifies[index]; - } else { - return 0; - } -} - -QT_END_NAMESPACE - -#endif // QDECLARATIVEDATA_P_H diff --git a/src/declarative/qml/qdeclarativedirparser.cpp b/src/declarative/qml/qdeclarativedirparser.cpp deleted file mode 100644 index f7d5be3601..0000000000 --- a/src/declarative/qml/qdeclarativedirparser.cpp +++ /dev/null @@ -1,298 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativedirparser_p.h" -#include "qdeclarativeerror.h" -#include "qdeclarativeglobal_p.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -QDeclarativeDirParser::QDeclarativeDirParser() - : _isParsed(false) -{ -} - -QDeclarativeDirParser::~QDeclarativeDirParser() -{ -} - -QUrl QDeclarativeDirParser::url() const -{ - return _url; -} - -void QDeclarativeDirParser::setUrl(const QUrl &url) -{ - _url = url; -} - -QString QDeclarativeDirParser::fileSource() const -{ - return _filePathSouce; -} - -void QDeclarativeDirParser::setFileSource(const QString &filePath) -{ - _filePathSouce = filePath; -} - -QString QDeclarativeDirParser::source() const -{ - return _source; -} - -void QDeclarativeDirParser::setSource(const QString &source) -{ - _isParsed = false; - _source = source; -} - -bool QDeclarativeDirParser::isParsed() const -{ - return _isParsed; -} - -bool QDeclarativeDirParser::parse() -{ - if (_isParsed) - return true; - - _isParsed = true; - _errors.clear(); - _plugins.clear(); - _components.clear(); - _scripts.clear(); - - if (_source.isEmpty() && !_filePathSouce.isEmpty()) { - QFile file(_filePathSouce); - if (!QDeclarative_isFileCaseCorrect(_filePathSouce)) { - QDeclarativeError error; - error.setDescription(QString::fromUtf8("cannot load module \"$$URI$$\": File name case mismatch for \"%1\"").arg(_filePathSouce)); - _errors.prepend(error); - return false; - } else if (file.open(QFile::ReadOnly)) { - _source = QString::fromUtf8(file.readAll()); - } else { - QDeclarativeError error; - error.setDescription(QString::fromUtf8("module \"$$URI$$\" definition \"%1\" not readable").arg(_filePathSouce)); - _errors.prepend(error); - return false; - } - } - - QTextStream stream(&_source); - int lineNumber = 0; - - forever { - ++lineNumber; - - const QString line = stream.readLine(); - if (line.isNull()) - break; - - QString sections[3]; - int sectionCount = 0; - - int index = 0; - const int length = line.length(); - - while (index != length) { - const QChar ch = line.at(index); - - if (ch.isSpace()) { - do { ++index; } - while (index != length && line.at(index).isSpace()); - - } else if (ch == QLatin1Char('#')) { - // recognized a comment - break; - - } else { - const int start = index; - - do { ++index; } - while (index != length && !line.at(index).isSpace()); - - const QString lexeme = line.mid(start, index - start); - - if (sectionCount >= 3) { - reportError(lineNumber, start, QLatin1String("unexpected token")); - - } else { - sections[sectionCount++] = lexeme; - } - } - } - - if (sectionCount == 0) { - continue; // no sections, no party. - - } else if (sections[0] == QLatin1String("plugin")) { - if (sectionCount < 2) { - reportError(lineNumber, -1, - QString::fromUtf8("plugin directive requires one or two arguments, but %1 were provided").arg(sectionCount - 1)); - - continue; - } - - const Plugin entry(sections[1], sections[2]); - - _plugins.append(entry); - - } else if (sections[0] == QLatin1String("internal")) { - if (sectionCount != 3) { - reportError(lineNumber, -1, - QString::fromUtf8("internal types require 2 arguments, but %1 were provided").arg(sectionCount - 1)); - continue; - } - Component entry(sections[1], sections[2], -1, -1); - entry.internal = true; - _components.append(entry); - } else if (sections[0] == QLatin1String("typeinfo")) { - if (sectionCount != 2) { - reportError(lineNumber, -1, - QString::fromUtf8("typeinfo requires 1 argument, but %1 were provided").arg(sectionCount - 1)); - continue; - } -#ifdef QT_CREATOR - TypeInfo typeInfo(sections[1]); - _typeInfos.append(typeInfo); -#endif - - } else if (sectionCount == 2) { - // No version specified (should only be used for relative qmldir files) - const Component entry(sections[0], sections[1], -1, -1); - _components.append(entry); - } else if (sectionCount == 3) { - const QString &version = sections[1]; - const int dotIndex = version.indexOf(QLatin1Char('.')); - - if (dotIndex == -1) { - reportError(lineNumber, -1, QLatin1String("expected '.'")); - } else if (version.indexOf(QLatin1Char('.'), dotIndex + 1) != -1) { - reportError(lineNumber, -1, QLatin1String("unexpected '.'")); - } else { - bool validVersionNumber = false; - const int majorVersion = version.left(dotIndex).toInt(&validVersionNumber); - - if (validVersionNumber) { - const int minorVersion = version.mid(dotIndex + 1).toInt(&validVersionNumber); - - if (validVersionNumber) { - const QString &fileName = sections[2]; - - if (fileName.endsWith(QLatin1String(".js"))) { - // A 'js' extension indicates a namespaced script import - const Script entry(sections[0], fileName, majorVersion, minorVersion); - _scripts.append(entry); - } else { - const Component entry(sections[0], fileName, majorVersion, minorVersion); - _components.append(entry); - } - } - } - } - } else { - reportError(lineNumber, -1, - QString::fromUtf8("a component declaration requires two or three arguments, but %1 were provided").arg(sectionCount)); - } - } - - return hasError(); -} - -void QDeclarativeDirParser::reportError(int line, int column, const QString &description) -{ - QDeclarativeError error; - error.setUrl(_url); - error.setLine(line); - error.setColumn(column); - error.setDescription(description); - _errors.append(error); -} - -bool QDeclarativeDirParser::hasError() const -{ - if (! _errors.isEmpty()) - return true; - - return false; -} - -QList QDeclarativeDirParser::errors(const QString &uri) const -{ - QList errors = _errors; - for (int i = 0; i < errors.size(); ++i) { - QDeclarativeError &e = errors[i]; - QString description = e.description(); - description.replace(QLatin1String("$$URI$$"), uri); - e.setDescription(description); - } - return errors; -} - -QList QDeclarativeDirParser::plugins() const -{ - return _plugins; -} - -QList QDeclarativeDirParser::components() const -{ - return _components; -} - -QList QDeclarativeDirParser::scripts() const -{ - return _scripts; -} - -#ifdef QT_CREATOR -QList QDeclarativeDirParser::typeInfos() const -{ - return _typeInfos; -} -#endif - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativedirparser_p.h b/src/declarative/qml/qdeclarativedirparser_p.h deleted file mode 100644 index 40b4b57a12..0000000000 --- a/src/declarative/qml/qdeclarativedirparser_p.h +++ /dev/null @@ -1,166 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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.1, 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEDIRPARSER_P_H -#define QDECLARATIVEDIRPARSER_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 - -QT_BEGIN_NAMESPACE - -class QDeclarativeError; -class QDeclarativeDirParser -{ - Q_DISABLE_COPY(QDeclarativeDirParser) - -public: - QDeclarativeDirParser(); - ~QDeclarativeDirParser(); - - QUrl url() const; - void setUrl(const QUrl &url); - - QString fileSource() const; - void setFileSource(const QString &filePath); - - QString source() const; - void setSource(const QString &source); - - bool isParsed() const; - bool parse(); - - bool hasError() const; - QList errors(const QString &uri) const; - - struct Plugin - { - Plugin() {} - - Plugin(const QString &name, const QString &path) - : name(name), path(path) {} - - QString name; - QString path; - }; - - struct Component - { - Component() - : majorVersion(0), minorVersion(0), internal(false) {} - - Component(const QString &typeName, const QString &fileName, int majorVersion, int minorVersion) - : typeName(typeName), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion), - internal(false) {} - - QString typeName; - QString fileName; - int majorVersion; - int minorVersion; - bool internal; - }; - - struct Script - { - Script() - : majorVersion(0), minorVersion(0) {} - - Script(const QString &nameSpace, const QString &fileName, int majorVersion, int minorVersion) - : nameSpace(nameSpace), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion) {} - - QString nameSpace; - QString fileName; - int majorVersion; - int minorVersion; - }; - - QList components() const; - QList