diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2010-02-03 11:57:09 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2010-02-03 11:57:09 (GMT) |
commit | ead9159c8bfa94004d29c9a0c4b4c93ecce0951e (patch) | |
tree | 5b588e4379c8525cb937cdbc0b050fc44761fbae | |
parent | 5f11d2125b9cc37768fb8174870ced5934cdacf2 (diff) | |
parent | 3838762e4b572017efc42e9f7dbfc43d262807cf (diff) | |
download | Qt-ead9159c8bfa94004d29c9a0c4b4c93ecce0951e.zip Qt-ead9159c8bfa94004d29c9a0c4b4c93ecce0951e.tar.gz Qt-ead9159c8bfa94004d29c9a0c4b4c93ecce0951e.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
383 files changed, 4115 insertions, 1540 deletions
diff --git a/bin/patch_capabilities.pl b/bin/patch_capabilities.pl index b6bf5c3..9daa13e 100755 --- a/bin/patch_capabilities.pl +++ b/bin/patch_capabilities.pl @@ -111,12 +111,31 @@ if (@ARGV) # Parse each line. while (<PKG>) { + # Patch pkg UID my $line = $_; my $newLine = $line; - if ( $line =~ m/^\#.*\(0x[0-9|a-f|A-F]*\).*$/) + if ($line =~ m/^\#.*\(0x[0-9|a-f|A-F]*\).*$/) { $newLine =~ s/\(0x./\(0xE/; } + + # Patch embedded sis name and UID + if ($line =~ m/^@.*\.sis.*\(0x[0-9|a-f|A-F]*\).*$/) + { + $newLine =~ s/\(0x./\(0xE/; + if ($line !~ m/^.*_selfsigned.sis.*$/) + { + $newLine =~ s/\.sis/_selfsigned\.sis/i; + } + } + + # Remove all dependencies to other packages to reduce unnecessary error messages + # from depended packages that are also patched and therefore have different UID. + if ($line =~ m/^\(0x[0-9|a-f|A-F]*\).*\{.*\}$/) + { + $newLine = "" + } + print NEW_PKG $newLine; chomp ($line); @@ -115,7 +115,7 @@ getQMakeConf1() inc_file=`echo "$line" | sed -n -e "/^include.*(.*)/s/include.*(\(.*\)).*$/\1/p"` current_dir=`dirname "$1"` conf_file="$current_dir/$inc_file" - if [ ! -e "$conf_file" ]; then + if [ ! -f "$conf_file" ]; then echo "WARNING: Unable to find file $conf_file" >&2 continue fi @@ -2278,7 +2278,7 @@ if [ "$OPT_SHADOW" = "yes" ]; then fi # symlink fonts to be able to run application from build directory -if [ "$PLATFORM_QWS" = "yes" ] && [ ! -e "${outpath}/lib/fonts" ]; then +if [ "$PLATFORM_QWS" = "yes" ] && [ ! -d "${outpath}/lib/fonts" ]; then if [ "$PLATFORM" = "$XPLATFORM" ]; then mkdir -p "${outpath}/lib" ln -s "${relpath}/lib/fonts" "${outpath}/lib/fonts" @@ -7557,6 +7557,8 @@ elif [ "$CFG_OPENSSL" = "linked" ]; then OPENSSL_LINKAGE="(linked)" fi echo "OpenSSL support ..... $CFG_OPENSSL $OPENSSL_LINKAGE" +echo "Alsa support ........ $CFG_ALSA" +echo [ "$CFG_PTMALLOC" != "no" ] && echo "Use ptmalloc ........ $CFG_PTMALLOC" @@ -7581,8 +7583,6 @@ if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_FRAMEWORK" = "yes" ] && [ "$CFG_DEBUG" echo "NOTE: Mac OS X frameworks implicitly build debug and release Qt libraries." echo fi -echo "alsa support ........ $CFG_ALSA" -echo sepath=`echo "$relpath" | sed -e 's/\\./\\\\./g'` PROCS=1 diff --git a/demos/declarative/calculator/CalcButton.qml b/demos/declarative/calculator/CalcButton.qml index 03ede9c..08851d0 100644 --- a/demos/declarative/calculator/CalcButton.qml +++ b/demos/declarative/calculator/CalcButton.qml @@ -9,8 +9,8 @@ Rectangle { id: button; width: 50; height: 30 border.color: palette.mid; radius: 6 gradient: Gradient { - GradientStop { id: G1; position: 0.0; color: Qt.lighter(palette.button) } - GradientStop { id: G2; position: 1.0; color: palette.button } + GradientStop { id: gradientStop1; position: 0.0; color: Qt.lighter(palette.button) } + GradientStop { id: gradientStop2; position: 1.0; color: palette.button } } Text { id: label; anchors.centerIn: parent; color: palette.buttonText } @@ -29,13 +29,13 @@ Rectangle { states: [ State { name: "Pressed"; when: clickRegion.pressed == true - PropertyChanges { target: G1; color: palette.dark } - PropertyChanges { target: G2; color: palette.button } + PropertyChanges { target: gradientStop1; color: palette.dark } + PropertyChanges { target: gradientStop2; color: palette.button } }, State { name: "Toggled"; when: button.toggled == true - PropertyChanges { target: G1; color: palette.dark } - PropertyChanges { target: G2; color: palette.button } + PropertyChanges { target: gradientStop1; color: palette.dark } + PropertyChanges { target: gradientStop2; color: palette.button } } ] } diff --git a/demos/declarative/flickr/flickr-desktop.qml b/demos/declarative/flickr/flickr-desktop.qml index 10babeb..4e3b6cb 100644 --- a/demos/declarative/flickr/flickr-desktop.qml +++ b/demos/declarative/flickr/flickr-desktop.qml @@ -57,7 +57,7 @@ Item { id: shadows Image { source: "common/pics/shadow-right.png"; x: whiteRect.width; height: whiteRect.height } Image { source: "common/pics/shadow-bottom.png"; y: whiteRect.height; width: whiteRect.width } - Image { id: Corner; source: "common/pics/shadow-corner.png"; x: whiteRect.width; y: whiteRect.height } + Image { id: corner; source: "common/pics/shadow-corner.png"; x: whiteRect.width; y: whiteRect.height } } } diff --git a/demos/declarative/twitter/content/FatDelegate.qml b/demos/declarative/twitter/content/FatDelegate.qml index 23b4838..2b9288b 100644 --- a/demos/declarative/twitter/content/FatDelegate.qml +++ b/demos/declarative/twitter/content/FatDelegate.qml @@ -1,7 +1,7 @@ import Qt 4.6 Component { - id: ListDelegate + id: listDelegate Item { id: wrapper; width: wrapper.ListView.view.width; height: if(txt.height > 58){txt.height+8}else{58}//50+4+4 Script { diff --git a/doc/src/declarative/advtutorial2.qdoc b/doc/src/declarative/advtutorial2.qdoc index dcc7c70..2aa68f3 100644 --- a/doc/src/declarative/advtutorial2.qdoc +++ b/doc/src/declarative/advtutorial2.qdoc @@ -48,7 +48,7 @@ first thing to do is to generate all of the blocks. Now we need to dynamically generate all of these blocks, because you have a new, random set of blocks every time. As they are dynamically generated every time the new game button is clicked, as opposed to on startup, we will be dynamically generating the blocks -in the ECMAScript, as opposed to using a \l Repeater. +in the JavaScript, as opposed to using a \l Repeater. This adds enough script to justify a new file, \c{samegame.js}, the intial version of which is shown below @@ -62,7 +62,7 @@ The \c createBlock function is a lot bigger, and I'll explain it block by block. First we ensure that the component has been constructed. QML elements, including composite ones like the \c Block.qml that we've written, are never created directly in script. While there is a function to parse and create an arbitrary QML string, in the case where you are repeatedly creating the same item you will want to use the \c createComponent function. \c createComponent is -a built-in function in the declarative ECMAScript, and returns a component object. +a built-in function in the declarative JavaScript, and returns a component object. A component object prepares and stores a QML element (usually a composite element) for easy and efficient use. When the component is ready, you can create a new instance of the loaded QML with the \c createObject method. If the component is loaded remotely (over HTTP for example) then you will have to wait for the component to finish loading diff --git a/doc/src/declarative/anchor-layout.qdoc b/doc/src/declarative/anchor-layout.qdoc index 4766236..2bd0ec5 100644 --- a/doc/src/declarative/anchor-layout.qdoc +++ b/doc/src/declarative/anchor-layout.qdoc @@ -87,8 +87,8 @@ By specifying multiple horizontal or vertical anchors you can control the size o \code Rectangle { id: rect1; x: 0; ... } -Rectangle { id: rect2; anchors.left: rect1.right; anchors.right: Rect3.left; ... } -Rectangle { id: Rect3; x: 150; ... } +Rectangle { id: rect2; anchors.left: rect1.right; anchors.right: rect3.left; ... } +Rectangle { id: rect3; x: 150; ... } \endcode \image edge4.png @@ -99,11 +99,11 @@ For performance reasons, you can only anchor an item to its siblings and direct \badcode Item { - id: Group1 + id: group1 Rectangle { id: rect1; ... } } Item { - id: Group2 + id: group2 Rectangle { id: rect2; anchors.left: rect1.right; ... } // invalid anchor! } \endcode diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc index ae64361..8228c11 100644 --- a/doc/src/declarative/declarativeui.qdoc +++ b/doc/src/declarative/declarativeui.qdoc @@ -55,8 +55,8 @@ language, and a rich set of \l {QML Elements}{QML elements} that can be used from QML. QML is an extension to \l {http://www.ecma-international.org/publications/standards/Ecma-262.htm} -{ECMAScript}, that provides a mechanism to declaratively build an object tree -of QML elements. QML improves the integration between ECMAScript and Qt's +{JavaScript}, that provides a mechanism to declaratively build an object tree +of QML elements. QML improves the integration between JavaScript and Qt's existing QObject based type system, adds support for automatic \l {Property Binding}{property bindings} and provides \l {Network Transparency}{network transparency} at the language level. @@ -83,7 +83,7 @@ completely new applications. QML is fully \l {Extending QML}{extensible from C+ \list \o \l {QML Documents} \o \l {Property Binding} -\o \l {ECMAScript Blocks} +\o \l {JavaScript Blocks} \o \l {QML Scope} \o \l {Network Transparency} \o \l {Data Models} diff --git a/doc/src/declarative/dynamicobjects.qdoc b/doc/src/declarative/dynamicobjects.qdoc index c8ea981..fede2cd 100644 --- a/doc/src/declarative/dynamicobjects.qdoc +++ b/doc/src/declarative/dynamicobjects.qdoc @@ -44,13 +44,13 @@ \title Dynamic Object Creation QML has some support for dynamically loading and managing QML objects from -within ECMAscript blocks. It is preferable to use the existing QML elements for +within Javascript blocks. It is preferable to use the existing QML elements for dynamic object management wherever possible; these are \l{Loader}, \l{Repeater}, \l{ListView}, \l{GridView} and \l{PathView}. It is also possible to dynamically create and manage objects from C++, and this is preferable for hybrid QML/C++ applications - see \l{Using QML in C++ Applications}. Dynamically creating and managing objects from -within ECMAscript blocks is intended for when none of the existing QML elements +within Javascript blocks is intended for when none of the existing QML elements fit the needs of your application, and you do not desire for your application to involve C++ code. diff --git a/doc/src/declarative/example-slideswitch.qdoc b/doc/src/declarative/example-slideswitch.qdoc index 492a8ea..41a8574 100644 --- a/doc/src/declarative/example-slideswitch.qdoc +++ b/doc/src/declarative/example-slideswitch.qdoc @@ -108,7 +108,7 @@ For more information on states see \l{qmlstates}{QML States}. \section2 Functions -We add two ECMAScript functions to our switch: +We add two JavaScript functions to our switch: \snippet examples/declarative/slideswitch/content/Switch.qml 2 @@ -121,7 +121,7 @@ states (\e on and \e off). This second function is called when the knob is released and we want to make sure that the knob does not end up between states (neither \e on nor \e off). If it is the case call the \c toggle() function otherwise we do nothing. -For more information on scripts see \l{qmlecmascript.html}{ECMAScript Blocks}. +For more information on scripts see \l{qmlecmascript.html}{JavaScript Blocks}. \section2 Transition \snippet examples/declarative/slideswitch/content/Switch.qml 7 diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc index 893838f..42b054f 100644 --- a/doc/src/declarative/extending.qdoc +++ b/doc/src/declarative/extending.qdoc @@ -380,11 +380,11 @@ implement the rsvp attached property. \snippet examples/declarative/extending/signal/example.qml 0 \snippet examples/declarative/extending/signal/example.qml 1 -The QML snippet shown above associates the evaluation of a ECMAScript expression +The QML snippet shown above associates the evaluation of a JavaScript expression with the emission of a Qt signal. All Qt signals on a registered class become available as special "signal -properties" within QML to which the user can assign a single ECMAScript +properties" within QML to which the user can assign a single JavaScript expression. The signal property's name is a transformed version of the Qt signal name: "on" is prepended, and the first letter of the signal name upper cased. For example, the signal used in the example above has the following @@ -464,7 +464,7 @@ HappyBirthday's name property remains up to date with the celebrant. Property binding is a core feature of QML. In addition to assigning literal values, property bindings allow the developer to assign an arbitrarily complex -ECMAScript expression that may include dependencies on other property values. +JavaScript expression that may include dependencies on other property values. Whenever the expression's result changes - through a change in one of its constituent values - the expression is automatically reevaluated and the new result assigned to the property. diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc index b26f223..764552a 100644 --- a/doc/src/declarative/globalobject.qdoc +++ b/doc/src/declarative/globalobject.qdoc @@ -43,7 +43,7 @@ \page qmlglobalobject.html \title QML Global Object -Contains all the properties of the ECMAScript global object, plus: +Contains all the properties of the JavaScript global object, plus: \tableofcontents diff --git a/doc/src/declarative/ecmascriptblocks.qdoc b/doc/src/declarative/javascriptblocks.qdoc index 749111f..9c72a9c 100644 --- a/doc/src/declarative/ecmascriptblocks.qdoc +++ b/doc/src/declarative/javascriptblocks.qdoc @@ -40,23 +40,23 @@ ****************************************************************************/ /*! -\page qmlecmascript.html -\title ECMAScript Blocks +\page qmljavascript.html +\title JavaScript Blocks QML encourages building UIs declaratively, using \l {Property Binding} and the composition of existing \l {QML Elements}. If imperative code is required to implement -more advanced behavior, the \l Script element can be used to add ECMAScript code directly -to a QML file, or to include an external ECMAScript file. +more advanced behavior, the \l Script element can be used to add JavaScript code directly +to a QML file, or to include an external JavaScript file. The \l Script element is a QML language \e intrinsic. It can be used anywhere in a QML file, \e except as the root element of a file or sub-component, but cannot be -assigned to an object property or given an id. The included ECMAScript is evaluated +assigned to an object property or given an id. The included JavaScript is evaluated in a scope chain. The \l {QML Scope} documentation covers the specifics of scoping in QML. -A restriction on the ECMAScript used in QML is that you cannot add new members to the +A restriction on the JavaScript used in QML is that you cannot add new members to the global object. This happens transparently when you try to use a variable without -declaring it, and so declaring local variables is required when using ECMA script in +declaring it, and so declaring local variables is required when using Java script in QML. The global object in QML has a variety of helper functions added to it, to aid UI @@ -68,7 +68,7 @@ you do not need the \l Script element. See \l {Extending types from QML#Adding n \section1 Inline Script -Small blocks of ECMAScript can be included directly inside a \l {QML Document} as +Small blocks of JavaScript can be included directly inside a \l {QML Document} as the body of the \l Script element. \code @@ -129,7 +129,7 @@ until the script has been retrieved. \section1 Running Script at Startup -It is occasionally necessary to run a block of ECMAScript code at application (or +It is occasionally necessary to run a block of JavaScript code at application (or component instance) "startup". While it is tempting to just include the startup script as \e {global code} in an external script file, this can have severe limitations as the QML environment may not have been fully established. For example, some objects @@ -160,7 +160,7 @@ execute at startup, they are run sequentially in an undefined order. \section1 QML Script Restrictions -QML \l Script blocks contain standard ECMAScript code. QML introduces the following +QML \l Script blocks contain standard JavaScript code. QML introduces the following restrictions. \list @@ -169,8 +169,8 @@ restrictions. In QML, the global object is constant - existing properties cannot be modified or deleted, and no new properties may be created. -Most ECMAScript programs do not explicitly modify the global object. However, -ECMAScript's automatic creation of undeclared variables is an implicit modification +Most JavaScript programs do not explicitly modify the global object. However, +JavaScript's automatic creation of undeclared variables is an implicit modification of the global object, and is prohibited in QML. Assuming that the \c a variable does not exist in the scope chain, the following code diff --git a/doc/src/declarative/propertybinding.qdoc b/doc/src/declarative/propertybinding.qdoc index 8d0ffa9..ad4f13e 100644 --- a/doc/src/declarative/propertybinding.qdoc +++ b/doc/src/declarative/propertybinding.qdoc @@ -44,11 +44,11 @@ \title Property Binding Property binding is a declarative way of specifying the value of a property. Binding allows -a property's value to be expressed as an ECMAScript expression that defines the value relative +a property's value to be expressed as an JavaScript expression that defines the value relative to other property values or data accessible in the application. The property value is automatically kept up to date if the other properties or data values change. -Property bindings are created implicitly in QML whenever a property is assigned an ECMAScript +Property bindings are created implicitly in QML whenever a property is assigned an JavaScript expression. The following QML uses two property bindings to connect the size of the rectangle to that of \c otherItem. @@ -59,10 +59,10 @@ Rectangle { } \endcode -QML extends a standards compliant ECMAScript engine, so any valid ECMAScript expression can be +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 builtin ECMAScript objects like \e {Date} and \e {Math}. Assigning a constant value to a -property can even be thought of as a binding - afterall, a constant is a valid ECMAScript +use builtin JavaScript objects like \e {Date} and \e {Math}. Assigning a constant value to a +property can even be thought of as a binding - afterall, a constant is a valid JavaScript expression! Here are some examples of more complex bindings: \code @@ -80,7 +80,7 @@ Rectangle { } \endcode -Being ECMAScript expressions, bindings are evaluated in a scope chain. The \l {QML Scope} +Being JavaScript expressions, bindings are evaluated in a scope chain. The \l {QML Scope} documentation covers the specifics of scoping in QML. \list diff --git a/doc/src/declarative/qmldocument.qdoc b/doc/src/declarative/qmldocument.qdoc index 453c023..deb6e1c 100644 --- a/doc/src/declarative/qmldocument.qdoc +++ b/doc/src/declarative/qmldocument.qdoc @@ -83,7 +83,7 @@ modifies the document prior to presentation to the QML runtime. \c import statem do not "include" code in the document, but instead instruct the QML runtime on how to resolve type references found in the document. Any type reference present in a QML document - such as \c Rectangle and \c ListView - including those made within an -\l {ECMAScript Block} or \l {Property Binding}s, are \e resolved based exclusively on the +\l {JavaScript Block} or \l {Property Binding}s, are \e resolved based exclusively on the import statements. QML does not import any modules by default, so at least one \c import statement must be present or no elements will be available! diff --git a/doc/src/declarative/qmlintro.qdoc b/doc/src/declarative/qmlintro.qdoc index 8141c90..3891515 100644 --- a/doc/src/declarative/qmlintro.qdoc +++ b/doc/src/declarative/qmlintro.qdoc @@ -192,22 +192,29 @@ Item { \section3 The \c id property -The \c id property is a special property of type \e id. Assigning an id to an object allows you -to refer to it elsewhere. +Each object can be given a special unique property called an \e id. Assigning an id enables the object +to be referred to by other objects and scripts. + +The first Rectangle element below has an \e id, "myRect". The second Rectange element defines its +own width by referring to \tt myRect.width, which means it will have the same \tt width +value as the first Rectangle element. \code Item { - Text { - id: myName - text: "..." + Rectangle { + id: myRect + width: 100 + height: 100 } - Text { - text: myName.text + Rectangle { + width: myRect.width + height: 200 } } \endcode -\c Ids must begin with a lowercase letter. +Note that an \e id must begin with a lower-case letter or an underscore, and cannot contain characters other than letters, numbers and underscores. + \section2 List properties diff --git a/doc/src/declarative/qmlmodels.qdoc b/doc/src/declarative/qmlmodels.qdoc index 322f225..4115e8d 100644 --- a/doc/src/declarative/qmlmodels.qdoc +++ b/doc/src/declarative/qmlmodels.qdoc @@ -169,11 +169,58 @@ will be positioned by the view. \section1 C++ Data Models -\list -\o QAbstractItemModel provides the roles set via the QAbstractItemModel::setRoleNames() method. -\o QStringList provides the contents of the list via the \e modelData role. -\o QList<QObject*> provides the properties of the objects in the list as roles. -\endlist +\section2 QAbstractItemModel + +QAbstractItemModel provides the roles set via the QAbstractItemModel::setRoleNames() method. + + +\section2 QStringList + +QStringList provides the contents of the list via the \e modelData role. + + +\section2 QList<QObject*> + +QList<QObject*> provides the properties of the objects in the list as roles. + +\code +class DataObject : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(QString color READ color WRITE setColor) +... +}; + +QList<QObject*> 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")); + +QmlContext *ctxt = view.rootContext(); +ctxt->setContextProperty("myModel", QVariant::fromValue(&dataList)); +\endcode + +The properties of the object may then be accessed in the delegate: + +\code +ListView { + width: 100 + height: 100 + anchors.fill: parent + model: myModel + delegate: Component { + Rectangle { + height: 25 + width: 100 + color: model.color + Text { text: name } + } + } +} +\endcode \section1 Other Data Models diff --git a/doc/src/declarative/qmlreference.qdoc b/doc/src/declarative/qmlreference.qdoc index 614bc18..a413c22 100644 --- a/doc/src/declarative/qmlreference.qdoc +++ b/doc/src/declarative/qmlreference.qdoc @@ -74,7 +74,7 @@ \list \o \l {QML Documents} \o \l {Property Binding} - \o \l {ECMAScript Blocks} + \o \l {JavaScript Blocks} \o \l {QML Scope} \o \l {Network Transparency} \o \l {qmlmodels}{Data Models} diff --git a/doc/src/declarative/qtbinding.qdoc b/doc/src/declarative/qtbinding.qdoc index 68723bf..2909f2e 100644 --- a/doc/src/declarative/qtbinding.qdoc +++ b/doc/src/declarative/qtbinding.qdoc @@ -91,7 +91,7 @@ the root context is available to all object instances. To expose data to a QML component instance, applications set \l {QmlContext::setContextProperty()} {context properties} which are then accessible by name from QML \l {Property Binding}s and -\l {ECMAScript Blocks}. The following example shows how to expose a background color to a QML +\l {JavaScript Blocks}. The following example shows how to expose a background color to a QML file. \table diff --git a/doc/src/declarative/scope.qdoc b/doc/src/declarative/scope.qdoc index ef30f94..defb217 100644 --- a/doc/src/declarative/scope.qdoc +++ b/doc/src/declarative/scope.qdoc @@ -45,16 +45,16 @@ \tableofcontents -\l {Property Binding}s and \l {ECMAScript Blocks} are executed in a scope chain automatically +\l {Property Binding}s and \l {JavaScript Blocks} are executed in a scope chain automatically established by QML when a component instance is constructed. QML is a \e {dynamically scoped} language. Different object instances instantiated from the same component can exist in different scope chains. \image qml-scope.png -\section1 ECMAScript Variable object +\section1 JavaScript Variable object -Each binding and script block has its own distinct ECMAScript variable object where local +Each binding and script block has its own distinct JavaScript variable object where local variables are stored. That is, local variables from different bindings and script blocks never conflict. @@ -375,6 +375,6 @@ Rectangle { \section1 QML Global Object -The \l {QML Global Object} contains all the properties of the ECMAScript global object, plus some +The \l {QML Global Object} contains all the properties of the JavaScript global object, plus some QML specific extensions. */ diff --git a/doc/src/examples/svgalib.qdoc b/doc/src/examples/svgalib.qdoc index 9142112..cf6512c 100644 --- a/doc/src/examples/svgalib.qdoc +++ b/doc/src/examples/svgalib.qdoc @@ -43,6 +43,9 @@ \example qws/svgalib \title Accelerated Graphics Driver Example + \warning This example was designed to work with Qt 4.4 and will not work + with current versions of Qt. It will be removed from Qt 4.7. + The Accelerated Graphics Driver example shows how you can write your own accelerated graphics driver and \l {add your graphics driver to Qt for Embedded Linux}. In \l{Qt for Embedded Linux}, diff --git a/doc/src/getting-started/examples.qdoc b/doc/src/getting-started/examples.qdoc index 6b4ec61..0c18773 100644 --- a/doc/src/getting-started/examples.qdoc +++ b/doc/src/getting-started/examples.qdoc @@ -406,7 +406,7 @@ \clearfloat \section1 \l{D-Bus Examples}{D-Bus} \beginfloatleft - \l{D-Bus Examples}{\inlineimage qt-embedded-examples.png + \l{D-Bus Examples}{\inlineimage dbus-examples.png } \endfloat @@ -416,7 +416,7 @@ \clearfloat \section1 \l{Qt for Embedded Linux Examples}{Qt for Embedded Linux} \beginfloatleft - \l{Qt for Embedded Linux Examples}{\inlineimage dbus-examples.png + \l{Qt for Embedded Linux Examples}{\inlineimage qt-embedded-examples.png } \endfloat diff --git a/doc/src/platforms/emb-install.qdoc b/doc/src/platforms/emb-install.qdoc index c13fbef..623ba89 100644 --- a/doc/src/platforms/emb-install.qdoc +++ b/doc/src/platforms/emb-install.qdoc @@ -84,7 +84,9 @@ Before building the \l{Qt for Embedded Linux} library, run the \c ./configure script to configure the library for your development architecture. You can list all of the configuration system's - options by typing \c {./configure -help}. + options by typing + + \snippet doc/src/snippets/code/doc_src_emb-install.qdoc embedded help Note that by default, \l{Qt for Embedded Linux} is configured for installation in the \c{/usr/local/Trolltech/QtEmbedded-%VERSION%} diff --git a/doc/src/snippets/code/doc_src_emb-install.qdoc b/doc/src/snippets/code/doc_src_emb-install.qdoc index 60775d2..f24f087 100644 --- a/doc/src/snippets/code/doc_src_emb-install.qdoc +++ b/doc/src/snippets/code/doc_src_emb-install.qdoc @@ -41,18 +41,22 @@ //! [0] cd <anywhere> -gunzip qt-embedded-linux-commercial-src-%VERSION%.tar.gz -tar xf qt-embedded-linux-commercial-src-%VERSION%.tar +gunzip qt-everywhere-opensource-src-%VERSION%.tar.gz +tar xf qt-everywhere-opensource-src-%VERSION%.tar //! [0] //! [1] -~/qt-embedded-linux-commercial-src-%VERSION% +~/qt-everywhere-opensource-src-%VERSION% //! [1] +//! [embedded help] +./configure -embedded -help +//! [embedded help] + //! [2] -cd ~/qt-embedded-linux-commercial-src-%VERSION% +cd ~/qt-everywhere-opensource-src-%VERSION% ./configure -embedded [architecture] //! [2] diff --git a/doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp b/doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp index 483c675..4f27661 100644 --- a/doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp +++ b/doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp @@ -260,3 +260,14 @@ class CustomItem : public QGraphicsItem ... }; //! [QGraphicsItem type] + +//! [18] +class QGraphicsPathItem : public QAbstractGraphicsShapeItem +{ + public: + enum { Type = 2 }; + int type() const { return Type; } + ... +}; +//! [18] + diff --git a/doc/src/snippets/declarative/listview/dummydata/ContactModel.qml b/doc/src/snippets/declarative/listview/dummydata/ContactModel.qml index 31e02ea..6832308 100644 --- a/doc/src/snippets/declarative/listview/dummydata/ContactModel.qml +++ b/doc/src/snippets/declarative/listview/dummydata/ContactModel.qml @@ -1,7 +1,7 @@ import Qt 4.6 ListModel { - id: ContactModel + id: contactModel ListElement { name: "Bill Smith" number: "555 3264" diff --git a/doc/src/snippets/declarative/pathview/dummydata/MenuModel.qml b/doc/src/snippets/declarative/pathview/dummydata/MenuModel.qml index 20b3b7d..1334cf4 100644 --- a/doc/src/snippets/declarative/pathview/dummydata/MenuModel.qml +++ b/doc/src/snippets/declarative/pathview/dummydata/MenuModel.qml @@ -1,7 +1,7 @@ import Qt 4.6 ListModel { - id: MenuModel + id: menuModel ListElement { name: "Bill Jones" icon: "pics/qtlogo-64.png" diff --git a/doc/src/windows-and-dialogs/mainwindow.qdoc b/doc/src/windows-and-dialogs/mainwindow.qdoc index ea8411f..6adfa75 100644 --- a/doc/src/windows-and-dialogs/mainwindow.qdoc +++ b/doc/src/windows-and-dialogs/mainwindow.qdoc @@ -51,7 +51,7 @@ \nextpage The Application Main Window - A \l{Widgets}{widget} that is not embedded in a parent widget is called a window. + A \l{Widgets Tutorial}{widget} that is not embedded in a parent widget is called a window. Usually, windows have a frame and a title bar, although it is also possible to create windows without such decoration using suitable window flags). In Qt, QMainWindow and the various subclasses of QDialog are the most common window types. diff --git a/examples/declarative/listview/dummydata/MyPetsModel.qml b/examples/declarative/listview/dummydata/MyPetsModel.qml index 074fc13..1ac37bb 100644 --- a/examples/declarative/listview/dummydata/MyPetsModel.qml +++ b/examples/declarative/listview/dummydata/MyPetsModel.qml @@ -1,9 +1,9 @@ import Qt 4.6 // ListModel allows free form list models to be defined and populated. -// Be sure to name the file the same as the id. + ListModel { - id: MyListElementsModel + id: petsModel ListElement { name: "Polly" type: "Parrot" diff --git a/examples/declarative/listview/dummydata/Recipes.qml b/examples/declarative/listview/dummydata/Recipes.qml index 533730f..68e94ac 100644 --- a/examples/declarative/listview/dummydata/Recipes.qml +++ b/examples/declarative/listview/dummydata/Recipes.qml @@ -1,7 +1,7 @@ import Qt 4.6 ListModel { - id: Recipes + id: recipesModel ListElement { title: "Pancakes" picture: "content/pics/pancakes.jpg" diff --git a/examples/declarative/listview/sections.qml b/examples/declarative/listview/sections.qml index 6e72ce7..877026b 100644 --- a/examples/declarative/listview/sections.qml +++ b/examples/declarative/listview/sections.qml @@ -42,7 +42,7 @@ Rectangle { } // The list ListView { - id: List + id: myList width: 200 height: parent.height model: MyPetsModel diff --git a/examples/declarative/objectlistmodel/dataobject.cpp b/examples/declarative/objectlistmodel/dataobject.cpp new file mode 100644 index 0000000..da85fe2 --- /dev/null +++ b/examples/declarative/objectlistmodel/dataobject.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QDebug> +#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) +{ + m_name = name; +} + +QString DataObject::color() const +{ + return m_color; +} + +void DataObject::setColor(const QString &color) +{ + m_color = color; +} diff --git a/examples/declarative/objectlistmodel/dataobject.h b/examples/declarative/objectlistmodel/dataobject.h new file mode 100644 index 0000000..c0aa159 --- /dev/null +++ b/examples/declarative/objectlistmodel/dataobject.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef DATAOBJECT_H +#define DATAOBJECT_H + +#include <QObject> + +class DataObject : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(QString color READ color WRITE setColor) + +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); + +private: + QString m_name; + QString m_color; +}; + +#endif // DATAOBJECT_H diff --git a/examples/declarative/objectlistmodel/main.cpp b/examples/declarative/objectlistmodel/main.cpp new file mode 100644 index 0000000..3f2ac6d --- /dev/null +++ b/examples/declarative/objectlistmodel/main.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QApplication> + +#include <qmlengine.h> +#include <qmlcontext.h> +#include <qml.h> +#include <qmlgraphicsitem.h> +#include <qmlview.h> + +#include "dataobject.h" + +/* + This example illustrates exposing a QList<QObject*> as a + model in QML +*/ + +int main(int argc, char ** argv) +{ + QApplication app(argc, argv); + + QmlView view; + view.setUrl(QUrl("qrc:view.qml")); + + QList<QObject*> 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")); + + QmlContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", QVariant::fromValue(&dataList)); + + view.execute(); + view.show(); + + return app.exec(); +} + diff --git a/examples/declarative/objectlistmodel/objectlistmodel.pro b/examples/declarative/objectlistmodel/objectlistmodel.pro new file mode 100644 index 0000000..ca61e4c --- /dev/null +++ b/examples/declarative/objectlistmodel/objectlistmodel.pro @@ -0,0 +1,11 @@ +TEMPLATE = app +TARGET = objectlistmodel +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative + +# Input +SOURCES += main.cpp \ + dataobject.cpp +HEADERS += dataobject.h +RESOURCES += objectlistmodel.qrc diff --git a/examples/declarative/objectlistmodel/objectlistmodel.qrc b/examples/declarative/objectlistmodel/objectlistmodel.qrc new file mode 100644 index 0000000..17e9301 --- /dev/null +++ b/examples/declarative/objectlistmodel/objectlistmodel.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>view.qml</file> +</qresource> +</RCC> diff --git a/examples/declarative/objectlistmodel/view.qml b/examples/declarative/objectlistmodel/view.qml new file mode 100644 index 0000000..5f5e415 --- /dev/null +++ b/examples/declarative/objectlistmodel/view.qml @@ -0,0 +1,16 @@ +import Qt 4.6 + +ListView { + width: 100 + height: 100 + anchors.fill: parent + model: myModel + delegate: Component { + Rectangle { + height: 25 + width: 100 + color: model.color + Text { text: name } + } + } +} diff --git a/examples/declarative/tutorials/samegame/samegame1/Button.qml b/examples/declarative/tutorials/samegame/samegame1/Button.qml index 9792a22..85e6777 100644 --- a/examples/declarative/tutorials/samegame/samegame1/Button.qml +++ b/examples/declarative/tutorials/samegame/samegame1/Button.qml @@ -2,7 +2,7 @@ import Qt 4.6 Rectangle { - id: Container + id: container signal clicked property string text: "Button" @@ -18,10 +18,10 @@ Rectangle { GradientStop { position: 1.0; color: activePalette.button } } - MouseRegion { id: mr; anchors.fill: parent; onClicked: Container.clicked() } + MouseRegion { id: mr; anchors.fill: parent; onClicked: container.clicked() } Text { - id: txtItem; text: Container.text; anchors.centerIn: Container; color: activePalette.buttonText + id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText } } //![0] diff --git a/examples/declarative/tutorials/samegame/samegame1/samegame.qml b/examples/declarative/tutorials/samegame/samegame1/samegame.qml index fad2175..c2d3939 100644 --- a/examples/declarative/tutorials/samegame/samegame1/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame1/samegame.qml @@ -2,13 +2,13 @@ import Qt 4.6 Rectangle { - id: Screen + id: screen width: 490; height: 720 SystemPalette { id: activePalette } Item { - width: parent.width; anchors.top: parent.top; anchors.bottom: ToolBar.top + width: parent.width; anchors.top: parent.top; anchors.bottom: toolbar.top Image { id: background @@ -18,10 +18,10 @@ Rectangle { } Rectangle { - id: ToolBar + id: toolbar color: activePalette.window height: 32; width: parent.width - anchors.bottom: Screen.bottom + anchors.bottom: screen.bottom Button { id: btnA; text: "New Game"; onClicked: console.log("Implement me!"); @@ -30,7 +30,7 @@ Rectangle { } Text { - id: Score + id: score text: "Score: Who knows?"; font.bold: true anchors.right: parent.right; anchors.rightMargin: 3 anchors.verticalCenter: parent.verticalCenter diff --git a/examples/declarative/tutorials/samegame/samegame2/Button.qml b/examples/declarative/tutorials/samegame/samegame2/Button.qml index 9e515e0..63cd555 100644 --- a/examples/declarative/tutorials/samegame/samegame2/Button.qml +++ b/examples/declarative/tutorials/samegame/samegame2/Button.qml @@ -1,7 +1,7 @@ import Qt 4.6 Rectangle { - id: Container + id: container signal clicked property string text: "Button" @@ -17,9 +17,9 @@ Rectangle { GradientStop { position: 1.0; color: activePalette.button } } - MouseRegion { id: mr; anchors.fill: parent; onClicked: Container.clicked() } + MouseRegion { id: mr; anchors.fill: parent; onClicked: container.clicked() } Text { - id: txtItem; text: Container.text; anchors.centerIn: Container; color: activePalette.buttonText + id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText } } diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.qml b/examples/declarative/tutorials/samegame/samegame2/samegame.qml index e0e467a..8d837da 100644 --- a/examples/declarative/tutorials/samegame/samegame2/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame2/samegame.qml @@ -1,7 +1,7 @@ import Qt 4.6 Rectangle { - id: Screen + id: screen width: 490; height: 720 SystemPalette { id: activePalette } @@ -10,7 +10,7 @@ Rectangle { //![2] Item { - width: parent.width; anchors.top: parent.top; anchors.bottom: ToolBar.top + width: parent.width; anchors.top: parent.top; anchors.bottom: toolbar.top Image { id: background @@ -20,10 +20,10 @@ Rectangle { } Rectangle { - id: ToolBar + id: toolbar color: activePalette.window height: 32; width: parent.width - anchors.bottom: Screen.bottom + anchors.bottom: screen.bottom //![1] Button { @@ -34,7 +34,7 @@ Rectangle { //![1] Text { - id: Score + id: score text: "Score: Who knows?"; font.bold: true anchors.right: parent.right; anchors.rightMargin: 3 anchors.verticalCenter: parent.verticalCenter diff --git a/examples/declarative/tutorials/samegame/samegame3/Button.qml b/examples/declarative/tutorials/samegame/samegame3/Button.qml index 9e515e0..63cd555 100644 --- a/examples/declarative/tutorials/samegame/samegame3/Button.qml +++ b/examples/declarative/tutorials/samegame/samegame3/Button.qml @@ -1,7 +1,7 @@ import Qt 4.6 Rectangle { - id: Container + id: container signal clicked property string text: "Button" @@ -17,9 +17,9 @@ Rectangle { GradientStop { position: 1.0; color: activePalette.button } } - MouseRegion { id: mr; anchors.fill: parent; onClicked: Container.clicked() } + MouseRegion { id: mr; anchors.fill: parent; onClicked: container.clicked() } Text { - id: txtItem; text: Container.text; anchors.centerIn: Container; color: activePalette.buttonText + id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText } } diff --git a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml index 5fe6aa0..96dc246 100644 --- a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml +++ b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml @@ -8,16 +8,16 @@ Rectangle { page.opacity = 0; } function show(txt) { - MyText.text = txt; + myText.text = txt; page.opacity = 1; } signal closed(); - color: "white"; border.width: 1; width: MyText.width + 20; height: 60; + color: "white"; border.width: 1; width: myText.width + 20; height: 60; opacity: 0 opacity: Behavior { NumberAnimation { duration: 1000 } } - Text { id: MyText; anchors.centerIn: parent; text: "Hello World!" } + Text { id: myText; anchors.centerIn: parent; text: "Hello World!" } MouseRegion { id: mr; anchors.fill: parent; onClicked: forceClose(); } } //![0] diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.qml b/examples/declarative/tutorials/samegame/samegame3/samegame.qml index e1eb542..8bdb428 100644 --- a/examples/declarative/tutorials/samegame/samegame3/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame3/samegame.qml @@ -2,14 +2,14 @@ import Qt 4.6 Rectangle { - id: Screen + id: screen width: 490; height: 720 SystemPalette { id: activePalette } Script { source: "samegame.js" } Item { - width: parent.width; anchors.top: parent.top; anchors.bottom: ToolBar.top + width: parent.width; anchors.top: parent.top; anchors.bottom: toolbar.top Image { id: background @@ -40,10 +40,10 @@ Rectangle { //![2] Rectangle { - id: ToolBar + id: toolbar color: activePalette.window height: 32; width: parent.width - anchors.bottom: Screen.bottom + anchors.bottom: screen.bottom Button { id: btnA; text: "New Game"; onClicked: initBoard(); @@ -52,7 +52,7 @@ Rectangle { } Text { - id: Score + id: score text: "Score: " + gameCanvas.score; font.bold: true anchors.right: parent.right; anchors.rightMargin: 3 anchors.verticalCenter: parent.verticalCenter diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Button.qml b/examples/declarative/tutorials/samegame/samegame4/content/Button.qml index 9e515e0..63cd555 100644 --- a/examples/declarative/tutorials/samegame/samegame4/content/Button.qml +++ b/examples/declarative/tutorials/samegame/samegame4/content/Button.qml @@ -1,7 +1,7 @@ import Qt 4.6 Rectangle { - id: Container + id: container signal clicked property string text: "Button" @@ -17,9 +17,9 @@ Rectangle { GradientStop { position: 1.0; color: activePalette.button } } - MouseRegion { id: mr; anchors.fill: parent; onClicked: Container.clicked() } + MouseRegion { id: mr; anchors.fill: parent; onClicked: container.clicked() } Text { - id: txtItem; text: Container.text; anchors.centerIn: Container; color: activePalette.buttonText + id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText } } diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml index 401d211..3371d53 100644 --- a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml +++ b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml @@ -7,15 +7,15 @@ Rectangle { page.opacity = 0; } function show(txt) { - MyText.text = txt; + myText.text = txt; page.opacity = 1; } signal closed(); - color: "white"; border.width: 1; width: MyText.width + 20; height: 60; + color: "white"; border.width: 1; width: myText.width + 20; height: 60; opacity: 0 opacity: Behavior { NumberAnimation { duration: 1000 } } - Text { id: MyText; anchors.centerIn: parent; text: "Hello World!" } + Text { id: myText; anchors.centerIn: parent; text: "Hello World!" } MouseRegion { id: mr; anchors.fill: parent; onClicked: forceClose(); } } diff --git a/examples/network/googlesuggest/googlesuggest.cpp b/examples/network/googlesuggest/googlesuggest.cpp index 79bc448..0c85773 100644 --- a/examples/network/googlesuggest/googlesuggest.cpp +++ b/examples/network/googlesuggest/googlesuggest.cpp @@ -231,4 +231,5 @@ void GSuggestCompletion::handleNetworkData(QNetworkReply *networkReply) networkReply->deleteLater(); } -//! [9]
\ No newline at end of file +//! [9] + diff --git a/examples/network/googlesuggest/searchbox.cpp b/examples/network/googlesuggest/searchbox.cpp index 69dc20e..8ef6f00 100644 --- a/examples/network/googlesuggest/searchbox.cpp +++ b/examples/network/googlesuggest/searchbox.cpp @@ -69,4 +69,5 @@ void SearchBox::doSearch() QString url = QString(GSEARCH_URL).arg(text()); QDesktopServices::openUrl(QUrl(url)); } -//! [2]
\ No newline at end of file +//! [2] + diff --git a/examples/network/network-chat/chatdialog.cpp b/examples/network/network-chat/chatdialog.cpp index d8bcb30..da65270 100644 --- a/examples/network/network-chat/chatdialog.cpp +++ b/examples/network/network-chat/chatdialog.cpp @@ -79,7 +79,7 @@ void ChatDialog::appendMessage(const QString &from, const QString &message) QTextCursor cursor(textEdit->textCursor()); cursor.movePosition(QTextCursor::End); QTextTable *table = cursor.insertTable(1, 2, tableFormat); - table->cellAt(0, 0).firstCursorPosition().insertText("<" + from + "> "); + table->cellAt(0, 0).firstCursorPosition().insertText('<' + from + "> "); table->cellAt(0, 1).firstCursorPosition().insertText(message); QScrollBar *bar = textEdit->verticalScrollBar(); bar->setValue(bar->maximum()); diff --git a/examples/network/network-chat/client.cpp b/examples/network/network-chat/client.cpp index 2b8725c..f516783 100644 --- a/examples/network/network-chat/client.cpp +++ b/examples/network/network-chat/client.cpp @@ -69,8 +69,8 @@ void Client::sendMessage(const QString &message) QString Client::nickName() const { - return QString(peerManager->userName()) + "@" + QHostInfo::localHostName() - + ":" + QString::number(server.serverPort()); + return QString(peerManager->userName()) + '@' + QHostInfo::localHostName() + + ':' + QString::number(server.serverPort()); } bool Client::hasConnection(const QHostAddress &senderIp, int senderPort) const diff --git a/examples/network/network-chat/connection.cpp b/examples/network/network-chat/connection.cpp index 1df8a2d..5c636b9 100644 --- a/examples/network/network-chat/connection.cpp +++ b/examples/network/network-chat/connection.cpp @@ -83,7 +83,7 @@ bool Connection::sendMessage(const QString &message) return false; QByteArray msg = message.toUtf8(); - QByteArray data = "MESSAGE " + QByteArray::number(msg.size()) + " " + msg; + QByteArray data = "MESSAGE " + QByteArray::number(msg.size()) + ' ' + msg; return write(data) == data.size(); } @@ -118,7 +118,7 @@ void Connection::processReadyRead() return; } - username = QString(buffer) + "@" + peerAddress().toString() + ":" + username = QString(buffer) + '@' + peerAddress().toString() + ':' + QString::number(peerPort()); currentDataType = Undefined; numBytesForCurrentDataType = 0; @@ -162,7 +162,7 @@ void Connection::sendPing() void Connection::sendGreetingMessage() { QByteArray greeting = greetingMessage.toUtf8(); - QByteArray data = "GREETING " + QByteArray::number(greeting.size()) + " " + greeting; + QByteArray data = "GREETING " + QByteArray::number(greeting.size()) + ' ' + greeting; if (write(data) == data.size()) isGreetingMessageSent = true; } diff --git a/examples/network/network-chat/peermanager.cpp b/examples/network/network-chat/peermanager.cpp index 5ad2dc7..430031b 100644 --- a/examples/network/network-chat/peermanager.cpp +++ b/examples/network/network-chat/peermanager.cpp @@ -61,7 +61,7 @@ PeerManager::PeerManager(Client *client) foreach (QString string, envVariables) { int index = environment.indexOf(QRegExp(string)); if (index != -1) { - QStringList stringList = environment.at(index).split("="); + QStringList stringList = environment.at(index).split('='); if (stringList.size() == 2) { username = stringList.at(1).toUtf8(); break; diff --git a/examples/network/qftp/ftpwindow.cpp b/examples/network/qftp/ftpwindow.cpp index ae3a2b6..3fd62f8 100644 --- a/examples/network/qftp/ftpwindow.cpp +++ b/examples/network/qftp/ftpwindow.cpp @@ -324,7 +324,8 @@ void FtpWindow::processItem(QTreeWidgetItem *item, int /*column*/) if (isDirectory.value(name)) { fileList->clear(); isDirectory.clear(); - currentPath += "/" + name; + currentPath += '/'; + currentPath += name; ftp->cd(name); ftp->list(); cdToParentButton->setEnabled(true); diff --git a/examples/network/securesocketclient/sslclient.cpp b/examples/network/securesocketclient/sslclient.cpp index 1422f1c..0d6a581 100644 --- a/examples/network/securesocketclient/sslclient.cpp +++ b/examples/network/securesocketclient/sslclient.cpp @@ -177,7 +177,7 @@ void SslClient::socketReadyRead() void SslClient::sendData() { QString input = form->sessionInput->text(); - appendString(input + "\n"); + appendString(input + '\n'); socket->write(input.toUtf8() + "\r\n"); form->sessionInput->clear(); } diff --git a/examples/network/torrent/trackerclient.cpp b/examples/network/torrent/trackerclient.cpp index 4f23d54..2397737 100644 --- a/examples/network/torrent/trackerclient.cpp +++ b/examples/network/torrent/trackerclient.cpp @@ -105,7 +105,7 @@ void TrackerClient::fetchPeerList() QString passkey = "?"; if (fullUrl.contains("?passkey")) { passkey = metaInfo.announceUrl().mid(fullUrl.indexOf("?passkey"), -1); - passkey += "&"; + passkey += '&'; } // Percent encode the hash diff --git a/examples/tools/customtype/message.cpp b/examples/tools/customtype/message.cpp index 4ef041a..d27159e 100644 --- a/examples/tools/customtype/message.cpp +++ b/examples/tools/customtype/message.cpp @@ -64,7 +64,7 @@ Message::Message(const QString &body, const QStringList &headers) } //! [custom type streaming operator] -QDebug &operator<<(QDebug &dbg, const Message &message) +QDebug operator<<(QDebug dbg, const Message &message) { QStringList pieces = message.body().split("\r\n", QString::SkipEmptyParts); if (pieces.isEmpty()) diff --git a/examples/tools/customtype/message.h b/examples/tools/customtype/message.h index 361f803..4ef48d4 100644 --- a/examples/tools/customtype/message.h +++ b/examples/tools/customtype/message.h @@ -70,7 +70,7 @@ Q_DECLARE_METATYPE(Message); //! [custom type meta-type declaration] //! [custom type streaming operator] -QDebug &operator<<(QDebug &dbg, const Message &message); +QDebug operator<<(QDebug dbg, const Message &message); //! [custom type streaming operator] #endif diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 6fe71d6..128df75 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -8,4 +8,4 @@ The commit imported was from the and has the sha1 checksum - 8f5ca3ba5da63a47d4f90bbd867d3e8453443dd3 + ca7b2e1e1ca558050cf49dd8f7c9b35e4b9d4df5 diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index 8e1c965..40a2149 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,68 @@ +2010-01-14 Andreas Kling <andreas.kling@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Enable scrolling optimization for pages with embedded widgets + + https://bugs.webkit.org/show_bug.cgi?id=33373 + + Added a basic manual test for scrolling of embedded QWidgets. + + * manual-tests/qt/qtplugin-scrolling.html: Added. + * platform/ScrollView.cpp: + (WebCore::ScrollView::scrollContents): + (WebCore::ScrollView::setParent): + * platform/ScrollView.h: + * platform/qt/ScrollViewQt.cpp: + (WebCore::ScrollView::platformInit): + (WebCore::ScrollView::platformAddChild): + (WebCore::ScrollView::platformRemoveChild): + * plugins/qt/PluginViewQt.cpp: + (WebCore::PluginView::updatePluginWidget): + (WebCore::PluginView::invalidateRect): + +2010-01-29 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Turn off websocket support by default for Qt 4.6.x + https://bugs.webkit.org/show_bug.cgi?id=34284 + + * WebCore.pro: + +2010-01-26 Holger Hans Peter Freyther <zecke@selfish.org> + + Reviewed by Simon Hausmann. + + [Qt] JavaScript prompt is currently broken. + https://bugs.webkit.org/show_bug.cgi?id=30914 + + Remove the manual test case in favor of an automated + test case in WebKit/qt/tests/qwebpage. + + * manual-tests/qt/java-script-prompt.html: Removed. + +2010-01-25 Janne Koskinen <janne.p.koskinen@digia.com> + + Reviewed by Simon Hausmann. + + [Qt] Phone backup support for QtWebkit for Symbian devices. + https://bugs.webkit.org/show_bug.cgi?id=34077 + + * WebCore.pro: + +2010-01-21 Thiago Macieira <thiago.macieira@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Fix incorrect dependency to QtXmlPatterns in generated include/QtWebKit/QtWebKit header + + The generated file includes QtXmlPatterns/QtXmlPatterns, which is neither used/required by + the public QtWebKit API nor will it be available if Qt is configured with -no-xmlpatterns. + + * WebCore.pro: Trick syncqt to believe that xmlpatterns is not a dependency, so that it's not + included in the generated file. It'll still be used and linked to with this trick. + 2010-01-17 Srinidhi Shreedhara <srinidhi.shreedhara@nokia.com> Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index 04aba62..f364d3b 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -18,7 +18,10 @@ symbian: { " " webkitlibs.pkg_prerules = vendorinfo - DEPLOYMENT += webkitlibs + webkitbackup.sources = ../WebKit/qt/symbian/backup_registration.xml + webkitbackup.path = /private/10202D56/import/packages/$$replace(TARGET.UID3, 0x,) + + DEPLOYMENT += webkitlibs webkitbackup TARGET.UID3 = 0x200267C2 # RO text (code) section in qtwebkit.dll exceeds allocated space for gcce udeb target. @@ -183,7 +186,7 @@ contains(DEFINES, ENABLE_SINGLE_THREADED=1) { } # Web Socket support. -!contains(DEFINES, ENABLE_WEB_SOCKETS=.): DEFINES += ENABLE_WEB_SOCKETS=1 +!contains(DEFINES, ENABLE_WEB_SOCKETS=.): DEFINES += ENABLE_WEB_SOCKETS=0 # XSLT support with QtXmlPatterns !contains(DEFINES, ENABLE_XSLT=.) { @@ -2780,7 +2783,7 @@ unix:!mac:CONFIG += link_pkgconfig contains(DEFINES, ENABLE_XSLT=1) { FEATURE_DEFINES_JAVASCRIPT += ENABLE_XSLT=1 - QT += xmlpatterns + tobe|!tobe: QT += xmlpatterns SOURCES += \ bindings/js/JSXSLTProcessorConstructor.cpp \ @@ -3415,14 +3418,8 @@ CONFIG(QTDIR_build):isEqual(QT_MAJOR_VERSION, 4):greaterThan(QT_MINOR_VERSION, 4 symbian { shared { - contains(MMP_RULES, defBlock) { - MMP_RULES -= defBlock - - MMP_RULES += "$${LITERAL_HASH}ifdef WINSCW" \ - "DEFFILE ../WebKit/qt/symbian/bwins/$${TARGET}.def" \ - "$${LITERAL_HASH}elif defined EABI" \ - "DEFFILE ../WebKit/qt/symbian/eabi/$${TARGET}.def" \ - "$${LITERAL_HASH}endif" + contains(CONFIG, def_files) { + defFilePath=../WebKit/qt/symbian } } } diff --git a/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.cpp b/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.cpp index 12edc42..d270e37 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.cpp @@ -216,7 +216,6 @@ #include "JSWebKitCSSTransformValue.h" #include "JSWebKitPoint.h" #include "JSWebKitTransitionEvent.h" -#include "JSWebSocket.h" #include "JSWheelEvent.h" #include "JSWorker.h" #include "JSXMLHttpRequest.h" @@ -247,7 +246,7 @@ ASSERT_CLASS_FITS_IN_CELL(JSDOMWindow); /* Hash table */ -static const HashTableValue JSDOMWindowTableValues[297] = +static const HashTableValue JSDOMWindowTableValues[296] = { { "screen", DontDelete|ReadOnly, (intptr_t)jsDOMWindowScreen, (intptr_t)0 }, { "history", DontDelete|ReadOnly, (intptr_t)jsDOMWindowHistory, (intptr_t)0 }, @@ -540,7 +539,6 @@ static const HashTableValue JSDOMWindowTableValues[297] = { "MessageChannel", DontDelete, (intptr_t)jsDOMWindowMessageChannelConstructor, (intptr_t)setJSDOMWindowMessageChannelConstructor }, { "Worker", DontDelete, (intptr_t)jsDOMWindowWorkerConstructor, (intptr_t)setJSDOMWindowWorkerConstructor }, { "SharedWorker", DontDelete, (intptr_t)jsDOMWindowSharedWorkerConstructor, (intptr_t)setJSDOMWindowSharedWorkerConstructor }, - { "WebSocket", DontDelete, (intptr_t)jsDOMWindowWebSocketConstructor, (intptr_t)setJSDOMWindowWebSocketConstructor }, { "Plugin", DontDelete, (intptr_t)jsDOMWindowPluginConstructor, (intptr_t)setJSDOMWindowPluginConstructor }, { "PluginArray", DontDelete, (intptr_t)jsDOMWindowPluginArrayConstructor, (intptr_t)setJSDOMWindowPluginArrayConstructor }, { "MimeType", DontDelete, (intptr_t)jsDOMWindowMimeTypeConstructor, (intptr_t)setJSDOMWindowMimeTypeConstructor }, @@ -588,7 +586,7 @@ static JSC_CONST_HASHTABLE HashTable JSDOMWindowTable = #if ENABLE(PERFECT_HASH_SIZE) { 65535, JSDOMWindowTableValues, 0 }; #else - { 1068, 1023, JSDOMWindowTableValues, 0 }; + { 1067, 1023, JSDOMWindowTableValues, 0 }; #endif /* Hash table for prototype */ @@ -3275,14 +3273,6 @@ JSValue jsDOMWindowSharedWorkerConstructor(ExecState* exec, const Identifier&, c return castedThis->sharedWorker(exec); } -JSValue jsDOMWindowWebSocketConstructor(ExecState* exec, const Identifier&, const PropertySlot& slot) -{ - JSDOMWindow* castedThis = static_cast<JSDOMWindow*>(asObject(slot.slotBase())); - if (!castedThis->allowsAccessFrom(exec)) - return jsUndefined(); - return castedThis->webSocket(exec); -} - JSValue jsDOMWindowPluginConstructor(ExecState* exec, const Identifier&, const PropertySlot& slot) { JSDOMWindow* castedThis = static_cast<JSDOMWindow*>(asObject(slot.slotBase())); @@ -5678,14 +5668,6 @@ void setJSDOMWindowSharedWorkerConstructor(ExecState* exec, JSObject* thisObject static_cast<JSDOMWindow*>(thisObject)->putDirect(Identifier(exec, "SharedWorker"), value); } -void setJSDOMWindowWebSocketConstructor(ExecState* exec, JSObject* thisObject, JSValue value) -{ - if (!static_cast<JSDOMWindow*>(thisObject)->allowsAccessFrom(exec)) - return; - // Shadowing a built-in constructor - static_cast<JSDOMWindow*>(thisObject)->putDirect(Identifier(exec, "WebSocket"), value); -} - void setJSDOMWindowPluginConstructor(ExecState* exec, JSObject* thisObject, JSValue value) { if (!static_cast<JSDOMWindow*>(thisObject)->allowsAccessFrom(exec)) diff --git a/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.h b/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.h index afc8106..5a087e7 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.h +++ b/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.h @@ -82,7 +82,6 @@ public: JSC::JSValue messageChannel(JSC::ExecState*) const; JSC::JSValue worker(JSC::ExecState*) const; JSC::JSValue sharedWorker(JSC::ExecState*) const; - JSC::JSValue webSocket(JSC::ExecState*) const; JSC::JSValue audio(JSC::ExecState*) const; // Custom functions @@ -679,8 +678,6 @@ JSC::JSValue jsDOMWindowWorkerConstructor(JSC::ExecState*, const JSC::Identifier void setJSDOMWindowWorkerConstructor(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); JSC::JSValue jsDOMWindowSharedWorkerConstructor(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); void setJSDOMWindowSharedWorkerConstructor(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); -JSC::JSValue jsDOMWindowWebSocketConstructor(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); -void setJSDOMWindowWebSocketConstructor(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); JSC::JSValue jsDOMWindowPluginConstructor(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); void setJSDOMWindowPluginConstructor(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); JSC::JSValue jsDOMWindowPluginArrayConstructor(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); diff --git a/src/3rdparty/webkit/WebCore/platform/ScrollView.cpp b/src/3rdparty/webkit/WebCore/platform/ScrollView.cpp index ee8726a..e67daf9 100644 --- a/src/3rdparty/webkit/WebCore/platform/ScrollView.cpp +++ b/src/3rdparty/webkit/WebCore/platform/ScrollView.cpp @@ -507,7 +507,7 @@ void ScrollView::scrollContents(const IntSize& scrollDelta) hostWindow()->repaint(panScrollIconDirtyRect, true); } - if (canBlitOnScroll() && !rootPreventsBlitting()) { // The main frame can just blit the WebView window + if (canBlitOnScroll()) { // The main frame can just blit the WebView window // FIXME: Find a way to blit subframes without blitting overlapping content hostWindow()->scroll(-scrollDelta, scrollViewRect, clipRect); } else { @@ -597,14 +597,6 @@ void ScrollView::setParent(ScrollView* parentView) if (m_scrollbarsAvoidingResizer && parent()) parent()->adjustScrollbarsAvoidingResizerCount(-m_scrollbarsAvoidingResizer); -#if PLATFORM(QT) - if (m_widgetsPreventingBlitting && parent()) - parent()->adjustWidgetsPreventingBlittingCount(-m_widgetsPreventingBlitting); - - if (m_widgetsPreventingBlitting && parentView) - parentView->adjustWidgetsPreventingBlittingCount(m_widgetsPreventingBlitting); -#endif - Widget::setParent(parentView); if (m_scrollbarsAvoidingResizer && parent()) diff --git a/src/3rdparty/webkit/WebCore/platform/ScrollView.h b/src/3rdparty/webkit/WebCore/platform/ScrollView.h index 1950a54..5dacff5 100644 --- a/src/3rdparty/webkit/WebCore/platform/ScrollView.h +++ b/src/3rdparty/webkit/WebCore/platform/ScrollView.h @@ -305,16 +305,6 @@ private: NSScrollView<WebCoreFrameScrollView>* scrollView() const; #endif -#if PLATFORM(QT) -public: - void adjustWidgetsPreventingBlittingCount(int delta); -private: - bool rootPreventsBlitting() const { return root()->m_widgetsPreventingBlitting > 0; } - unsigned m_widgetsPreventingBlitting; -#else - bool rootPreventsBlitting() const { return false; } -#endif - #if PLATFORM(GTK) public: void setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj); diff --git a/src/3rdparty/webkit/WebCore/platform/qt/PopupMenuQt.cpp b/src/3rdparty/webkit/WebCore/platform/qt/PopupMenuQt.cpp index 989b34c..714cac9 100644 --- a/src/3rdparty/webkit/WebCore/platform/qt/PopupMenuQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/qt/PopupMenuQt.cpp @@ -39,6 +39,7 @@ #include <QGraphicsProxyWidget> #include <QGraphicsScene> #include <QGraphicsView> +#include <QGraphicsWebView> #include <QListWidget> #include <QListWidgetItem> #include <QMenu> @@ -57,8 +58,10 @@ PopupMenu::PopupMenu(PopupMenuClient* client) PopupMenu::~PopupMenu() { - delete m_popup; - delete m_proxy; + // If we create a proxy, then the deletion of the proxy and the + // combo will be done by the proxy's parent (QGraphicsWebView) + if (!m_proxy) + delete m_popup; } void PopupMenu::clear() @@ -100,9 +103,8 @@ void PopupMenu::show(const IntRect& r, FrameView* v, int index) if (QGraphicsView* view = qobject_cast<QGraphicsView*>(client->ownerWidget())) { if (!m_proxy) { - m_proxy = new QGraphicsProxyWidget; + m_proxy = new QGraphicsProxyWidget(qobject_cast<QGraphicsWebView*>(client->pluginParent())); m_proxy->setWidget(m_popup); - view->scene()->addItem(m_proxy); } else m_proxy->setVisible(true); m_proxy->setGeometry(rect); diff --git a/src/3rdparty/webkit/WebCore/platform/qt/QWebPopup.cpp b/src/3rdparty/webkit/WebCore/platform/qt/QWebPopup.cpp index f7ebbc7..f6a8167 100644 --- a/src/3rdparty/webkit/WebCore/platform/qt/QWebPopup.cpp +++ b/src/3rdparty/webkit/WebCore/platform/qt/QWebPopup.cpp @@ -44,9 +44,16 @@ QWebPopup::QWebPopup(PopupMenuClient* client) void QWebPopup::exec() { + // QCursor::pos() is not a great idea for a touch screen, but we don't need the coordinates + // as comboboxes with Qt on Maemo 5 come up in their full width on the screen. + // On the other platforms it's okay to use QCursor::pos(). +#if defined(Q_WS_MAEMO_5) + showPopup(); +#else QMouseEvent event(QEvent::MouseButtonPress, QCursor::pos(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); QCoreApplication::sendEvent(this, &event); +#endif } void QWebPopup::showPopup() diff --git a/src/3rdparty/webkit/WebCore/platform/qt/ScrollViewQt.cpp b/src/3rdparty/webkit/WebCore/platform/qt/ScrollViewQt.cpp index ccbd751..17ad253 100644 --- a/src/3rdparty/webkit/WebCore/platform/qt/ScrollViewQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/qt/ScrollViewQt.cpp @@ -36,32 +36,19 @@ namespace WebCore { void ScrollView::platformInit() { - m_widgetsPreventingBlitting = 0; } void ScrollView::platformDestroy() { } -// Windowed plugins are using native windows and are thus preventing -// us from doing any kind of scrolling optimization. - -void ScrollView::adjustWidgetsPreventingBlittingCount(int delta) -{ - m_widgetsPreventingBlitting += delta; - if (parent()) - parent()->adjustWidgetsPreventingBlittingCount(delta); -} - void ScrollView::platformAddChild(Widget*) { - adjustWidgetsPreventingBlittingCount(1); } void ScrollView::platformRemoveChild(Widget* child) { child->hide(); - adjustWidgetsPreventingBlittingCount(-1); } } diff --git a/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp b/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp index e61736b..476ab8a 100644 --- a/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp @@ -126,6 +126,10 @@ void PluginView::updatePluginWidget() // scroll, we need to move/resize immediately. if (!m_windowRect.intersects(frameView->frameRect())) setNPWindowIfNeeded(); + + // Make sure we get repainted afterwards. This is necessary for downward + // scrolling to move the plugin widget properly. + invalidate(); } void PluginView::setFocus() @@ -657,7 +661,8 @@ NPError PluginView::getValue(NPNVariable variable, void* value) void PluginView::invalidateRect(const IntRect& rect) { if (m_isWindowed) { - platformWidget()->update(rect); + if (platformWidget()) + platformWidget()->update(rect); return; } diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp index 29bde0d..e4c2afc 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp @@ -1369,6 +1369,11 @@ void QWebFrame::print(QPrinter *printer) const // paranoia check fromPage = qMax(1, fromPage); toPage = qMin(printContext.pageCount(), toPage); + if (toPage < fromPage) { + // if the user entered a page range outside the actual number + // of printable pages, just return + return; + } if (printer->pageOrder() == QPrinter::LastPageFirst) { int tmp = fromPage; diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index ee555f3..697570f 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,63 @@ +2010-01-28 Trond KjernÃ¥sen <trond@trolltech.com> + + Reviewed by Simon Hausmann. + + [Qt] Fix for endless print loop when printing web pages + + * Api/qwebframe.cpp: + (QWebFrame::print): + +2010-01-26 Simon Hausmann <simon.hausmann@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Show comboboxes on Maemo 5 + https://bugs.webkit.org/show_bug.cgi?id=34088 + + Don't try to show the combobox by simulating a mouse event from QCursor::pos() to + get the combobox position right. The position on Maemo 5 is independent from the mouse + and there's no QCursor::pos(). + + * WebCoreSupport/QtFallbackWebPopup.cpp: + (WebCore::QtFallbackWebPopup::show): + +2010-01-26 Holger Hans Peter Freyther <zecke@selfish.org> + + Reviewed by Simon Hausmann. + + [Qt] JavaScript prompt is currently broken + https://bugs.webkit.org/show_bug.cgi?id=30914 + + In r52152 a patch was landed to convert a null QString + to an empty WebCore::String in case the prompt was accepted + but the default implementation returned the null QString. + + The patch tried to avoid assign to result twice and + was not checking the QString if it is null but the default + value. This lead to always returning an empty string on + successful prompts. Fix it by checking the variable 'x' + for isNull. + + The manual test case used didn't cover the case of non + empty input, replace it with an automatic test case that + should cover all cases. + + * WebCoreSupport/ChromeClientQt.cpp: + (WebCore::ChromeClientQt::runJavaScriptPrompt): Fix the bug. + * tests/qwebpage/tst_qwebpage.cpp: Add automatic test case + (JSPromptPage::JSPromptPage): + (JSPromptPage::javaScriptPrompt): + (tst_QWebPage::testJSPrompt): + +2010-01-25 Janne Koskinen <janne.p.koskinen@digia.com> + + Reviewed by Simon Hausmann. + + [Qt] Phone backup support for QtWebkit for Symbian devices. + https://bugs.webkit.org/show_bug.cgi?id=34077 + + * symbian/backup_registration.xml: Added. + 2009-11-19 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> Reviewed by Kenneth Rohde Christiansen. diff --git a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp index c5d2792..0c5df4a 100644 --- a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp +++ b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp @@ -281,7 +281,7 @@ bool ChromeClientQt::runJavaScriptPrompt(Frame* f, const String& message, const // Fix up a quirk in the QInputDialog class. If no input happened the string should be empty // but it is null. See https://bugs.webkit.org/show_bug.cgi?id=30914. - if (rc && result.isNull()) + if (rc && x.isNull()) result = String(""); else result = x; diff --git a/src/3rdparty/webkit/WebKit/qt/symbian/backup_registration.xml b/src/3rdparty/webkit/WebKit/qt/symbian/backup_registration.xml new file mode 100644 index 0000000..e026140 --- /dev/null +++ b/src/3rdparty/webkit/WebKit/qt/symbian/backup_registration.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" standalone="yes"?> +<backup_registration> + <system_backup/> + <restore requires_reboot = "no"/> +</backup_registration> diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp index ee1969d..0e04acc 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp @@ -1,6 +1,7 @@ /* Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) Copyright (C) 2009 Girish Ramakrishnan <girish@forwardbias.in> + Copyright (C) 2010 Holger Hans Peter Freyther This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -154,6 +155,7 @@ private slots: void screenshot(); void originatingObjectInNetworkRequests(); + void testJSPrompt(); private: QWebView* m_view; @@ -1781,5 +1783,72 @@ void tst_QWebPage::originatingObjectInNetworkRequests() #endif } +/** + * Test fixups for https://bugs.webkit.org/show_bug.cgi?id=30914 + * + * From JS we test the following conditions. + * + * OK + QString() => SUCCESS, empty string (but not null) + * OK + "text" => SUCCESS, "text" + * CANCEL + QString() => CANCEL, null string + * CANCEL + "text" => CANCEL, null string + */ +class JSPromptPage : public QWebPage { + Q_OBJECT +public: + JSPromptPage() + {} + + bool javaScriptPrompt(QWebFrame* frame, const QString& msg, const QString& defaultValue, QString* result) + { + if (msg == QLatin1String("test1")) { + *result = QString(); + return true; + } else if (msg == QLatin1String("test2")) { + *result = QLatin1String("text"); + return true; + } else if (msg == QLatin1String("test3")) { + *result = QString(); + return false; + } else if (msg == QLatin1String("test4")) { + *result = QLatin1String("text"); + return false; + } + + qFatal("Unknown msg."); + return QWebPage::javaScriptPrompt(frame, msg, defaultValue, result); + } +}; + +void tst_QWebPage::testJSPrompt() +{ + JSPromptPage page; + bool res; + + // OK + QString() + res = page.mainFrame()->evaluateJavaScript( + "var retval = prompt('test1');" + "retval=='' && retval.length == 0;").toBool(); + QVERIFY(res); + + // OK + "text" + res = page.mainFrame()->evaluateJavaScript( + "var retval = prompt('test2');" + "retval=='text' && retval.length == 4;").toBool(); + QVERIFY(res); + + // Cancel + QString() + res = page.mainFrame()->evaluateJavaScript( + "var retval = prompt('test3');" + "retval===null;").toBool(); + QVERIFY(res); + + // Cancel + "text" + res = page.mainFrame()->evaluateJavaScript( + "var retval = prompt('test4');" + "retval===null;").toBool(); + QVERIFY(res); +} + QTEST_MAIN(tst_QWebPage) #include "tst_qwebpage.moc" diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 722d6d3..9179485 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -98,7 +98,7 @@ static inline QByteArray openModeToFopenMode(QIODevice::OpenMode flags, const QS if (!fileName.isEmpty() && QT_STAT(QFile::encodeName(fileName), &statBuf) == 0 && (statBuf.st_mode & S_IFMT) == S_IFREG) { - mode += "+"; + mode += '+'; } else { mode = "wb+"; } diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 2c31509..64015ce 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -1091,30 +1091,23 @@ static inline int pathHashKey(QSettings::Format format, QSettings::Scope scope) return int((uint(format) << 1) | uint(scope == QSettings::SystemScope)); } -static QString getPath(QSettings::Format format, QSettings::Scope scope) +static void initDefaultPaths(QMutexLocker *locker) { - Q_ASSERT((int)QSettings::NativeFormat == 0); - Q_ASSERT((int)QSettings::IniFormat == 1); - + PathHash *pathHash = pathHashFunc(); QString homePath = QDir::homePath(); QString systemPath; - QMutexLocker locker(globalMutex()); - PathHash *pathHash = pathHashFunc(); - bool loadSystemPath = pathHash->isEmpty(); - locker.unlock(); - - if (loadSystemPath) { - /* - QLibraryInfo::location() uses QSettings, so in order to - avoid a dead-lock, we can't hold the global mutex while - calling it. - */ - systemPath = QLibraryInfo::location(QLibraryInfo::SettingsPath); - systemPath += QLatin1Char('/'); - } + locker->unlock(); + + /* + QLibraryInfo::location() uses QSettings, so in order to + avoid a dead-lock, we can't hold the global mutex while + calling it. + */ + systemPath = QLibraryInfo::location(QLibraryInfo::SettingsPath); + systemPath += QLatin1Char('/'); - locker.relock(); + locker->relock(); if (pathHash->isEmpty()) { /* Lazy initialization of pathHash. We initialize the @@ -1155,6 +1148,17 @@ static QString getPath(QSettings::Format format, QSettings::Scope scope) #endif #endif } +} + +static QString getPath(QSettings::Format format, QSettings::Scope scope) +{ + Q_ASSERT((int)QSettings::NativeFormat == 0); + Q_ASSERT((int)QSettings::IniFormat == 1); + + QMutexLocker locker(globalMutex()); + PathHash *pathHash = pathHashFunc(); + if (pathHash->isEmpty()) + initDefaultPaths(&locker); QString result = pathHash->value(pathHashKey(format, scope)); if (!result.isEmpty()) @@ -3455,6 +3459,8 @@ void QSettings::setPath(Format format, Scope scope, const QString &path) { QMutexLocker locker(globalMutex()); PathHash *pathHash = pathHashFunc(); + if (pathHash->isEmpty()) + initDefaultPaths(&locker); pathHash->insert(pathHashKey(format, scope), path + QDir::separator()); } diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index a131d6c..076cc33 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3241,8 +3241,11 @@ static QString qt_ACE_do(const QString &domain, AceOperation op) while (1) { int idx = nextDotDelimiter(domain, lastIdx); int labelLength = idx - lastIdx; - if (labelLength == 0) + if (labelLength == 0) { + if (idx == domain.length()) + break; return QString(); // two delimiters in a row -- empty label not allowed + } // RFC 3490 says, about the ToASCII operation: // 3. If the UseSTD3ASCIIRules flag is set, then perform these checks: diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index 21816b9..1b4b356 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -130,7 +130,7 @@ multiple- or virtual-inheritance (that is, in cases where two different pointer addresses can refer to the same object). In that case, if a pointer is cast to a different type and its value changes, - QSharedPointer's pointer tracking mechanism mail fail to detect that the + QSharedPointer's pointer tracking mechanism may fail to detect that the object being tracked is the same. \omit diff --git a/src/dbus/qdbusargument.cpp b/src/dbus/qdbusargument.cpp index 3466d90..7defc9a 100644 --- a/src/dbus/qdbusargument.cpp +++ b/src/dbus/qdbusargument.cpp @@ -535,7 +535,6 @@ QDBusArgument &QDBusArgument::operator<<(const QByteArray &arg) /*! \internal - Returns the type signature of the D-Bus type this QDBusArgument \since 4.5 Appends the variant \a v. diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 30fa0b6..44abf7b 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1660,9 +1660,6 @@ void QDBusConnectionPrivate::setConnection(DBusConnection *dbc, const QDBusError } QString busService = QLatin1String(DBUS_SERVICE_DBUS); - WatchedServicesHash::mapped_type &bus = watchedServices[busService]; - bus.refcount = 1; - bus.owner = getNameOwnerNoCache(busService); connectSignal(busService, QString(), QString(), QLatin1String("NameAcquired"), QStringList(), QString(), this, SLOT(registerService(QString))); connectSignal(busService, QString(), QString(), QLatin1String("NameLost"), QStringList(), QString(), @@ -2004,7 +2001,8 @@ bool QDBusConnectionPrivate::connectSignal(const QString &service, entry.path == hook.path && entry.signature == hook.signature && entry.obj == hook.obj && - entry.midx == hook.midx) { + entry.midx == hook.midx && + entry.argumentMatch == hook.argumentMatch) { // no need to compare the parameters if it's the same slot return true; // already there } @@ -2046,10 +2044,7 @@ void QDBusConnectionPrivate::connectSignal(const QString &key, const SignalHook // Do we need to watch for this name? if (shouldWatchService(hook.service)) { WatchedServicesHash::mapped_type &data = watchedServices[hook.service]; - if (data.refcount) { - // already watching - ++data.refcount; - } else { + if (++data.refcount == 1) { // we need to watch for this service changing QString dbusServerService = QLatin1String(DBUS_SERVICE_DBUS); connectSignal(dbusServerService, QString(), QLatin1String(DBUS_INTERFACE_DBUS), @@ -2089,7 +2084,8 @@ bool QDBusConnectionPrivate::disconnectSignal(const QString &service, entry.path == hook.path && entry.signature == hook.signature && entry.obj == hook.obj && - entry.midx == hook.midx) { + entry.midx == hook.midx && + entry.argumentMatch == hook.argumentMatch) { // no need to compare the parameters if it's the same slot disconnectSignal(it); return true; // it was there @@ -2105,19 +2101,6 @@ QDBusConnectionPrivate::disconnectSignal(SignalHookHash::Iterator &it) { const SignalHook &hook = it.value(); - WatchedServicesHash::Iterator sit = watchedServices.find(hook.service); - if (sit != watchedServices.end()) { - if (sit.value().refcount == 1) { - watchedServices.erase(sit); - QString dbusServerService = QLatin1String(DBUS_SERVICE_DBUS); - disconnectSignal(dbusServerService, QString(), QLatin1String(DBUS_INTERFACE_DBUS), - QLatin1String("NameOwnerChanged"), QStringList() << hook.service, QString(), - this, SLOT(_q_serviceOwnerChanged(QString,QString,QString))); - } else { - --sit.value().refcount; - } - } - bool erase = false; MatchRefCountHash::iterator i = matchRefCounts.find(hook.matchRule); if (i == matchRefCounts.end()) { @@ -2136,6 +2119,20 @@ QDBusConnectionPrivate::disconnectSignal(SignalHookHash::Iterator &it) if (connection && erase) { qDBusDebug("Removing rule: %s", hook.matchRule.constData()); q_dbus_bus_remove_match(connection, hook.matchRule, NULL); + + // Successfully disconnected the signal + // Were we watching for this name? + WatchedServicesHash::Iterator sit = watchedServices.find(hook.service); + if (sit != watchedServices.end()) { + if (--sit.value().refcount == 0) { + watchedServices.erase(sit); + QString dbusServerService = QLatin1String(DBUS_SERVICE_DBUS); + disconnectSignal(dbusServerService, QString(), QLatin1String(DBUS_INTERFACE_DBUS), + QLatin1String("NameOwnerChanged"), QStringList() << hook.service, QString(), + this, SLOT(_q_serviceOwnerChanged(QString,QString,QString))); + } + } + } return signalHooks.erase(it); diff --git a/src/dbus/qdbusmarshaller.cpp b/src/dbus/qdbusmarshaller.cpp index f156e04..8ec328e 100644 --- a/src/dbus/qdbusmarshaller.cpp +++ b/src/dbus/qdbusmarshaller.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qdbusargument_p.h" +#include "qdbusmetatype_p.h" #include "qdbusutil_p.h" QT_BEGIN_NAMESPACE @@ -167,7 +168,7 @@ inline bool QDBusMarshaller::append(const QDBusVariant &arg) QByteArray tmpSignature; const char *signature = 0; - if (int(id) == qMetaTypeId<QDBusArgument>()) { + if (int(id) == QDBusMetaTypeId::argument) { // take the signature from the QDBusArgument object we're marshalling tmpSignature = qvariant_cast<QDBusArgument>(value).currentSignature().toLatin1(); @@ -353,7 +354,7 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg) } // intercept QDBusArgument parameters here - if (id == qMetaTypeId<QDBusArgument>()) { + if (id == QDBusMetaTypeId::argument) { QDBusArgument dbusargument = qvariant_cast<QDBusArgument>(arg); QDBusArgumentPrivate *d = QDBusArgumentPrivate::d(dbusargument); if (!d->message) diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp index da031f1..c4edb28 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp @@ -819,6 +819,32 @@ void QmlGraphicsFlickable::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) } } +void QmlGraphicsFlickable::wheelEvent(QGraphicsSceneWheelEvent *event) +{ + Q_D(QmlGraphicsFlickable); + if (!d->interactive) { + QmlGraphicsItem::wheelEvent(event); + } else if (yflick()) { + if (event->delta() > 0) + d->velocityY = qMax(event->delta() - d->verticalVelocity.value(), qreal(250.0)); + else + d->velocityY = qMin(event->delta() - d->verticalVelocity.value(), qreal(-250.0)); + d->flicked = false; + d->flickY(d->velocityY); + event->accept(); + } else if (xflick()) { + if (event->delta() > 0) + d->velocityX = qMax(event->delta() - d->horizontalVelocity.value(), qreal(250.0)); + else + d->velocityX = qMin(event->delta() - d->horizontalVelocity.value(), qreal(-250.0)); + d->flicked = false; + d->flickX(d->velocityX); + event->accept(); + } else { + QmlGraphicsItem::wheelEvent(event); + } +} + void QmlGraphicsFlickablePrivate::captureDelayedPress(QGraphicsSceneMouseEvent *event) { Q_Q(QmlGraphicsFlickable); diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable_p.h b/src/declarative/graphicsitems/qmlgraphicsflickable_p.h index df6f6b1..ea07da4 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflickable_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsflickable_p.h @@ -166,6 +166,7 @@ protected: void mousePressEvent(QGraphicsSceneMouseEvent *event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); + void wheelEvent(QGraphicsSceneWheelEvent *event); void timerEvent(QTimerEvent *event); QmlGraphicsFlickableVisibleArea *visibleArea(); diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp index 2fad3bb..afc2e15 100644 --- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp @@ -151,14 +151,14 @@ class QmlGraphicsGridViewPrivate : public QmlGraphicsFlickablePrivate public: QmlGraphicsGridViewPrivate() - : model(0), currentItem(0), flow(QmlGraphicsGridView::LeftToRight) + : currentItem(0), flow(QmlGraphicsGridView::LeftToRight) , visiblePos(0), visibleIndex(0) , currentIndex(-1) , cellWidth(100), cellHeight(100), columns(1), requestedIndex(-1) , highlightComponent(0), highlight(0), trackedItem(0) , moveReason(Other), buffer(0), highlightXAnimator(0), highlightYAnimator(0) , bufferMode(NoBuffer) , ownModel(false), wrap(false), autoHighlight(true) - , fixCurrentVisibility(false), lazyRelease(false) {} + , fixCurrentVisibility(false), lazyRelease(false), layoutScheduled(false) {} void init(); void clear(); @@ -167,6 +167,7 @@ public: void refill(qreal from, qreal to, bool doBuffer=false); void updateGrid(); + void scheduleLayout(); void layout(bool removed=false); void updateUnrequestedIndexes(); void updateUnrequestedPositions(); @@ -306,7 +307,7 @@ public: } } - QmlGraphicsVisualModel *model; + QGuard<QmlGraphicsVisualModel> model; QVariant modelVariant; QList<FxGridItem*> visibleItems; QHash<QmlGraphicsItem*,int> unrequestedItems; @@ -335,6 +336,7 @@ public: bool autoHighlight : 1; bool fixCurrentVisibility : 1; bool lazyRelease : 1; + bool layoutScheduled : 1; }; void QmlGraphicsGridViewPrivate::init() @@ -372,6 +374,7 @@ FxGridItem *QmlGraphicsGridViewPrivate::createItem(int modelIndex) model->completeItem(); listItem->item->setZValue(1); listItem->item->setParent(q->viewport()); + unrequestedItems.remove(listItem->item); } requestedIndex = 0; return listItem; @@ -381,7 +384,7 @@ FxGridItem *QmlGraphicsGridViewPrivate::createItem(int modelIndex) void QmlGraphicsGridViewPrivate::releaseItem(FxGridItem *item) { Q_Q(QmlGraphicsGridView); - if (!item) + if (!item || !model) return; if (trackedItem == item) { QObject::disconnect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged())); @@ -435,7 +438,7 @@ void QmlGraphicsGridViewPrivate::refill(qreal from, qreal to, bool doBuffer) // creating/releasing multiple items in one frame // while flicking (as much as possible). while (modelIndex < model->count() && rowPos <= fillTo + rowSize()*(columns - colNum)/(columns+1)) { - //qDebug() << "refill: append item" << modelIndex; +// qDebug() << "refill: append item" << modelIndex; if (!(item = createItem(modelIndex))) break; item->setPosition(colPos, rowPos); @@ -463,7 +466,7 @@ void QmlGraphicsGridViewPrivate::refill(qreal from, qreal to, bool doBuffer) } colNum = colPos / colSize(); while (visibleIndex > 0 && rowPos + rowSize() - 1 >= fillFrom - rowSize()*(colNum+1)/(columns+1)){ - //qDebug() << "refill: prepend item" << visibleIndex-1 << "top pos" << rowPos << colPos; +// qDebug() << "refill: prepend item" << visibleIndex-1 << "top pos" << rowPos << colPos; if (!(item = createItem(visibleIndex-1))) break; --visibleIndex; @@ -487,7 +490,7 @@ void QmlGraphicsGridViewPrivate::refill(qreal from, qreal to, bool doBuffer) && item->endRowPos() < bufferFrom - rowSize()*(item->colPos()/colSize()+1)/(columns+1)) { if (item->attached->delayRemove()) break; - //qDebug() << "refill: remove first" << visibleIndex << "top end pos" << item->endRowPos(); +// qDebug() << "refill: remove first" << visibleIndex << "top end pos" << item->endRowPos(); if (item->index != -1) visibleIndex++; visibleItems.removeFirst(); @@ -499,7 +502,7 @@ void QmlGraphicsGridViewPrivate::refill(qreal from, qreal to, bool doBuffer) && item->rowPos() > bufferTo + rowSize()*(columns - item->colPos()/colSize())/(columns+1)) { if (item->attached->delayRemove()) break; - //qDebug() << "refill: remove last" << visibleIndex+visibleItems.count()-1; +// qDebug() << "refill: remove last" << visibleIndex+visibleItems.count()-1; visibleItems.removeLast(); releaseItem(item); changed = true; @@ -528,19 +531,27 @@ void QmlGraphicsGridViewPrivate::updateGrid() } } +void QmlGraphicsGridViewPrivate::scheduleLayout() +{ + Q_Q(QmlGraphicsGridView); + if (!layoutScheduled) { + layoutScheduled = true; + QMetaObject::invokeMethod(q, "layout", Qt::QueuedConnection); + } +} + void QmlGraphicsGridViewPrivate::layout(bool removed) { Q_Q(QmlGraphicsGridView); + layoutScheduled = false; if (visibleItems.count()) { qreal rowPos = visibleItems.first()->rowPos(); qreal colPos = visibleItems.first()->colPos(); - if (visibleIndex % columns != 0) { + int col = visibleIndex % columns; + if (colPos != col * colSize()) { if (removed) rowPos -= rowSize(); - colPos = (visibleIndex % columns) * colSize(); - visibleItems.first()->setPosition(colPos, rowPos); - } else if (colPos != 0) { - colPos = 0; + colPos = col * colSize(); visibleItems.first()->setPosition(colPos, rowPos); } for (int i = 1; i < visibleItems.count(); ++i) { @@ -555,6 +566,7 @@ void QmlGraphicsGridViewPrivate::layout(bool removed) } q->refill(); updateHighlight(); + moveReason = Other; if (flow == QmlGraphicsGridView::LeftToRight) { q->setViewportHeight(endPosition() - startPosition()); fixupY(); @@ -1126,7 +1138,7 @@ void QmlGraphicsGridView::setCacheBuffer(int buffer) These properties holds the width and height of each cell in the grid - The default sell size is 100x100. + The default cell size is 100x100. */ int QmlGraphicsGridView::cellWidth() const { @@ -1406,7 +1418,7 @@ void QmlGraphicsGridView::trackedPositionChanged() Q_D(QmlGraphicsGridView); if (!d->trackedItem) return; - if (!isFlicking() && !d->moving && d->moveReason != QmlGraphicsGridViewPrivate::Mouse) { + if (!isFlicking() && !d->moving && d->moveReason == QmlGraphicsGridViewPrivate::SetIndex) { const qreal viewPos = d->position(); if (d->trackedItem->rowPos() < viewPos && d->currentItem->rowPos() < viewPos) { d->setPosition(d->currentItem->rowPos() < d->trackedItem->rowPos() ? d->trackedItem->rowPos() : d->currentItem->rowPos()); @@ -1446,12 +1458,12 @@ void QmlGraphicsGridView::itemsInserted(int modelIndex, int count) // Special case of appending an item to the model. index = d->visibleIndex + d->visibleItems.count(); } else { - if (modelIndex + count - 1 < d->visibleIndex) { + if (modelIndex <= d->visibleIndex) { // Insert before visible items d->visibleIndex += count; for (int i = 0; i < d->visibleItems.count(); ++i) { FxGridItem *listItem = d->visibleItems.at(i); - if (listItem->index != -1) + if (listItem->index != -1 && listItem->index >= modelIndex) listItem->index += count; } } @@ -1492,71 +1504,25 @@ void QmlGraphicsGridView::itemsInserted(int modelIndex, int count) } QList<FxGridItem*> added; - FxGridItem *firstItem = d->firstVisibleItem(); - if (firstItem && rowPos < firstItem->rowPos()) { - int from = d->position() - d->buffer; - int i = 0; - int insertionIdx = index; - for (i = insertCount-1; i >= 0 && rowPos > from; --i) { - int mod = (modelIndex+i) % d->columns; - while (mod++ < d->columns && modelIndex + i < d->model->count() && i < insertCount) { - FxGridItem *item = d->createItem(modelIndex + i); - d->visibleItems.insert(insertionIdx, item); - item->setPosition(colPos, rowPos); - added.append(item); - colPos -= d->colSize(); - if (colPos < 0) { - colPos = d->colSize() * (d->columns-1); - rowPos -= d->rowSize(); - } - ++index; - ++i; - } - } - if (i >= 0) { - // If we didn't insert all our new items - anything - // before the current index is not visible - remove it. - while (insertionIdx--) { - FxGridItem *item = d->visibleItems.takeFirst(); - if (item->index != -1) - d->visibleIndex++; - d->releaseItem(item); - } - } else { - // adjust pos of items before inserted items. - for (int i = insertionIdx-1; i >= 0; i--) { - FxGridItem *gridItem = d->visibleItems.at(i); - gridItem->setPosition(colPos, rowPos); - colPos -= d->colSize(); - if (colPos < 0) { - colPos = d->colSize() * (d->columns-1); - rowPos -= d->rowSize(); - } - } - } - } else { - int i = 0; - for (i = 0; i < insertCount && rowPos + d->rowSize() - 1 <= to; ++i) { - int mod = (modelIndex+i) % d->columns; - while (mod++ < d->columns && modelIndex + i < d->model->count() && i < insertCount) { - FxGridItem *item = d->createItem(modelIndex + i); - d->visibleItems.insert(index, item); - item->setPosition(colPos, rowPos); - added.append(item); - colPos += d->colSize(); - if (colPos > d->colSize() * (d->columns-1)) { - colPos = 0; - rowPos += d->rowSize(); - } - ++index; - ++i; - } + int i = 0; + while (i < insertCount && rowPos <= to + d->rowSize()*(d->columns - (colPos/d->colSize()))/qreal(d->columns)) { + FxGridItem *item = d->createItem(modelIndex + i); + d->visibleItems.insert(index, item); + item->setPosition(colPos, rowPos); + added.append(item); + colPos += d->colSize(); + if (colPos > d->colSize() * (d->columns-1)) { + colPos = 0; + rowPos += d->rowSize(); } - if (i < insertCount) { - // We didn't insert all our new items, which means anything - // beyond the current index is not visible - remove it. - while (d->visibleItems.count() > index) - d->releaseItem(d->visibleItems.takeLast()); + ++index; + ++i; + } + if (i < insertCount) { + // We didn't insert all our new items, which means anything + // beyond the current index is not visible - remove it. + while (d->visibleItems.count() > index) { + d->releaseItem(d->visibleItems.takeLast()); } } @@ -1586,32 +1552,7 @@ void QmlGraphicsGridView::itemsRemoved(int modelIndex, int count) { Q_D(QmlGraphicsGridView); bool currentRemoved = d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count; - int index = d->mapFromModel(modelIndex); - if (index == -1) { - if (modelIndex + count - 1 < d->visibleIndex) { - // Items removed before our visible items. - d->visibleIndex -= count; - for (int i = 0; i < d->visibleItems.count(); ++i) { - FxGridItem *listItem = d->visibleItems.at(i); - if (listItem->index != -1) - listItem->index -= count; - } - } - if (d->currentIndex >= modelIndex + count) { - d->currentIndex -= count; - if (d->currentItem) - d->currentItem->index -= count; - } else if (currentRemoved) { - // current item has been removed. - d->releaseItem(d->currentItem); - d->currentItem = 0; - d->currentIndex = -1; - d->updateCurrent(qMin(modelIndex, d->model->count()-1)); - } - d->layout(true); - emit countChanged(); - return; - } + bool removedVisible = false; // Remove the items from the visible list, skipping anything already marked for removal QList<FxGridItem*>::Iterator it = d->visibleItems.begin(); @@ -1619,6 +1560,8 @@ void QmlGraphicsGridView::itemsRemoved(int modelIndex, int count) FxGridItem *item = *it; if (item->index == -1 || item->index < modelIndex) { // already removed, or before removed items + if (item->index < modelIndex) + removedVisible = true; ++it; } else if (item->index >= modelIndex + count) { // after removed items @@ -1626,6 +1569,7 @@ void QmlGraphicsGridView::itemsRemoved(int modelIndex, int count) ++it; } else { // removed item + removedVisible = true; item->attached->emitRemove(); if (item->attached->delayRemove()) { item->index = -1; @@ -1659,17 +1603,27 @@ void QmlGraphicsGridView::itemsRemoved(int modelIndex, int count) } } - if (d->visibleItems.isEmpty()) { - d->visibleIndex = 0; - d->setPosition(0); - refill(); - } else { - // Correct the positioning of the items - d->layout(); + if (removedVisible) { + if (d->visibleItems.isEmpty()) { + d->visibleIndex = 0; + d->setPosition(0); + refill(); + } else { + // Correct the positioning of the items + d->scheduleLayout(); + } } + emit countChanged(); } +void QmlGraphicsGridView::layout() +{ + Q_D(QmlGraphicsGridView); + if (d->layoutScheduled) + d->layout(); +} + void QmlGraphicsGridView::destroyRemoved() { Q_D(QmlGraphicsGridView); diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview_p.h b/src/declarative/graphicsitems/qmlgraphicsgridview_p.h index 1615469..d2ef70e 100644 --- a/src/declarative/graphicsitems/qmlgraphicsgridview_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsgridview_p.h @@ -148,6 +148,7 @@ private Q_SLOTS: void createdItem(int index, QmlGraphicsItem *item); void destroyingItem(QmlGraphicsItem *item); void sizeChange(); + void layout(); private: void refill(); diff --git a/src/declarative/graphicsitems/qmlgraphicsimage.cpp b/src/declarative/graphicsitems/qmlgraphicsimage.cpp index ad43027..a1e8c17 100644 --- a/src/declarative/graphicsitems/qmlgraphicsimage.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsimage.cpp @@ -128,6 +128,7 @@ QML_DEFINE_TYPE(Qt,4,6,Image,QmlGraphicsImage) QmlGraphicsImage::QmlGraphicsImage(QmlGraphicsItem *parent) : QmlGraphicsImageBase(*(new QmlGraphicsImagePrivate), parent) { + connect(this, SIGNAL(sourceChanged(QUrl)), this, SLOT(updatePaintedGeometry())); } QmlGraphicsImage::QmlGraphicsImage(QmlGraphicsImagePrivate &dd, QmlGraphicsItem *parent) @@ -270,6 +271,8 @@ void QmlGraphicsImage::updatePaintedGeometry() if (d->fillMode == PreserveAspectFit) { qreal widthScale = width() / qreal(d->pix.width()); qreal heightScale = height() / qreal(d->pix.height()); + if (!d->pix.width() || !d->pix.height()) + return; if (widthScale <= heightScale) { d->paintedWidth = width(); d->paintedHeight = widthScale * qreal(d->pix.height()); diff --git a/src/declarative/graphicsitems/qmlgraphicsimage_p.h b/src/declarative/graphicsitems/qmlgraphicsimage_p.h index 36066e1..dde5d79 100644 --- a/src/declarative/graphicsitems/qmlgraphicsimage_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsimage_p.h @@ -86,6 +86,8 @@ Q_SIGNALS: protected: QmlGraphicsImage(QmlGraphicsImagePrivate &dd, QmlGraphicsItem *parent); void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); + +protected Q_SLOTS: void updatePaintedGeometry(); private: diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp index bd3c1ea..f26496e 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp @@ -57,6 +57,7 @@ #include <QFile> #include <QEvent> #include <QGraphicsSceneMouseEvent> +#include <QtCore/qnumeric.h> #include <QtScript/qscriptengine.h> #include <QtGui/qgraphicstransform.h> #include <QtGui/qgraphicseffect.h> @@ -2790,6 +2791,7 @@ void QmlGraphicsItem::setTransformOrigin(TransformOrigin origin) if (origin != d->origin) { d->origin = origin; QGraphicsItem::setTransformOriginPoint(d->computeTransformOrigin()); + emit transformOriginChanged(d->origin); } } @@ -2842,6 +2844,9 @@ qreal QmlGraphicsItem::width() const void QmlGraphicsItem::setWidth(qreal w) { Q_D(QmlGraphicsItem); + if (qIsNaN(w)) + return; + d->widthValid = true; if (d->width == w) return; @@ -2911,6 +2916,9 @@ qreal QmlGraphicsItem::height() const void QmlGraphicsItem::setHeight(qreal h) { Q_D(QmlGraphicsItem); + if (qIsNaN(h)) + return; + d->heightValid = true; if (d->height == h) return; diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.h b/src/declarative/graphicsitems/qmlgraphicsitem.h index df8c634..8ae2d5c 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem.h +++ b/src/declarative/graphicsitems/qmlgraphicsitem.h @@ -91,7 +91,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsItem : public QGraphicsObject, public QmlP Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL) Q_PROPERTY(bool wantsFocus READ wantsFocus NOTIFY wantsFocusChanged) Q_PROPERTY(QmlList<QGraphicsTransform *>* transform READ transform DESIGNABLE false FINAL) - Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin) + Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin NOTIFY transformOriginChanged) Q_PROPERTY(bool smooth READ smooth WRITE setSmooth) Q_PROPERTY(QGraphicsEffect *effect READ graphicsEffect WRITE setGraphicsEffect) Q_ENUMS(TransformOrigin) @@ -176,6 +176,7 @@ Q_SIGNALS: void focusChanged(); void wantsFocusChanged(); void parentChanged(); + void transformOriginChanged(TransformOrigin); protected: bool isComponentComplete() const; diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp index f75833a..8fb7c84 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp @@ -210,7 +210,7 @@ class QmlGraphicsListViewPrivate : public QmlGraphicsFlickablePrivate, private Q public: QmlGraphicsListViewPrivate() - : model(0), currentItem(0), orient(QmlGraphicsListView::Vertical) + : currentItem(0), orient(QmlGraphicsListView::Vertical) , visiblePos(0), visibleIndex(0) , averageSize(100.0), currentIndex(-1), requestedIndex(-1) , highlightRangeStart(0), highlightRangeEnd(0) @@ -495,7 +495,7 @@ public: virtual void flickX(qreal velocity); virtual void flickY(qreal velocity); - QmlGraphicsVisualModel *model; + QGuard<QmlGraphicsVisualModel> model; QVariant modelVariant; QList<FxListItem*> visibleItems; QHash<QmlGraphicsItem*,int> unrequestedItems; @@ -605,6 +605,7 @@ FxListItem *QmlGraphicsListViewPrivate::createItem(int modelIndex) if (listItem->attached->m_prevSection != listItem->attached->m_section) createSection(listItem); } + unrequestedItems.remove(listItem->item); } requestedIndex = -1; @@ -614,7 +615,7 @@ FxListItem *QmlGraphicsListViewPrivate::createItem(int modelIndex) void QmlGraphicsListViewPrivate::releaseItem(FxListItem *item) { Q_Q(QmlGraphicsListView); - if (!item) + if (!item || !model) return; if (trackedItem == item) { const char *notifier1 = orient == QmlGraphicsListView::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged()); @@ -731,6 +732,7 @@ void QmlGraphicsListViewPrivate::refill(qreal from, qreal to, bool doBuffer) if (footer) updateFooter(); updateViewport(); + updateUnrequestedPositions(); } else if (!doBuffer && buffer && bufferMode != NoBuffer) { refill(from, to, true); } @@ -765,7 +767,6 @@ void QmlGraphicsListViewPrivate::layout() updateHeader(); if (footer) updateFooter(); - updateUnrequestedPositions(); updateViewport(); } @@ -779,14 +780,20 @@ void QmlGraphicsListViewPrivate::updateUnrequestedIndexes() void QmlGraphicsListViewPrivate::updateUnrequestedPositions() { - QHash<QmlGraphicsItem*,int>::const_iterator it; - for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it) { - if (visibleItem(*it)) - continue; - if (orient == QmlGraphicsListView::Vertical) - it.key()->setY(positionAt(*it)); - else - it.key()->setX(positionAt(*it)); + Q_Q(QmlGraphicsListView); + if (unrequestedItems.count()) { + qreal pos = position(); + QHash<QmlGraphicsItem*,int>::const_iterator it; + for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it) { + QmlGraphicsItem *item = it.key(); + if (orient == QmlGraphicsListView::Vertical) { + if (item->y() + item->height() > pos && item->y() < pos + q->height()) + item->setY(positionAt(*it)); + } else { + if (item->x() + item->width() > pos && item->x() < pos + q->width()) + item->setX(positionAt(*it)); + } + } } } @@ -2114,12 +2121,14 @@ void QmlGraphicsListView::viewportMoved() const qreal minX = minXExtent(); if ((minX - d->_moveX.value() < height()/2 || d->flickTargetX - d->_moveX.value() < height()/2) && minX != d->flickTargetX) - d->flickX(-d->verticalVelocity.value()); + d->flickX(-d->horizontalVelocity.value()); + d->bufferMode = QmlGraphicsListViewPrivate::BufferBefore; } else if (d->velocityX < 0) { const qreal maxX = maxXExtent(); if ((d->_moveX.value() - maxX < height()/2 || d->_moveX.value() - d->flickTargetX < height()/2) && maxX != d->flickTargetX) - d->flickX(-d->verticalVelocity.value()); + d->flickX(-d->horizontalVelocity.value()); + d->bufferMode = QmlGraphicsListViewPrivate::BufferAfter; } } d->inFlickCorrection = false; @@ -2399,12 +2408,12 @@ void QmlGraphicsListView::itemsInserted(int modelIndex, int count) // Special case of appending an item to the model. modelIndex = d->visibleIndex + d->visibleItems.count(); } else { - if (modelIndex + count - 1 < d->visibleIndex) { + if (modelIndex < d->visibleIndex) { // Insert before visible items d->visibleIndex += count; for (int i = 0; i < d->visibleItems.count(); ++i) { FxListItem *listItem = d->visibleItems.at(i); - if (listItem->index != -1) + if (listItem->index != -1 && listItem->index >= modelIndex) listItem->index += count; } } @@ -2609,6 +2618,7 @@ void QmlGraphicsListView::destroyRemoved() void QmlGraphicsListView::itemsMoved(int from, int to, int count) { Q_D(QmlGraphicsListView); + d->updateUnrequestedIndexes(); if (d->visibleItems.isEmpty()) { refill(); diff --git a/src/declarative/graphicsitems/qmlgraphicsloader.cpp b/src/declarative/graphicsitems/qmlgraphicsloader.cpp index bb1020c..7cd4d1a 100644 --- a/src/declarative/graphicsitems/qmlgraphicsloader.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsloader.cpp @@ -64,8 +64,14 @@ void QmlGraphicsLoaderPrivate::clear() } source = QUrl(); - delete item; - item = 0; + if (item) { + // We can't delete immediately because our item may have triggered + // the Loader to load a different item. + item->setVisible(false); + static_cast<QGraphicsItem*>(item)->setParentItem(0); + item->deleteLater(); + item = 0; + } } void QmlGraphicsLoaderPrivate::initResize() diff --git a/src/declarative/graphicsitems/qmlgraphicspathview.cpp b/src/declarative/graphicsitems/qmlgraphicspathview.cpp index 112eda2..85e87eb 100644 --- a/src/declarative/graphicsitems/qmlgraphicspathview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspathview.cpp @@ -71,9 +71,11 @@ inline qreal qmlMod(qreal x, qreal y) class QmlGraphicsPathViewAttached : public QObject { Q_OBJECT + + Q_PROPERTY(bool onPath READ isOnPath NOTIFY onPathChanged) public: QmlGraphicsPathViewAttached(QObject *parent) - : QObject(parent), mo(new QmlOpenMetaObject(this)) + : QObject(parent), mo(new QmlOpenMetaObject(this)), onPath(false) { } @@ -91,10 +93,49 @@ public: mo->setValue(name, val); } + bool isOnPath() const { return onPath; } + void setOnPath(bool on) { + if (on != onPath) { + onPath = on; + emit onPathChanged(); + } + } + +Q_SIGNALS: + void onPathChanged(); + private: QmlOpenMetaObject *mo; + bool onPath; }; + +QmlGraphicsItem *QmlGraphicsPathViewPrivate::getItem(int modelIndex) +{ + Q_Q(QmlGraphicsPathView); + requestedIndex = modelIndex; + QmlGraphicsItem *item = model->item(modelIndex); + if (item) { + if (QObject *obj = QmlGraphicsPathView::qmlAttachedProperties(item)) + static_cast<QmlGraphicsPathViewAttached *>(obj)->setOnPath(true); + item->setParentItem(q); + } + requestedIndex = -1; + return item; +} + +void QmlGraphicsPathViewPrivate::releaseItem(QmlGraphicsItem *item) +{ + if (!item || !model) + return; + if (QObject *obj = QmlGraphicsPathView::qmlAttachedProperties(item)) + static_cast<QmlGraphicsPathViewAttached *>(obj)->setOnPath(false); + if (model->release(item) == 0) { + if (QObject *obj = QmlGraphicsPathView::qmlAttachedProperties(item)) + static_cast<QmlGraphicsPathViewAttached *>(obj)->setOnPath(false); + } +} + /*! \qmlclass PathView QmlGraphicsPathView \brief The PathView element lays out model-provided items on a path. @@ -126,6 +167,26 @@ QmlGraphicsPathView::~QmlGraphicsPathView() } /*! + \qmlattachedproperty bool PathView::onPath + This attached property holds whether the item is currently on the path. + + If a pathItemCount has been set, it is possible that some items may + be instantiated, but not considered to be currently on the path. + Usually, these items would be set invisible, for example: + + \code + Component { + Rectangle { + visible: PathView.onPath + ... + } + } + \endcode + + It is attached to each instance of the delegate. +*/ + +/*! \qmlproperty model PathView::model This property holds the model providing data for the view. diff --git a/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h b/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h index 7ffe6ac..18cb205 100644 --- a/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h @@ -79,7 +79,7 @@ public: : path(0), currentIndex(0), startPc(0), lastDist(0) , lastElapsed(0), stealMouse(false), ownModel(false), activeItem(0) , snapPos(0), dragMargin(0), moveOffset(this, &QmlGraphicsPathViewPrivate::setOffset) - , firstIndex(0), pathItems(-1), pathOffset(0), requestedIndex(-1), model(0) + , firstIndex(0), pathItems(-1), pathOffset(0), requestedIndex(-1) , moveReason(Other) { fixupOffsetEvent = QmlTimeLineEvent::timeLineEvent<QmlGraphicsPathViewPrivate, &QmlGraphicsPathViewPrivate::fixOffset>(&moveOffset, this); @@ -95,18 +95,8 @@ public: q->connect(&tl, SIGNAL(updated()), q, SLOT(ticked())); } - QmlGraphicsItem *getItem(int modelIndex) { - Q_Q(QmlGraphicsPathView); - requestedIndex = modelIndex; - QmlGraphicsItem *item = model->item(modelIndex); - if (item) - item->setParentItem(q); - requestedIndex = -1; - return item; - } - void releaseItem(QmlGraphicsItem *item) { - model->release(item); - } + QmlGraphicsItem *getItem(int modelIndex); + void releaseItem(QmlGraphicsItem *item); bool isValid() const { return model && model->count() > 0 && model->isValid() && path; @@ -143,7 +133,7 @@ public: int pathOffset; int requestedIndex; QList<QmlGraphicsItem *> items; - QmlGraphicsVisualModel *model; + QGuard<QmlGraphicsVisualModel> model; QVariant modelVariant; enum MovementReason { Other, Key, Mouse }; MovementReason moveReason; diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp index 70e3a43..2fc143d 100644 --- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp @@ -462,7 +462,8 @@ int QmlGraphicsVisualDataModelDataMetaObject::createProperty(const char *name, c QmlGraphicsVisualDataModelPrivate *model = QmlGraphicsVisualDataModelPrivate::get(data->m_model); if ((!model->m_listModelInterface || !model->m_abstractItemModel) && model->m_listAccessor) { - if (model->m_listAccessor->type() == QmlListAccessor::QmlList) { + if (model->m_listAccessor->type() == QmlListAccessor::QmlList + || model->m_listAccessor->type() == QmlListAccessor::QListPtr) { model->ensureRoles(); QObject *object = model->m_listAccessor->at(data->m_index).value<QObject*>(); if (object && object->property(name).isValid()) @@ -724,7 +725,7 @@ void QmlGraphicsVisualDataModel::setModel(const QVariant &model) } d->m_listAccessor = new QmlListAccessor; d->m_listAccessor->setList(model, d->m_context?d->m_context->engine():qmlEngine(this)); - if (d->m_listAccessor->type() != QmlListAccessor::QmlList) + if (d->m_listAccessor->type() != QmlListAccessor::QmlList && d->m_listAccessor->type() != QmlListAccessor::QListPtr) d->m_metaDataCacheable = true; if (d->m_delegate && d->modelCount()) { emit itemsInserted(0, d->modelCount()); @@ -805,8 +806,12 @@ QmlGraphicsVisualDataModel::ReleaseFlags QmlGraphicsVisualDataModel::release(Qml } if (d->m_cache.releaseItem(obj)) { - if (inPackage) + if (inPackage) { emit destroyingPackage(qobject_cast<QmlPackage*>(obj)); + } else { + item->setVisible(false); + static_cast<QGraphicsItem*>(item)->setParentItem(0); + } stat |= Destroyed; obj->deleteLater(); } else if (!inPackage) { diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index bb7abf3..26ebd27 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -115,7 +115,7 @@ QList<QmlError> QmlCompiler::errors() const /*! Returns true if \a val is a legal object id, false otherwise. - Legal ids must start with a letter or underscore, and contain only + Legal ids must start with a lower-case letter or underscore, and contain only letters, numbers and underscores. */ bool QmlCompiler::isValidId(const QString &val) @@ -123,6 +123,12 @@ bool QmlCompiler::isValidId(const QString &val) if (val.isEmpty()) return false; + // TODO this will be enforced and return false + if (val.at(0).isLetter() && !val.at(0).isLower()) { + //return false; + qWarning() << "id '" + val + "' is invalid: ids cannot start with uppercase letters. This will be enforced in an upcoming version of QML."; + } + QChar u(QLatin1Char('_')); for (int ii = 0; ii < val.count(); ++ii) if (val.at(ii) != u && @@ -677,6 +683,13 @@ void QmlCompiler::compileTree(Object *tree) QmlEnginePrivate::get(engine)->registerCompositeType(output); } +static bool ValuePtrLessThan(const Value *t1, const Value *t2) +{ + return t1->location.start.line < t2->location.start.line || + (t1->location.start.line == t2->location.start.line && + t1->location.start.column < t2->location.start.column); +} + bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt) { componentStat.objects++; @@ -736,9 +749,46 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt) } } + // Merge + Property *defaultProperty = 0; + Property *skipProperty = 0; + if (obj->defaultProperty) { + const QMetaObject *metaObject = obj->metaObject(); + Q_ASSERT(metaObject); + QMetaProperty p = QmlMetaType::defaultProperty(metaObject); + if (p.name()) { + Property *explicitProperty = obj->getProperty(p.name(), false); + if (explicitProperty && !explicitProperty->value) { + skipProperty = explicitProperty; + + defaultProperty = new Property; + defaultProperty->parent = obj; + defaultProperty->isDefault = true; + defaultProperty->location = obj->defaultProperty->location; + defaultProperty->listValueRange = obj->defaultProperty->listValueRange; + defaultProperty->listCommaPositions = obj->defaultProperty->listCommaPositions; + + defaultProperty->values = obj->defaultProperty->values; + defaultProperty->values += explicitProperty->values; + foreach(Value *value, defaultProperty->values) + value->addref(); + qSort(defaultProperty->values.begin(), defaultProperty->values.end(), ValuePtrLessThan); + + } else { + defaultProperty = obj->defaultProperty; + defaultProperty->addref(); + } + } else { + defaultProperty = obj->defaultProperty; + defaultProperty->addref(); + } + } + // Build all explicit properties specified foreach(Property *prop, obj->properties) { + if (prop == skipProperty) + continue; if (prop->name == "id") continue; @@ -768,8 +818,8 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt) } // Build the default property - if (obj->defaultProperty) { - Property *prop = obj->defaultProperty; + if (defaultProperty) { + Property *prop = defaultProperty; bool canDefer = false; if (isCustomParser) { @@ -791,6 +841,9 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt) prop->isDeferred = true; } + if (defaultProperty) + defaultProperty->release(); + // Compile custom parser parts if (isCustomParser && !customProps.isEmpty()) { QmlCustomParser *cp = output->types.at(obj->type).type->customParser(); diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index a33aea7..ea0c054 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -122,7 +122,7 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) contextClass(0), sharedContext(0), sharedScope(0), objectClass(0), valueTypeClass(0), globalClass(0), cleanup(0), erroredBindings(0), inProgressCreations(0), scriptEngine(this), workerScriptEngine(0), componentAttacheds(0), inBeginCreate(false), - networkAccessManager(0), networkAccessManagerFactory(0), accessManagerValid(false), + networkAccessManager(0), networkAccessManagerFactory(0), typeManager(e), uniqueId(1) { globalClass = new QmlGlobalScriptClass(&scriptEngine); @@ -221,6 +221,11 @@ QScriptValue QmlScriptEngine::resolvedUrl(QScriptContext *ctxt, QScriptEngine *e return QScriptValue(r.toString()); } +QNetworkAccessManager *QmlScriptEngine::networkAccessManager() +{ + return p->getNetworkAccessManager(); +} + QmlEnginePrivate::~QmlEnginePrivate() { while (cleanup) { @@ -412,10 +417,18 @@ QmlNetworkAccessManagerFactory *QmlEngine::networkAccessManagerFactory() const return d->networkAccessManagerFactory; } -void QmlEngine::namInvalidated() +QNetworkAccessManager *QmlEnginePrivate::getNetworkAccessManager() const { - Q_D(QmlEngine); - d->accessManagerValid = false; + Q_Q(const QmlEngine); + + if (!networkAccessManager) { + if (networkAccessManagerFactory) { + networkAccessManager = networkAccessManagerFactory->create(const_cast<QmlEngine*>(q)); + } else { + networkAccessManager = new QNetworkAccessManager(const_cast<QmlEngine*>(q)); + } + } + return networkAccessManager; } /*! @@ -432,21 +445,7 @@ void QmlEngine::namInvalidated() QNetworkAccessManager *QmlEngine::networkAccessManager() const { Q_D(const QmlEngine); - if (!d->accessManagerValid) { - delete d->networkAccessManagerFactory; - d->networkAccessManagerFactory = 0; - } - if (!d->networkAccessManager) { - if (d->networkAccessManagerFactory) { - connect(d->networkAccessManagerFactory, SIGNAL(invalidated()) - , this, SLOT(namInvalidated()), Qt::UniqueConnection); - d->networkAccessManager = d->networkAccessManagerFactory->create(const_cast<QmlEngine*>(this)); - } else { - d->networkAccessManager = new QNetworkAccessManager(const_cast<QmlEngine*>(this)); - } - d->accessManagerValid = true; - } - return d->networkAccessManager; + return d->getNetworkAccessManager(); } /*! diff --git a/src/declarative/qml/qmlengine.h b/src/declarative/qml/qmlengine.h index b9ec277..7ee014a 100644 --- a/src/declarative/qml/qmlengine.h +++ b/src/declarative/qml/qmlengine.h @@ -95,9 +95,6 @@ public: Q_SIGNALS: void quit (); -private Q_SLOTS: - void namInvalidated(); - private: Q_DECLARE_PRIVATE(QmlEngine) }; diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index 6f62b40..6aa5d69 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -108,8 +108,7 @@ class QmlScriptEngine : public QScriptEngine { public: QmlScriptEngine(QmlEnginePrivate *priv); - - ~QmlScriptEngine(); + virtual ~QmlScriptEngine(); QUrl resolvedUrl(QScriptContext *context, const QUrl& url); // resolved against p's context, or baseUrl if no p static QScriptValue resolvedUrl(QScriptContext *ctxt, QScriptEngine *engine); @@ -127,6 +126,8 @@ public: QScriptClass *nodeListClass; QUrl baseUrl; + + virtual QNetworkAccessManager *networkAccessManager(); }; class Q_AUTOTEST_EXPORT QmlEnginePrivate : public QObjectPrivate @@ -209,9 +210,10 @@ public: QmlComponentAttached *componentAttacheds; bool inBeginCreate; + + QNetworkAccessManager *getNetworkAccessManager() const; mutable QNetworkAccessManager *networkAccessManager; mutable QmlNetworkAccessManagerFactory *networkAccessManagerFactory; - mutable bool accessManagerValid; QmlCompositeTypeManager typeManager; QStringList fileImportPath; diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp index 3e8d71a..ff1705b 100644 --- a/src/declarative/qml/qmlexpression.cpp +++ b/src/declarative/qml/qmlexpression.cpp @@ -184,7 +184,7 @@ QScriptValue QmlExpressionPrivate::evalInObjectScope(QmlContext *context, QObjec /*! \class QmlExpression - \brief The QmlExpression class evaluates ECMAScript in a QML context. + \brief The QmlExpression class evaluates JavaScript in a QML context. */ /*! @@ -212,7 +212,7 @@ QmlExpression::QmlExpression(QmlContext *ctxt, void *expr, /*! Create a QmlExpression object. - The \a expression ECMAScript will be executed in the \a ctxt QmlContext. + The \a expression JavaScript will be executed in the \a ctxt QmlContext. If specified, the \a scope object's properties will also be in scope during the expression's execution. */ diff --git a/src/declarative/qml/qmlnetworkaccessmanagerfactory.cpp b/src/declarative/qml/qmlnetworkaccessmanagerfactory.cpp index 6ae20de..76f20d8 100644 --- a/src/declarative/qml/qmlnetworkaccessmanagerfactory.cpp +++ b/src/declarative/qml/qmlnetworkaccessmanagerfactory.cpp @@ -76,18 +76,4 @@ QmlNetworkAccessManagerFactory::~QmlNetworkAccessManagerFactory() implementation of this method is reentrant. */ -/*! - Invalidates all currently created QNetworkAccessManager(s) which - will cause create() to be called for subsequent network access. -*/ -void QmlNetworkAccessManagerFactory::invalidate() -{ - emit invalidated(); -} - -/*! - \internal - \fn QmlNetworkAccessManagerFactory::invalidated() -*/ - QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlnetworkaccessmanagerfactory.h b/src/declarative/qml/qmlnetworkaccessmanagerfactory.h index f64918b..ce9860f 100644 --- a/src/declarative/qml/qmlnetworkaccessmanagerfactory.h +++ b/src/declarative/qml/qmlnetworkaccessmanagerfactory.h @@ -51,16 +51,12 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QNetworkAccessManager; -class Q_DECLARATIVE_EXPORT QmlNetworkAccessManagerFactory : public QObject +class Q_DECLARATIVE_EXPORT QmlNetworkAccessManagerFactory { - Q_OBJECT public: virtual ~QmlNetworkAccessManagerFactory(); - void invalidate(); virtual QNetworkAccessManager *create(QObject *parent) = 0; -Q_SIGNALS: - void invalidated(); }; QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp index 5fd76c6..4ff4746 100644 --- a/src/declarative/qml/qmlobjectscriptclass.cpp +++ b/src/declarative/qml/qmlobjectscriptclass.cpp @@ -70,7 +70,7 @@ struct ObjectData : public QScriptDeclarativeClass::Object { */ QmlObjectScriptClass::QmlObjectScriptClass(QmlEngine *bindEngine) : QmlScriptClass(QmlEnginePrivate::getScriptEngine(bindEngine)), -#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) +#if (QT_VERSION > QT_VERSION_CHECK(4, 6, 2)) || defined(QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE) methods(bindEngine), #endif lastData(0), engine(bindEngine) @@ -231,7 +231,7 @@ QmlObjectScriptClass::property(QObject *obj, const Identifier &name) if (lastData->flags & QmlPropertyCache::Data::IsVMEFunction) { return Value(scriptEngine, ((QmlVMEMetaObject *)(obj->metaObject()))->vmeMethod(lastData->coreIndex)); } else { -#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) +#if (QT_VERSION > QT_VERSION_CHECK(4, 6, 2)) || defined(QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE) // Uncomment to use QtScript method call logic // QScriptValue sobj = scriptEngine->newQObject(obj); // return Value(scriptEngine, sobj.property(toString(name))); @@ -444,7 +444,7 @@ QStringList QmlObjectScriptClass::propertyNames(Object *object) return cache->propertyNames(); } -#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) +#if (QT_VERSION > QT_VERSION_CHECK(4, 6, 2)) || defined(QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE) struct MethodData : public QScriptDeclarativeClass::Object { MethodData(QObject *o, const QmlPropertyCache::Data &d) : object(o), data(d) {} diff --git a/src/declarative/qml/qmlobjectscriptclass_p.h b/src/declarative/qml/qmlobjectscriptclass_p.h index ebb2c2a..470c555 100644 --- a/src/declarative/qml/qmlobjectscriptclass_p.h +++ b/src/declarative/qml/qmlobjectscriptclass_p.h @@ -65,7 +65,7 @@ class QScriptContext; class QScriptEngine; class QmlContext; -#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) +#if (QT_VERSION > QT_VERSION_CHECK(4, 6, 2)) || defined(QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE) class Q_AUTOTEST_EXPORT QmlObjectMethodScriptClass : public QScriptDeclarativeClass { public: @@ -118,7 +118,7 @@ protected: virtual QObject *toQObject(Object *, bool *ok = 0); private: -#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) +#if (QT_VERSION > QT_VERSION_CHECK(4, 6, 2)) || defined(QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE) QmlObjectMethodScriptClass methods; #endif diff --git a/src/declarative/qml/qmlscript.cpp b/src/declarative/qml/qmlscript.cpp index ba62898..10fc9a6 100644 --- a/src/declarative/qml/qmlscript.cpp +++ b/src/declarative/qml/qmlscript.cpp @@ -70,7 +70,7 @@ defining functions that are only executed later once the context is fully defined. - \sa {ECMAScript Blocks} + \sa {JavaScript Blocks} */ /*! diff --git a/src/declarative/qml/qmlscriptclass_p.h b/src/declarative/qml/qmlscriptclass_p.h index 7ffb2ae..847ee66 100644 --- a/src/declarative/qml/qmlscriptclass_p.h +++ b/src/declarative/qml/qmlscriptclass_p.h @@ -66,7 +66,7 @@ public: static QVariant toVariant(QmlEngine *, const QScriptValue &); -#if (QT_VERSION < QT_VERSION_CHECK(4, 6, 2)) +#if (QT_VERSION <= QT_VERSION_CHECK(4, 6, 2)) && !defined(QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE) struct Value : public QScriptValue { Value() : QScriptValue() {} Value(QScriptEngine *engine, int v) : QScriptValue(engine, v) {} diff --git a/src/declarative/qml/qmlworkerscript.cpp b/src/declarative/qml/qmlworkerscript.cpp index 75c5179..f58aa8b 100644 --- a/src/declarative/qml/qmlworkerscript.cpp +++ b/src/declarative/qml/qmlworkerscript.cpp @@ -51,6 +51,7 @@ #include <QtCore/qwaitcondition.h> #include <QtScript/qscriptvalueiterator.h> #include <QtCore/qfile.h> +#include <QtNetwork/qnetworkaccessmanager.h> #include <QtDeclarative/qmlinfo.h> QT_BEGIN_NAMESPACE @@ -107,7 +108,14 @@ public: struct ScriptEngine : public QmlScriptEngine { ScriptEngine(QmlWorkerScriptEnginePrivate *parent) : QmlScriptEngine(0), p(parent) {} + ~ScriptEngine() { delete manager; }; QmlWorkerScriptEnginePrivate *p; + QNetworkAccessManager *manager; + + virtual QNetworkAccessManager *networkAccessManager() { + if (!manager) manager = new QNetworkAccessManager; + return manager; + } }; ScriptEngine *workerEngine; static QmlWorkerScriptEnginePrivate *get(QScriptEngine *e) { @@ -128,6 +136,9 @@ public: QScriptValue callback; }; + QNetworkAccessManager *networkAccessManager; + QNetworkAccessManager *getNetworkAccessManager(); + QHash<int, WorkerScript *> workers; QScriptValue getWorker(int); @@ -224,7 +235,7 @@ private: Q_DECLARE_METATYPE(QmlWorkerListModelAgent::VariantRef); QmlWorkerScriptEnginePrivate::QmlWorkerScriptEnginePrivate() -: workerEngine(0), m_nextId(0) +: workerEngine(0), networkAccessManager(0), m_nextId(0) { } diff --git a/src/declarative/qml/qmlxmlhttprequest.cpp b/src/declarative/qml/qmlxmlhttprequest.cpp index f69f254..86bec20 100644 --- a/src/declarative/qml/qmlxmlhttprequest.cpp +++ b/src/declarative/qml/qmlxmlhttprequest.cpp @@ -940,7 +940,7 @@ public: Opened = 1, HeadersReceived = 2, Loading = 3, Done = 4 }; - QmlXMLHttpRequest(); + QmlXMLHttpRequest(QNetworkAccessManager *manager); virtual ~QmlXMLHttpRequest(); QScriptValue callback() const; @@ -966,12 +966,16 @@ private slots: void finished(); private: + void requestFromUrl(const QUrl &url); + State m_state; bool m_errorFlag; bool m_sendFlag; QString m_method; QUrl m_url; QByteArray m_responseEntityBody; + QByteArray m_data; + int m_redirectCount; typedef QPair<QByteArray, QByteArray> HeaderPair; typedef QList<HeaderPair> HeadersList; @@ -989,26 +993,18 @@ private: void destroyNetwork(); QNetworkAccessManager *m_nam; - QNetworkAccessManager *networkAccessManager() - { - if (!m_nam) { - m_nam = new QNetworkAccessManager; - // XXX proxy, etc... - } - return m_nam; - } + QNetworkAccessManager *networkAccessManager() { return m_nam; } }; -QmlXMLHttpRequest::QmlXMLHttpRequest() +QmlXMLHttpRequest::QmlXMLHttpRequest(QNetworkAccessManager *manager) : m_state(Unsent), m_errorFlag(false), m_sendFlag(false), - m_network(0), m_nam(0) + m_redirectCount(0), m_network(0), m_nam(manager) { } QmlXMLHttpRequest::~QmlXMLHttpRequest() { destroyNetwork(); - delete m_nam; } QScriptValue QmlXMLHttpRequest::callback() const @@ -1109,16 +1105,10 @@ void QmlXMLHttpRequest::fillHeadersList() } } -QScriptValue QmlXMLHttpRequest::send(const QByteArray &data) +void QmlXMLHttpRequest::requestFromUrl(const QUrl &url) { - m_errorFlag = false; - m_sendFlag = true; - - QScriptValue cbv = dispatchCallback(); - if (cbv.isError()) return cbv; - - m_request.setUrl(m_url); QNetworkRequest request = m_request; + request.setUrl(url); if(m_method == QLatin1String("POST") || m_method == QLatin1String("PUT")) { QVariant var = request.header(QNetworkRequest::ContentTypeHeader); @@ -1153,9 +1143,9 @@ QScriptValue QmlXMLHttpRequest::send(const QByteArray &data) else if (m_method == QLatin1String("HEAD")) m_network = networkAccessManager()->head(request); else if(m_method == QLatin1String("POST")) - m_network = networkAccessManager()->post(request, data); + m_network = networkAccessManager()->post(request, m_data); else if(m_method == QLatin1String("PUT")) - m_network = networkAccessManager()->put(request, data); + m_network = networkAccessManager()->put(request, m_data); QObject::connect(m_network, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadProgress(qint64))); @@ -1163,6 +1153,16 @@ QScriptValue QmlXMLHttpRequest::send(const QByteArray &data) this, SLOT(error(QNetworkReply::NetworkError))); QObject::connect(m_network, SIGNAL(finished()), this, SLOT(finished())); +} + +QScriptValue QmlXMLHttpRequest::send(const QByteArray &data) +{ + m_errorFlag = false; + m_sendFlag = true; + m_redirectCount = 0; + m_data = data; + + requestFromUrl(m_url); return QScriptValue(); } @@ -1224,6 +1224,7 @@ void QmlXMLHttpRequest::error(QNetworkReply::NetworkError error) m_responseEntityBody = QByteArray(); m_request = QNetworkRequest(); + m_data.clear(); destroyNetwork(); if (error == QNetworkReply::ContentAccessDenied || @@ -1243,9 +1244,19 @@ void QmlXMLHttpRequest::error(QNetworkReply::NetworkError error) if (cbv.isError()) printError(cbv); } +#define XMLHTTPREQUEST_MAXIMUM_REDIRECT_RECURSION 15 void QmlXMLHttpRequest::finished() { - // ### We need to transparently redirect as dictated by the spec + m_redirectCount++; + if (m_redirectCount < XMLHTTPREQUEST_MAXIMUM_REDIRECT_RECURSION) { + QVariant redirect = m_network->attribute(QNetworkRequest::RedirectionTargetAttribute); + if (redirect.isValid()) { + QUrl url = redirect.toUrl(); + destroyNetwork(); + requestFromUrl(url); + return; + } + } m_status = m_network->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); @@ -1259,6 +1270,7 @@ void QmlXMLHttpRequest::finished() if (cbv.isError()) printError(cbv); } m_responseEntityBody.append(m_network->readAll()); + m_data.clear(); destroyNetwork(); if (m_state < Loading) { m_state = Loading; @@ -1548,7 +1560,7 @@ static QScriptValue qmlxmlhttprequest_onreadystatechange(QScriptContext *context static QScriptValue qmlxmlhttprequest_new(QScriptContext *context, QScriptEngine *engine) { if (context->isCalledAsConstructor()) { - context->thisObject().setData(engine->newQObject(new QmlXMLHttpRequest(), QScriptEngine::ScriptOwnership)); + context->thisObject().setData(engine->newQObject(new QmlXMLHttpRequest(QmlScriptEngine::get(engine)->networkAccessManager()), QScriptEngine::ScriptOwnership)); } return engine->undefinedValue(); } diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index 8c70539..0b19574 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -161,10 +161,10 @@ static void dump(ModelNode *node, int ind); id: fruitDelegate Item { width: 200; height: 50 - Text { id: Name; text: name } + Text { id: name; text: name } Text { text: '$'+cost; anchors.right: parent.right } Row { - anchors.top: Name.bottom + anchors.top: name.bottom spacing: 5 Text { text: "Attributes:" } Repeater { diff --git a/src/declarative/util/qmlpixmapcache.cpp b/src/declarative/util/qmlpixmapcache.cpp index 5189118..755863a 100644 --- a/src/declarative/util/qmlpixmapcache.cpp +++ b/src/declarative/util/qmlpixmapcache.cpp @@ -75,6 +75,20 @@ inline uint qHash(const QUrl &uri) return qHash(uri.toEncoded(QUrl::FormattingOption(0x100))); } + +class QmlImageReaderEvent : public QEvent +{ +public: + enum ReadError { NoError, Loading, Decoding }; + + QmlImageReaderEvent(QmlImageReaderEvent::ReadError err, QImage &img) + : QEvent(QEvent::User), error(err), image(img) {} + + ReadError error; + QImage image; +}; + +class QmlImageRequestHandler; class QmlImageReader : public QThread { Q_OBJECT @@ -89,130 +103,61 @@ public: protected: void run(); - bool event(QEvent *event); - -private slots: - void networkRequestDone(); - void namInvalidated() { - accessManagerValid = false; - } private: - QNetworkAccessManager *networkAccessManager() { - if (!accessManagerValid) { - delete accessManager; - accessManager = 0; - } - if (!accessManager) { - if (engine && engine->networkAccessManagerFactory()) { - connect(engine->networkAccessManagerFactory(), SIGNAL(invalidated()) - , this, SLOT(namInvalidated()), Qt::UniqueConnection); - accessManager = engine->networkAccessManagerFactory()->create(this); - } else { - accessManager = new QNetworkAccessManager(this); - } - accessManagerValid = true; - } - return accessManager; - } - QList<QmlPixmapReply*> jobs; QList<QmlPixmapReply*> cancelled; - QHash<QNetworkReply*,QmlPixmapReply*> replies; - QNetworkAccessManager *accessManager; - bool accessManagerValid; QmlEngine *engine; + QmlImageRequestHandler *handler; QMutex mutex; + static QHash<QmlEngine *,QmlImageReader*> readers; + friend class QmlImageRequestHandler; }; QHash<QmlEngine *,QmlImageReader*> QmlImageReader::readers; -class QmlImageReaderEvent : public QEvent -{ -public: - enum ReadError { NoError, Loading, Decoding }; - - QmlImageReaderEvent(QmlImageReaderEvent::ReadError err, QImage &img) - : QEvent(QEvent::User), error(err), image(img) {} - - ReadError error; - QImage image; -}; - -QmlImageReader::QmlImageReader(QmlEngine *eng) - : QThread(eng), accessManager(0), accessManagerValid(false), engine(eng) +class QmlImageRequestHandler : public QObject { - start(QThread::LowPriority); -} - -QmlImageReader::~QmlImageReader() -{ -} - -QmlImageReader *QmlImageReader::instance(QmlEngine *engine) -{ - QmlImageReader *reader = readers.value(engine); - if (!reader) { - static QMutex rmutex; - rmutex.lock(); - reader = new QmlImageReader(engine); - readers.insert(engine, reader); - rmutex.unlock(); + Q_OBJECT +public: + QmlImageRequestHandler(QmlImageReader *read, QmlEngine *eng) + : QObject(), accessManager(0), engine(eng), reader(read) + { + QCoreApplication::postEvent(this, new QEvent(QEvent::User)); } - return reader; -} + QmlPixmapReply *getImage(const QUrl &url); + void cancel(QmlPixmapReply *reply); -QmlPixmapReply *QmlImageReader::getImage(const QUrl &url) -{ - mutex.lock(); - QmlPixmapReply *reply = new QmlPixmapReply(engine, url); - jobs.append(reply); - if (jobs.count() == 1) - QCoreApplication::postEvent(this, new QEvent(QEvent::User)); - mutex.unlock(); - return reply; -} +protected: + bool event(QEvent *event); -void QmlImageReader::cancel(QmlPixmapReply *reply) -{ - mutex.lock(); - if (reply->isLoading()) { - // Already requested. Add to cancel list to be cancelled in reader thread. - cancelled.append(reply); - if (cancelled.count() == 1) - QCoreApplication::postEvent(this, new QEvent(QEvent::User)); - } else { - // Not yet processed - just remove from waiting list - QList<QmlPixmapReply*>::iterator it = jobs.begin(); - while (it != jobs.end()) { - QmlPixmapReply *job = *it; - if (job == reply) { - jobs.erase(it); - break; +private slots: + void networkRequestDone(); + +private: + QNetworkAccessManager *networkAccessManager() { + if (!accessManager) { + if (engine && engine->networkAccessManagerFactory()) { + accessManager = engine->networkAccessManagerFactory()->create(this); + } else { + accessManager = new QNetworkAccessManager(this); } - ++it; } + return accessManager; } - mutex.unlock(); -} - -void QmlImageReader::run() -{ -#ifdef Q_OS_LINUX - struct sched_param param; - int policy; - pthread_getschedparam(pthread_self(), &policy, ¶m); - pthread_setschedparam(pthread_self(), SCHED_IDLE, ¶m); -#endif + QHash<QNetworkReply*,QmlPixmapReply*> replies; + QNetworkAccessManager *accessManager; + QmlEngine *engine; + QmlImageReader *reader; +}; - exec(); -} +//=========================================================================== -bool QmlImageReader::event(QEvent *event) +bool QmlImageRequestHandler::event(QEvent *event) { if (event->type() == QEvent::User) { static int replyDownloadProgress = -1; @@ -224,15 +169,15 @@ bool QmlImageReader::event(QEvent *event) replyDownloadProgress = QNetworkReply::staticMetaObject.indexOfSignal("downloadProgress(qint64,qint64)"); replyFinished = QNetworkReply::staticMetaObject.indexOfSignal("finished()"); downloadProgress = QmlPixmapReply::staticMetaObject.indexOfSignal("downloadProgress(qint64,qint64)"); - thisNetworkRequestDone = QmlImageReader::staticMetaObject.indexOfSlot("networkRequestDone()"); + thisNetworkRequestDone = QmlImageRequestHandler::staticMetaObject.indexOfSlot("networkRequestDone()"); } while (1) { - mutex.lock(); + reader->mutex.lock(); - if (cancelled.count()) { - for (int i = 0; i < cancelled.count(); ++i) { - QmlPixmapReply *job = cancelled.at(i); + if (reader->cancelled.count()) { + for (int i = 0; i < reader->cancelled.count(); ++i) { + QmlPixmapReply *job = reader->cancelled.at(i); QNetworkReply *reply = replies.key(job, 0); if (reply && reply->isRunning()) { replies.remove(reply); @@ -240,29 +185,19 @@ bool QmlImageReader::event(QEvent *event) job->release(true); } } - cancelled.clear(); - } - - if (!accessManagerValid) { - // throw away existing requests and reschedule. - QHash<QNetworkReply*,QmlPixmapReply*>::iterator it = replies.begin(); - for (; it != replies.end(); ++it) { - delete it.key(); - jobs.prepend(*it); - } - replies.clear(); + reader->cancelled.clear(); } - if (!jobs.count() || replies.count() > maxImageRequestCount) { - mutex.unlock(); + if (!reader->jobs.count() || replies.count() > maxImageRequestCount) { + reader->mutex.unlock(); break; } - QmlPixmapReply *runningJob = jobs.takeFirst(); + QmlPixmapReply *runningJob = reader->jobs.takeFirst(); runningJob->addRef(); runningJob->setLoading(); QUrl url = runningJob->url(); - mutex.unlock(); + reader->mutex.unlock(); // fetch QNetworkRequest req(url); @@ -280,7 +215,7 @@ bool QmlImageReader::event(QEvent *event) return QObject::event(event); } -void QmlImageReader::networkRequestDone() +void QmlImageRequestHandler::networkRequestDone() { QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); QmlPixmapReply *job = replies.take(reply); @@ -306,6 +241,84 @@ void QmlImageReader::networkRequestDone() reply->deleteLater(); } +//=========================================================================== + +QmlImageReader::QmlImageReader(QmlEngine *eng) + : QThread(eng), engine(eng), handler(0) +{ + start(QThread::LowPriority); +} + +QmlImageReader::~QmlImageReader() +{ + delete handler; +} + +QmlImageReader *QmlImageReader::instance(QmlEngine *engine) +{ + QmlImageReader *reader = readers.value(engine); + if (!reader) { + static QMutex rmutex; + rmutex.lock(); + reader = new QmlImageReader(engine); + readers.insert(engine, reader); + rmutex.unlock(); + } + + return reader; +} + +QmlPixmapReply *QmlImageReader::getImage(const QUrl &url) +{ + mutex.lock(); + QmlPixmapReply *reply = new QmlPixmapReply(engine, url); + jobs.append(reply); + if (jobs.count() == 1 && handler) + QCoreApplication::postEvent(handler, new QEvent(QEvent::User)); + mutex.unlock(); + return reply; +} + +void QmlImageReader::cancel(QmlPixmapReply *reply) +{ + mutex.lock(); + if (reply->isLoading()) { + // Already requested. Add to cancel list to be cancelled in reader thread. + cancelled.append(reply); + if (cancelled.count() == 1 && handler) + QCoreApplication::postEvent(handler, new QEvent(QEvent::User)); + } else { + // Not yet processed - just remove from waiting list + QList<QmlPixmapReply*>::iterator it = jobs.begin(); + while (it != jobs.end()) { + QmlPixmapReply *job = *it; + if (job == reply) { + jobs.erase(it); + break; + } + ++it; + } + } + mutex.unlock(); +} + +void QmlImageReader::run() +{ +#if defined(Q_OS_LINUX) && defined(SCHED_IDLE) + struct sched_param param; + int policy; + + pthread_getschedparam(pthread_self(), &policy, ¶m); + pthread_setschedparam(pthread_self(), SCHED_IDLE, ¶m); +#endif + + handler = new QmlImageRequestHandler(this, engine); + + exec(); +} + +//=========================================================================== + static bool readImage(QIODevice *dev, QPixmap *pixmap) { QImageReader imgio(dev); diff --git a/src/declarative/util/qmlpixmapcache_p.h b/src/declarative/util/qmlpixmapcache_p.h index 0140352..c202ea8 100644 --- a/src/declarative/util/qmlpixmapcache_p.h +++ b/src/declarative/util/qmlpixmapcache_p.h @@ -83,6 +83,7 @@ private: private: Q_DISABLE_COPY(QmlPixmapReply) Q_DECLARE_PRIVATE(QmlPixmapReply) + friend class QmlImageRequestHandler; friend class QmlImageReader; friend class QmlPixmapCache; }; diff --git a/src/gui/dialogs/qprintdialog.h b/src/gui/dialogs/qprintdialog.h index 390a4a0..ecd50c1 100644 --- a/src/gui/dialogs/qprintdialog.h +++ b/src/gui/dialogs/qprintdialog.h @@ -97,9 +97,9 @@ public: void done(int result); #if defined (Q_OS_UNIX) && defined (QT3_SUPPORT) - void setPrinter(QPrinter *, bool = false); - QPrinter *printer() const; - void addButton(QPushButton *button); + QT3_SUPPORT void setPrinter(QPrinter *, bool = false); + QT3_SUPPORT QPrinter *printer() const; + QT3_SUPPORT void addButton(QPushButton *button); #endif void setOption(PrintDialogOption option, bool on = true); diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index ad23df3..10ef5ea 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -383,9 +383,9 @@ void QGraphicsEffectSourcePrivate::invalidateCache(InvalidateReason reason) cons { if (m_cachedMode != QGraphicsEffect::PadToEffectiveBoundingRect && (reason == EffectRectChanged - || reason == TransformChanged - && m_cachedSystem == Qt::LogicalCoordinates)) + || (reason == TransformChanged && m_cachedSystem == Qt::LogicalCoordinates))) { return; + } QPixmapCache::remove(m_cacheKey); } diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index c53a893..500bdd0 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -268,6 +268,17 @@ */ /*! + \variable QGraphicsItem::Type + + The type value returned by the virtual type() function in standard + graphics item classes in Qt. All such standard graphics item + classes in Qt are associated with a unique value for Type, + e.g. the value returned by QGraphicsPathItem::type() is 2. + + \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 18 +*/ + +/*! \variable QGraphicsItem::UserType The lowest permitted type value for custom items (subclasses @@ -276,6 +287,8 @@ and declaring a Type enum value. Example: \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 1 + + \note UserType = 65536 */ /*! @@ -655,6 +668,7 @@ #include <QtCore/qtimer.h> #include <QtCore/qvariant.h> #include <QtCore/qvarlengtharray.h> +#include <QtCore/qnumeric.h> #include <QtGui/qapplication.h> #include <QtGui/qbitmap.h> #include <QtGui/qpainter.h> @@ -1558,17 +1572,18 @@ const QGraphicsObject *QGraphicsItem::toGraphicsObject() const } /*! - Sets this item's parent item to \a parent. If this item already has a - parent, it is first removed from the previous parent. If \a parent is 0, - this item will become a top-level item. + Sets this item's parent item to \a newParent. If this item already + has a parent, it is first removed from the previous parent. If \a + newParent is 0, this item will become a top-level item. - Note that this implicitly adds this graphics item to the scene of - the parent. You should not \l{QGraphicsScene::addItem()}{add} the - item to the scene yourself. + Note that this implicitly adds this graphics item to the scene of + the parent. You should not \l{QGraphicsScene::addItem()}{add} the + item to the scene yourself. - Calling this function on an item that is an ancestor of \a parent have undefined behaviour. + Calling this function on an item that is an ancestor of \a newParent + have undefined behaviour. - \sa parentItem(), childItems() + \sa parentItem(), childItems() */ void QGraphicsItem::setParentItem(QGraphicsItem *newParent) { @@ -3425,6 +3440,9 @@ void QGraphicsItem::setX(qreal x) if (d_ptr->inDestructor) return; + if (qIsNaN(x)) + return; + d_ptr->setPosHelper(QPointF(x, d_ptr->pos.y())); } @@ -3449,6 +3467,9 @@ void QGraphicsItem::setY(qreal y) if (d_ptr->inDestructor) return; + if (qIsNaN(y)) + return; + d_ptr->setPosHelper(QPointF(d_ptr->pos.x(), y)); } @@ -7241,7 +7262,9 @@ void QGraphicsItem::prepareGeometryChange() QGraphicsScenePrivate *scenePrivate = d_ptr->scene->d_func(); scenePrivate->index->prepareBoundingRectChange(this); - scenePrivate->markDirty(this, QRectF(), /*invalidateChildren=*/true); + scenePrivate->markDirty(this, QRectF(), /*invalidateChildren=*/true, /*force=*/false, + /*ignoreOpacity=*/ false, /*removingItemFromScene=*/ false, + /*updateBoundingRect=*/true); // For compatibility reasons, we have to update the item's old geometry // if someone is connected to the changed signal or the scene has no views. diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 9219773..54d47fa 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -4832,7 +4832,8 @@ void QGraphicsScenePrivate::draw(QGraphicsItem *item, QPainter *painter, const Q } void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, bool invalidateChildren, - bool force, bool ignoreOpacity, bool removingItemFromScene) + bool force, bool ignoreOpacity, bool removingItemFromScene, + bool updateBoundingRect) { Q_ASSERT(item); if (updateAll) @@ -4903,7 +4904,8 @@ void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, b if (ignoreOpacity) item->d_ptr->ignoreOpacity = 1; - item->d_ptr->markParentDirty(); + if (!updateBoundingRect) + item->d_ptr->markParentDirty(); } static inline bool updateHelper(QGraphicsViewPrivate *view, QGraphicsItemPrivate *item, diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index 54d8130..04ffe0f 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -222,7 +222,8 @@ public: QRegion *, QWidget *, qreal, const QTransform *const, bool, bool); void markDirty(QGraphicsItem *item, const QRectF &rect = QRectF(), bool invalidateChildren = false, - bool force = false, bool ignoreOpacity = false, bool removingItemFromScene = false); + bool force = false, bool ignoreOpacity = false, bool removingItemFromScene = false, + bool updateBoundingRect = false); void processDirtyItemsRecursive(QGraphicsItem *item, bool dirtyAncestorContainsChildren = false, qreal parentOpacity = qreal(1.0)); diff --git a/src/gui/kernel/qcocoamenuloader_mac.mm b/src/gui/kernel/qcocoamenuloader_mac.mm index 9f90cec..18b3772 100644 --- a/src/gui/kernel/qcocoamenuloader_mac.mm +++ b/src/gui/kernel/qcocoamenuloader_mac.mm @@ -110,6 +110,12 @@ QT_USE_NAMESPACE } } +- (void)removeActionsFromAppMenu +{ + for (NSMenuItem *item in [appMenu itemArray]) + [item setTag:nil]; +} + - (void)dealloc { [lastAppSpecificItem release]; diff --git a/src/gui/kernel/qcocoamenuloader_mac_p.h b/src/gui/kernel/qcocoamenuloader_mac_p.h index 432a7a6..81c136e 100644 --- a/src/gui/kernel/qcocoamenuloader_mac_p.h +++ b/src/gui/kernel/qcocoamenuloader_mac_p.h @@ -70,6 +70,7 @@ } - (void)ensureAppMenuInMenu:(NSMenu *)menu; +- (void)removeActionsFromAppMenu; - (NSMenu *)applicationMenu; - (NSMenu *)menu; - (NSMenuItem *)quitMenuItem; diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index f61d2fe..d255604 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -644,6 +644,8 @@ extern "C" { - (void)mouseEntered:(NSEvent *)event { + if (qwidgetprivate->data.in_destructor) + return; QEvent enterEvent(QEvent::Enter); NSPoint windowPoint = [event locationInWindow]; NSPoint globalPoint = [[event window] convertBaseToScreen:windowPoint]; diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm index eda75db..c7c7caf 100644 --- a/src/gui/kernel/qeventdispatcher_mac.mm +++ b/src/gui/kernel/qeventdispatcher_mac.mm @@ -569,7 +569,7 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags) // in cocoa. [NSApp run] should be called at least once for any cocoa app. if (NSModalSession session = d->currentModalSession()) { QBoolBlocker execGuard(d->currentExecIsNSAppRun, false); - while (!d->interrupt && [NSApp runModalSession:session] == NSRunContinuesResponse) + while ([NSApp runModalSession:session] == NSRunContinuesResponse && !d->interrupt) qt_mac_waitForMoreModalSessionEvents(); if (!d->interrupt && session == d->currentModalSessionCached) { // INVARIANT: Someone called e.g. [NSApp stopModal:] from outside the event diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index e36ab9b..e06a810 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -143,6 +143,9 @@ extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp void macWindowFade(void * /*OSWindowRef*/ window, float durationSeconds) { +#ifdef QT_MAC_USE_COCOA + QMacCocoaAutoReleasePool pool; +#endif OSWindowRef wnd = static_cast<OSWindowRef>(window); if (wnd) { QWidget *widget; @@ -1278,4 +1281,17 @@ void qt_cocoaChangeOverrideCursor(const QCursor &cursor) } #endif +QMacCocoaAutoReleasePool::QMacCocoaAutoReleasePool() +{ +#ifndef QT_MAC_USE_COCOA + NSApplicationLoad(); +#endif + pool = (void*)[[NSAutoreleasePool alloc] init]; +} + +QMacCocoaAutoReleasePool::~QMacCocoaAutoReleasePool() +{ + [(NSAutoreleasePool*)pool release]; +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index ede87de..ffad38b 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -3352,7 +3352,7 @@ QPoint QWidget::pos() const \note Setting the size to \c{QSize(0, 0)} will cause the widget to not appear on screen. This also applies to windows. - \sa pos, geometry, minimumSize, maximumSize, resizeEvent() + \sa pos, geometry, minimumSize, maximumSize, resizeEvent(), adjustSize() */ /*! diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 3dbc843..78c1562 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -404,7 +404,7 @@ inline static void qt_mac_set_fullscreen_mode(bool b) return; qt_mac_app_fullscreen = b; if (b) { - SetSystemUIMode(kUIModeAllSuppressed, 0); + SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar); } else { SetSystemUIMode(kUIModeNormal, 0); } @@ -3510,6 +3510,8 @@ void QWidgetPrivate::hide_sys() if (!QWidget::mouseGrabber()){ QWidget *enterWidget = QApplication::widgetAt(QCursor::pos()); + if (enterWidget && enterWidget->data->in_destructor) + enterWidget = 0; QApplicationPrivate::dispatchEnterLeave(enterWidget, qt_mouseover); qt_mouseover = enterWidget; } diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 97d69b2..7a680f2 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -667,32 +667,47 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg switch (ct) { case QStyle::CT_PushButton: { - const QPushButton *psh = static_cast<const QPushButton *>(widg); - QString buttonText = qt_mac_removeMnemonics(psh->text()); - if (buttonText.contains(QLatin1Char('\n'))) - ret = QSize(-1, -1); - else if (sz == QAquaSizeLarge) - ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricPushButtonHeight)); - else if (sz == QAquaSizeSmall) - ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricSmallPushButtonHeight)); - else if (sz == QAquaSizeMini) - ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricMiniPushButtonHeight)); - - if (!psh->icon().isNull()){ - // If the button got an icon, and the icon is larger than the - // button, we can't decide on a default size - ret.setWidth(-1); - if (ret.height() < psh->iconSize().height()) - ret.setHeight(-1); - } - else if (buttonText == QLatin1String("OK") || buttonText == QLatin1String("Cancel")){ - // Aqua Style guidelines restrict the size of OK and Cancel buttons to 68 pixels. - // However, this doesn't work for German, therefore only do it for English, - // I suppose it would be better to do some sort of lookups for languages - // that like to have really long words. - ret.setWidth(77 - 8); - } - + const QPushButton *psh = qobject_cast<const QPushButton *>(widg); + // If this comparison is false, then the widget was not a push button. + // This is bad and there's very little we can do since we were requested to find a + // sensible size for a widget that pretends to be a QPushButton but is not. + if(psh) { + QString buttonText = qt_mac_removeMnemonics(psh->text()); + if (buttonText.contains(QLatin1Char('\n'))) + ret = QSize(-1, -1); + else if (sz == QAquaSizeLarge) + ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricPushButtonHeight)); + else if (sz == QAquaSizeSmall) + ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricSmallPushButtonHeight)); + else if (sz == QAquaSizeMini) + ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricMiniPushButtonHeight)); + + if (!psh->icon().isNull()){ + // If the button got an icon, and the icon is larger than the + // button, we can't decide on a default size + ret.setWidth(-1); + if (ret.height() < psh->iconSize().height()) + ret.setHeight(-1); + } + else if (buttonText == QLatin1String("OK") || buttonText == QLatin1String("Cancel")){ + // Aqua Style guidelines restrict the size of OK and Cancel buttons to 68 pixels. + // However, this doesn't work for German, therefore only do it for English, + // I suppose it would be better to do some sort of lookups for languages + // that like to have really long words. + ret.setWidth(77 - 8); + } + } else { + // The only sensible thing to do is to return whatever the style suggests... + if (sz == QAquaSizeLarge) + ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricPushButtonHeight)); + else if (sz == QAquaSizeSmall) + ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricSmallPushButtonHeight)); + else if (sz == QAquaSizeMini) + ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricMiniPushButtonHeight)); + else + // Since there's no default size we return the large size... + ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricPushButtonHeight)); + } #if 0 //Not sure we are applying the rules correctly for RadioButtons/CheckBoxes --Sam } else if (ct == QStyle::CT_RadioButton) { QRadioButton *rdo = static_cast<QRadioButton *>(widg); @@ -749,23 +764,30 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg if (sz == QAquaSizeSmall) { int width = 0, height = 0; if (szHint == QSize(-1, -1)) { //just 'guess'.. - const QToolButton *bt = static_cast<const QToolButton *>(widg); - if (!bt->icon().isNull()) { - QSize iconSize = bt->iconSize(); - QSize pmSize = bt->icon().actualSize(QSize(32, 32), QIcon::Normal); - width = qMax(width, qMax(iconSize.width(), pmSize.width())); - height = qMax(height, qMax(iconSize.height(), pmSize.height())); - } - if (!bt->text().isNull() && bt->toolButtonStyle() != Qt::ToolButtonIconOnly) { - int text_width = bt->fontMetrics().width(bt->text()), - text_height = bt->fontMetrics().height(); - if (bt->toolButtonStyle() == Qt::ToolButtonTextUnderIcon) { - width = qMax(width, text_width); - height += text_height; - } else { - width += text_width; - width = qMax(height, text_height); + const QToolButton *bt = qobject_cast<const QToolButton *>(widg); + // If this conversion fails then the widget was not what it claimed to be. + if(bt) { + if (!bt->icon().isNull()) { + QSize iconSize = bt->iconSize(); + QSize pmSize = bt->icon().actualSize(QSize(32, 32), QIcon::Normal); + width = qMax(width, qMax(iconSize.width(), pmSize.width())); + height = qMax(height, qMax(iconSize.height(), pmSize.height())); + } + if (!bt->text().isNull() && bt->toolButtonStyle() != Qt::ToolButtonIconOnly) { + int text_width = bt->fontMetrics().width(bt->text()), + text_height = bt->fontMetrics().height(); + if (bt->toolButtonStyle() == Qt::ToolButtonTextUnderIcon) { + width = qMax(width, text_width); + height += text_height; + } else { + width += text_width; + width = qMax(height, text_height); + } } + } else { + // Let's return the size hint... + width = szHint.width(); + height = szHint.height(); } } else { width = szHint.width(); @@ -778,37 +800,47 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg break; case QStyle::CT_Slider: { int w = -1; - const QSlider *sld = static_cast<const QSlider *>(widg); - if (sz == QAquaSizeLarge) { - if (sld->orientation() == Qt::Horizontal) { - w = qt_mac_aqua_get_metric(kThemeMetricHSliderHeight); - if (sld->tickPosition() != QSlider::NoTicks) - w += qt_mac_aqua_get_metric(kThemeMetricHSliderTickHeight); - } else { - w = qt_mac_aqua_get_metric(kThemeMetricVSliderWidth); - if (sld->tickPosition() != QSlider::NoTicks) - w += qt_mac_aqua_get_metric(kThemeMetricVSliderTickWidth); - } - } else if (sz == QAquaSizeSmall) { - if (sld->orientation() == Qt::Horizontal) { - w = qt_mac_aqua_get_metric(kThemeMetricSmallHSliderHeight); - if (sld->tickPosition() != QSlider::NoTicks) - w += qt_mac_aqua_get_metric(kThemeMetricSmallHSliderTickHeight); - } else { - w = qt_mac_aqua_get_metric(kThemeMetricSmallVSliderWidth); - if (sld->tickPosition() != QSlider::NoTicks) - w += qt_mac_aqua_get_metric(kThemeMetricSmallVSliderTickWidth); - } - } else if (sz == QAquaSizeMini) { - if (sld->orientation() == Qt::Horizontal) { - w = qt_mac_aqua_get_metric(kThemeMetricMiniHSliderHeight); - if (sld->tickPosition() != QSlider::NoTicks) - w += qt_mac_aqua_get_metric(kThemeMetricMiniHSliderTickHeight); - } else { - w = qt_mac_aqua_get_metric(kThemeMetricMiniVSliderWidth); - if (sld->tickPosition() != QSlider::NoTicks) - w += qt_mac_aqua_get_metric(kThemeMetricMiniVSliderTickWidth); + const QSlider *sld = qobject_cast<const QSlider *>(widg); + // If this conversion fails then the widget was not what it claimed to be. + if(sld) { + if (sz == QAquaSizeLarge) { + if (sld->orientation() == Qt::Horizontal) { + w = qt_mac_aqua_get_metric(kThemeMetricHSliderHeight); + if (sld->tickPosition() != QSlider::NoTicks) + w += qt_mac_aqua_get_metric(kThemeMetricHSliderTickHeight); + } else { + w = qt_mac_aqua_get_metric(kThemeMetricVSliderWidth); + if (sld->tickPosition() != QSlider::NoTicks) + w += qt_mac_aqua_get_metric(kThemeMetricVSliderTickWidth); + } + } else if (sz == QAquaSizeSmall) { + if (sld->orientation() == Qt::Horizontal) { + w = qt_mac_aqua_get_metric(kThemeMetricSmallHSliderHeight); + if (sld->tickPosition() != QSlider::NoTicks) + w += qt_mac_aqua_get_metric(kThemeMetricSmallHSliderTickHeight); + } else { + w = qt_mac_aqua_get_metric(kThemeMetricSmallVSliderWidth); + if (sld->tickPosition() != QSlider::NoTicks) + w += qt_mac_aqua_get_metric(kThemeMetricSmallVSliderTickWidth); + } + } else if (sz == QAquaSizeMini) { + if (sld->orientation() == Qt::Horizontal) { + w = qt_mac_aqua_get_metric(kThemeMetricMiniHSliderHeight); + if (sld->tickPosition() != QSlider::NoTicks) + w += qt_mac_aqua_get_metric(kThemeMetricMiniHSliderTickHeight); + } else { + w = qt_mac_aqua_get_metric(kThemeMetricMiniVSliderWidth); + if (sld->tickPosition() != QSlider::NoTicks) + w += qt_mac_aqua_get_metric(kThemeMetricMiniVSliderTickWidth); + } } + } else { + // This is tricky, we were requested to find a size for a slider which is not + // a slider. We don't know if this is vertical or horizontal or if we need to + // have tick marks or not. + // For this case we will return an horizontal slider without tick marks. + w = qt_mac_aqua_get_metric(kThemeMetricHSliderHeight); + w += qt_mac_aqua_get_metric(kThemeMetricHSliderTickHeight); } if (sld->orientation() == Qt::Horizontal) ret.setHeight(w); @@ -4309,8 +4341,6 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, rect.setY(0); rect.setHeight(widget->height()); } - if (opt->direction == Qt::RightToLeft) - rect.adjust(15, 0, -20, 0); } break; case SE_ProgressBarGroove: diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index ecb3242..9b99161 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -985,7 +985,7 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom //Handle graphics const QRect sliderHandle = subControlRect(control, optionSlider, SC_SliderHandle, widget); QS60StylePrivate::SkinElements handleElement; - if (optionSlider->state & QStyle::State_Sunken) + if (optionSlider->state & State_Sunken) handleElement = horizontal ? QS60StylePrivate::SE_SliderHandleSelectedHorizontal : QS60StylePrivate::SE_SliderHandleSelectedVertical; else @@ -2620,29 +2620,31 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple // lets use spinbox frame here as well, as no combobox specific value available. const int frameThickness = cmb->frame ? pixelMetric(PM_SpinBoxFrameWidth, cmb, widget) : 0; const int buttonWidth = qMax(cmb->rect.height(), buttonIconSize); - const int xposMod = (cmb->rect.x()) + width - buttonMargin - buttonWidth; - const int ypos = cmb->rect.y(); QSize buttonSize; buttonSize.setWidth(buttonWidth + 2 * buttonMargin); buttonSize.setHeight(qMax(8, (cmb->rect.height() >> 1) - frameThickness)); //buttons should be squares buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); switch (scontrol) { - case SC_ComboBoxArrow: + case SC_ComboBoxArrow: { + const int xposMod = cmb->rect.x() + width - buttonMargin - buttonWidth; + const int ypos = cmb->rect.y(); ret.setRect(xposMod, ypos + buttonMargin, buttonWidth, height - 2 * buttonMargin); + } break; case SC_ComboBoxEditField: { - const int withFrameX = cmb->rect.x() + cmb->rect.width() - frameThickness - buttonSize.width(); + const int withFrameX = cmb->rect.x() + width - frameThickness - buttonSize.width(); ret = QRect( frameThickness, frameThickness, withFrameX - frameThickness, - cmb->rect.height() - 2 * frameThickness); + height - 2 * frameThickness); } break; default: break; } + ret = visualRect(cmb->direction, cmb->rect, ret); } break; case CC_GroupBox: @@ -3166,6 +3168,10 @@ bool QS60Style::eventFilter(QObject *object, QEvent *event) return QStyle::eventFilter(object, event); } +/*! + \internal + Handle the timer \a event. +*/ void QS60Style::timerEvent(QTimerEvent *event) { #ifdef Q_WS_S60 diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 2cd238f..eae2291 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -74,7 +74,6 @@ typedef struct { unsigned short width; int major_version; int minor_version; - bool mirroring; // TODO: (nice to have) Use Qt::LayoutDirection const char* layoutName; } layoutHeader; @@ -353,12 +352,12 @@ public: int timerId() const {return m_currentData->m_timerId;} int currentFrame() const {return m_currentData->m_currentFrame;} - void setFrameCount(const int &frameCount) {m_currentData->m_frames = frameCount;} - void setInterval(const int &interval) {m_currentData->m_interval = interval;} + void setFrameCount(int frameCount) {m_currentData->m_frames = frameCount;} + void setInterval(int interval) {m_currentData->m_interval = interval;} void setAnimationObject(CAknBitmapAnimation* animation); void setResourceBased(bool resourceBased) {m_currentData->m_resourceBased = resourceBased;} - void setTimerId(const int &timerId) {m_currentData->m_timerId = timerId;} - void setCurrentFrame(const int ¤tFrame) {m_currentData->m_currentFrame = currentFrame;} + void setTimerId(int timerId) {m_currentData->m_timerId = timerId;} + void setCurrentFrame(int currentFrame) {m_currentData->m_currentFrame = currentFrame;} void resetToDefaults(); diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index a3bb169..872bc2b 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -105,7 +105,7 @@ AnimationData::AnimationData(const QS60StyleEnums::SkinParts part, int frames, i } AnimationDataV2::AnimationDataV2(const AnimationData &data) : AnimationData(data.m_id, data.m_frames, data.m_interval), - m_resourceBased(false), m_animation(0), m_timerId(0) + m_animation(0), m_currentFrame(0), m_resourceBased(false), m_timerId(0) { } AnimationDataV2::~AnimationDataV2() diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 9343cb7..c000457 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -357,9 +357,6 @@ void QFontEngine::getGlyphPositions(const QGlyphLayout &glyphs, const QTransform ++i; } } else { - positions.resize(glyphs.numGlyphs); - glyphs_out.resize(glyphs.numGlyphs); - int i = 0; while (i < glyphs.numGlyphs) { if (!glyphs.attributes[i].dontPrint) { QFixed gpos_x = xpos + glyphs.offsets[i].x; diff --git a/src/gui/text/qtextoption.cpp b/src/gui/text/qtextoption.cpp index 0c8aeec..c1e254c 100644 --- a/src/gui/text/qtextoption.cpp +++ b/src/gui/text/qtextoption.cpp @@ -52,6 +52,9 @@ struct QTextOptionPrivate /*! Constructs a text option with default properties for text. + The text alignment property is set to Qt::AlignLeft. The + word wrap property is set to QTextOption::WordWrap. The + using of design metrics flag is set to false. */ QTextOption::QTextOption() : align(Qt::AlignLeft), @@ -67,6 +70,8 @@ QTextOption::QTextOption() /*! Constructs a text option with the given \a alignment for text. + The word wrap property is set to QTextOption::WordWrap. The using + of design metrics flag is set to false. */ QTextOption::QTextOption(Qt::Alignment alignment) : align(alignment), diff --git a/src/gui/util/qsystemtrayicon_mac.mm b/src/gui/util/qsystemtrayicon_mac.mm index ae805f6..0265a83 100644 --- a/src/gui/util/qsystemtrayicon_mac.mm +++ b/src/gui/util/qsystemtrayicon_mac.mm @@ -569,16 +569,3 @@ private: } @end - -/* Done here because this is the only .mm for now! -Sam */ -QMacCocoaAutoReleasePool::QMacCocoaAutoReleasePool() -{ - NSApplicationLoad(); - pool = (void*)[[NSAutoreleasePool alloc] init]; -} - -QMacCocoaAutoReleasePool::~QMacCocoaAutoReleasePool() -{ - [(NSAutoreleasePool*)pool release]; -} - diff --git a/src/gui/widgets/qmainwindowlayout_mac.mm b/src/gui/widgets/qmainwindowlayout_mac.mm index ee79f5a..d92168a 100644 --- a/src/gui/widgets/qmainwindowlayout_mac.mm +++ b/src/gui/widgets/qmainwindowlayout_mac.mm @@ -472,14 +472,20 @@ void QMainWindowLayout::removeFromMacToolbar(QToolBar *toolbar) void QMainWindowLayout::cleanUpMacToolbarItems() { - for (int i = 0; i < toolbarItemsCopy.size(); ++i) +#ifdef QT_MAC_USE_COCOA + QMacCocoaAutoReleasePool pool; +#endif + for (int i = 0; i < toolbarItemsCopy.size(); ++i) { +#ifdef QT_MAC_USE_COCOA + NSToolbarItem *item = static_cast<NSToolbarItem *>(toolbarItemsCopy.at(i)); + [item setView:0]; +#endif CFRelease(toolbarItemsCopy.at(i)); + } toolbarItemsCopy.clear(); unifiedToolbarHash.clear(); #ifdef QT_MAC_USE_COCOA - QMacCocoaAutoReleasePool pool; - OSWindowRef window = qt_mac_window_for(layoutState.mainWindow); NSToolbar *macToolbar = [window toolbar]; if (macToolbar) { diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 5031d88..8ce7cc0 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -1588,10 +1588,9 @@ QAction *QMenu::insertSeparator(QAction *before) } /*! - This will set the default action to \a act. The default action may - have a visual queue depending on the current QStyle. A default - action is usually meant to indicate what will defaultly happen on a - drop, as shown in a context menu. + This sets the default action to \a act. The default action may have + a visual cue, depending on the current QStyle. A default action + usually indicates what will happen by default when a drop occurs. \sa defaultAction() */ diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index cd7f9bd..7e4bbb5 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -175,6 +175,22 @@ static quint32 constructModifierMask(quint32 accel_key) return ret; } +static void cancelAllMenuTracking() +{ +#ifdef QT_MAC_USE_COCOA + QMacCocoaAutoReleasePool pool; + NSMenu *mainMenu = [NSApp mainMenu]; + [mainMenu cancelTracking]; + for (NSMenuItem *item in [mainMenu itemArray]) { + if ([item submenu]) { + [[item submenu] cancelTracking]; + } + } +#else + CancelMenuTracking(AcquireRootMenu(), true, 0); +#endif +} + static bool actualMenuItemVisibility(const QMenuBarPrivate::QMacMenuBarPrivate *mbp, const QMacMenuAction *action) { @@ -1830,6 +1846,12 @@ void QMenuBarPrivate::macDestroyMenuBar() mac_menubar = 0; if (qt_mac_current_menubar.qmenubar == q) { +#ifdef QT_MAC_USE_COCOA + QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader(); + [loader removeActionsFromAppMenu]; +#else + cancelAllMenuTracking(); +#endif extern void qt_event_request_menubarupdate(); //qapplication_mac.cpp qt_event_request_menubarupdate(); } @@ -1933,20 +1955,6 @@ static bool qt_mac_should_disable_menu(QMenuBar *menuBar, QWidget *modalWidget) return qt_mac_is_ancestor(menuBar->parentWidget(), modalWidget); } -static void cancelAllMenuTracking() -{ -#ifdef QT_MAC_USE_COCOA - QMacCocoaAutoReleasePool pool; - NSMenu *mainMenu = [NSApp mainMenu]; - [mainMenu cancelTracking]; - for (NSMenuItem *item in [mainMenu itemArray]) { - if ([item submenu]) { - [[item submenu] cancelTracking]; - } - } -#endif -} - /*! \internal diff --git a/src/network/access/qfilenetworkreply.cpp b/src/network/access/qfilenetworkreply.cpp index 8c5065c..4ac9a8c 100644 --- a/src/network/access/qfilenetworkreply.cpp +++ b/src/network/access/qfilenetworkreply.cpp @@ -49,10 +49,15 @@ QT_BEGIN_NAMESPACE QFileNetworkReplyPrivate::QFileNetworkReplyPrivate() - : QNetworkReplyPrivate(), realFileSize(0) + : QNetworkReplyPrivate(), fileEngine(0), fileSize(0), filePos(0) { } +QFileNetworkReplyPrivate::~QFileNetworkReplyPrivate() +{ + delete fileEngine; +} + QFileNetworkReply::~QFileNetworkReply() { } @@ -94,9 +99,8 @@ QFileNetworkReply::QFileNetworkReply(QObject *parent, const QNetworkRequest &req if (fileName.isEmpty()) { fileName = url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery); } - d->realFile.setFileName(fileName); - QFileInfo fi(d->realFile); + QFileInfo fi(fileName); if (fi.isDir()) { QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Cannot open %1: Path is a directory").arg(url.toString()); setError(QNetworkReply::ContentOperationNotPermittedError, msg); @@ -106,14 +110,15 @@ QFileNetworkReply::QFileNetworkReply(QObject *parent, const QNetworkRequest &req return; } - bool opened = d->realFile.open(QIODevice::ReadOnly | QIODevice::Unbuffered); + d->fileEngine = QAbstractFileEngine::create(fileName); + bool opened = d->fileEngine->open(QIODevice::ReadOnly | QIODevice::Unbuffered); // could we open the file? if (!opened) { QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Error opening %1: %2") - .arg(d->realFile.fileName(), d->realFile.errorString()); + .arg(fileName, d->fileEngine->errorString()); - if (d->realFile.exists()) { + if (fi.exists()) { setError(QNetworkReply::ContentAccessDenied, msg); QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection, Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ContentAccessDenied)); @@ -126,13 +131,13 @@ QFileNetworkReply::QFileNetworkReply(QObject *parent, const QNetworkRequest &req return; } - d->realFileSize = fi.size(); + d->fileSize = fi.size(); setHeader(QNetworkRequest::LastModifiedHeader, fi.lastModified()); - setHeader(QNetworkRequest::ContentLengthHeader, d->realFileSize); + setHeader(QNetworkRequest::ContentLengthHeader, d->fileSize); QMetaObject::invokeMethod(this, "metaDataChanged", Qt::QueuedConnection); QMetaObject::invokeMethod(this, "downloadProgress", Qt::QueuedConnection, - Q_ARG(qint64, d->realFileSize), Q_ARG(qint64, d->realFileSize)); + Q_ARG(qint64, d->fileSize), Q_ARG(qint64, d->fileSize)); QMetaObject::invokeMethod(this, "readyRead", Qt::QueuedConnection); QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection); } @@ -146,20 +151,25 @@ void QFileNetworkReply::close() { Q_D(QFileNetworkReply); QNetworkReply::close(); - d->realFile.close(); + if (d->fileEngine) + d->fileEngine->close(); } void QFileNetworkReply::abort() { Q_D(QFileNetworkReply); QNetworkReply::close(); - d->realFile.close(); + if (d->fileEngine) + d->fileEngine->close(); } qint64 QFileNetworkReply::bytesAvailable() const { Q_D(const QFileNetworkReply); - return QNetworkReply::bytesAvailable() + d->realFile.bytesAvailable(); + if (!d->fileEngine) + return 0; + + return QNetworkReply::bytesAvailable() + d->fileSize - d->filePos; } bool QFileNetworkReply::isSequential () const @@ -170,7 +180,7 @@ bool QFileNetworkReply::isSequential () const qint64 QFileNetworkReply::size() const { Q_D(const QFileNetworkReply); - return d->realFileSize; + return d->fileSize; } /*! @@ -179,11 +189,17 @@ qint64 QFileNetworkReply::size() const qint64 QFileNetworkReply::readData(char *data, qint64 maxlen) { Q_D(QFileNetworkReply); - qint64 ret = d->realFile.read(data, maxlen); - if (ret == 0 && bytesAvailable() == 0) + if (!d->fileEngine) + return -1; + + qint64 ret = d->fileEngine->read(data, maxlen); + if (ret == 0 && bytesAvailable() == 0) { return -1; // everything had been read - else - return ret; + } else if (ret > 0) { + d->filePos += ret; + } + + return ret; } diff --git a/src/network/access/qfilenetworkreply_p.h b/src/network/access/qfilenetworkreply_p.h index 125fa2e..710ec9f 100644 --- a/src/network/access/qfilenetworkreply_p.h +++ b/src/network/access/qfilenetworkreply_p.h @@ -57,6 +57,7 @@ #include "qnetworkreply_p.h" #include "qnetworkaccessmanager.h" #include <QFile> +#include <QAbstractFileEngine> QT_BEGIN_NAMESPACE @@ -85,9 +86,11 @@ class QFileNetworkReplyPrivate: public QNetworkReplyPrivate { public: QFileNetworkReplyPrivate(); + ~QFileNetworkReplyPrivate(); - QFile realFile; - qint64 realFileSize; + QAbstractFileEngine *fileEngine; + qint64 fileSize; + qint64 filePos; virtual bool isFinished() const; diff --git a/src/network/access/qhttpnetworkheader.cpp b/src/network/access/qhttpnetworkheader.cpp index c2cc69c..669f9cf 100644 --- a/src/network/access/qhttpnetworkheader.cpp +++ b/src/network/access/qhttpnetworkheader.cpp @@ -80,7 +80,7 @@ QByteArray QHttpNetworkHeaderPrivate::headerField(const QByteArray &name, const QByteArray result; bool first = true; - foreach (QByteArray value, allValues) { + foreach (const QByteArray &value, allValues) { if (!first) result += ", "; first = false; diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index 58123b2..61a95fe 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -753,7 +753,7 @@ void QNetworkAccessHttpBackend::replyHeaderChanged() QByteArray value = rawHeader(it->first); if (!value.isEmpty()) { if (qstricmp(it->first.constData(), "set-cookie") == 0) - value += "\n"; + value += '\n'; else value += ", "; } diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index 6dcd05d..a2bef67 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -649,7 +649,7 @@ static QVariant parseCookieHeader(const QByteArray &raw) { QList<QNetworkCookie> result; QList<QByteArray> cookieList = raw.split(';'); - foreach (QByteArray cookie, cookieList) { + foreach (const QByteArray &cookie, cookieList) { QList<QNetworkCookie> parsed = QNetworkCookie::parseCookies(cookie.trimmed()); if (parsed.count() != 1) return QVariant(); // invalid Cookie: header diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index 193a043..e4023c8 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -270,7 +270,7 @@ void QAuthenticatorPrivate::parseHttpResponse(const QHttpResponseHeader &header, break; case Ntlm: // #### extract from header - realm = QString(); + realm.clear(); break; case DigestMd5: { realm = QString::fromLatin1(options.value("realm")); @@ -281,7 +281,7 @@ void QAuthenticatorPrivate::parseHttpResponse(const QHttpResponseHeader &header, break; } default: - realm = QString(); + realm.clear(); challenge = QByteArray(); phase = Invalid; } diff --git a/src/network/kernel/qnetworkinterface.cpp b/src/network/kernel/qnetworkinterface.cpp index 367e3c4..1115c63 100644 --- a/src/network/kernel/qnetworkinterface.cpp +++ b/src/network/kernel/qnetworkinterface.cpp @@ -541,7 +541,7 @@ QList<QNetworkInterface> QNetworkInterface::allInterfaces() { QList<QSharedDataPointer<QNetworkInterfacePrivate> > privs = manager()->allInterfaces(); QList<QNetworkInterface> result; - foreach (QSharedDataPointer<QNetworkInterfacePrivate> p, privs) { + foreach (const QSharedDataPointer<QNetworkInterfacePrivate> &p, privs) { QNetworkInterface item; item.d = p; result << item; @@ -560,7 +560,7 @@ QList<QHostAddress> QNetworkInterface::allAddresses() { QList<QSharedDataPointer<QNetworkInterfacePrivate> > privs = manager()->allInterfaces(); QList<QHostAddress> result; - foreach (const QSharedDataPointer<QNetworkInterfacePrivate> p, privs) { + foreach (const QSharedDataPointer<QNetworkInterfacePrivate> &p, privs) { foreach (const QNetworkAddressEntry &entry, p->addressEntries) result += entry.ip(); } diff --git a/src/network/socket/qlocalserver.cpp b/src/network/socket/qlocalserver.cpp index ede3c89..ef7fc02 100644 --- a/src/network/socket/qlocalserver.cpp +++ b/src/network/socket/qlocalserver.cpp @@ -122,9 +122,9 @@ void QLocalServer::close() qDeleteAll(d->pendingConnections); d->pendingConnections.clear(); d->closeServer(); - d->serverName = QString(); - d->fullServerName = QString(); - d->errorString = QString(); + d->serverName.clear(); + d->fullServerName.clear(); + d->errorString.clear(); d->error = QAbstractSocket::UnknownSocketError; } @@ -226,8 +226,8 @@ bool QLocalServer::listen(const QString &name) } if (!d->listen(name)) { - d->serverName = QString(); - d->fullServerName = QString(); + d->serverName.clear(); + d->fullServerName.clear(); return false; } diff --git a/src/network/socket/qlocalsocket_tcp.cpp b/src/network/socket/qlocalsocket_tcp.cpp index 9f574d4..5b5e84f 100644 --- a/src/network/socket/qlocalsocket_tcp.cpp +++ b/src/network/socket/qlocalsocket_tcp.cpp @@ -102,8 +102,8 @@ void QLocalSocketPrivate::_q_stateChanged(QAbstractSocket::SocketState newState) switch(newState) { case QAbstractSocket::UnconnectedState: state = QLocalSocket::UnconnectedState; - serverName = QString(); - fullServerName = QString(); + serverName.clear(); + fullServerName.clear(); break; case QAbstractSocket::ConnectingState: state = QLocalSocket::ConnectingState; @@ -218,7 +218,7 @@ void QLocalSocket::connectToServer(const QString &name, OpenMode openMode) || state() == ConnectingState) return; - d->errorString = QString(); + d->errorString.clear(); d->state = ConnectingState; emit stateChanged(d->state); @@ -333,8 +333,8 @@ void QLocalSocket::close() { Q_D(QLocalSocket); d->tcpSocket->close(); - d->serverName = QString(); - d->fullServerName = QString(); + d->serverName.clear(); + d->fullServerName.clear(); QIODevice::close(); } diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index 73c2465..1ca11d8 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -109,8 +109,8 @@ void QLocalSocketPrivate::_q_stateChanged(QAbstractSocket::SocketState newState) switch(newState) { case QAbstractSocket::UnconnectedState: state = QLocalSocket::UnconnectedState; - serverName = QString(); - fullServerName = QString(); + serverName.clear(); + fullServerName.clear(); break; case QAbstractSocket::ConnectingState: state = QLocalSocket::ConnectingState; @@ -225,7 +225,7 @@ void QLocalSocket::connectToServer(const QString &name, OpenMode openMode) || state() == ConnectingState) return; - d->errorString = QString(); + d->errorString.clear(); d->unixSocket.setSocketState(QAbstractSocket::ConnectingState); d->state = ConnectingState; emit stateChanged(d->state); @@ -341,7 +341,7 @@ void QLocalSocketPrivate::_q_connectToSocket() errorOccurred(QLocalSocket::UnknownSocketError, function); } connectingSocket = -1; - connectingName = QString(); + connectingName.clear(); connectingOpenMode = 0; } @@ -438,10 +438,10 @@ void QLocalSocket::close() if (d->connectingSocket != -1) ::close(d->connectingSocket); d->connectingSocket = -1; - d->connectingName = QString(); + d->connectingName.clear(); d->connectingOpenMode = 0; - d->serverName = QString(); - d->fullServerName = QString(); + d->serverName.clear(); + d->fullServerName.clear(); QIODevice::close(); } diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp index 6e1df93..a890b3b 100644 --- a/src/network/socket/qnativesocketengine.cpp +++ b/src/network/socket/qnativesocketengine.cpp @@ -778,6 +778,14 @@ qint64 QNativeSocketEngine::read(char *data, qint64 maxSize) QNativeSocketEnginePrivate::RemoteHostClosedErrorString); close(); return -1; + } else if (readBytes == -1) { + if (!d->hasSetSocketError) { + d->hasSetSocketError = true; + d->socketError = QAbstractSocket::NetworkError; + d->socketErrorString = qt_error_string(); + } + close(); + return -1; } return readBytes; } diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index d3b0fe5..9a2c349 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -903,7 +903,7 @@ qint64 QNativeSocketEnginePrivate::nativeRead(char *data, qint64 maxSize) case EBADF: case EINVAL: case EIO: - setError(QAbstractSocket::NetworkError, ReadErrorString); + //error string is now set in read(), not here in nativeRead() break; #ifdef Q_OS_SYMBIAN case EPIPE: diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index 7088a57..8177b4f 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -1068,7 +1068,7 @@ qint64 QNativeSocketEnginePrivate::nativeRead(char *data, qint64 maxLength) break; case WSAEBADF: case WSAEINVAL: - setError(QAbstractSocket::NetworkError, ReadErrorString); + //error string is now set in read(), not here in nativeRead() break; case WSAECONNRESET: case WSAECONNABORTED: @@ -1199,8 +1199,10 @@ void QNativeSocketEnginePrivate::nativeClose() #if defined (QTCPSOCKETENGINE_DEBUG) qDebug("QNativeSocketEnginePrivate::nativeClose()"); #endif - linger l = {1, 0}; - ::setsockopt(socketDescriptor, SOL_SOCKET, SO_DONTLINGER, (char*)&l, sizeof(l)); + // We were doing a setsockopt here before with SO_DONTLINGER. (However with kind of wrong + // usage of parameters, it wants a BOOL but we used a struct and pretended it to be bool). + // We don't think setting this option should be done here, if a user wants it she/he can + // do it manually with socketDescriptor()/setSocketDescriptor(); ::closesocket(socketDescriptor); } diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index 9a9b1b5..fd647e2 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -634,11 +634,11 @@ QByteArray QSslCertificatePrivate::QByteArray_from_X509(X509 *x509, QSsl::Encodi QByteArray tmp; for (int i = 0; i <= array.size() - 64; i += 64) { tmp += QByteArray::fromRawData(array.data() + i, 64); - tmp += "\n"; + tmp += '\n'; } if (int remainder = array.size() % 64) { tmp += QByteArray::fromRawData(array.data() + array.size() - remainder, remainder); - tmp += "\n"; + tmp += '\n'; } return BEGINCERTSTRING "\n" + tmp + ENDCERTSTRING "\n"; diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 6947aa7..9623570 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -1109,7 +1109,7 @@ void QSslSocket::setCiphers(const QString &ciphers) { Q_D(QSslSocket); d->configuration.ciphers.clear(); - foreach (QString cipherName, ciphers.split(QLatin1String(":"),QString::SkipEmptyParts)) { + foreach (const QString &cipherName, ciphers.split(QLatin1String(":"),QString::SkipEmptyParts)) { for (int i = 0; i < 3; ++i) { // ### Crude QSslCipher cipher(cipherName, QSsl::SslProtocol(i)); diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 892d330..ce2aee1 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -818,7 +818,7 @@ bool QSslSocketBackendPrivate::startHandshake() QRegExp regexp(commonName, Qt::CaseInsensitive, QRegExp::Wildcard); if (!regexp.exactMatch(peerName)) { bool matched = false; - foreach (QString altName, configuration.peerCertificate + foreach (const QString &altName, configuration.peerCertificate .alternateSubjectNames().values(QSsl::DnsEntry)) { regexp.setPattern(altName); if (regexp.exactMatch(peerName)) { diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 48e43b2..2a60708 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4419,8 +4419,17 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, bool auto_swap = autoBufferSwap(); QPaintEngine::Type oldEngineType = qgl_engine_selector()->preferredPaintEngine(); - qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL); + QPaintEngine *engine = paintEngine(); + if (engine && (oldEngineType == QPaintEngine::OpenGL2) && engine->isActive()) { + qWarning("QGLWidget::renderText(): Calling renderText() while a GL 2 paint engine is" + " active on the same device is not allowed."); + return; + } + + // this changes what paintEngine() returns + qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL); + engine = paintEngine(); QPainter *p; bool reuse_painter = false; if (engine->isActive()) { @@ -4513,8 +4522,17 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con win_y = height - win_y; // y is inverted QPaintEngine::Type oldEngineType = qgl_engine_selector()->preferredPaintEngine(); - qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL); QPaintEngine *engine = paintEngine(); + + if (engine && (oldEngineType == QPaintEngine::OpenGL2) && engine->isActive()) { + qWarning("QGLWidget::renderText(): Calling renderText() while a GL 2 paint engine is" + " active on the same device is not allowed."); + return; + } + + // this changes what paintEngine() returns + qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL); + engine = paintEngine(); QPainter *p; bool reuse_painter = false; bool use_depth_testing = glIsEnabled(GL_DEPTH_TEST); diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index 5e2f1f5..79484fa 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -106,6 +106,19 @@ QT_BEGIN_NAMESPACE \snippet doc/src/snippets/code/src_opengl_qglshaderprogram.cpp 2 + \section1 Binary shaders and programs + + Binary shaders may be specified using \c{glShaderBinary()} on + the return value from QGLShader::shaderId(). The QGLShader instance + containing the binary can then be added to the shader program with + addShader() and linked in the usual fashion with link(). + + Binary programs may be specified using \c{glProgramBinaryOES()} + on the return value from programId(). Then the application should + call link(), which will notice that the program has already been + specified and linked, allowing other operations to be performed + on the shader program. + \sa QGLShader */ @@ -632,8 +645,6 @@ bool QGLShaderProgram::addShader(QGLShader *shader) qWarning("QGLShaderProgram::addShader: Program and shader are not associated with same context."); return false; } - if (!shader->d_func()->compiled) - return false; if (!shader->d_func()->shaderGuard.id()) return false; glAttachShader(d->programGuard.id(), shader->d_func()->shaderGuard.id()); @@ -820,8 +831,20 @@ bool QGLShaderProgram::link() GLuint program = d->programGuard.id(); if (!program) return false; + GLint value; + if (d->shaders.isEmpty()) { + // If there are no explicit shaders, then it is possible that the + // application added a program binary with glProgramBinaryOES(), + // or otherwise populated the shaders itself. Check to see if the + // program is already linked and bail out if so. + value = 0; + glGetProgramiv(program, GL_LINK_STATUS, &value); + d->linked = (value != 0); + if (d->linked) + return true; + } glLinkProgram(program); - GLint value = 0; + value = 0; glGetProgramiv(program, GL_LINK_STATUS, &value); d->linked = (value != 0); value = 0; @@ -928,6 +951,15 @@ void QGLShaderProgram::release() GLuint QGLShaderProgram::programId() const { Q_D(const QGLShaderProgram); + GLuint id = d->programGuard.id(); + if (id) + return id; + + // Create the identifier if we don't have one yet. This is for + // applications that want to create the attached shader configuration + // themselves, particularly those using program binaries. + if (!const_cast<QGLShaderProgram *>(this)->init()) + return 0; return d->programGuard.id(); } diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp index 4f49476..b2351fa 100644 --- a/src/plugins/imageformats/ico/qicohandler.cpp +++ b/src/plugins/imageformats/ico/qicohandler.cpp @@ -556,7 +556,11 @@ QImage ICOReader::iconAt(int index) else // # colors used icoAttrib.ncolors = header.biClrUsed ? header.biClrUsed : 1 << icoAttrib.nbits; icoAttrib.w = iconEntry.bWidth; + if (icoAttrib.w == 0) + icoAttrib.w = header.biWidth; icoAttrib.h = iconEntry.bHeight; + if (icoAttrib.h == 0) + icoAttrib.h = header.biHeight/2; QImage::Format format = QImage::Format_ARGB32; if (icoAttrib.nbits == 24) diff --git a/src/s60installs/sqlite3_selfsigned.sis b/src/s60installs/sqlite3_selfsigned.sis Binary files differnew file mode 100644 index 0000000..a025ac5 --- /dev/null +++ b/src/s60installs/sqlite3_selfsigned.sis diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index 1db2e1b..5bfe46a 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -1148,10 +1148,15 @@ bool QScriptValue::strictlyEquals(const QScriptValue &other) const } if (d->type != other.d_ptr->type) { - if (d->type == QScriptValuePrivate::JavaScriptCore) - return JSC::JSValue::strictEqual(d->jscValue, d->engine->scriptValueToJSCValue(other)); - else if (other.d_ptr->type == QScriptValuePrivate::JavaScriptCore) - return JSC::JSValue::strictEqual(other.d_ptr->engine->scriptValueToJSCValue(*this), other.d_ptr->jscValue); + if (d->type == QScriptValuePrivate::JavaScriptCore) { + QScriptEnginePrivate *eng_p = d->engine ? d->engine : other.d_ptr->engine; + if (eng_p) + return JSC::JSValue::strictEqual(d->jscValue, eng_p->scriptValueToJSCValue(other)); + } else if (other.d_ptr->type == QScriptValuePrivate::JavaScriptCore) { + QScriptEnginePrivate *eng_p = other.d_ptr->engine ? other.d_ptr->engine : d->engine; + if (eng_p) + return JSC::JSValue::strictEqual(eng_p->scriptValueToJSCValue(*this), other.d_ptr->jscValue); + } return false; } diff --git a/src/script/bridge/qscriptdeclarativeclass_p.h b/src/script/bridge/qscriptdeclarativeclass_p.h index 357d1d5..a0fd6d5 100644 --- a/src/script/bridge/qscriptdeclarativeclass_p.h +++ b/src/script/bridge/qscriptdeclarativeclass_p.h @@ -47,6 +47,7 @@ class QScriptContext; class Q_SCRIPT_EXPORT QScriptDeclarativeClass { public: +#define QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE class Q_SCRIPT_EXPORT Value { public: diff --git a/src/src.pro b/src/src.pro index 8dec49b..f2070ae 100644 --- a/src/src.pro +++ b/src/src.pro @@ -106,6 +106,7 @@ src_declarative.target = sub-declarative contains(QT_CONFIG, webkit) { src_webkit.depends = src_gui src_sql src_network src_xml contains(QT_CONFIG, phonon):src_webkit.depends += src_phonon + contains(QT_CONFIG, xmlpatterns): src_webkit.depends += src_xmlpatterns contains(QT_CONFIG, declarative):src_declarative.depends += src_webkit #exists($$QT_SOURCE_TREE/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro): src_webkit.depends += src_javascriptcore } diff --git a/tests/auto/declarative/animations/data/badproperty1.qml b/tests/auto/declarative/animations/data/badproperty1.qml index fda322c..d31cae9 100644 --- a/tests/auto/declarative/animations/data/badproperty1.qml +++ b/tests/auto/declarative/animations/data/badproperty1.qml @@ -1,21 +1,21 @@ import Qt 4.6 Rectangle { - id: Wrapper + id: wrapper width: 240 height: 320 Rectangle { - id: MyRect + id: myRect color: "red" width: 50; height: 50 x: 100; y: 100 } states: State { name: "state1" - PropertyChanges { target: MyRect; border.color: "blue" } + PropertyChanges { target: myRect; border.color: "blue" } } transitions: Transition { - ColorAnimation { target: MyRect; to: "red"; property: "border.colr"; duration: 1000 } + ColorAnimation { target: myRect; to: "red"; property: "border.colr"; duration: 1000 } } - Component.onCompleted: if (Wrapper.state == "state1") Wrapper.state = ""; else Wrapper.state = "state1"; + Component.onCompleted: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; } diff --git a/tests/auto/declarative/animations/data/badproperty2.qml b/tests/auto/declarative/animations/data/badproperty2.qml index 0e8366a..3b8b111 100644 --- a/tests/auto/declarative/animations/data/badproperty2.qml +++ b/tests/auto/declarative/animations/data/badproperty2.qml @@ -1,21 +1,21 @@ import Qt 4.6 Rectangle { - id: Wrapper + id: wrapper width: 240 height: 320 Rectangle { - id: MyRect + id: myRect color: "red" width: 50; height: 50 x: 100; y: 100 } states: State { name: "state1" - PropertyChanges { target: MyRect; border.color: "blue" } + PropertyChanges { target: myRect; border.color: "blue" } } transitions: Transition { - ColorAnimation { target: MyRect; to: "red"; property: "border"; duration: 1000 } + ColorAnimation { target: myRect; to: "red"; property: "border"; duration: 1000 } } - Component.onCompleted: if (Wrapper.state == "state1") Wrapper.state = ""; else Wrapper.state = "state1"; + Component.onCompleted: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; } diff --git a/tests/auto/declarative/animations/data/badtype4.qml b/tests/auto/declarative/animations/data/badtype4.qml index 347e581..b5096f4 100644 --- a/tests/auto/declarative/animations/data/badtype4.qml +++ b/tests/auto/declarative/animations/data/badtype4.qml @@ -1,23 +1,23 @@ import Qt 4.6 Rectangle { - id: Wrapper + id: wrapper width: 240 height: 320 Rectangle { - id: MyRect - objectName: "MyRect" + id: myRect + objectName: "myRect" color: "red" width: 50; height: 50 x: 100; y: 100 MouseRegion { anchors.fill: parent - onClicked: if (Wrapper.state == "state1") Wrapper.state = ""; else Wrapper.state = "state1"; + onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; } } states: State { name: "state1" - PropertyChanges { target: MyRect; x: 200; color: "blue" } + PropertyChanges { target: myRect; x: 200; color: "blue" } } transitions: Transition { //comment out each in turn to make sure each only animates the relevant property diff --git a/tests/auto/declarative/animations/data/dotproperty.qml b/tests/auto/declarative/animations/data/dotproperty.qml index 3ddb002..369491f 100644 --- a/tests/auto/declarative/animations/data/dotproperty.qml +++ b/tests/auto/declarative/animations/data/dotproperty.qml @@ -1,22 +1,22 @@ import Qt 4.6 Rectangle { - id: Wrapper + id: wrapper width: 240 height: 320 Rectangle { - id: MyRect + id: myRect color: "red" width: 50; height: 50 x: 100; y: 100 MouseRegion { anchors.fill: parent - onClicked: if (Wrapper.state == "state1") Wrapper.state = ""; else Wrapper.state = "state1"; + onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; } } states: State { name: "state1" - PropertyChanges { target: MyRect; border.color: "blue" } + PropertyChanges { target: myRect; border.color: "blue" } } transitions: Transition { ColorAnimation { matchProperties: "border.color"; duration: 1000 } diff --git a/tests/auto/declarative/animations/data/mixedtype1.qml b/tests/auto/declarative/animations/data/mixedtype1.qml index a91c6d3..a9eed24 100644 --- a/tests/auto/declarative/animations/data/mixedtype1.qml +++ b/tests/auto/declarative/animations/data/mixedtype1.qml @@ -1,23 +1,23 @@ import Qt 4.6 Rectangle { - id: Wrapper + id: wrapper width: 240 height: 320 Rectangle { - id: MyRect - objectName: "MyRect" + id: myRect + objectName: "myRect" color: "red" width: 50; height: 50 x: 100; y: 100 MouseRegion { anchors.fill: parent - onClicked: if (Wrapper.state == "state1") Wrapper.state = ""; else Wrapper.state = "state1"; + onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; } } states: State { name: "state1" - PropertyChanges { target: MyRect; x: 200; border.width: 10 } + PropertyChanges { target: myRect; x: 200; border.width: 10 } } transitions: Transition { PropertyAnimation { matchProperties: "x,border.width"; duration: 1000 } //x is real, border.width is int diff --git a/tests/auto/declarative/animations/data/mixedtype2.qml b/tests/auto/declarative/animations/data/mixedtype2.qml index d12e913..8acb825 100644 --- a/tests/auto/declarative/animations/data/mixedtype2.qml +++ b/tests/auto/declarative/animations/data/mixedtype2.qml @@ -1,23 +1,23 @@ import Qt 4.6 Rectangle { - id: Wrapper + id: wrapper width: 240 height: 320 Rectangle { - id: MyRect - objectName: "MyRect" + id: myRect + objectName: "myRect" color: "red" width: 50; height: 50 x: 100; y: 100 MouseRegion { anchors.fill: parent - onClicked: if (Wrapper.state == "state1") Wrapper.state = ""; else Wrapper.state = "state1"; + onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; } } states: State { name: "state1" - PropertyChanges { target: MyRect; x: 200; color: "blue" } + PropertyChanges { target: myRect; x: 200; color: "blue" } } transitions: Transition { PropertyAnimation { matchProperties: "x,color"; duration: 1000 } //x is real, color is color diff --git a/tests/auto/declarative/pathview/data/pathview.qml b/tests/auto/declarative/pathview/data/pathview.qml index be5673c..8fa8d59 100644 --- a/tests/auto/declarative/pathview/data/pathview.qml +++ b/tests/auto/declarative/pathview/data/pathview.qml @@ -6,7 +6,7 @@ Rectangle { color: "#ffffff" resources: [ Component { - id: Delegate + id: delegate Rectangle { id: wrapper objectName: "wrapper" @@ -38,7 +38,7 @@ Rectangle { width: 240 height: 320 model: testModel - delegate: Delegate + delegate: delegate snapPosition: 0.01 path: Path { startY: 120 diff --git a/tests/auto/declarative/qmlecmascript/data/aliasPropertyAndBinding.qml b/tests/auto/declarative/qmlecmascript/data/aliasPropertyAndBinding.qml index 7fdd8ca..5c3ea1f 100644 --- a/tests/auto/declarative/qmlecmascript/data/aliasPropertyAndBinding.qml +++ b/tests/auto/declarative/qmlecmascript/data/aliasPropertyAndBinding.qml @@ -2,11 +2,11 @@ import Qt 4.6 import Qt.test 1.0 MyQmlObject { - property alias c1: MyObject.c1 + property alias c1: myObject.c1 property int c2: 3 property int c3: c2 objectProperty: QtObject { - id: MyObject + id: myObject property int c1 } } diff --git a/tests/auto/declarative/qmlecmascript/data/assignBasicTypes.qml b/tests/auto/declarative/qmlecmascript/data/assignBasicTypes.qml new file mode 100644 index 0000000..128db69 --- /dev/null +++ b/tests/auto/declarative/qmlecmascript/data/assignBasicTypes.qml @@ -0,0 +1,29 @@ +import Qt.test 1.0 +import Qt 4.6 + +MyTypeObject { + Component.onCompleted: { + flagProperty = "FlagVal1 | FlagVal3" + enumProperty = "EnumVal2" + stringProperty = "Hello World!" + uintProperty = 10 + intProperty = -19 + realProperty = 23.2 + doubleProperty = -19.7 + floatProperty = 8.5 + colorProperty = "red" + dateProperty = "1982-11-25" + timeProperty = "11:11:32" + dateTimeProperty = "2009-05-12T13:22:01" + pointProperty = "99,13" + pointFProperty = "-10.1,12.3" + sizeProperty = "99x13" + sizeFProperty = "0.1x0.2" + rectProperty = "9,7,100x200" + rectFProperty = "1000.1,-10.9,400x90.99" + boolProperty = true + variantProperty = "Hello World!" + vectorProperty = "10,1,2.2" + urlProperty = "main.qml" + } +} diff --git a/tests/auto/declarative/qmlecmascript/data/attachedProperty.qml b/tests/auto/declarative/qmlecmascript/data/attachedProperty.qml index c5088e3..061eda0 100644 --- a/tests/auto/declarative/qmlecmascript/data/attachedProperty.qml +++ b/tests/auto/declarative/qmlecmascript/data/attachedProperty.qml @@ -2,10 +2,10 @@ import Qt.test 1.0 import Qt.test 1.0 as Namespace MyQmlObject { - id: Me + id: me property int a: MyQmlObject.value property int b: Namespace.MyQmlObject.value - property int c: Me.Namespace.MyQmlObject.value - property int d: Me.Namespace.MyQmlObject.value + property int c: me.Namespace.MyQmlObject.value + property int d: me.Namespace.MyQmlObject.value } diff --git a/tests/auto/declarative/qmlecmascript/data/bindingLoop.qml b/tests/auto/declarative/qmlecmascript/data/bindingLoop.qml index 8b22dd1..80545cf 100644 --- a/tests/auto/declarative/qmlecmascript/data/bindingLoop.qml +++ b/tests/auto/declarative/qmlecmascript/data/bindingLoop.qml @@ -3,12 +3,12 @@ import Qt.test 1.0 MyQmlContainer { children : [ MyQmlObject { - id: Object1 - stringProperty: "hello" + Object2.stringProperty + id: object1 + stringProperty: "hello" + object2.stringProperty }, MyQmlObject { - id: Object2 - stringProperty: "hello" + Object1.stringProperty + id: object2 + stringProperty: "hello" + object1.stringProperty } ] } diff --git a/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.2.qml b/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.2.qml index d205526..207a06b 100644 --- a/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.2.qml +++ b/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.2.qml @@ -1,11 +1,11 @@ import Qt.test 1.0 MyQmlObject { - property alias c1: MyConstants.c1 - property alias c2: MyConstants.c2 + property alias c1: myConstants.c1 + property alias c2: myConstants.c2 objectProperty: ConstantsOverrideBindings { - id: MyConstants + id: myConstants c2: 10 } } diff --git a/tests/auto/declarative/qmlecmascript/data/dynamicCreation.helper.qml b/tests/auto/declarative/qmlecmascript/data/dynamicCreation.helper.qml deleted file mode 100644 index b26d6e1..0000000 --- a/tests/auto/declarative/qmlecmascript/data/dynamicCreation.helper.qml +++ /dev/null @@ -1,5 +0,0 @@ -import Qt.test 1.0 - -MyQmlObject{ - objectName: "objectTwo" -} diff --git a/tests/auto/declarative/qmlecmascript/data/extendedObjectPropertyLookup.qml b/tests/auto/declarative/qmlecmascript/data/extendedObjectPropertyLookup.qml index ab379c1..9a82ad1 100644 --- a/tests/auto/declarative/qmlecmascript/data/extendedObjectPropertyLookup.qml +++ b/tests/auto/declarative/qmlecmascript/data/extendedObjectPropertyLookup.qml @@ -3,6 +3,6 @@ import Qt 4.6 QtObject { property MyExtendedObject a; - a: MyExtendedObject { id: Root } - property int b: Math.max(Root.extendedProperty, 0) + a: MyExtendedObject { id: root } + property int b: Math.max(root.extendedProperty, 0) } diff --git a/tests/auto/declarative/qmlecmascript/data/idShortcutInvalidates.1.qml b/tests/auto/declarative/qmlecmascript/data/idShortcutInvalidates.1.qml index b377b94..2db0fc6 100644 --- a/tests/auto/declarative/qmlecmascript/data/idShortcutInvalidates.1.qml +++ b/tests/auto/declarative/qmlecmascript/data/idShortcutInvalidates.1.qml @@ -2,12 +2,12 @@ import Qt.test 1.0 import Qt 4.6 MyQmlObject { - objectProperty: if(1) OtherObject + objectProperty: if(1) otherObject property var obj obj: QtObject { - id: OtherObject + id: otherObject } } diff --git a/tests/auto/declarative/qmlecmascript/data/idShortcutInvalidates.qml b/tests/auto/declarative/qmlecmascript/data/idShortcutInvalidates.qml index 40cacf6..f66428d 100644 --- a/tests/auto/declarative/qmlecmascript/data/idShortcutInvalidates.qml +++ b/tests/auto/declarative/qmlecmascript/data/idShortcutInvalidates.qml @@ -2,11 +2,11 @@ import Qt.test 1.0 import Qt 4.6 MyQmlObject { - objectProperty: OtherObject + objectProperty: otherObject property var obj obj: QtObject { - id: OtherObject + id: otherObject } } diff --git a/tests/auto/declarative/qmlecmascript/data/listToVariant.qml b/tests/auto/declarative/qmlecmascript/data/listToVariant.qml new file mode 100644 index 0000000..47f4e50 --- /dev/null +++ b/tests/auto/declarative/qmlecmascript/data/listToVariant.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +QtObject { + property var test: children +} diff --git a/tests/auto/declarative/qmlecmascript/data/methods.1.qml b/tests/auto/declarative/qmlecmascript/data/methods.1.qml index 42ed9a5..0bbee16 100644 --- a/tests/auto/declarative/qmlecmascript/data/methods.1.qml +++ b/tests/auto/declarative/qmlecmascript/data/methods.1.qml @@ -1,6 +1,6 @@ import Qt.test 1.0 MyQmlObject { - id: MyObject - onBasicSignal: MyObject.methodNoArgs() + id: myObject + onBasicSignal: myObject.methodNoArgs() } diff --git a/tests/auto/declarative/qmlecmascript/data/methods.2.qml b/tests/auto/declarative/qmlecmascript/data/methods.2.qml index 70911f7..9f0c6b1 100644 --- a/tests/auto/declarative/qmlecmascript/data/methods.2.qml +++ b/tests/auto/declarative/qmlecmascript/data/methods.2.qml @@ -1,6 +1,6 @@ import Qt.test 1.0 MyQmlObject { - id: MyObject - onBasicSignal: MyObject.method(163) + id: myObject + onBasicSignal: myObject.method(163) } diff --git a/tests/auto/declarative/qmlecmascript/data/objectsCompareAsEqual.qml b/tests/auto/declarative/qmlecmascript/data/objectsCompareAsEqual.qml index 2526576..18e488a 100644 --- a/tests/auto/declarative/qmlecmascript/data/objectsCompareAsEqual.qml +++ b/tests/auto/declarative/qmlecmascript/data/objectsCompareAsEqual.qml @@ -1,15 +1,15 @@ import Qt 4.6 Item { - id: Root + id: root - property var item: Child - Item { id: Child } + property var item: child + Item { id: child } - property bool test1: Child == Child - property bool test2: Child.parent == Root - property bool test3: Root != Child - property bool test4: item == Child - property bool test5: item != Root + property bool test1: child == child + property bool test2: child.parent == root + property bool test3: root != child + property bool test4: item == child + property bool test5: item != root } diff --git a/tests/auto/declarative/qmlecmascript/data/outerBindingOverridesInnerBinding.qml b/tests/auto/declarative/qmlecmascript/data/outerBindingOverridesInnerBinding.qml index 49ada1f..0a933e8 100644 --- a/tests/auto/declarative/qmlecmascript/data/outerBindingOverridesInnerBinding.qml +++ b/tests/auto/declarative/qmlecmascript/data/outerBindingOverridesInnerBinding.qml @@ -1,12 +1,12 @@ import Qt.test 1.0 MyQmlObject { - property alias c1: MyConstants.c1 - property alias c2: MyConstants.c2 + property alias c1: myConstants.c1 + property alias c2: myConstants.c2 property int c3: 0 objectProperty: ConstantsOverrideBindings { - id: MyConstants + id: myConstants c2: c3 } diff --git a/tests/auto/declarative/qmlecmascript/data/scope.qml b/tests/auto/declarative/qmlecmascript/data/scope.qml index 80222c8..cccd3d3 100644 --- a/tests/auto/declarative/qmlecmascript/data/scope.qml +++ b/tests/auto/declarative/qmlecmascript/data/scope.qml @@ -1,7 +1,7 @@ import Qt 4.6 Item { - id: Root + id: root property int a: 1 property int binding: a @@ -16,7 +16,7 @@ Item { } Item { - id: NestedObject + id: nestedObject Script { function myNestedFunction() { @@ -32,17 +32,17 @@ Item { } ScopeObject { - id: CompObject + id: compObject } - property alias test1: Root.binding - property alias test2: NestedObject.binding - property alias test3: Root.binding2 - property alias test4: NestedObject.binding2 - property alias test5: Root.binding3 - property alias test6: NestedObject.binding3 - property alias test7: Root.binding4 - property alias test8: NestedObject.binding4 - property alias test9: CompObject.binding - property alias test10: CompObject.binding2 + property alias test1: root.binding + property alias test2: nestedObject.binding + property alias test3: root.binding2 + property alias test4: nestedObject.binding2 + property alias test5: root.binding3 + property alias test6: nestedObject.binding3 + property alias test7: root.binding4 + property alias test8: nestedObject.binding4 + property alias test9: compObject.binding + property alias test10: compObject.binding2 } diff --git a/tests/auto/declarative/qmlecmascript/data/signalParameterTypes.qml b/tests/auto/declarative/qmlecmascript/data/signalParameterTypes.qml index 42d26a1..6fc8b02 100644 --- a/tests/auto/declarative/qmlecmascript/data/signalParameterTypes.qml +++ b/tests/auto/declarative/qmlecmascript/data/signalParameterTypes.qml @@ -2,7 +2,7 @@ import Qt.test 1.0 MyQmlObject { - id: Root + id: root property int intProperty property real realProperty property color colorProperty @@ -12,5 +12,5 @@ MyQmlObject onMySignal: { intProperty = a; realProperty = b; colorProperty = c; variantProperty = d; } - onBasicSignal: Root.mySignal(10, 19.2, Qt.rgba(1, 1, 0, 1), Qt.rgba(1, 0, 1, 1)) + onBasicSignal: root.mySignal(10, 19.2, Qt.rgba(1, 1, 0, 1), Qt.rgba(1, 0, 1, 1)) } diff --git a/tests/auto/declarative/qmlecmascript/data/undefinedResetsProperty.2.qml b/tests/auto/declarative/qmlecmascript/data/undefinedResetsProperty.2.qml new file mode 100644 index 0000000..e73d38e2 --- /dev/null +++ b/tests/auto/declarative/qmlecmascript/data/undefinedResetsProperty.2.qml @@ -0,0 +1,10 @@ +import Qt.test 1.0 + +MyQmlObject { + resettableProperty: 19 + + function doReset() { + resettableProperty = undefined; + } +} + diff --git a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp index b28d805..f389d2c 100644 --- a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp +++ b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp @@ -729,7 +729,7 @@ void tst_QmlGraphicsGridView::changeFlow() // Confirm items positioned correctly and indexes correct int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count(); - for (int i = 3; i < model.count() && i < itemCount; ++i) { + for (int i = 0; i < model.count() && i < itemCount; ++i) { QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QVERIFY(item); @@ -748,7 +748,7 @@ void tst_QmlGraphicsGridView::changeFlow() // Confirm items positioned correctly and indexes correct itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count(); - for (int i = 3; i < model.count() && i < itemCount; ++i) { + for (int i = 0; i < model.count() && i < itemCount; ++i) { QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QVERIFY(item); @@ -952,13 +952,15 @@ QList<T*> tst_QmlGraphicsGridView::findItems(QmlGraphicsItem *parent, const QStr QList<T*> items; const QMetaObject &mo = T::staticMetaObject; //qDebug() << parent->QGraphicsObject::children().count() << "children"; - for (int i = 0; i < parent->QGraphicsObject::children().count(); ++i) { - QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->QGraphicsObject::children().at(i)); + for (int i = 0; i < parent->childItems().count(); ++i) { + QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i)); if(!item) continue; //qDebug() << "try" << item; - if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) + if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { items.append(static_cast<T*>(item)); + //qDebug() << " found:" << item; + } items += findItems<T>(item, objectName); } diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/navigation.qml b/tests/auto/declarative/qmlgraphicstextedit/data/navigation.qml index 5b8613f..dc4aee9 100644 --- a/tests/auto/declarative/qmlgraphicstextedit/data/navigation.qml +++ b/tests/auto/declarative/qmlgraphicstextedit/data/navigation.qml @@ -1,23 +1,23 @@ import Qt 4.6 Rectangle { - property var myInput: Input + property var myinput: input width: 800; height: 600; color: "blue" Item { - id: FirstItem; - KeyNavigation.right: Input + id: firstItem; + KeyNavigation.right: input } - TextEdit { id: Input; focus: true - KeyNavigation.left: FirstItem - KeyNavigation.right: LastItem - KeyNavigation.up: FirstItem - KeyNavigation.down: LastItem + TextEdit { id: input; focus: true + KeyNavigation.left: firstItem + KeyNavigation.right: lastItem + KeyNavigation.up: firstItem + KeyNavigation.down: lastItem } Item { - id: LastItem - KeyNavigation.left: Input + id: lastItem + KeyNavigation.left: input } } diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/readOnly.qml b/tests/auto/declarative/qmlgraphicstextedit/data/readOnly.qml index d2a8ce2..06b57ea 100644 --- a/tests/auto/declarative/qmlgraphicstextedit/data/readOnly.qml +++ b/tests/auto/declarative/qmlgraphicstextedit/data/readOnly.qml @@ -1,11 +1,11 @@ import Qt 4.6 Rectangle { - property var myInput: Input + property var myinput: input width: 800; height: 600; color: "blue" - TextEdit { id: Input; focus: true + TextEdit { id: input; focus: true readOnly: true text: "I am the very model of a modern major general.\n" } diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml b/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml index 282c52c..637de3a 100644 --- a/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml +++ b/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml @@ -1,23 +1,23 @@ import Qt 4.6 Rectangle { - property var myInput: Input + property var myinput: input width: 800; height: 600; color: "blue" Item { - id: FirstItem; - KeyNavigation.right: Input + id: firstItem; + KeyNavigation.right: input } - TextInput { id: Input; focus: true - KeyNavigation.left: FirstItem - KeyNavigation.right: LastItem - KeyNavigation.up: FirstItem - KeyNavigation.down: LastItem + Textinput { id: input; focus: true + KeyNavigation.left: firstItem + KeyNavigation.right: lastItem + KeyNavigation.up: firstItem + KeyNavigation.down: lastItem } Item { - id: LastItem - KeyNavigation.left: Input + id: lastItem + KeyNavigation.left: input } } diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/readOnly.qml b/tests/auto/declarative/qmlgraphicstextinput/data/readOnly.qml index 1389d86..886da0c 100644 --- a/tests/auto/declarative/qmlgraphicstextinput/data/readOnly.qml +++ b/tests/auto/declarative/qmlgraphicstextinput/data/readOnly.qml @@ -1,11 +1,11 @@ import Qt 4.6 Rectangle { - property var myInput: Input + property var myinput: input width: 800; height: 600; color: "blue" - TextInput { id: Input; focus: true + Textinput { id: input; focus: true readOnly: true text: "I am the very model of a modern major general.\n" } diff --git a/tests/auto/declarative/qmllanguage/data/Alias.qml b/tests/auto/declarative/qmllanguage/data/Alias.qml index af6187a..55aa231 100644 --- a/tests/auto/declarative/qmllanguage/data/Alias.qml +++ b/tests/auto/declarative/qmllanguage/data/Alias.qml @@ -1,8 +1,8 @@ import Qt 4.6 QtObject { - id: Root + id: root property int value: 1892 - property alias aliasValue: Root.value + property alias aliasValue: root.value } diff --git a/tests/auto/declarative/qmllanguage/data/alias.1.qml b/tests/auto/declarative/qmllanguage/data/alias.1.qml index 3ad8f38..500b0f6 100644 --- a/tests/auto/declarative/qmllanguage/data/alias.1.qml +++ b/tests/auto/declarative/qmllanguage/data/alias.1.qml @@ -2,7 +2,7 @@ import Test 1.0 import Qt 4.6 QtObject { - id: Root + id: root property int value: 10 - property alias valueAlias: Root.value + property alias valueAlias: root.value } diff --git a/tests/auto/declarative/qmllanguage/data/alias.2.qml b/tests/auto/declarative/qmllanguage/data/alias.2.qml index aa4d103..5c92270 100644 --- a/tests/auto/declarative/qmllanguage/data/alias.2.qml +++ b/tests/auto/declarative/qmllanguage/data/alias.2.qml @@ -1,8 +1,8 @@ import Test 1.0 MyQmlObject { - id: Root - property alias aliasObject: Root.qmlobjectProperty + id: root + property alias aliasObject: root.qmlobjectProperty qmlobjectProperty: MyQmlObject { value : 10 } } diff --git a/tests/auto/declarative/qmllanguage/data/alias.3.qml b/tests/auto/declarative/qmllanguage/data/alias.3.qml index fa8a253..e059937 100644 --- a/tests/auto/declarative/qmllanguage/data/alias.3.qml +++ b/tests/auto/declarative/qmllanguage/data/alias.3.qml @@ -2,9 +2,9 @@ import Qt 4.6 QtObject { property var other - other: Alias { id: MyAliasObject } + other: Alias { id: myAliasObject } - property alias value: MyAliasObject.aliasValue - property alias value2: MyAliasObject.value + property alias value: myAliasObject.aliasValue + property alias value2: myAliasObject.value } diff --git a/tests/auto/declarative/qmllanguage/data/alias.8.qml b/tests/auto/declarative/qmllanguage/data/alias.8.qml index 38dc10f..2b9ad85 100644 --- a/tests/auto/declarative/qmllanguage/data/alias.8.qml +++ b/tests/auto/declarative/qmllanguage/data/alias.8.qml @@ -2,8 +2,8 @@ import Qt 4.6 QtObject { property var other - other: Alias3 { id: MyAliasObject } + other: Alias3 { id: myAliasObject } - property int value: MyAliasObject.obj.myValue + property int value: myAliasObject.obj.myValue } diff --git a/tests/auto/declarative/qmllanguage/data/alias.9.qml b/tests/auto/declarative/qmllanguage/data/alias.9.qml index 8061f99..a2a41a1 100644 --- a/tests/auto/declarative/qmllanguage/data/alias.9.qml +++ b/tests/auto/declarative/qmllanguage/data/alias.9.qml @@ -2,8 +2,8 @@ import Qt 4.6 QtObject { property var other - other: Alias4 { id: MyAliasObject } + other: Alias4 { id: myAliasObject } - property int value: MyAliasObject.obj.myValue + property int value: myAliasObject.obj.myValue } diff --git a/tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.qml b/tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.qml index e607768..00cc0c4 100644 --- a/tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.qml +++ b/tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.qml @@ -1,5 +1,5 @@ import Qt 4.6 ListModel { ListElement { a: 10 } - ListElement { id: Foo; a: 12 } + ListElement { id: foo; a: 12 } } diff --git a/tests/auto/declarative/qmllanguage/data/declaredPropertyValues.qml b/tests/auto/declarative/qmllanguage/data/declaredPropertyValues.qml new file mode 100644 index 0000000..3987a3c --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/declaredPropertyValues.qml @@ -0,0 +1,8 @@ +import Qt 4.6 + +QtObject { + property int a: 10 + property int b: 10 + a + property QtObject c: QtObject {} + property list<QtObject> d: [ QtObject {}, QtObject {} ] +} diff --git a/tests/auto/declarative/qmllanguage/data/defaultPropertyListOrder.qml b/tests/auto/declarative/qmllanguage/data/defaultPropertyListOrder.qml new file mode 100644 index 0000000..3651511 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/defaultPropertyListOrder.qml @@ -0,0 +1,29 @@ +import Test 1.0 +import Qt 4.6 + +MyContainer { + QtObject { + property int index: 0 + } + + QtObject { + property int index: 1 + } + + children: [ + QtObject { + property int index: 2 + }, + QtObject { + property int index: 3 + } + ] + + QtObject { + property int index: 4 + } + + QtObject { + property int index: 5 + } +} diff --git a/tests/auto/declarative/qmllanguage/data/duplicateIDs.qml b/tests/auto/declarative/qmllanguage/data/duplicateIDs.qml index 9605b5b..a993abd 100644 --- a/tests/auto/declarative/qmllanguage/data/duplicateIDs.qml +++ b/tests/auto/declarative/qmllanguage/data/duplicateIDs.qml @@ -1,6 +1,6 @@ import Test 1.0 MyContainer { - MyQmlObject { id: MyID } - MyQmlObject { id: MyID } + MyQmlObject { id: myID } + MyQmlObject { id: myID } } diff --git a/tests/auto/declarative/qmllanguage/data/idProperty.qml b/tests/auto/declarative/qmllanguage/data/idProperty.qml index a413c0b..90c1483 100644 --- a/tests/auto/declarative/qmllanguage/data/idProperty.qml +++ b/tests/auto/declarative/qmllanguage/data/idProperty.qml @@ -1,8 +1,8 @@ import Test 1.0 MyContainer { - property var object : MyObjectId + property var object : myObjectId MyTypeObject { - id: "MyObjectId" + id: "myObjectId" } } diff --git a/tests/auto/declarative/qmllanguage/data/inlineQmlComponents.qml b/tests/auto/declarative/qmllanguage/data/inlineQmlComponents.qml index 79ceda6..478f06a 100644 --- a/tests/auto/declarative/qmllanguage/data/inlineQmlComponents.qml +++ b/tests/auto/declarative/qmllanguage/data/inlineQmlComponents.qml @@ -2,7 +2,7 @@ import Test 1.0 import Qt 4.6 MyContainer { Component { - id: MyComponent + id: myComponent MyQmlObject { value: 11 } diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.4.qml b/tests/auto/declarative/qmllanguage/data/invalidID.4.qml index 1f15fce..86010bf 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidID.4.qml +++ b/tests/auto/declarative/qmllanguage/data/invalidID.4.qml @@ -1,6 +1,6 @@ import Test 1.0 MyQmlObject { - id: Hello - id: World + id: hello + id: world } diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.5.qml b/tests/auto/declarative/qmllanguage/data/invalidID.5.qml index 0545b0d..5b92a1a 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidID.5.qml +++ b/tests/auto/declarative/qmllanguage/data/invalidID.5.qml @@ -1,6 +1,6 @@ import Test 1.0 -import Test 1.0 as Hello +import Test 1.0 as hello MyQmlObject { - id: Hello + id: hello } diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.6.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidID.6.errors.txt index 861e3d7..160e8b5 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidID.6.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/invalidID.6.errors.txt @@ -1 +1 @@ -3:9:id conflicts with type name +3:5:"StartsWithUpperCase" is not a valid object id diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.6.qml b/tests/auto/declarative/qmllanguage/data/invalidID.6.qml index ea34007..62187d9 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidID.6.qml +++ b/tests/auto/declarative/qmllanguage/data/invalidID.6.qml @@ -1,5 +1,5 @@ import Test 1.0 MyQmlObject { - id: MyQmlObject + id: StartsWithUpperCase } diff --git a/tests/auto/declarative/qmllanguage/data/listItemDeleteSelf.qml b/tests/auto/declarative/qmllanguage/data/listItemDeleteSelf.qml index fa2e831..779c6d4 100644 --- a/tests/auto/declarative/qmllanguage/data/listItemDeleteSelf.qml +++ b/tests/auto/declarative/qmllanguage/data/listItemDeleteSelf.qml @@ -2,7 +2,7 @@ import Qt 4.6 Item { ListModel { - id: FruitModel + id: fruitModel ListElement { name: "Apple" cost: 2.45 @@ -18,21 +18,21 @@ Item { } Component { - id: FruitDelegate + id: fruitDelegate Item { width: 200; height: 50 Text { text: name } Text { text: '$'+cost; anchors.right: parent.right } MouseRegion { anchors.fill: parent - onClicked: FruitModel.remove(index) + onClicked: fruitModel.remove(index) } } } ListView { - model: FruitModel - delegate: FruitDelegate + model: fruitModel + delegate: fruitDelegate anchors.fill: parent } } diff --git a/tests/auto/declarative/qmllanguage/data/simpleBindings.qml b/tests/auto/declarative/qmllanguage/data/simpleBindings.qml index 74867b3..2fcd1a5 100644 --- a/tests/auto/declarative/qmllanguage/data/simpleBindings.qml +++ b/tests/auto/declarative/qmllanguage/data/simpleBindings.qml @@ -1,6 +1,6 @@ import Test 1.0 MyTypeObject { - id: Me + id: me property int v1: 10 property int v2: 11 @@ -10,9 +10,9 @@ MyTypeObject { property int value4 value1: v1 - value2: Me.v1 + value2: me.v1 value3: v1 + v2 value4: Math.min(v1, v2) - objectProperty: Me + objectProperty: me } diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp index 0a636db..54442d5 100644 --- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp +++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp @@ -109,6 +109,8 @@ private slots: void i18n_data(); void onCompleted(); void scriptString(); + void defaultPropertyListOrder(); + void declaredPropertyValues(); void importsBuiltin_data(); void importsBuiltin(); @@ -528,7 +530,7 @@ void tst_qmllanguage::idProperty() MyTypeObject *child = qobject_cast<MyTypeObject *>(object->children()->at(0)); QVERIFY(child != 0); - QCOMPARE(child->id(), QString("MyObjectId")); + QCOMPARE(child->id(), QString("myObjectId")); QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child)); } @@ -1019,6 +1021,32 @@ void tst_qmllanguage::scriptString() QCOMPARE(object->grouped()->script().context(), qmlContext(object)); } +// Check that default property assignments are correctly spliced into explicit +// property assignments +void tst_qmllanguage::defaultPropertyListOrder() +{ + QmlComponent component(&engine, TEST_FILE("defaultPropertyListOrder.qml")); + VERIFY_ERRORS(0); + + MyContainer *container = qobject_cast<MyContainer *>(component.create()); + QVERIFY(container != 0); + + QCOMPARE(container->children()->count(), 6); + QCOMPARE(container->children()->at(0)->property("index"), QVariant(0)); + QCOMPARE(container->children()->at(1)->property("index"), QVariant(1)); + QCOMPARE(container->children()->at(2)->property("index"), QVariant(2)); + QCOMPARE(container->children()->at(3)->property("index"), QVariant(3)); + QCOMPARE(container->children()->at(4)->property("index"), QVariant(4)); + QCOMPARE(container->children()->at(5)->property("index"), QVariant(5)); +} + +void tst_qmllanguage::declaredPropertyValues() +{ + QmlComponent component(&engine, TEST_FILE("declaredPropertyValues.qml")); + QEXPECT_FAIL("", "QTBUG-7860", Abort); + VERIFY_ERRORS(0); +} + // Check that first child of qml is of given type. Empty type insists on error. void tst_qmllanguage::testType(const QString& qml, const QString& type) { diff --git a/tests/auto/declarative/shared/testhttpserver.cpp b/tests/auto/declarative/shared/testhttpserver.cpp index 6c9d849..490fc95 100644 --- a/tests/auto/declarative/shared/testhttpserver.cpp +++ b/tests/auto/declarative/shared/testhttpserver.cpp @@ -115,6 +115,11 @@ void TestHTTPServer::addAlias(const QString &filename, const QString &alias) aliases.insert(filename, alias); } +void TestHTTPServer::addRedirect(const QString &filename, const QString &redirectName) +{ + redirects.insert(filename, redirectName); +} + bool TestHTTPServer::wait(const QUrl &expect, const QUrl &reply, const QUrl &body) { m_hasFailed = false; @@ -230,6 +235,12 @@ void TestHTTPServer::readyRead() bool TestHTTPServer::reply(QTcpSocket *socket, const QByteArray &fileName) { + if (redirects.contains(fileName)) { + QByteArray response = "HTTP/1.1 302 Found\r\nContent-length: 0\r\nContent-type: text/html; charset=UTF-8\r\nLocation: " + redirects[fileName].toUtf8() + "\r\n\r\n"; + socket->write(response); + return true; + } + for (int ii = 0; ii < dirs.count(); ++ii) { QString dir = dirs.at(ii).first; Mode mode = dirs.at(ii).second; diff --git a/tests/auto/declarative/shared/testhttpserver.h b/tests/auto/declarative/shared/testhttpserver.h index 2a8709f..178122d 100644 --- a/tests/auto/declarative/shared/testhttpserver.h +++ b/tests/auto/declarative/shared/testhttpserver.h @@ -62,6 +62,7 @@ public: bool hasFailed() const; void addAlias(const QString &filename, const QString &aliasName); + void addRedirect(const QString &filename, const QString &redirectName); private slots: void newConnection(); @@ -83,6 +84,7 @@ private: bool m_hasFailed; QHash<QString,QString> aliases; + QHash<QString,QString> redirects; QTcpServer server; }; diff --git a/tests/auto/declarative/states/data/anchorChanges.qml b/tests/auto/declarative/states/data/anchorChanges.qml index 3d94f36..7dce889 100644 --- a/tests/auto/declarative/states/data/anchorChanges.qml +++ b/tests/auto/declarative/states/data/anchorChanges.qml @@ -1,7 +1,7 @@ import Qt 4.6 Rectangle { - id: Container + id: container width: 200; height: 200 Rectangle { id: myRect @@ -14,10 +14,10 @@ Rectangle { states: State { name: "right" AnchorChanges { - id: AncCh + id: ancCh target: myRect; reset: "left" - right: Container.right + right: container.right } } } diff --git a/tests/auto/declarative/states/data/anchorChanges2.qml b/tests/auto/declarative/states/data/anchorChanges2.qml index 2e13628..516ed58 100644 --- a/tests/auto/declarative/states/data/anchorChanges2.qml +++ b/tests/auto/declarative/states/data/anchorChanges2.qml @@ -3,8 +3,8 @@ import Qt 4.6 Rectangle { width: 200; height: 200 Rectangle { - id: MyRect - objectName: "MyRect" + id: myRect + objectName: "myRect" width: 50; height: 50 color: "green"; anchors.left: parent.left @@ -13,7 +13,7 @@ Rectangle { states: State { name: "right" AnchorChanges { - target: MyRect; + target: myRect; reset: "left" right: parent.right } diff --git a/tests/auto/declarative/states/data/anchorChanges3.qml b/tests/auto/declarative/states/data/anchorChanges3.qml index cf85472..e19bd9a 100644 --- a/tests/auto/declarative/states/data/anchorChanges3.qml +++ b/tests/auto/declarative/states/data/anchorChanges3.qml @@ -1,29 +1,29 @@ import Qt 4.6 Rectangle { - id: Container + id: container width: 200; height: 200 Rectangle { - id: MyRect - objectName: "MyRect" + id: myRect + objectName: "myRect" color: "green"; anchors.left: parent.left - anchors.right: RightGuideline.left - anchors.top: TopGuideline.top - anchors.bottom: Container.bottom + anchors.right: rightGuideline.left + anchors.top: topGuideline.top + anchors.bottom: container.bottom } - Item { objectName: "LeftGuideline"; id: LeftGuideline; x: 10 } - Item { id: RightGuideline; x: 150 } - Item { id: TopGuideline; y: 10 } - Item { objectName: "BottomGuideline"; id: BottomGuideline; y: 150 } + Item { objectName: "leftGuideline"; id: leftGuideline; x: 10 } + Item { id: rightGuideline; x: 150 } + Item { id: topGuideline; y: 10 } + Item { objectName: "bottomGuideline"; id: bottomGuideline; y: 150 } states: State { name: "reanchored" AnchorChanges { - target: MyRect; - left: LeftGuideline.left - right: Container.right - top: Container.top - bottom: BottomGuideline.bottom + target: myRect; + left: leftGuideline.left + right: container.right + top: container.top + bottom: bottomGuideline.bottom } } } diff --git a/tests/auto/declarative/states/data/anchorChanges4.qml b/tests/auto/declarative/states/data/anchorChanges4.qml index 717f506..b766c71 100644 --- a/tests/auto/declarative/states/data/anchorChanges4.qml +++ b/tests/auto/declarative/states/data/anchorChanges4.qml @@ -3,20 +3,20 @@ import Qt 4.6 Rectangle { width: 200; height: 200 Rectangle { - id: MyRect - objectName: "MyRect" + id: myRect + objectName: "myRect" color: "green"; anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter } - Item { objectName: "LeftGuideline"; id: LeftGuideline; x: 10 } - Item { objectName: "BottomGuideline"; id: BottomGuideline; y: 150 } + Item { objectName: "leftGuideline"; id: leftGuideline; x: 10 } + Item { objectName: "bottomGuideline"; id: bottomGuideline; y: 150 } states: State { name: "reanchored" AnchorChanges { - target: MyRect; - horizontalCenter: BottomGuideline.horizontalCenter - verticalCenter: LeftGuideline.verticalCenter + target: myRect; + horizontalCenter: bottomGuideline.horizontalCenter + verticalCenter: leftGuideline.verticalCenter } } } diff --git a/tests/auto/declarative/states/data/anchorChanges5.qml b/tests/auto/declarative/states/data/anchorChanges5.qml index ef5f041..2d4b3c0 100644 --- a/tests/auto/declarative/states/data/anchorChanges5.qml +++ b/tests/auto/declarative/states/data/anchorChanges5.qml @@ -3,20 +3,20 @@ import Qt 4.6 Rectangle { width: 200; height: 200 Rectangle { - id: MyRect - objectName: "MyRect" + id: myRect + objectName: "myRect" color: "green"; anchors.horizontalCenter: parent.horizontalCenter anchors.baseline: parent.baseline } - Item { objectName: "LeftGuideline"; id: LeftGuideline; x: 10 } - Item { objectName: "BottomGuideline"; id: BottomGuideline; y: 150 } + Item { objectName: "leftGuideline"; id: leftGuideline; x: 10 } + Item { objectName: "bottomGuideline"; id: bottomGuideline; y: 150 } states: State { name: "reanchored" AnchorChanges { - target: MyRect; - horizontalCenter: BottomGuideline.horizontalCenter - baseline: LeftGuideline.baseline + target: myRect; + horizontalCenter: bottomGuideline.horizontalCenter + baseline: leftGuideline.baseline } } } diff --git a/tests/auto/declarative/states/data/basicBinding.qml b/tests/auto/declarative/states/data/basicBinding.qml index 930a6b2..6528113 100644 --- a/tests/auto/declarative/states/data/basicBinding.qml +++ b/tests/auto/declarative/states/data/basicBinding.qml @@ -1,12 +1,12 @@ import Qt 4.6 Rectangle { - id: MyRectangle + id: myRectangle property color sourceColor: "blue" width: 100; height: 100 color: "red" states: State { name: "blue" - PropertyChanges { target: MyRectangle; color: sourceColor } + PropertyChanges { target: myRectangle; color: sourceColor } } } diff --git a/tests/auto/declarative/states/data/basicBinding2.qml b/tests/auto/declarative/states/data/basicBinding2.qml index 6bfaf5a..2e7b4cf 100644 --- a/tests/auto/declarative/states/data/basicBinding2.qml +++ b/tests/auto/declarative/states/data/basicBinding2.qml @@ -1,12 +1,12 @@ import Qt 4.6 Rectangle { - id: MyRectangle + id: myRectangle property color sourceColor: "red" width: 100; height: 100 color: sourceColor states: State { name: "blue" - PropertyChanges { target: MyRectangle; color: "blue" } + PropertyChanges { target: myRectangle; color: "blue" } } -}
\ No newline at end of file +} diff --git a/tests/auto/declarative/states/data/basicBinding3.qml b/tests/auto/declarative/states/data/basicBinding3.qml index 344bfae..a3c47d9 100644 --- a/tests/auto/declarative/states/data/basicBinding3.qml +++ b/tests/auto/declarative/states/data/basicBinding3.qml @@ -1,6 +1,6 @@ import Qt 4.6 Rectangle { - id: MyRectangle + id: myRectangle property color sourceColor: "red" property color sourceColor2: "blue" @@ -8,6 +8,6 @@ Rectangle { color: sourceColor states: State { name: "blue" - PropertyChanges { target: MyRectangle; color: sourceColor2 } + PropertyChanges { target: myRectangle; color: sourceColor2 } } -}
\ No newline at end of file +} diff --git a/tests/auto/declarative/states/data/basicBinding4.qml b/tests/auto/declarative/states/data/basicBinding4.qml index f0b72bd..1f52d0e 100644 --- a/tests/auto/declarative/states/data/basicBinding4.qml +++ b/tests/auto/declarative/states/data/basicBinding4.qml @@ -1,6 +1,6 @@ import Qt 4.6 Rectangle { - id: MyRectangle + id: myRectangle property color sourceColor: "blue" width: 100; height: 100 @@ -8,10 +8,10 @@ Rectangle { states: [ State { name: "blue" - PropertyChanges { target: MyRectangle; color: sourceColor } + PropertyChanges { target: myRectangle; color: sourceColor } }, State { name: "green" - PropertyChanges { target: MyRectangle; color: "green" } + PropertyChanges { target: myRectangle; color: "green" } }] } diff --git a/tests/auto/declarative/states/data/basicChanges.qml b/tests/auto/declarative/states/data/basicChanges.qml index 8d560c6..88ea256 100644 --- a/tests/auto/declarative/states/data/basicChanges.qml +++ b/tests/auto/declarative/states/data/basicChanges.qml @@ -1,10 +1,10 @@ import Qt 4.6 Rectangle { - id: MyRectangle + id: myRectangle width: 100; height: 100 color: "red" states: State { name: "blue" - PropertyChanges { target: MyRectangle; color: "blue" } + PropertyChanges { target: myRectangle; color: "blue" } } -}
\ No newline at end of file +} diff --git a/tests/auto/declarative/states/data/basicChanges2.qml b/tests/auto/declarative/states/data/basicChanges2.qml index 0f8783a..4dd293f 100644 --- a/tests/auto/declarative/states/data/basicChanges2.qml +++ b/tests/auto/declarative/states/data/basicChanges2.qml @@ -1,15 +1,15 @@ import Qt 4.6 Rectangle { - id: MyRectangle + id: myRectangle width: 100; height: 100 color: "red" states: [ State { name: "blue" - PropertyChanges { target: MyRectangle; color: "blue" } + PropertyChanges { target: myRectangle; color: "blue" } }, State { name: "green" - PropertyChanges { target: MyRectangle; color: "green" } + PropertyChanges { target: myRectangle; color: "green" } }] -}
\ No newline at end of file +} diff --git a/tests/auto/declarative/states/data/basicChanges3.qml b/tests/auto/declarative/states/data/basicChanges3.qml index 2a5ca5d..62ab1d5 100644 --- a/tests/auto/declarative/states/data/basicChanges3.qml +++ b/tests/auto/declarative/states/data/basicChanges3.qml @@ -1,15 +1,15 @@ import Qt 4.6 Rectangle { - id: MyRectangle + id: myRectangle width: 100; height: 100 color: "red" states: [ State { name: "blue" - PropertyChanges { target: MyRectangle; color: "blue" } + PropertyChanges { target: myRectangle; color: "blue" } }, State { name: "bordered" - PropertyChanges { target: MyRectangle; border.width: 2 } + PropertyChanges { target: myRectangle; border.width: 2 } }] } diff --git a/tests/auto/declarative/states/data/basicExtension.qml b/tests/auto/declarative/states/data/basicExtension.qml index 230e00b..1836f8a 100644 --- a/tests/auto/declarative/states/data/basicExtension.qml +++ b/tests/auto/declarative/states/data/basicExtension.qml @@ -1,16 +1,16 @@ import Qt 4.6 Rectangle { - id: MyRectangle + id: myRectangle width: 100; height: 100 color: "red" states: [ State { name: "blue" - PropertyChanges { target: MyRectangle; color: "blue" } + PropertyChanges { target: myRectangle; color: "blue" } }, State { name: "bordered" extend: "blue" - PropertyChanges { target: MyRectangle; border.width: 2 } + PropertyChanges { target: myRectangle; border.width: 2 } }] -}
\ No newline at end of file +} diff --git a/tests/auto/declarative/states/data/deleting.qml b/tests/auto/declarative/states/data/deleting.qml index 0c512dd..3da0b12 100644 --- a/tests/auto/declarative/states/data/deleting.qml +++ b/tests/auto/declarative/states/data/deleting.qml @@ -1,11 +1,11 @@ import Qt 4.6 Rectangle { - id: MyRectangle + id: myRectangle width: 100; height: 100 color: "red" states: State { name: "blue" - PropertyChanges { target: MyRectangle; color: "blue"; objectName: "pc1" } - PropertyChanges { target: MyRectangle; radius: 5; objectName: "pc2" } + PropertyChanges { target: myRectangle; color: "blue"; objectName: "pc1" } + PropertyChanges { target: myRectangle; radius: 5; objectName: "pc2" } } } diff --git a/tests/auto/declarative/states/data/deletingState.qml b/tests/auto/declarative/states/data/deletingState.qml index 9dc46a6..a5e8ed3 100644 --- a/tests/auto/declarative/states/data/deletingState.qml +++ b/tests/auto/declarative/states/data/deletingState.qml @@ -1,13 +1,13 @@ import Qt 4.6 Rectangle { - id: MyRectangle + id: myRectangle width: 100; height: 100 color: "red" StateGroup { id: stateGroup states: State { name: "blue" - PropertyChanges { target: MyRectangle; color: "blue" } + PropertyChanges { target: myRectangle; color: "blue" } } } } diff --git a/tests/auto/declarative/states/data/explicit.qml b/tests/auto/declarative/states/data/explicit.qml index ca7e274..7543f84 100644 --- a/tests/auto/declarative/states/data/explicit.qml +++ b/tests/auto/declarative/states/data/explicit.qml @@ -1,6 +1,6 @@ import Qt 4.6 Rectangle { - id: MyRectangle + id: myRectangle property color sourceColor: "blue" width: 100; height: 100 color: "red" @@ -8,7 +8,7 @@ Rectangle { name: "blue" PropertyChanges { objectName: "changes" - target: MyRectangle; explicit: true + target: myRectangle; explicit: true color: sourceColor } } diff --git a/tests/auto/declarative/states/data/fakeExtension.qml b/tests/auto/declarative/states/data/fakeExtension.qml index 3d85c4f..c7975e1 100644 --- a/tests/auto/declarative/states/data/fakeExtension.qml +++ b/tests/auto/declarative/states/data/fakeExtension.qml @@ -1,16 +1,16 @@ import Qt 4.6 Rectangle { - id: MyRectangle + id: myRectangle width: 100; height: 100 color: "red" states: [ State { name: "blue" - PropertyChanges { target: MyRectangle; color: "blue" } + PropertyChanges { target: myRectangle; color: "blue" } }, State { name: "green" extend: "blue" - PropertyChanges { target: MyRectangle; color: "green" } + PropertyChanges { target: myRectangle; color: "green" } }] -}
\ No newline at end of file +} diff --git a/tests/auto/declarative/states/data/nonExistantProp.qml b/tests/auto/declarative/states/data/nonExistantProp.qml index 582029d..a5dd86a 100644 --- a/tests/auto/declarative/states/data/nonExistantProp.qml +++ b/tests/auto/declarative/states/data/nonExistantProp.qml @@ -1,11 +1,11 @@ import Qt 4.6 Rectangle { - id: MyRectangle + id: myRectangle width: 100; height: 100 color: "red" states: State { name: "blue" - PropertyChanges { target: MyRectangle; colr: "blue" } + PropertyChanges { target: myRectangle; colr: "blue" } } } diff --git a/tests/auto/declarative/states/data/parentChange.qml b/tests/auto/declarative/states/data/parentChange.qml index 29596a8..087da6b 100644 --- a/tests/auto/declarative/states/data/parentChange.qml +++ b/tests/auto/declarative/states/data/parentChange.qml @@ -13,7 +13,7 @@ Rectangle { } } MouseRegion { - id: Clickable + id: clickable anchors.fill: parent } @@ -28,7 +28,7 @@ Rectangle { states: State { name: "reparented" - when: Clickable.pressed + when: clickable.pressed ParentChange { target: myRect parent: newParent diff --git a/tests/auto/declarative/states/data/parentChange2.qml b/tests/auto/declarative/states/data/parentChange2.qml index d1c6d6a..f0b00f5 100644 --- a/tests/auto/declarative/states/data/parentChange2.qml +++ b/tests/auto/declarative/states/data/parentChange2.qml @@ -16,13 +16,13 @@ Rectangle { } } MouseRegion { - id: Clickable + id: clickable anchors.fill: parent } states: State { name: "reparented" - when: Clickable.pressed + when: clickable.pressed ParentChange { target: myRect parent: newParent diff --git a/tests/auto/declarative/states/data/parentChange3.qml b/tests/auto/declarative/states/data/parentChange3.qml index c7b7bee..2aa507c 100644 --- a/tests/auto/declarative/states/data/parentChange3.qml +++ b/tests/auto/declarative/states/data/parentChange3.qml @@ -17,7 +17,7 @@ Rectangle { } } MouseRegion { - id: Clickable + id: clickable anchors.fill: parent } @@ -33,7 +33,7 @@ Rectangle { states: State { name: "reparented" - when: Clickable.pressed + when: clickable.pressed ParentChange { target: myRect parent: newParent diff --git a/tests/auto/declarative/states/data/parentChange4.qml b/tests/auto/declarative/states/data/parentChange4.qml index ee75176..d00274b 100644 --- a/tests/auto/declarative/states/data/parentChange4.qml +++ b/tests/auto/declarative/states/data/parentChange4.qml @@ -10,7 +10,7 @@ Rectangle { color: "red" } MouseRegion { - id: Clickable + id: clickable anchors.fill: parent } @@ -21,7 +21,7 @@ Rectangle { states: State { name: "reparented" - when: Clickable.pressed + when: clickable.pressed ParentChange { target: myRect parent: newParent diff --git a/tests/auto/declarative/states/data/parentChange5.qml b/tests/auto/declarative/states/data/parentChange5.qml index 47b733b..f75e2a3 100644 --- a/tests/auto/declarative/states/data/parentChange5.qml +++ b/tests/auto/declarative/states/data/parentChange5.qml @@ -10,7 +10,7 @@ Rectangle { color: "red" } MouseRegion { - id: Clickable + id: clickable anchors.fill: parent } @@ -21,7 +21,7 @@ Rectangle { states: State { name: "reparented" - when: Clickable.pressed + when: clickable.pressed ParentChange { target: myRect parent: newParent diff --git a/tests/auto/declarative/states/data/propertyErrors.qml b/tests/auto/declarative/states/data/propertyErrors.qml index 270462e..080e833 100644 --- a/tests/auto/declarative/states/data/propertyErrors.qml +++ b/tests/auto/declarative/states/data/propertyErrors.qml @@ -1,10 +1,10 @@ import Qt 4.6 Rectangle { - id: MyRectangle + id: myRectangle width: 100; height: 100 color: "red" states: State { name: "blue" - PropertyChanges { target: MyRectangle; colr: "blue"; wantsFocus: true } + PropertyChanges { target: myRectangle; colr: "blue"; wantsFocus: true } } } diff --git a/tests/auto/declarative/states/data/restoreEntryValues.qml b/tests/auto/declarative/states/data/restoreEntryValues.qml index d86f033..088c608 100644 --- a/tests/auto/declarative/states/data/restoreEntryValues.qml +++ b/tests/auto/declarative/states/data/restoreEntryValues.qml @@ -1,12 +1,12 @@ import Qt 4.6 Rectangle { - id: MyRectangle + id: myRectangle width: 100; height: 100 color: "red" states: State { name: "blue" PropertyChanges { - target: MyRectangle + target: myRectangle restoreEntryValues: false color: "blue" } diff --git a/tests/auto/declarative/states/data/script.qml b/tests/auto/declarative/states/data/script.qml index 6983419..3c5f33e 100644 --- a/tests/auto/declarative/states/data/script.qml +++ b/tests/auto/declarative/states/data/script.qml @@ -1,10 +1,10 @@ import Qt 4.6 Rectangle { - id: MyRectangle + id: myRectangle width: 100; height: 100 color: "red" states: State { name: "blue" - StateChangeScript { script: MyRectangle.color = "blue"; } + StateChangeScript { script: myRectangle.color = "blue"; } } } diff --git a/tests/auto/declarative/visual/ListView/basic1.qml b/tests/auto/declarative/visual/ListView/basic1.qml index 85934dc..3c371a6 100644 --- a/tests/auto/declarative/visual/ListView/basic1.qml +++ b/tests/auto/declarative/visual/ListView/basic1.qml @@ -4,7 +4,7 @@ Rectangle { color: "blue" width: 200 height: 300 - id: Page + id: page ListView { anchors.fill: parent delegate: Rectangle { diff --git a/tests/auto/declarative/visual/ListView/basic2.qml b/tests/auto/declarative/visual/ListView/basic2.qml index 4fe63ac..bdba65e 100644 --- a/tests/auto/declarative/visual/ListView/basic2.qml +++ b/tests/auto/declarative/visual/ListView/basic2.qml @@ -4,9 +4,9 @@ Rectangle { color: "blue" width: 200 height: 300 - id: Page + id: page Component { - id: Delegate + id: delegate Rectangle { color: "red" width: 100 @@ -18,7 +18,7 @@ Rectangle { } ListView { anchors.fill: parent - delegate: Delegate + delegate: delegate model: ListModel { ListElement { name: "January" diff --git a/tests/auto/declarative/visual/ListView/basic3.qml b/tests/auto/declarative/visual/ListView/basic3.qml index c0705e9..05ac358 100644 --- a/tests/auto/declarative/visual/ListView/basic3.qml +++ b/tests/auto/declarative/visual/ListView/basic3.qml @@ -4,9 +4,9 @@ Rectangle { color: "blue" width: 200 height: 300 - id: Page - ListModel { - id: Model + id: page + Listmodel { + id: model ListElement { name: "January" } @@ -16,7 +16,7 @@ Rectangle { } ListView { anchors.fill: parent - model: Model + model: model delegate: Rectangle { color: "red" width: 100 diff --git a/tests/auto/declarative/visual/ListView/basic4.qml b/tests/auto/declarative/visual/ListView/basic4.qml index c8e1bcc..3628bd3 100644 --- a/tests/auto/declarative/visual/ListView/basic4.qml +++ b/tests/auto/declarative/visual/ListView/basic4.qml @@ -4,9 +4,9 @@ Rectangle { color: "blue" width: 200 height: 300 - id: Page - ListModel { - id: Model + id: page + Listmodel { + id: model ListElement { name: "January" } @@ -15,7 +15,7 @@ Rectangle { } } Component { - id: Delegate + id: delegate Rectangle { color: "red" width: 100 @@ -27,7 +27,7 @@ Rectangle { } ListView { anchors.fill: parent - model: Model - delegate: Delegate + model: model + delegate: delegate } } diff --git a/tests/auto/declarative/visual/Package_Views/packageviews.qml b/tests/auto/declarative/visual/Package_Views/packageviews.qml index ece6b88..c8016b6 100644 --- a/tests/auto/declarative/visual/Package_Views/packageviews.qml +++ b/tests/auto/declarative/visual/Package_Views/packageviews.qml @@ -6,9 +6,9 @@ Rectangle { height: 200 color: "black" - VisualDataModel { - id: Model - model: ListModel { + VisualDatamodel { + id: model + model: Listmodel { ListElement { itemColor: "red" } ListElement { itemColor: "green" } ListElement { itemColor: "blue" } @@ -75,7 +75,7 @@ Rectangle { ListView { width: parent.width/2 height: parent.height - model: Model.parts.list + model: model.parts.list } GridView { @@ -84,6 +84,6 @@ Rectangle { cellWidth: 50 cellHeight: 50 height: parent.height - model: Model.parts.grid + model: model.parts.grid } } diff --git a/tests/auto/declarative/visual/animation/bindinganimation/bindinganimation.qml b/tests/auto/declarative/visual/animation/bindinganimation/bindinganimation.qml index 1afd4cd..732eb59 100644 --- a/tests/auto/declarative/visual/animation/bindinganimation/bindinganimation.qml +++ b/tests/auto/declarative/visual/animation/bindinganimation/bindinganimation.qml @@ -4,9 +4,9 @@ Rectangle { color: "blue" width: 320 height: 240 - id: Page + id: page Rectangle { - id: MyRectangle + id: myRectangle width: 100 height: 100 color: "red" @@ -16,12 +16,12 @@ Rectangle { State { name: "hello" PropertyChanges { - target: MyRectangle + target: myRectangle x: 50 + 50 } PropertyChanges { - target: MyMouseRegion - onClicked: Page.state = '' + target: myMouseRegion + onClicked: page.state = '' } } ] @@ -33,8 +33,8 @@ Rectangle { } ] MouseRegion { - id: MyMouseRegion + id: myMouseRegion anchors.fill: parent - onClicked: { Page.state= 'hello' } + onClicked: { page.state= 'hello' } } } diff --git a/tests/auto/declarative/visual/animation/parentAction/parentAction.qml b/tests/auto/declarative/visual/animation/parentAction/parentAction.qml index e69d234..1e3f402 100644 --- a/tests/auto/declarative/visual/animation/parentAction/parentAction.qml +++ b/tests/auto/declarative/visual/animation/parentAction/parentAction.qml @@ -8,7 +8,7 @@ Rectangle { transformOrigin: "Center" x: 10; y: 10 Rectangle { - id: MyRect + id: myRect x: 5 width: 100; height: 100 transformOrigin: "BottomLeft" @@ -16,7 +16,7 @@ Rectangle { } } MouseRegion { - id: Clickable + id: clickable anchors.fill: parent } @@ -32,13 +32,13 @@ Rectangle { states: State { name: "moved" - when: Clickable.pressed + when: clickable.pressed ParentChange { - target: MyRect + target: myRect parent: newParent } PropertyChanges { - target: MyRect + target: myRect rotation: -52 scale: 1 color: "blue" diff --git a/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml b/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml index a9d3c74..b670166 100644 --- a/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml +++ b/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml @@ -3,20 +3,20 @@ import Qt 4.6 Rectangle { width: 400; height: 400 Rectangle { - id: MyRect + id: myRect width: 100; height: 100 color: "red" } MouseRegion { - id: Clickable + id: clickable anchors.fill: parent } states: State { name: "state1" - when: Clickable.pressed + when: clickable.pressed PropertyChanges { - target: MyRect + target: myRect x: 50; y: 50 color: "blue" } diff --git a/tests/auto/declarative/visual/focusscope/test.qml b/tests/auto/declarative/visual/focusscope/test.qml index dd6d726..401c7dc 100644 --- a/tests/auto/declarative/visual/focusscope/test.qml +++ b/tests/auto/declarative/visual/focusscope/test.qml @@ -8,7 +8,7 @@ Rectangle { Keys.onDigit9Pressed: console.log("Error - Root") FocusScope { - id: MyScope + id: myScope focus: true Keys.onDigit9Pressed: console.log("Error - FocusScope") @@ -19,16 +19,16 @@ Rectangle { color: "transparent" border.width: 5 - border.color: MyScope.wantsFocus?"blue":"black" + border.color: myScope.wantsFocus?"blue":"black" Rectangle { - id: Item1 + id: item1 x: 10; y: 10 width: 100; height: 100; color: "green" border.width: 5 border.color: wantsFocus?"blue":"black" Keys.onDigit9Pressed: console.log("Top Left"); - KeyNavigation.right: Item2 + KeyNavigation.right: item2 focus: true Rectangle { @@ -38,12 +38,12 @@ Rectangle { } Rectangle { - id: Item2 + id: item2 x: 310; y: 10 width: 100; height: 100; color: "green" border.width: 5 border.color: wantsFocus?"blue":"black" - KeyNavigation.left: Item1 + KeyNavigation.left: item1 Keys.onDigit9Pressed: console.log("Top Right"); Rectangle { @@ -52,20 +52,20 @@ Rectangle { } } } - KeyNavigation.down: Item3 + KeyNavigation.down: item3 } Text { x:100; y:170; text: "Blue border indicates scoped focus\nBlack border indicates NOT scoped focus\nRed box indicates active focus\nUse arrow keys to navigate\nPress \"9\" to print currently focused item" } Rectangle { - id: Item3 + id: item3 x: 10; y: 300 width: 100; height: 100; color: "green" border.width: 5 border.color: wantsFocus?"blue":"black" Keys.onDigit9Pressed: console.log("Bottom Left"); - KeyNavigation.up: MyScope + KeyNavigation.up: myScope Rectangle { width: 50; height: 50; anchors.centerIn: parent diff --git a/tests/auto/declarative/visual/focusscope/test3.qml b/tests/auto/declarative/visual/focusscope/test3.qml index 4be9dc7..855bdc5 100644 --- a/tests/auto/declarative/visual/focusscope/test3.qml +++ b/tests/auto/declarative/visual/focusscope/test3.qml @@ -5,8 +5,8 @@ Rectangle { width: 800 height: 600 - ListModel { - id: Model + Listmodel { + id: model ListElement { name: "1" } ListElement { name: "2" } ListElement { name: "3" } @@ -19,16 +19,16 @@ Rectangle { } Component { - id: VerticalDelegate + id: verticalDelegate FocusScope { - id: Root + id: root width: 50; height: 50; Keys.onDigit9Pressed: console.log("Error - " + name) Rectangle { focus: true Keys.onDigit9Pressed: console.log(name) width: 50; height: 50; - color: Root.ListView.isCurrentItem?"red":"green" + color: root.ListView.isCurrentItem?"red":"green" Text { text: name; anchors.centerIn: parent } } } @@ -37,8 +37,8 @@ Rectangle { ListView { width: 800; height: 50; orientation: "Horizontal" focus: true - model: Model - delegate: VerticalDelegate + model: model + delegate: verticalDelegate preferredHighlightBegin: 100 preferredHighlightEnd: 101 highlightRangeMode: ListView.StrictlyEnforceRange diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/flickable-vertical.qml b/tests/auto/declarative/visual/qmlgraphicsflickable/flickable-vertical.qml index e9aae61..cc15755 100644 --- a/tests/auto/declarative/visual/qmlgraphicsflickable/flickable-vertical.qml +++ b/tests/auto/declarative/visual/qmlgraphicsflickable/flickable-vertical.qml @@ -15,8 +15,8 @@ Rectangle { ListElement { dayColor: "orange" } } - Flickable { - id: Flick + flickable { + id: flick height: parent.height-50 width: parent.width; viewportHeight: column.height @@ -37,10 +37,10 @@ Rectangle { } Rectangle { radius: 3 - x: Flick.width-8 + x: flick.width-8 width: 8 - y: Flick.visibleArea.yPosition * Flick.height - height: Flick.visibleArea.heightRatio * Flick.height + y: flick.visibleArea.yPosition * flick.height + height: flick.visibleArea.heightRatio * flick.height } // click to toggle interactive flag @@ -51,7 +51,7 @@ Rectangle { color: "red" MouseRegion { anchors.fill: parent - onClicked: Flick.interactive = Flick.interactive ? false : true + onClicked: flick.interactive = flick.interactive ? false : true } } @@ -64,7 +64,7 @@ Rectangle { color: "green" MouseRegion { anchors.fill: parent - onClicked: Flick.pressDelay = Flick.pressDelay > 0 ? 0 : 500 + onClicked: flick.pressDelay = flick.pressDelay > 0 ? 0 : 500 } } @@ -77,12 +77,12 @@ Rectangle { color: "yellow" MouseRegion { anchors.fill: parent - onClicked: Flick.overShoot = Flick.overShoot > 0 ? 0 : 30 + onClicked: flick.overShoot = flick.overShoot > 0 ? 0 : 30 } } Rectangle { - width: Math.abs(Flick.verticalVelocity)/100 + width: Math.abs(flick.verticalVelocity)/100 height: 50 x: 200 y: parent.height - 50 diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/qt-669.qml b/tests/auto/declarative/visual/qmlgraphicstextedit/qt-669.qml index e37f1b2..b01ddf8 100644 --- a/tests/auto/declarative/visual/qmlgraphicstextedit/qt-669.qml +++ b/tests/auto/declarative/visual/qmlgraphicstextedit/qt-669.qml @@ -1,7 +1,7 @@ import Qt 4.6 Rectangle { - Component { id: TestableCursor + Component { id: testableCursor //Doesn't blink Rectangle { color:"black" @@ -13,7 +13,7 @@ Rectangle { height:40; TextEdit { focus: true; - cursorDelegate: TestableCursor + cursorDelegate: testableCursor text: "Jackdaws love my big sphinx of Quartz" } } diff --git a/tests/auto/declarative/xmlhttprequest/data/redirectError.qml b/tests/auto/declarative/xmlhttprequest/data/redirectError.qml new file mode 100644 index 0000000..6b345cc --- /dev/null +++ b/tests/auto/declarative/xmlhttprequest/data/redirectError.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +QtObject { + property string url + + property bool dataOK: false + property bool done: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open("GET", url); + + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + done = true; + dataOK = x.status == 404; + } + } + + x.send(); + } +} + diff --git a/tests/auto/declarative/xmlhttprequest/data/redirectRecur.qml b/tests/auto/declarative/xmlhttprequest/data/redirectRecur.qml new file mode 100644 index 0000000..c0321dc --- /dev/null +++ b/tests/auto/declarative/xmlhttprequest/data/redirectRecur.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +QtObject { + property string url + + property bool dataOK: false + property bool done: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open("GET", url); + + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + done = true; + dataOK = x.status == 302; + } + } + + x.send(); + } +} + diff --git a/tests/auto/declarative/xmlhttprequest/data/redirects.qml b/tests/auto/declarative/xmlhttprequest/data/redirects.qml new file mode 100644 index 0000000..f6fabdb --- /dev/null +++ b/tests/auto/declarative/xmlhttprequest/data/redirects.qml @@ -0,0 +1,22 @@ +import Qt 4.6 + +QtObject { + property string url + + property bool dataOK: false + property bool done: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open("GET", url); + + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + done = true; + dataOK = x.responseText == "Redirected\n"; + } + } + + x.send(); + } +} diff --git a/tests/auto/declarative/xmlhttprequest/data/redirecttarget.html b/tests/auto/declarative/xmlhttprequest/data/redirecttarget.html new file mode 100644 index 0000000..95f35e0 --- /dev/null +++ b/tests/auto/declarative/xmlhttprequest/data/redirecttarget.html @@ -0,0 +1 @@ +Redirected diff --git a/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp b/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp index d3201e2..253e041 100644 --- a/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp +++ b/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp @@ -98,6 +98,7 @@ private slots: void responseText(); void responseXML_invalid(); void invalidMethodUsage(); + void redirects(); // Attributes void document(); @@ -1160,6 +1161,72 @@ void tst_xmlhttprequest::invalidMethodUsage() delete object; } +// Test that XMLHttpRequest transparently redirects +void tst_xmlhttprequest::redirects() +{ + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirecttarget.html"); + server.serveDirectory("data"); + + QmlComponent component(&engine, TEST_FILE("redirects.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/redirect.html"); + object->setProperty("expectedText", ""); + component.completeCreate(); + + TRY_WAIT(object->property("done").toBool() == true); + QCOMPARE(object->property("dataOK").toBool(), true); + + delete object; + } + + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirectmissing.html"); + server.serveDirectory("data"); + + QmlComponent component(&engine, TEST_FILE("redirectError.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/redirect.html"); + object->setProperty("expectedText", ""); + component.completeCreate(); + + TRY_WAIT(object->property("done").toBool() == true); + QCOMPARE(object->property("dataOK").toBool(), true); + + delete object; + } + + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirect.html"); + server.serveDirectory("data"); + + QmlComponent component(&engine, TEST_FILE("redirectRecur.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/redirect.html"); + object->setProperty("expectedText", ""); + component.completeCreate(); + + for (int ii = 0; ii < 60; ++ii) { + if (object->property("done").toBool()) break; + QTest::qWait(50); + } + QVERIFY(object->property("done").toBool() == true); + + QCOMPARE(object->property("dataOK").toBool(), true); + + delete object; + } +} + void tst_xmlhttprequest::responseXML_invalid() { QmlComponent component(&engine, TEST_FILE("responseXML_invalid.qml")); diff --git a/tests/auto/linguist/lupdate/.gitignore b/tests/auto/linguist/lupdate/.gitignore index 389f2dc..a11e8d1 100644 --- a/tests/auto/linguist/lupdate/.gitignore +++ b/tests/auto/linguist/lupdate/.gitignore @@ -1,4 +1,4 @@ tst_lupdate -testdata/good/*/project.ts -testdata/good/*/*/project.ts -testdata/recursivescan/*.ts +testdata/*/*.ts +testdata/*/*/*.ts +testdata/*/*/*/*.ts diff --git a/tests/auto/linguist/lupdate/testdata/good/cmdline_deeppath/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/cmdline_deeppath/lupdatecmd new file mode 100644 index 0000000..301d839 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/cmdline_deeppath/lupdatecmd @@ -0,0 +1,2 @@ +cd ../../recursivescan +lupdate sub/finddialog.cpp -ts project.ts diff --git a/tests/auto/linguist/lupdate/testdata/recursivescan/bar.ts.result b/tests/auto/linguist/lupdate/testdata/good/cmdline_deeppath/project.ts.result index 5c3c21c..5c3c21c 100644 --- a/tests/auto/linguist/lupdate/testdata/recursivescan/bar.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/cmdline_deeppath/project.ts.result diff --git a/tests/auto/linguist/lupdate/testdata/good/cmdline_recurse/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/cmdline_recurse/lupdatecmd new file mode 100644 index 0000000..1814e67 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/cmdline_recurse/lupdatecmd @@ -0,0 +1,2 @@ +cd ../../recursivescan +lupdate . -ts project.ts diff --git a/tests/auto/linguist/lupdate/testdata/recursivescan/foo.ts.result b/tests/auto/linguist/lupdate/testdata/good/cmdline_recurse/project.ts.result index 95a34fa..95a34fa 100644 --- a/tests/auto/linguist/lupdate/testdata/recursivescan/foo.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/cmdline_recurse/project.ts.result diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr3/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/codecfortr3/expectedoutput.txt new file mode 100644 index 0000000..feecdda --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr3/expectedoutput.txt @@ -0,0 +1 @@ +lupdate warning: Codec for tr\(\) 'ISO-8859-1' disagrees with existing file's codec 'UTF-8'\. Expect trouble\. diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr3/main.cpp b/tests/auto/linguist/lupdate/testdata/good/codecfortr3/main.cpp new file mode 100644 index 0000000..e4210c5 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr3/main.cpp @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +int main(int argc, char **argv) +{ + QObject::tr("hi"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr3/project.pro b/tests/auto/linguist/lupdate/testdata/good/codecfortr3/project.pro new file mode 100644 index 0000000..00a4dc4 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr3/project.pro @@ -0,0 +1,4 @@ +SOURCES += main.cpp + +TRANSLATIONS = project.ts +CODECFORTR = latin1 diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr3/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/codecfortr3/project.ts.before new file mode 100644 index 0000000..07ad79b --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr3/project.ts.before @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<defaultcodec>UTF-8</defaultcodec> +<context> + <name>QObject</name> + <message> + <location filename="main.cpp" line="44"/> + <source>hi</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr3/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/codecfortr3/project.ts.result new file mode 100644 index 0000000..b6899c1 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr3/project.ts.result @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>QObject</name> + <message> + <location filename="main.cpp" line="44"/> + <source>hi</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr4/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/codecfortr4/expectedoutput.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr4/expectedoutput.txt diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr4/main.cpp b/tests/auto/linguist/lupdate/testdata/good/codecfortr4/main.cpp new file mode 100644 index 0000000..e4210c5 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr4/main.cpp @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +int main(int argc, char **argv) +{ + QObject::tr("hi"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr4/project.pro b/tests/auto/linguist/lupdate/testdata/good/codecfortr4/project.pro new file mode 100644 index 0000000..4fddb02 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr4/project.pro @@ -0,0 +1,4 @@ +SOURCES += main.cpp + +TRANSLATIONS = project.ts +CODECFORTR = latin2 diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr4/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/codecfortr4/project.ts.before new file mode 100644 index 0000000..e18e34e --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr4/project.ts.before @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<defaultcodec>ISO-8859-2</defaultcodec> +<context> + <name>QObject</name> + <message> + <location filename="main.cpp" line="44"/> + <source>hi</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr4/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/codecfortr4/project.ts.result new file mode 100644 index 0000000..e18e34e --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr4/project.ts.result @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<defaultcodec>ISO-8859-2</defaultcodec> +<context> + <name>QObject</name> + <message> + <location filename="main.cpp" line="44"/> + <source>hi</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/from_subdir/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/from_subdir/lupdatecmd new file mode 100644 index 0000000..8a5b4ad --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/from_subdir/lupdatecmd @@ -0,0 +1 @@ +lupdate translations/translations.pro diff --git a/tests/auto/linguist/lupdate/testdata/good/from_subdir/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/from_subdir/project.ts.result new file mode 100644 index 0000000..7167cf3 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/from_subdir/project.ts.result @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>QApplication</name> + <message> + <location filename="src/main.cpp" line="49"/> + <source>string in main.cpp</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="src/main.h" line="45"/> + <source>string in main.h</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tools/linguist/shared/proreader.h b/tests/auto/linguist/lupdate/testdata/good/from_subdir/src/main.cpp index 70421d7..1a24ab2 100644 --- a/tools/linguist/shared/proreader.h +++ b/tests/auto/linguist/lupdate/testdata/good/from_subdir/src/main.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Linguist of the Qt Toolkit. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -39,19 +39,12 @@ ** ****************************************************************************/ -#ifndef PROREADER_H -#define PROREADER_H +// IMPORTANT!!!! If you want to add testdata to this file, +// always add it to the end in order to not change the linenumbers of translations!!! -#include <QtCore/QHash> +#include "main.h" -QT_BEGIN_NAMESPACE - -class ProFileEvaluator; - -void evaluateProFile(const ProFileEvaluator &visitor, QHash<QByteArray, QStringList> *varMap, - const QString &projectDir); -bool evaluateProFile(const QString &fileName, bool verbose, QHash<QByteArray, QStringList> *varMap); - -QT_END_NAMESPACE - -#endif // PROREADER_H +int main(char **argv, int argc) +{ + return QApplication::tr("string in main.cpp"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/from_subdir/src/main.h b/tests/auto/linguist/lupdate/testdata/good/from_subdir/src/main.h new file mode 100644 index 0000000..cc07d7c --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/from_subdir/src/main.h @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// IMPORTANT!!!! If you want to add testdata to this file, +// always add it to the end in order to not change the linenumbers of translations!!! + +QT_TRANSLATE_NOOP("QApplication", "string in main.h") diff --git a/tests/auto/linguist/lupdate/testdata/good/from_subdir/translations/translations.pro b/tests/auto/linguist/lupdate/testdata/good/from_subdir/translations/translations.pro new file mode 100644 index 0000000..1815c37 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/from_subdir/translations/translations.pro @@ -0,0 +1,7 @@ +VPATH = ../src +INCLUDEPATH = ../src + +SOURCES += main.cpp +HEADERS += main.h + +TRANSLATIONS += ../project.ts diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/recurse_full/expectedoutput.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full/expectedoutput.txt diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/recurse_full/lupdatecmd new file mode 100644 index 0000000..40987e2 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full/lupdatecmd @@ -0,0 +1,2 @@ +TRANSLATION: project.ts project_sub.ts +cd ../../subdirs_full diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_full/project.ts.result new file mode 100644 index 0000000..7d9a6f4 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full/project.ts.result @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>subdir1</name> + <message> + <location filename="subdir1/main.cpp" line="45"/> + <source>minimal test</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>subsub1</name> + <message> + <location filename="subdir2/subsub1/main.cpp" line="45"/> + <source>minimal test</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full/project_sub.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_full/project_sub.ts.result new file mode 100644 index 0000000..cddb963 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full/project_sub.ts.result @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<defaultcodec>ISO-8859-2</defaultcodec> +<context> + <name>subsub2</name> + <message> + <location filename="subdir2/subsub2/main.cpp" line="45"/> + <source>minimal test</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/expectedoutput.txt new file mode 100644 index 0000000..fd7a158 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/expectedoutput.txt @@ -0,0 +1,2 @@ +lupdate warning: TS files from command line will override TRANSLATIONS in project\.pro\. +lupdate warning: TS files from command line prevent recursing into .*/subdir2/subsub2/subsub2\.pro\. diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/lupdatecmd new file mode 100644 index 0000000..33296c3 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/lupdatecmd @@ -0,0 +1,3 @@ +TRANSLATION: project.ts project_sub.ts +cd ../../subdirs_full +lupdate project.pro -ts project.ts diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project.ts.result new file mode 100644 index 0000000..7d9a6f4 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project.ts.result @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>subdir1</name> + <message> + <location filename="subdir1/main.cpp" line="45"/> + <source>minimal test</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>subsub1</name> + <message> + <location filename="subdir2/subsub1/main.cpp" line="45"/> + <source>minimal test</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project_sub.ts.before b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project_sub.ts.before new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project_sub.ts.before diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project_sub.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project_sub.ts.result new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project_sub.ts.result diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/expectedoutput.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/expectedoutput.txt diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/lupdatecmd new file mode 100644 index 0000000..628acc0 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/lupdatecmd @@ -0,0 +1,2 @@ +cd ../../subdirs_full +lupdate subdir1/subdir1.pro subdir2/subsub1/subsub1.pro -ts project.ts diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/project.ts.result new file mode 100644 index 0000000..7d9a6f4 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/project.ts.result @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>subdir1</name> + <message> + <location filename="subdir1/main.cpp" line="45"/> + <source>minimal test</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>subsub1</name> + <message> + <location filename="subdir2/subsub1/main.cpp" line="45"/> + <source>minimal test</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/recurse_part/expectedoutput.txt new file mode 100644 index 0000000..808db18 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part/expectedoutput.txt @@ -0,0 +1 @@ +lupdate warning: no TS files specified\. Only diagnostics will be produced for 'project\.pro'\. diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/recurse_part/lupdatecmd new file mode 100644 index 0000000..3e15bc7 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part/lupdatecmd @@ -0,0 +1,2 @@ +TRANSLATION: project.ts project_sub.ts +cd ../../subdirs_part diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/recurse_part/project.ts.before new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part/project.ts.before diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_part/project.ts.result new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part/project.ts.result diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part/project_sub.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_part/project_sub.ts.result new file mode 100644 index 0000000..cddb963 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part/project_sub.ts.result @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<defaultcodec>ISO-8859-2</defaultcodec> +<context> + <name>subsub2</name> + <message> + <location filename="subdir2/subsub2/main.cpp" line="45"/> + <source>minimal test</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/expectedoutput.txt new file mode 100644 index 0000000..b904390 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/expectedoutput.txt @@ -0,0 +1 @@ +lupdate warning: TS files from command line prevent recursing into .*/subdir2/subsub2/subsub2\.pro\. diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/lupdatecmd new file mode 100644 index 0000000..41bfcec --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/lupdatecmd @@ -0,0 +1,3 @@ +TRANSLATION: project.ts project_sub.ts +cd ../../subdirs_part +lupdate project.pro -ts project.ts diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project.ts.result new file mode 100644 index 0000000..7d9a6f4 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project.ts.result @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>subdir1</name> + <message> + <location filename="subdir1/main.cpp" line="45"/> + <source>minimal test</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>subsub1</name> + <message> + <location filename="subdir2/subsub1/main.cpp" line="45"/> + <source>minimal test</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project_sub.ts.before b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project_sub.ts.before new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project_sub.ts.before diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project_sub.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project_sub.ts.result new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project_sub.ts.result diff --git a/tests/auto/linguist/lupdate/testdata/good/reloutput/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/reloutput/lupdatecmd index da6103f..90f609b 100644 --- a/tests/auto/linguist/lupdate/testdata/good/reloutput/lupdatecmd +++ b/tests/auto/linguist/lupdate/testdata/good/reloutput/lupdatecmd @@ -1,2 +1 @@ TRANSLATION: translations/project.ts -lupdate project.pro -ts translations/project.ts diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/project.pro b/tests/auto/linguist/lupdate/testdata/subdirs_full/project.pro new file mode 100644 index 0000000..1f744a7 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/project.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs +SUBDIRS = subdir1 subdir2/subdir2.pro + +TRANSLATIONS = project.ts diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir1/main.cpp b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir1/main.cpp new file mode 100644 index 0000000..0f1dc70 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir1/main.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +QString foo() +{ + QCoreApplication::translate("subdir1","minimal test"); +} diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir1/subdir1.pro b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir1/subdir1.pro new file mode 100644 index 0000000..28dcadc --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir1/subdir1.pro @@ -0,0 +1 @@ +SOURCES += main.cpp diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subdir2.pro b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subdir2.pro new file mode 100644 index 0000000..f8d03df --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subdir2.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS = subsub1 subsub2 diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub1/main.cpp b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub1/main.cpp new file mode 100644 index 0000000..8c82c80 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub1/main.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +QString foo() +{ + QCoreApplication::translate("subsub1","minimal test"); +} diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub1/subsub1.pro b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub1/subsub1.pro new file mode 100644 index 0000000..28dcadc --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub1/subsub1.pro @@ -0,0 +1 @@ +SOURCES += main.cpp diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub2/main.cpp b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub2/main.cpp new file mode 100644 index 0000000..ff85936 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub2/main.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +QString foo() +{ + QCoreApplication::translate("subsub2","minimal test"); +} diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub2/subsub2.pro b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub2/subsub2.pro new file mode 100644 index 0000000..3499222 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub2/subsub2.pro @@ -0,0 +1,4 @@ +SOURCES += main.cpp + +TRANSLATIONS = ../../project_sub.ts +CODECFORTR = ISO-8859-2 diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/project.pro b/tests/auto/linguist/lupdate/testdata/subdirs_part/project.pro new file mode 100644 index 0000000..d803c37 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/project.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS = subdir1 subdir2/subdir2.pro diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir1/main.cpp b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir1/main.cpp new file mode 100644 index 0000000..0f1dc70 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir1/main.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +QString foo() +{ + QCoreApplication::translate("subdir1","minimal test"); +} diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir1/subdir1.pro b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir1/subdir1.pro new file mode 100644 index 0000000..28dcadc --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir1/subdir1.pro @@ -0,0 +1 @@ +SOURCES += main.cpp diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subdir2.pro b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subdir2.pro new file mode 100644 index 0000000..f8d03df --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subdir2.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS = subsub1 subsub2 diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub1/main.cpp b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub1/main.cpp new file mode 100644 index 0000000..8c82c80 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub1/main.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +QString foo() +{ + QCoreApplication::translate("subsub1","minimal test"); +} diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub1/subsub1.pro b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub1/subsub1.pro new file mode 100644 index 0000000..28dcadc --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub1/subsub1.pro @@ -0,0 +1 @@ +SOURCES += main.cpp diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub2/main.cpp b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub2/main.cpp new file mode 100644 index 0000000..ff85936 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub2/main.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +QString foo() +{ + QCoreApplication::translate("subsub2","minimal test"); +} diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub2/subsub2.pro b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub2/subsub2.pro new file mode 100644 index 0000000..3499222 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub2/subsub2.pro @@ -0,0 +1,4 @@ +SOURCES += main.cpp + +TRANSLATIONS = ../../project_sub.ts +CODECFORTR = ISO-8859-2 diff --git a/tests/auto/linguist/lupdate/tst_lupdate.cpp b/tests/auto/linguist/lupdate/tst_lupdate.cpp index 568be37..c179462 100644 --- a/tests/auto/linguist/lupdate/tst_lupdate.cpp +++ b/tests/auto/linguist/lupdate/tst_lupdate.cpp @@ -59,8 +59,6 @@ public: private slots: void good_data(); void good(); - void commandline_data(); - void commandline(); #if CHECK_SIMTEXTH void simtexth(); void simtexth_data(); @@ -245,10 +243,10 @@ void tst_lupdate::good() qDebug() << "Checking..."; - QString generatedtsfile(dir + QLatin1String("/project.ts")); - - // look for a command + QString workDir = dir; + QStringList generatedtsfiles(QLatin1String("project.ts")); QString lupdatecmd; + QFile file(dir + "/lupdatecmd"); if (file.exists()) { QVERIFY2(file.open(QIODevice::ReadOnly | QIODevice::Text), qPrintable(file.fileName())); @@ -262,23 +260,32 @@ void tst_lupdate::good() break; } else if (cmdstring.startsWith("TRANSLATION:")) { cmdstring.remove(0, 12); - generatedtsfile = dir + QLatin1Char('/') + cmdstring.trimmed(); + generatedtsfiles.clear(); + foreach (const QByteArray &s, cmdstring.split(' ')) + if (!s.isEmpty()) + generatedtsfiles << s; + } else if (cmdstring.startsWith("cd ")) { + cmdstring.remove(0, 3); + workDir = QDir::cleanPath(dir + QLatin1Char('/') + cmdstring); } } file.close(); } - QFile::remove(generatedtsfile); - QString beforetsfile = generatedtsfile + QLatin1String(".before"); - if (QFile::exists(beforetsfile)) - QVERIFY2(QFile::copy(beforetsfile, generatedtsfile), qPrintable(beforetsfile)); + foreach (const QString &ts, generatedtsfiles) { + QString genTs = workDir + QLatin1Char('/') + ts; + QFile::remove(genTs); + QString beforetsfile = dir + QLatin1Char('/') + ts + QLatin1String(".before"); + if (QFile::exists(beforetsfile)) + QVERIFY2(QFile::copy(beforetsfile, genTs), qPrintable(beforetsfile)); + } if (lupdatecmd.isEmpty()) lupdatecmd = QLatin1String("project.pro"); lupdatecmd.prepend("-silent "); QProcess proc; - proc.setWorkingDirectory(dir); + proc.setWorkingDirectory(workDir); proc.setProcessChannelMode(QProcess::MergedChannels); proc.start(m_cmdLupdate + ' ' + lupdatecmd, QIODevice::ReadWrite | QIODevice::Text); QVERIFY2(proc.waitForFinished(5000), qPrintable(lupdatecmd)); @@ -287,7 +294,7 @@ void tst_lupdate::good() "\"lupdate " + lupdatecmd.toLatin1() + "\" crashed\n" + output); QVERIFY2(!proc.exitCode(), "\"lupdate " + lupdatecmd.toLatin1() + "\" exited with code " + - QByteArray::number(proc.exitCode()) + "\n" + proc.readAll()); + QByteArray::number(proc.exitCode()) + "\n" + output); // If the file expectedoutput.txt exists, compare the // console output with the content of that file @@ -299,47 +306,9 @@ void tst_lupdate::good() return; } - QString expectedFile = generatedtsfile + QLatin1String(".result"); - doCompare(generatedtsfile, expectedFile, false); -} - -void tst_lupdate::commandline_data() -{ - QTest::addColumn<QString>("currentPath"); - QTest::addColumn<QString>("commandline"); - QTest::addColumn<QString>("generatedtsfile"); - QTest::addColumn<QString>("expectedtsfile"); - - QTest::newRow("Recursive scan") << QString("recursivescan") - << QString(". -ts foo.ts") << QString("foo.ts") << QString("foo.ts.result"); - QTest::newRow("Deep path argument") << QString("recursivescan") - << QString("sub/finddialog.cpp -ts bar.ts") << QString("bar.ts") << QString("bar.ts.result"); -} - -void tst_lupdate::commandline() -{ - QFETCH(QString, currentPath); - QFETCH(QString, commandline); - QFETCH(QString, generatedtsfile); - QFETCH(QString, expectedtsfile); - - QString generated = - m_basePath + currentPath + QLatin1Char('/') + generatedtsfile; - QFile gen(generated); - if (gen.exists()) - QVERIFY(gen.remove()); - QProcess proc; - proc.setWorkingDirectory(m_basePath + currentPath); - proc.setProcessChannelMode(QProcess::MergedChannels); - proc.start(m_cmdLupdate + " -silent " + commandline, QIODevice::ReadWrite | QIODevice::Text); - QVERIFY2(proc.waitForFinished(5000), qPrintable(commandline)); - QVERIFY2(proc.exitStatus() == QProcess::NormalExit, - "\"lupdate -silent " + commandline.toLatin1() + "\" crashed\n" + proc.readAll()); - QVERIFY2(!proc.exitCode(), - "\"lupdate -silent " + commandline.toLatin1() + "\" exited with code " + - QByteArray::number(proc.exitCode()) + "\n" + proc.readAll()); - - doCompare(generated, m_basePath + currentPath + QLatin1Char('/') + expectedtsfile, false); + foreach (const QString &ts, generatedtsfiles) + doCompare(workDir + QLatin1Char('/') + ts, + dir + QLatin1Char('/') + ts + QLatin1String(".result"), false); } #if CHECK_SIMTEXTH diff --git a/tests/auto/qimagereader/baseline/35floppy.ico b/tests/auto/qimagereader/baseline/35floppy.ico Binary files differdeleted file mode 100644 index 59fd37e..0000000 --- a/tests/auto/qimagereader/baseline/35floppy.ico +++ /dev/null diff --git a/tests/auto/qimagereader/baseline/35floppy.png b/tests/auto/qimagereader/baseline/35floppy.png Binary files differnew file mode 100644 index 0000000..56b9b44 --- /dev/null +++ b/tests/auto/qimagereader/baseline/35floppy.png diff --git a/tests/auto/qimagereader/baseline/connect.png b/tests/auto/qimagereader/baseline/connect.png Binary files differnew file mode 100644 index 0000000..9544bb9 --- /dev/null +++ b/tests/auto/qimagereader/baseline/connect.png diff --git a/tests/auto/qimagereader/baseline/kde_favicon.ico b/tests/auto/qimagereader/baseline/kde_favicon.ico Binary files differdeleted file mode 100644 index 15bcdbb..0000000 --- a/tests/auto/qimagereader/baseline/kde_favicon.ico +++ /dev/null diff --git a/tests/auto/qimagereader/baseline/kde_favicon.png b/tests/auto/qimagereader/baseline/kde_favicon.png Binary files differnew file mode 100644 index 0000000..e19287b --- /dev/null +++ b/tests/auto/qimagereader/baseline/kde_favicon.png diff --git a/tests/auto/qimagereader/baseline/semitransparent.ico b/tests/auto/qimagereader/baseline/semitransparent.ico Binary files differdeleted file mode 100644 index dd23de9..0000000 --- a/tests/auto/qimagereader/baseline/semitransparent.ico +++ /dev/null diff --git a/tests/auto/qimagereader/baseline/semitransparent.png b/tests/auto/qimagereader/baseline/semitransparent.png Binary files differnew file mode 100644 index 0000000..a3ad780 --- /dev/null +++ b/tests/auto/qimagereader/baseline/semitransparent.png diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index 72c5c8b..e7cfe68 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -1633,7 +1633,8 @@ void tst_QImageReader::pixelCompareWithBaseline_data() QTest::newRow("floppy (16px,32px - 16 colors)") << "35floppy.ico"; QTest::newRow("semitransparent") << "semitransparent.ico"; - QTest::newRow("slightlybroken") << "kde_favicon.ico"; + QTest::newRow("slightlybrokenBMPHeader") << "kde_favicon.ico"; + QTest::newRow("sightlybrokenIconHeader") << "connect.ico"; } void tst_QImageReader::pixelCompareWithBaseline() @@ -1641,14 +1642,20 @@ void tst_QImageReader::pixelCompareWithBaseline() QFETCH(QString, fileName); QImage icoImg; + const QString inputFileName(QString::fromAscii("images/%1").arg(fileName)); + QFileInfo fi(inputFileName); + // might fail if the plugin does not exist, which is ok. - if (icoImg.load(QString::fromAscii("images/%1").arg(fileName))) { - QString baselineFileName = QString::fromAscii("baseline/%1").arg(fileName); + if (icoImg.load(inputFileName)) { + icoImg = icoImg.convertToFormat(QImage::Format_ARGB32_Premultiplied); + const QString baselineFileName(QString::fromAscii("baseline/%1.png").arg(fi.baseName())); #if 0 icoImg.save(baselineFileName); #else QImage baseImg; QVERIFY(baseImg.load(baselineFileName)); + baseImg = baseImg.convertToFormat(QImage::Format_ARGB32_Premultiplied); + QCOMPARE(int(baseImg.format()), int(icoImg.format())); QCOMPARE(baseImg, icoImg); #endif } diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index b384a55..ef960d0 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -2907,7 +2907,7 @@ void tst_QScriptValue::equals() QScriptValue qobj1 = eng.newQObject(this); QScriptValue qobj2 = eng.newQObject(this); QScriptValue qobj3 = eng.newQObject(0); - QScriptValue qobj4 = eng.newQObject(new QObject()); + QScriptValue qobj4 = eng.newQObject(new QObject(), QScriptEngine::ScriptOwnership); QVERIFY(qobj1.equals(qobj2)); // compares the QObject pointers QVERIFY(!qobj2.equals(qobj4)); // compares the QObject pointers QVERIFY(!qobj2.equals(obj2)); // compares the QObject pointers @@ -3091,6 +3091,20 @@ void tst_QScriptValue::strictlyEquals() QVERIFY(!falskt.strictlyEquals(null)); QVERIFY(!falskt.strictlyEquals(QScriptValue())); + QVERIFY(!QScriptValue(false).strictlyEquals(123)); + QVERIFY(!QScriptValue(QScriptValue::UndefinedValue).strictlyEquals(123)); + QVERIFY(!QScriptValue(QScriptValue::NullValue).strictlyEquals(123)); + QVERIFY(!QScriptValue(false).strictlyEquals("ciao")); + QVERIFY(!QScriptValue(QScriptValue::UndefinedValue).strictlyEquals("ciao")); + QVERIFY(!QScriptValue(QScriptValue::NullValue).strictlyEquals("ciao")); + QVERIFY(QScriptValue(&eng, "ciao").strictlyEquals("ciao")); + QVERIFY(QScriptValue("ciao").strictlyEquals(QScriptValue(&eng, "ciao"))); + QVERIFY(!QScriptValue("ciao").strictlyEquals(123)); + QVERIFY(!QScriptValue("ciao").strictlyEquals(QScriptValue(&eng, 123))); + QVERIFY(!QScriptValue(123).strictlyEquals("ciao")); + QVERIFY(!QScriptValue(123).strictlyEquals(QScriptValue(&eng, "ciao"))); + QVERIFY(!QScriptValue(&eng, 123).strictlyEquals("ciao")); + QScriptValue obj1 = eng.newObject(); QScriptValue obj2 = eng.newObject(); QCOMPARE(obj1.strictlyEquals(obj2), false); diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index 33812fe..f108f4c 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -165,6 +165,8 @@ private slots: void ace_testsuite(); void std3violations_data(); void std3violations(); + void std3deviations_data(); + void std3deviations(); void tldRestrictions_data(); void tldRestrictions(); void emptyQueryOrFragment(); @@ -3238,6 +3240,8 @@ void tst_QUrl::std3violations_data() QTest::newRow("bang") << "foo!" << false; QTest::newRow("plus") << "foo+bar" << false; QTest::newRow("dot") << "foo.bar"; + QTest::newRow("startingdot") << ".bar" << false; + QTest::newRow("startingdot2") << ".example.com" << false; QTest::newRow("slash") << "foo/bar" << true; QTest::newRow("colon") << "foo:80" << true; QTest::newRow("question") << "foo?bar" << true; @@ -3282,6 +3286,24 @@ void tst_QUrl::std3violations() QVERIFY(!url.isValid()); } +void tst_QUrl::std3deviations_data() +{ + QTest::addColumn<QString>("source"); + + QTest::newRow("ending-dot") << "example.com."; + QTest::newRow("ending-dot3002") << QString("example.com") + QChar(0x3002); +} + +void tst_QUrl::std3deviations() +{ + QFETCH(QString, source); + QVERIFY(!QUrl::toAce(source).isEmpty()); + + QUrl url; + url.setHost(source); + QVERIFY(!url.host().isEmpty()); +} + void tst_QUrl::tldRestrictions_data() { QTest::addColumn<QString>("tld"); diff --git a/tests/auto/selftests/expected_xunit.txt b/tests/auto/selftests/expected_xunit.txt index 5ec4668..3c014e3 100644 --- a/tests/auto/selftests/expected_xunit.txt +++ b/tests/auto/selftests/expected_xunit.txt @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="UTF-8" ?> <testsuite errors="5" failures="3" tests="9" name="tst_Xunit"> <properties> - <property value="4.6.2" name="QTestVersion"/> - <property value="4.6.2" name="QtVersion"/> + <property value="<INSERT_QT_VERSION_HERE>" name="QTestVersion"/> + <property value="<INSERT_QT_VERSION_HERE>" name="QtVersion"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="pass" name="testFunc1"> diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp index 89ece0f..0b9cee0 100644 --- a/tests/auto/selftests/tst_selftests.cpp +++ b/tests/auto/selftests/tst_selftests.cpp @@ -248,7 +248,7 @@ void tst_Selftests::doRunSubTest(QString &subdir, QStringList &arguments ) continue; const QString output(QString::fromLatin1(line)); - const QString expected(QString::fromLatin1(exp.at(i))); + const QString expected(QString::fromLatin1(exp.at(i)).replace("<INSERT_QT_VERSION_HERE>", QT_VERSION_STR)); if (line.contains("ASSERT") && output != expected) QEXPECT_FAIL("assert", "QTestLib prints out the absolute path.", Continue); diff --git a/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro b/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro index 39267c8..3f49ccc 100644 --- a/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro +++ b/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro @@ -1,7 +1,6 @@ TEMPLATE = subdirs contains(QT_CONFIG,xmlpatterns) { SUBDIRS += lib - !wince*:lib.file = lib/lib.pro test.depends = lib } SUBDIRS += test diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro index 7ea4f24..a7ec85b 100644 --- a/tests/benchmarks/benchmarks.pro +++ b/tests/benchmarks/benchmarks.pro @@ -5,6 +5,7 @@ SUBDIRS = containers-associative \ qbytearray \ qfileinfo \ qfile_vs_qnetworkaccessmanager \ + qfontmetrics \ qhostinfo \ qpainter \ qtestlib-simple events \ diff --git a/tests/benchmarks/qfontmetrics/main.cpp b/tests/benchmarks/qfontmetrics/main.cpp new file mode 100644 index 0000000..d3f85ef --- /dev/null +++ b/tests/benchmarks/qfontmetrics/main.cpp @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QObject> +#include <QFont> +#include <QFontMetrics> + +#include <qtest.h> + +//this test benchmarks the once-off (per font configuration) cost +//associated with using QFontMetrics +class tst_QFontMetrics : public QObject +{ + Q_OBJECT +public: + tst_QFontMetrics() {} +private slots: + void fontmetrics_create(); + void fontmetrics_create_once_loaded(); + + void fontmetrics_height(); + void fontmetrics_height_once_loaded(); + +private: + void testQFontMetrics(const QFontMetrics &fm); +}; + +void tst_QFontMetrics::testQFontMetrics( const QFontMetrics &fm ) +{ + int fontHeight = fm.height(); +} + +void tst_QFontMetrics::fontmetrics_create() +{ + QBENCHMARK { + QFont boldfont = QApplication::font(); + boldfont.setBold( true ); + boldfont.setPointSize(boldfont.pointSize() * 1.5 ); + QFontMetrics bfm( boldfont ); + } +} + +void tst_QFontMetrics::fontmetrics_create_once_loaded() +{ + QBENCHMARK { + QFont boldfont = QApplication::font(); + boldfont.setBold( true ); + boldfont.setPointSize(boldfont.pointSize() * 1.5 ); + QFontMetrics bfm( boldfont ); + } +} + +void tst_QFontMetrics::fontmetrics_height() +{ + QFont boldfont = QApplication::font(); + boldfont.setBold( true ); + boldfont.setPointSize(boldfont.pointSize() * 1.5 ); + QFontMetrics bfm( boldfont ); + + QBENCHMARK { testQFontMetrics(bfm); } +} + +void tst_QFontMetrics::fontmetrics_height_once_loaded() +{ + QFont boldfont = QApplication::font(); + boldfont.setBold( true ); + boldfont.setPointSize(boldfont.pointSize() * 1.5 ); + QFontMetrics bfm( boldfont ); + QBENCHMARK { testQFontMetrics(bfm); } +} + +QTEST_MAIN(tst_QFontMetrics) + +#include "main.moc" diff --git a/tests/benchmarks/qfontmetrics/qfontmetrics.pro b/tests/benchmarks/qfontmetrics/qfontmetrics.pro new file mode 100644 index 0000000..b6c7b92 --- /dev/null +++ b/tests/benchmarks/qfontmetrics/qfontmetrics.pro @@ -0,0 +1,5 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_QFontMetrics + +SOURCES += main.cpp diff --git a/tests/benchmarks/qpainter/tst_qpainter.cpp b/tests/benchmarks/qpainter/tst_qpainter.cpp index 7c6634e..39b2244 100644 --- a/tests/benchmarks/qpainter/tst_qpainter.cpp +++ b/tests/benchmarks/qpainter/tst_qpainter.cpp @@ -45,6 +45,10 @@ #include <QDialog> #include <QImage> #include <QPaintEngine> +#include <math.h> +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif Q_DECLARE_METATYPE(QLine) Q_DECLARE_METATYPE(QRect) @@ -178,6 +182,35 @@ private slots: void clipAndFill_data(); void clipAndFill(); + void drawRoundedRect(); + void drawScaledRoundedRect(); + void drawTransformedRoundedRect(); + + void drawScaledAntialiasedRoundedRect_data(); + void drawTransformedAntialiasedRoundedRect_data(); + void drawAntialiasedRoundedRect(); + void drawScaledAntialiasedRoundedRect(); + void drawTransformedAntialiasedRoundedRect(); + + void drawScaledImageRoundedRect_data(); + void drawTransformedImageRoundedRect_data(); + void drawImageRoundedRect(); + void drawScaledImageRoundedRect(); + void drawTransformedImageRoundedRect(); + + void drawScaledBorderPixmapRoundedRect_data(); + void drawTransformedBorderPixmapRoundedRect_data(); + void drawBorderPixmapRoundedRect(); + void drawScaledBorderPixmapRoundedRect(); + void drawTransformedBorderPixmapRoundedRect(); + + void drawTransformedTransparentImage_data(); + void drawTransformedSemiTransparentImage_data(); + void drawTransformedFilledImage_data(); + void drawTransformedTransparentImage(); + void drawTransformedSemiTransparentImage(); + void drawTransformedFilledImage(); + private: void setupBrushes(); void createPrimitives(); @@ -185,6 +218,8 @@ private: void drawPrimitives_data_helper(bool fancypens); void fillPrimitives_helper(QPainter *painter, PrimitiveType type, PrimitiveSet *s); + QTransform transformForAngle(qreal angle); + QPaintDevice *surface() { return new QPixmap(1024, 1024); @@ -1123,6 +1158,474 @@ void tst_QPainter::clipAndFill() } } +QTransform tst_QPainter::transformForAngle(qreal angle) +{ + const qreal inv_dist_to_plane = 1. / 1024.; + + QTransform transform; + + QTransform rotTrans; + rotTrans.translate(-40, 0); + QTransform rotTrans2; + rotTrans2.translate(40, 0); + + qreal rad = angle * 2. * M_PI / 360.; + qreal c = ::cos(rad); + qreal s = ::sin(rad); + + qreal x = 0; + qreal y = 80; + qreal z = 0; + + qreal len = x * x + y * y + z * z; + if (len != 1.) { + len = ::sqrt(len); + x /= len; + y /= len; + z /= len; + } + + QTransform rot(x*x*(1-c)+c, x*y*(1-c)-z*s, x*z*(1-c)+y*s*inv_dist_to_plane, + y*x*(1-c)+z*s, y*y*(1-c)+c, y*z*(1-c)-x*s*inv_dist_to_plane, + 0, 0, 1); + + transform *= rotTrans; + transform *= rot; + transform *= rotTrans2; + + return transform; +} + +void tst_QPainter::drawRoundedRect() +{ + QImage surface(100, 100, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + p.setPen(QPen(Qt::black, 1)); + p.setBrush(Qt::red); + + QBENCHMARK { + p.drawRoundedRect(QRectF(.5, .5, 80, 80), 10, 10); + } +} + +void tst_QPainter::drawScaledRoundedRect() +{ + QImage surface(400, 400, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + p.setPen(QPen(Qt::black, 1)); + p.setBrush(Qt::red); + p.scale(3, 3); + + QBENCHMARK { + p.drawRoundedRect(10, 10, 80, 80, 10, 10); + } +} + +void tst_QPainter::drawTransformedRoundedRect() +{ + QImage surface(400, 400, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + p.setPen(QPen(Qt::black, 1)); + p.setBrush(Qt::red); + + QBENCHMARK { + p.setWorldTransform(QTransform(0.956957, 0, 0.000704124, 0, 1, 0, 16.141, 0, 0.735953)); + p.drawRoundedRect(100, 100, 80, 80, 10, 10); + } +} + +void tst_QPainter::drawAntialiasedRoundedRect() +{ + QImage surface(100, 100, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + p.setRenderHint(QPainter::Antialiasing, true); + p.setPen(QPen(Qt::black, 1)); + p.setBrush(Qt::red); + + QBENCHMARK { + p.drawRoundedRect(QRectF(.5, .5, 80, 80), 10, 10); + } +} + +void tst_QPainter::drawScaledAntialiasedRoundedRect_data() +{ + QTest::addColumn<float>("scale"); + + for (float i = 0; i < 3; i += .1) + QTest::newRow(QString(QLatin1String("scale=%1")).arg(i).toLatin1()) << i; +} + +void tst_QPainter::drawScaledAntialiasedRoundedRect() +{ + QFETCH(float, scale); + + QImage surface(400, 400, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + p.setRenderHint(QPainter::Antialiasing, true); + p.setPen(QPen(Qt::black, 1)); + p.setBrush(Qt::red); + p.scale(scale, scale); + + QBENCHMARK { + p.drawRoundedRect(10, 10, 80, 80, 10, 10); + } +} + +void tst_QPainter::drawTransformedAntialiasedRoundedRect_data() +{ + QTest::addColumn<QTransform>("transform"); + + for (float angle = 0; angle < 360; angle += 10) + QTest::newRow(QString(QLatin1String("angle=%1")).arg(angle).toLatin1()) << transformForAngle(angle); +} + +void tst_QPainter::drawTransformedAntialiasedRoundedRect() +{ + QFETCH(QTransform, transform); + + QImage surface(400, 400, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + p.setRenderHint(QPainter::Antialiasing, true); + p.setPen(QPen(Qt::black, 1)); + p.setBrush(Qt::red); + + QBENCHMARK { + p.setWorldTransform(transform); + p.drawRoundedRect(100, 100, 80, 80, 10, 10); + } +} + +void tst_QPainter::drawImageRoundedRect() +{ + //setup image + const int radius = 10; + QImage rectImage(81, 81, QImage::Format_ARGB32_Premultiplied); + rectImage.fill(0); + QPainter rp(&rectImage); + rp.setRenderHint(QPainter::Antialiasing); + rp.setPen(Qt::black); + rp.setBrush(Qt::red); + rp.drawRoundedRect(QRectF(.5, .5, 80, 80), radius, radius); + + //setup surface + QImage surface(100, 100, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + QBENCHMARK { + p.drawImage(0,0, rectImage); + } +} + +void tst_QPainter::drawScaledImageRoundedRect_data() +{ + QTest::addColumn<int>("imageType"); + + QTest::newRow("imagetype=ARGB32_Pre") << (int)QImage::Format_ARGB32_Premultiplied; + QTest::newRow("imagetype=ARGB8565_Pre") << (int)QImage::Format_ARGB8565_Premultiplied; +} + +void tst_QPainter::drawScaledImageRoundedRect() +{ + QFETCH(int, imageType); + + //setup image + const int radius = 10; + QImage rectImage(81, 81, (QImage::Format)imageType); + rectImage.fill(0); + QPainter rp(&rectImage); + rp.setRenderHint(QPainter::Antialiasing); + rp.setPen(Qt::black); + rp.setBrush(Qt::red); + rp.drawRoundedRect(QRectF(.5, .5, 80, 80), radius, radius); + + //setup surface + QImage surface(400, 400, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + p.scale(3, 3); + + QBENCHMARK { + p.drawImage(0,0, rectImage); + } +} + +void tst_QPainter::drawTransformedImageRoundedRect_data() +{ + QTest::addColumn<int>("imageType"); + + QTest::newRow("imagetype=ARGB32_Pre") << (int)QImage::Format_ARGB32_Premultiplied; + QTest::newRow("imagetype=ARGB8565_Pre") << (int)QImage::Format_ARGB8565_Premultiplied; +} + +void tst_QPainter::drawTransformedImageRoundedRect() +{ + QFETCH(int, imageType); + + //setup image + const int radius = 10; + QImage rectImage(81, 81, (QImage::Format)imageType); + rectImage.fill(0); + QPainter rp(&rectImage); + rp.setRenderHint(QPainter::Antialiasing); + rp.setPen(Qt::black); + rp.setBrush(Qt::red); + rp.drawRoundedRect(QRectF(.5, .5, 80, 80), radius, radius); + + //setup surface + QImage surface(400, 400, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + QBENCHMARK { + p.setWorldTransform(QTransform(0.956957, 0, 0.000704124, 0, 1, 0, 16.141, 0, 0.735953)); + p.drawImage(100,100, rectImage); + } +} + +//code from QmlGraphicsRectangle for drawing rounded rects +void tst_QPainter::drawBorderPixmapRoundedRect() +{ + //setup image + const int pw = 1; + const int radius = 10; + QImage rectImage(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2, QImage::Format_ARGB32_Premultiplied); + rectImage.fill(0); + QPainter rp(&rectImage); + rp.setRenderHint(QPainter::Antialiasing); + rp.setPen(Qt::black); + rp.setBrush(Qt::red); + if (pw%2) + rp.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, rectImage.width()-(pw+1), rectImage.height()-(pw+1)), radius, radius); + else + rp.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, rectImage.width()-pw, rectImage.height()-pw), radius, radius); + QPixmap rectPixmap = QPixmap::fromImage(rectImage); + + //setup surface + QImage surface(100, 100, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + QBENCHMARK { + const int pw = 2; + int width = 80; + int height = 80; + + int xOffset = (rectPixmap.width()-1)/2; + int yOffset = (rectPixmap.height()-1)/2; + Q_ASSERT(rectPixmap.width() == 2*xOffset + 1); + Q_ASSERT(rectPixmap.height() == 2*yOffset + 1); + + QMargins margins(xOffset, yOffset, xOffset, yOffset); + QTileRules rules(Qt::StretchTile, Qt::StretchTile); + //NOTE: even though our item may have qreal-based width and height, qDrawBorderPixmap only supports QRects + qDrawBorderPixmap(&p, QRect(-pw/2, -pw/2, width+pw, height+pw), margins, rectPixmap, rectPixmap.rect(), margins, rules); + } +} + +void tst_QPainter::drawScaledBorderPixmapRoundedRect_data() +{ + QTest::addColumn<float>("scale"); + QTest::addColumn<int>("imageType"); + + for (float i = 0; i < 3; i += .1) + QTest::newRow(QString(QLatin1String("scale=%1; imagetype=ARGB32_Pre")).arg(i).toLatin1()) << i << (int)QImage::Format_ARGB32_Premultiplied; + //for (float i = 0; i < 3; i += .1) + // QTest::newRow(QString(QLatin1String("scale=%1; imagetype=ARGB8565_Pre")).arg(i).toLatin1()) << i << (int)QImage::Format_ARGB8565_Premultiplied; +} + +//code from QmlGraphicsRectangle for drawing rounded rects +void tst_QPainter::drawScaledBorderPixmapRoundedRect() +{ + QFETCH(float, scale); + QFETCH(int, imageType); + + //setup image + const int pw = 1; + const int radius = 10; + QImage rectImage(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2, (QImage::Format)imageType); + rectImage.fill(0); + QPainter rp(&rectImage); + rp.setRenderHint(QPainter::Antialiasing); + rp.setPen(Qt::black); + rp.setBrush(Qt::red); + if (pw%2) + rp.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, rectImage.width()-(pw+1), rectImage.height()-(pw+1)), radius, radius); + else + rp.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, rectImage.width()-pw, rectImage.height()-pw), radius, radius); + + QPixmap rectPixmap = QPixmap::fromImage(rectImage); + + //setup surface + QImage surface(400, 400, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + p.scale(scale, scale); + + QBENCHMARK { + const int pw = 2; + int width = 80; + int height = 80; + + int xOffset = (rectPixmap.width()-1)/2; + int yOffset = (rectPixmap.height()-1)/2; + Q_ASSERT(rectPixmap.width() == 2*xOffset + 1); + Q_ASSERT(rectPixmap.height() == 2*yOffset + 1); + + QMargins margins(xOffset, yOffset, xOffset, yOffset); + QTileRules rules(Qt::StretchTile, Qt::StretchTile); + qDrawBorderPixmap(&p, QRect(-pw/2, -pw/2, width+pw, height+pw), margins, rectPixmap, rectPixmap.rect(), margins, rules); + } +} + +void tst_QPainter::drawTransformedBorderPixmapRoundedRect_data() +{ + QTest::addColumn<QTransform>("transform"); + QTest::addColumn<int>("imageType"); + + for (float angle = 0; angle < 360; angle += 10) + QTest::newRow(QString(QLatin1String("angle=%1; imagetype=ARGB32_Pre")).arg(angle).toLatin1()) << transformForAngle(angle) << (int)QImage::Format_ARGB32_Premultiplied; + //for (float angle = 0; angle < 360; angle += 10) + // QTest::newRow(QString(QLatin1String("angle=%1; imagetype=ARGB8565_Pre")).arg(angle).toLatin1()) << transformForAngle(angle) << (int)QImage::Format_ARGB8565_Premultiplied; + +} + +//code from QmlGraphicsRectangle for drawing rounded rects +void tst_QPainter::drawTransformedBorderPixmapRoundedRect() +{ + QFETCH(QTransform, transform); + QFETCH(int, imageType); + + //setup image + const int pw = 1; + const int radius = 10; + QImage rectImage(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2, (QImage::Format)imageType); + rectImage.fill(0); + QPainter rp(&rectImage); + rp.setRenderHint(QPainter::Antialiasing); + rp.setPen(Qt::black); + rp.setBrush(Qt::red); + if (pw%2) + rp.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, rectImage.width()-(pw+1), rectImage.height()-(pw+1)), radius, radius); + else + rp.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, rectImage.width()-pw, rectImage.height()-pw), radius, radius); + + QPixmap rectPixmap = QPixmap::fromImage(rectImage); + + //setup surface + QImage surface(400, 400, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + QBENCHMARK { + p.setWorldTransform(transform); + const int pw = 2; + int width = 80; + int height = 80; + + int xOffset = (rectPixmap.width()-1)/2; + int yOffset = (rectPixmap.height()-1)/2; + Q_ASSERT(rectPixmap.width() == 2*xOffset + 1); + Q_ASSERT(rectPixmap.height() == 2*yOffset + 1); + + QMargins margins(xOffset, yOffset, xOffset, yOffset); + QTileRules rules(Qt::StretchTile, Qt::StretchTile); + qDrawBorderPixmap(&p, QRect(-pw/2, -pw/2, width+pw, height+pw), margins, rectPixmap, rectPixmap.rect(), margins, rules); + } +} + +void tst_QPainter::drawTransformedTransparentImage_data() +{ + QTest::addColumn<int>("imageType"); + + QTest::newRow("imagetype=ARGB32_Pre") << (int)QImage::Format_ARGB32_Premultiplied; + QTest::newRow("imagetype=ARGB8565_Pre") << (int)QImage::Format_ARGB8565_Premultiplied; +} + +void tst_QPainter::drawTransformedTransparentImage() +{ + QFETCH(int, imageType); + + //setup image + QImage transImage(200, 200, (QImage::Format)imageType); + transImage.fill(0); + + //setup surface + QImage surface(200, 200, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + QBENCHMARK { + p.setWorldTransform(QTransform(0.956957, 0, 0.000704124, 0, 1, 0, 16.141, 0, 0.735953)); + p.drawImage(0,0, transImage); + } +} + +void tst_QPainter::drawTransformedSemiTransparentImage_data() +{ + QTest::addColumn<int>("imageType"); + + QTest::newRow("imagetype=ARGB32_Pre") << (int)QImage::Format_ARGB32_Premultiplied; + QTest::newRow("imagetype=ARGB8565_Pre") << (int)QImage::Format_ARGB8565_Premultiplied; +} + +void tst_QPainter::drawTransformedSemiTransparentImage() +{ + QFETCH(int, imageType); + + //setup image + QImage transImage(200, 200, (QImage::Format)imageType); + transImage.fill(QColor(0,0,0, 128).rgba()); + + //setup surface + QImage surface(200, 200, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + QBENCHMARK { + p.setWorldTransform(QTransform(0.956957, 0, 0.000704124, 0, 1, 0, 16.141, 0, 0.735953)); + p.drawImage(0,0, transImage); + } +} + +void tst_QPainter::drawTransformedFilledImage_data() +{ + QTest::addColumn<int>("imageType"); + + QTest::newRow("imagetype=ARGB32_Pre") << (int)QImage::Format_ARGB32_Premultiplied; + QTest::newRow("imagetype=ARGB8565_Pre") << (int)QImage::Format_ARGB8565_Premultiplied; +} + +void tst_QPainter::drawTransformedFilledImage() +{ + QFETCH(int, imageType); + + //setup image + QImage filledImage(200, 200, (QImage::Format)imageType); + filledImage.fill(QColor(0,0,0).rgb()); + + //setup surface + QImage surface(200, 200, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + QBENCHMARK { + p.setWorldTransform(QTransform(0.956957, 0, 0.000704124, 0, 1, 0, 16.141, 0, 0.735953)); + p.drawImage(0,0, filledImage); + } +} QTEST_MAIN(tst_QPainter) diff --git a/tests/benchmarks/qtext/main.cpp b/tests/benchmarks/qtext/main.cpp index 4bd2bee..9854a9f 100644 --- a/tests/benchmarks/qtext/main.cpp +++ b/tests/benchmarks/qtext/main.cpp @@ -44,7 +44,10 @@ #include <QTextDocumentWriter> #include <QTextLayout> #include <QTextCursor> +#include <private/qtextcontrol_p.h> +#include <qmath.h> #include <QFile> +#include <QPainter> #include <QBuffer> #include <qtest.h> @@ -56,6 +59,7 @@ class tst_QText: public QObject public: tst_QText() { m_lorem = QString::fromLatin1("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi."); + m_shortLorem = QString::fromLatin1("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."); } private slots: @@ -69,8 +73,26 @@ private slots: void odfWriting_text(); void odfWriting_images(); + void constructControl(); + void constructDocument(); + + void layout(); + void paintLayoutToPixmap(); + void paintLayoutToPixmap_painterFill(); + + void document(); + void paintDocToPixmap(); + void paintDocToPixmap_painterFill(); + + void control(); + void paintControlToPixmap(); + void paintControlToPixmap_painterFill(); + private: + QSize setupTextLayout(QTextLayout *layout); + QString m_lorem; + QString m_shortLorem; }; void tst_QText::loadHtml_data() @@ -195,6 +217,189 @@ void tst_QText::odfWriting_images() delete doc; } +QSize tst_QText::setupTextLayout(QTextLayout *layout) +{ + bool wrap = true; + int wrapWidth = 300; + layout->setCacheEnabled(true); + + int height = 0; + qreal widthUsed = 0; + qreal lineWidth = 0; + + //set manual width + if (wrap) + lineWidth = wrapWidth; + + layout->beginLayout(); + + while (1) { + QTextLine line = layout->createLine(); + if (!line.isValid()) + break; + + if (wrap) + line.setLineWidth(lineWidth); + } + layout->endLayout(); + + for (int i = 0; i < layout->lineCount(); ++i) { + QTextLine line = layout->lineAt(i); + widthUsed = qMax(widthUsed, line.naturalTextWidth()); + line.setPosition(QPointF(0, height)); + height += int(line.height()); + } + return QSize(qCeil(widthUsed), height); +} + +void tst_QText::constructControl() +{ + QTextControl *control = new QTextControl; + delete control; + + QBENCHMARK { + QTextControl *control = new QTextControl; + delete control; + } +} + +void tst_QText::constructDocument() +{ + QTextDocument *doc = new QTextDocument; + delete doc; + + QBENCHMARK { + QTextDocument *doc = new QTextDocument; + delete doc; + } +} + +void tst_QText::layout() +{ + QTextLayout layout(m_shortLorem); + setupTextLayout(&layout); + + QBENCHMARK { + QTextLayout layout(m_shortLorem); + setupTextLayout(&layout); + } +} + +void tst_QText::paintLayoutToPixmap() +{ + QTextLayout layout(m_shortLorem); + QSize size = setupTextLayout(&layout); + + QBENCHMARK { + QPixmap img(size); + img.fill(Qt::transparent); + QPainter p(&img); + layout.draw(&p, QPointF(0, 0)); + } +} + +void tst_QText::paintLayoutToPixmap_painterFill() +{ + QTextLayout layout(m_shortLorem); + QSize size = setupTextLayout(&layout); + + QBENCHMARK { + QPixmap img(size); + QPainter p(&img); + p.setCompositionMode(QPainter::CompositionMode_Source); + p.fillRect(0, 0, img.width(), img.height(), Qt::transparent); + p.setCompositionMode(QPainter::CompositionMode_SourceOver); + layout.draw(&p, QPointF(0, 0)); + } +} + +void tst_QText::document() +{ + QTextDocument *doc = new QTextDocument; + + QBENCHMARK { + QTextDocument *doc = new QTextDocument; + doc->setHtml(m_shortLorem); + } +} + +void tst_QText::paintDocToPixmap() +{ + QTextDocument *doc = new QTextDocument; + doc->setHtml(m_shortLorem); + doc->setTextWidth(300); + QSize size = doc->size().toSize(); + + QBENCHMARK { + QPixmap img(size); + img.fill(Qt::transparent); + QPainter p(&img); + doc->drawContents(&p); + } +} + +void tst_QText::paintDocToPixmap_painterFill() +{ + QTextDocument *doc = new QTextDocument; + doc->setHtml(m_shortLorem); + doc->setTextWidth(300); + QSize size = doc->size().toSize(); + + QBENCHMARK { + QPixmap img(size); + QPainter p(&img); + p.setCompositionMode(QPainter::CompositionMode_Source); + p.fillRect(0, 0, img.width(), img.height(), Qt::transparent); + p.setCompositionMode(QPainter::CompositionMode_SourceOver); + doc->drawContents(&p); + } +} + +void tst_QText::control() +{ + QTextControl *control = new QTextControl(m_shortLorem); + + QBENCHMARK { + QTextControl *control = new QTextControl; + QTextDocument *doc = control->document(); + doc->setHtml(m_shortLorem); + } +} + +void tst_QText::paintControlToPixmap() +{ + QTextControl *control = new QTextControl; + QTextDocument *doc = control->document(); + doc->setHtml(m_shortLorem); + doc->setTextWidth(300); + QSize size = doc->size().toSize(); + + QBENCHMARK { + QPixmap img(size); + img.fill(Qt::transparent); + QPainter p(&img); + control->drawContents(&p, QRectF(QPointF(0, 0), QSizeF(size))); + } +} + +void tst_QText::paintControlToPixmap_painterFill() +{ + QTextControl *control = new QTextControl; + QTextDocument *doc = control->document(); + doc->setHtml(m_shortLorem); + doc->setTextWidth(300); + QSize size = doc->size().toSize(); + + QBENCHMARK { + QPixmap img(size); + QPainter p(&img); + p.setCompositionMode(QPainter::CompositionMode_Source); + p.fillRect(0, 0, img.width(), img.height(), Qt::transparent); + p.setCompositionMode(QPainter::CompositionMode_SourceOver); + control->drawContents(&p, QRectF(QPointF(0, 0), QSizeF(size))); + } +} + QTEST_MAIN(tst_QText) #include "main.moc" diff --git a/tools/assistant/lib/qhelpsearchquerywidget.cpp b/tools/assistant/lib/qhelpsearchquerywidget.cpp index b614cb4..f2bb816 100644 --- a/tools/assistant/lib/qhelpsearchquerywidget.cpp +++ b/tools/assistant/lib/qhelpsearchquerywidget.cpp @@ -122,17 +122,17 @@ private: void retranslate() { - simpleSearchLabel->setText(tr("Search for:")); - prevQueryButton->setToolTip(tr("Previous search")); - nextQueryButton->setToolTip(tr("Next search")); - searchButton->setText(tr("Search")); + simpleSearchLabel->setText(QHelpSearchQueryWidget::tr("Search for:")); + prevQueryButton->setToolTip(QHelpSearchQueryWidget::tr("Previous search")); + nextQueryButton->setToolTip(QHelpSearchQueryWidget::tr("Next search")); + searchButton->setText(QHelpSearchQueryWidget::tr("Search")); #ifdef QT_CLUCENE_SUPPORT - advancedSearchLabel->setText(tr("Advanced search")); - similarLabel->setText(tr("words <B>similar</B> to:")); - withoutLabel->setText(tr("<B>without</B> the words:")); - exactLabel->setText(tr("with <B>exact phrase</B>:")); - allLabel->setText(tr("with <B>all</B> of the words:")); - atLeastLabel->setText(tr("with <B>at least one</B> of the words:")); + advancedSearchLabel->setText(QHelpSearchQueryWidget::tr("Advanced search")); + similarLabel->setText(QHelpSearchQueryWidget::tr("words <B>similar</B> to:")); + withoutLabel->setText(QHelpSearchQueryWidget::tr("<B>without</B> the words:")); + exactLabel->setText(QHelpSearchQueryWidget::tr("with <B>exact phrase</B>:")); + allLabel->setText(QHelpSearchQueryWidget::tr("with <B>all</B> of the words:")); + atLeastLabel->setText(QHelpSearchQueryWidget::tr("with <B>at least one</B> of the words:")); #endif } diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 7751143..abf81bd 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -2535,8 +2535,11 @@ void Configure::generateOutputVars() qtConfig += "phonon-backend"; } - if (dictionary["MULTIMEDIA"] == "yes") + if (dictionary["MULTIMEDIA"] == "yes") { qtConfig += "multimedia"; + if (dictionary["AUDIO_BACKEND"] == "yes") + qtConfig += "audio-backend"; + } if (dictionary["WEBKIT"] == "yes") qtConfig += "webkit"; diff --git a/tools/designer/src/components/formeditor/formwindow.cpp b/tools/designer/src/components/formeditor/formwindow.cpp index 2d013c9..9fd084d 100644 --- a/tools/designer/src/components/formeditor/formwindow.cpp +++ b/tools/designer/src/components/formeditor/formwindow.cpp @@ -2219,6 +2219,11 @@ QMenu *FormWindow::createPopupMenu(QWidget *w) QToolBoxHelper::addToolBoxContextMenuActions(toolBox, popup); } + if (manager->actionLower()->isEnabled()) { + popup->addAction(manager->actionLower()); + popup->addAction(manager->actionRaise()); + popup->addSeparator(); + } popup->addAction(manager->actionCut()); popup->addAction(manager->actionCopy()); } diff --git a/tools/designer/src/components/formeditor/formwindow.h b/tools/designer/src/components/formeditor/formwindow.h index eed7417..3eee476 100644 --- a/tools/designer/src/components/formeditor/formwindow.h +++ b/tools/designer/src/components/formeditor/formwindow.h @@ -278,8 +278,6 @@ private: void checkPreviewGeometry(QRect &r); - void finishContextMenu(QWidget *w, QWidget *menuParent, QContextMenuEvent *e); - bool handleContextMenu(QWidget *widget, QWidget *managedWidget, QContextMenuEvent *e); bool handleMouseButtonDblClickEvent(QWidget *widget, QWidget *managedWidget, QMouseEvent *e); bool handleMousePressEvent(QWidget *widget, QWidget *managedWidget, QMouseEvent *e); diff --git a/tools/designer/src/components/formeditor/qdesigner_resource.cpp b/tools/designer/src/components/formeditor/qdesigner_resource.cpp index b005e42..b659179 100644 --- a/tools/designer/src/components/formeditor/qdesigner_resource.cpp +++ b/tools/designer/src/components/formeditor/qdesigner_resource.cpp @@ -1446,7 +1446,7 @@ void QDesignerResource::applyTabStops(QWidget *widget, DomTabStops *tabStops) return; QList<QWidget*> tabOrder; - foreach (QString widgetName, tabStops->elementTabStop()) { + foreach (const QString &widgetName, tabStops->elementTabStop()) { if (QWidget *w = qFindChild<QWidget*>(widget, widgetName)) { tabOrder.append(w); } @@ -2418,7 +2418,7 @@ DomResources *QDesignerResource::saveResources(const QStringList &qrcPaths) QList<DomResource*> dom_include; if (resourceSet) { const QStringList activePaths = resourceSet->activeQrcPaths(); - foreach (QString path, activePaths) { + foreach (const QString &path, activePaths) { if (qrcPaths.contains(path)) { DomResource *dom_res = new DomResource; QString conv_path = path; diff --git a/tools/designer/src/components/propertyeditor/designerpropertymanager.h b/tools/designer/src/components/propertyeditor/designerpropertymanager.h index 0ec5241..11f900b 100644 --- a/tools/designer/src/components/propertyeditor/designerpropertymanager.h +++ b/tools/designer/src/components/propertyeditor/designerpropertymanager.h @@ -102,7 +102,7 @@ class DesignerPropertyManager : public QtVariantPropertyManager { Q_OBJECT public: - DesignerPropertyManager(QDesignerFormEditorInterface *core, QObject *parent = 0); + explicit DesignerPropertyManager(QDesignerFormEditorInterface *core, QObject *parent = 0); ~DesignerPropertyManager(); virtual QStringList attributes(int propertyType) const; diff --git a/tools/designer/src/designer/qdesigner_actions.cpp b/tools/designer/src/designer/qdesigner_actions.cpp index fbaf461..887ba98 100644 --- a/tools/designer/src/designer/qdesigner_actions.cpp +++ b/tools/designer/src/designer/qdesigner_actions.cpp @@ -580,7 +580,7 @@ bool QDesignerActions::openForm(QWidget *parent) return false; bool atLeastOne = false; - foreach (QString fileName, fileNames) { + foreach (const QString &fileName, fileNames) { if (readInForm(fileName) && !atLeastOne) atLeastOne = true; } @@ -869,7 +869,7 @@ bool QDesignerActions::writeOutForm(QDesignerFormWindowInterface *fw, const QStr if (f.fileName() != fileName) { removeBackup(backupFile); fi.setFile(fileName); - backupFile = QString(); + backupFile.clear(); if (fi.exists()) backupFile = createBackup(fileName); } diff --git a/tools/designer/src/designer/qdesigner_server.cpp b/tools/designer/src/designer/qdesigner_server.cpp index 8016dff..de1532c 100644 --- a/tools/designer/src/designer/qdesigner_server.cpp +++ b/tools/designer/src/designer/qdesigner_server.cpp @@ -83,7 +83,7 @@ void QDesignerServer::sendOpenRequest(int port, const QStringList &files) sSocket->connectToHost(QHostAddress::LocalHost, port); if(sSocket->waitForConnected(3000)) { - foreach(QString file, files) + foreach(const QString &file, files) { QFileInfo fi(file); sSocket->write(fi.absoluteFilePath().toUtf8() + '\n'); @@ -96,9 +96,8 @@ void QDesignerServer::sendOpenRequest(int port, const QStringList &files) void QDesignerServer::readFromClient() { - QString file = QString(); while (m_socket->canReadLine()) { - file = QString::fromUtf8(m_socket->readLine()); + QString file = QString::fromUtf8(m_socket->readLine()); if (!file.isNull()) { file.remove(QLatin1Char('\n')); file.remove(QLatin1Char('\r')); @@ -143,7 +142,6 @@ QDesignerClient::~QDesignerClient() void QDesignerClient::readFromSocket() { - QString file = QString(); while (m_socket->canReadLine()) { QString file = QString::fromUtf8(m_socket->readLine()); if (!file.isNull()) { diff --git a/tools/designer/src/designer/qdesigner_server.h b/tools/designer/src/designer/qdesigner_server.h index 08bce68..d522056 100644 --- a/tools/designer/src/designer/qdesigner_server.h +++ b/tools/designer/src/designer/qdesigner_server.h @@ -53,7 +53,7 @@ class QDesignerServer: public QObject { Q_OBJECT public: - QDesignerServer(QObject *parent = 0); + explicit QDesignerServer(QObject *parent = 0); virtual ~QDesignerServer(); quint16 serverPort() const; diff --git a/tools/designer/src/lib/shared/actioneditor.cpp b/tools/designer/src/lib/shared/actioneditor.cpp index 624b8bb..26ac8a8 100644 --- a/tools/designer/src/lib/shared/actioneditor.cpp +++ b/tools/designer/src/lib/shared/actioneditor.cpp @@ -428,7 +428,7 @@ void ActionEditor::unmanageAction(QAction *action) m_actionView->model()->remove(row); } -// Set an intial property and mark it as changed in the sheet +// Set an initial property and mark it as changed in the sheet static void setInitialProperty(QDesignerPropertySheetExtension *sheet, const QString &name, const QVariant &value) { const int index = sheet->indexOf(name); diff --git a/tools/designer/src/lib/shared/actionrepository.cpp b/tools/designer/src/lib/shared/actionrepository.cpp index 64cf9c4..e3ff2c1 100644 --- a/tools/designer/src/lib/shared/actionrepository.cpp +++ b/tools/designer/src/lib/shared/actionrepository.cpp @@ -244,7 +244,7 @@ QMimeData *ActionModel::mimeData(const QModelIndexList &indexes ) const ActionRepositoryMimeData::ActionList actionList; QSet<QAction*> actions; - foreach (const QModelIndex &index, indexes) + foreach (const QModelIndex &index, indexes) if (QStandardItem *item = itemFromIndex(index)) if (QAction *action = actionOfItem(item)) actions.insert(action); diff --git a/tools/designer/src/lib/shared/connectionedit_p.h b/tools/designer/src/lib/shared/connectionedit_p.h index 4f0148d..37dfe75 100644 --- a/tools/designer/src/lib/shared/connectionedit_p.h +++ b/tools/designer/src/lib/shared/connectionedit_p.h @@ -87,7 +87,7 @@ public: class EndPoint { public: enum Type { Source, Target }; - EndPoint(Connection *_con = 0, Type _type = Source) : con(_con), type(_type) {} + explicit EndPoint(Connection *_con = 0, Type _type = Source) : con(_con), type(_type) {} bool isNull() const { return con == 0; } bool operator == (const EndPoint &other) const { return con == other.con && type == other.type; } bool operator != (const EndPoint &other) const { return !operator == (other); } diff --git a/tools/designer/src/lib/shared/filterwidget_p.h b/tools/designer/src/lib/shared/filterwidget_p.h index fdb199d..025d708 100644 --- a/tools/designer/src/lib/shared/filterwidget_p.h +++ b/tools/designer/src/lib/shared/filterwidget_p.h @@ -66,7 +66,7 @@ class QPushButton; namespace qdesigner_internal { /* A line edit that displays a grayed hintText (like "Type Here to Filter") - * when not focussed and empty. When connecting to the changed signals and + * when not focused and empty. When connecting to the changed signals and * querying text, one has to be aware that the text is set to that hint * text if isShowingHintText() returns true (that is, does not contain * valid user input). This widget should never have initial focus diff --git a/tools/designer/src/lib/shared/iconloader.cpp b/tools/designer/src/lib/shared/iconloader.cpp index 2c97f62..df0bb7e 100644 --- a/tools/designer/src/lib/shared/iconloader.cpp +++ b/tools/designer/src/lib/shared/iconloader.cpp @@ -60,7 +60,7 @@ QDESIGNER_SHARED_EXPORT QIcon createIconSet(const QString &name) #endif << (QString::fromUtf8(":/trolltech/formeditor/images/designer_") + name); - foreach (QString f, candidates) { + foreach (const QString &f, candidates) { if (QFile::exists(f)) return QIcon(f); } diff --git a/tools/designer/src/lib/shared/iconselector_p.h b/tools/designer/src/lib/shared/iconselector_p.h index 63d4ad7..3373f80 100644 --- a/tools/designer/src/lib/shared/iconselector_p.h +++ b/tools/designer/src/lib/shared/iconselector_p.h @@ -76,7 +76,7 @@ class QDESIGNER_SHARED_EXPORT LanguageResourceDialog : public QDialog { Q_OBJECT - LanguageResourceDialog(QDesignerResourceBrowserInterface *rb, QWidget *parent = 0); + explicit LanguageResourceDialog(QDesignerResourceBrowserInterface *rb, QWidget *parent = 0); public: virtual ~LanguageResourceDialog(); diff --git a/tools/designer/src/lib/shared/plugindialog.cpp b/tools/designer/src/lib/shared/plugindialog.cpp index c79dcf2..3e88043 100644 --- a/tools/designer/src/lib/shared/plugindialog.cpp +++ b/tools/designer/src/lib/shared/plugindialog.cpp @@ -105,7 +105,7 @@ void PluginDialog::populateTreeWidget() QTreeWidgetItem *topLevelItem = setTopLevelItem(QLatin1String("Loaded Plugins")); QFont boldFont = topLevelItem->font(0); - foreach (QString fileName, fileNames) { + foreach (const QString &fileName, fileNames) { QPluginLoader loader(fileName); const QFileInfo fileInfo(fileName); @@ -127,7 +127,7 @@ void PluginDialog::populateTreeWidget() if (!notLoadedPlugins.isEmpty()) { QTreeWidgetItem *topLevelItem = setTopLevelItem(QLatin1String("Failed Plugins")); const QFont boldFont = topLevelItem->font(0); - foreach (const QString plugin, notLoadedPlugins) { + foreach (const QString &plugin, notLoadedPlugins) { const QString failureReason = pluginManager->failureReason(plugin); QTreeWidgetItem *pluginItem = setPluginItem(topLevelItem, plugin, boldFont); setItem(pluginItem, failureReason, failureReason, QString(), QIcon()); diff --git a/tools/designer/src/lib/shared/qdesigner_introspection.cpp b/tools/designer/src/lib/shared/qdesigner_introspection.cpp index 170a111..7bc60d4 100644 --- a/tools/designer/src/lib/shared/qdesigner_introspection.cpp +++ b/tools/designer/src/lib/shared/qdesigner_introspection.cpp @@ -63,7 +63,7 @@ static QStringList byteArrayListToStringList(const QList<QByteArray> &l) static inline QString charToQString(const char *c) { if (!c) - return QString::null; + return QString(); return QString::fromUtf8(c); } diff --git a/tools/designer/src/lib/shared/qdesigner_objectinspector_p.h b/tools/designer/src/lib/shared/qdesigner_objectinspector_p.h index 354ef2a..f4b6672 100644 --- a/tools/designer/src/lib/shared/qdesigner_objectinspector_p.h +++ b/tools/designer/src/lib/shared/qdesigner_objectinspector_p.h @@ -85,7 +85,7 @@ class QDESIGNER_SHARED_EXPORT QDesignerObjectInspector: public QDesignerObjectIn { Q_OBJECT public: - QDesignerObjectInspector(QWidget *parent = 0, Qt::WindowFlags flags = 0); + explicit QDesignerObjectInspector(QWidget *parent = 0, Qt::WindowFlags flags = 0); // Select a qobject unmanaged by form window virtual bool selectObject(QObject *o) = 0; diff --git a/tools/designer/src/lib/shared/qdesigner_promotiondialog_p.h b/tools/designer/src/lib/shared/qdesigner_promotiondialog_p.h index d1e407d..1e63d81 100644 --- a/tools/designer/src/lib/shared/qdesigner_promotiondialog_p.h +++ b/tools/designer/src/lib/shared/qdesigner_promotiondialog_p.h @@ -80,9 +80,9 @@ namespace qdesigner_internal { class NewPromotedClassPanel : public QGroupBox { Q_OBJECT public: - NewPromotedClassPanel(const QStringList &baseClasses, - int selectedBaseClass = -1, - QWidget *parent = 0); + explicit NewPromotedClassPanel(const QStringList &baseClasses, + int selectedBaseClass = -1, + QWidget *parent = 0); signals: void newPromotedClass(const PromotionParameters &, bool *ok); @@ -114,10 +114,10 @@ namespace qdesigner_internal { public: enum Mode { ModeEdit, ModeEditChooseClass }; - QDesignerPromotionDialog(QDesignerFormEditorInterface *core, - QWidget *parent = 0, - const QString &promotableWidgetClassName = QString(), - QString *promoteTo = 0); + explicit QDesignerPromotionDialog(QDesignerFormEditorInterface *core, + QWidget *parent = 0, + const QString &promotableWidgetClassName = QString(), + QString *promoteTo = 0); // Return an alphabetically ordered list of base class names for adding new classes. static const QStringList &baseClassNames(const QDesignerPromotionInterface *promotion); diff --git a/tools/designer/src/lib/shared/qdesigner_propertyeditor_p.h b/tools/designer/src/lib/shared/qdesigner_propertyeditor_p.h index c618bd7..cdd53f0 100644 --- a/tools/designer/src/lib/shared/qdesigner_propertyeditor_p.h +++ b/tools/designer/src/lib/shared/qdesigner_propertyeditor_p.h @@ -69,7 +69,7 @@ class QDESIGNER_SHARED_EXPORT QDesignerPropertyEditor: public QDesignerPropertyE { Q_OBJECT public: - QDesignerPropertyEditor(QWidget *parent = 0, Qt::WindowFlags flags = 0); + explicit QDesignerPropertyEditor(QWidget *parent = 0, Qt::WindowFlags flags = 0); // A pair <ValidationMode, bool isTranslatable>. typedef QPair<TextPropertyValidationMode, bool> StringPropertyParameters; diff --git a/tools/designer/src/lib/shared/qdesigner_toolbar.cpp b/tools/designer/src/lib/shared/qdesigner_toolbar.cpp index 1cee074..02a2f6d 100644 --- a/tools/designer/src/lib/shared/qdesigner_toolbar.cpp +++ b/tools/designer/src/lib/shared/qdesigner_toolbar.cpp @@ -440,7 +440,7 @@ QAction *ToolBarEventFilter::actionAt(const QToolBar *tb, const QPoint &pos) return tb->actions().at(index); } -//that's a trick to get acces to the initStyleOption which is a protected member +//that's a trick to get access to the initStyleOption which is a protected member class FriendlyToolBar : public QToolBar { public: friend class ToolBarEventFilter; diff --git a/tools/designer/src/lib/shared/qdesigner_utils_p.h b/tools/designer/src/lib/shared/qdesigner_utils_p.h index 502703d..fac0697 100644 --- a/tools/designer/src/lib/shared/qdesigner_utils_p.h +++ b/tools/designer/src/lib/shared/qdesigner_utils_p.h @@ -298,7 +298,7 @@ class QDESIGNER_SHARED_EXPORT DesignerIconCache : public QObject { Q_OBJECT public: - DesignerIconCache(DesignerPixmapCache *pixmapCache, QObject *parent = 0); + explicit DesignerIconCache(DesignerPixmapCache *pixmapCache, QObject *parent = 0); QIcon icon(const PropertySheetIconValue &value) const; void clear(); signals: @@ -313,7 +313,7 @@ private: class QDESIGNER_SHARED_EXPORT PropertySheetStringValue { public: - PropertySheetStringValue(const QString &value = QString(), + explicit PropertySheetStringValue(const QString &value = QString(), bool translatable = true, const QString &disambiguation = QString(), const QString &comment = QString()); @@ -345,11 +345,11 @@ private: class QDESIGNER_SHARED_EXPORT PropertySheetKeySequenceValue { public: - PropertySheetKeySequenceValue(const QKeySequence &value = QKeySequence(), + explicit PropertySheetKeySequenceValue(const QKeySequence &value = QKeySequence(), bool translatable = true, const QString &disambiguation = QString(), const QString &comment = QString()); - PropertySheetKeySequenceValue(const QKeySequence::StandardKey &standardKey, + explicit PropertySheetKeySequenceValue(const QKeySequence::StandardKey &standardKey, bool translatable = true, const QString &disambiguation = QString(), const QString &comment = QString()); diff --git a/tools/designer/src/lib/shared/qdesigner_widgetbox_p.h b/tools/designer/src/lib/shared/qdesigner_widgetbox_p.h index cf944b9..13b7f74 100644 --- a/tools/designer/src/lib/shared/qdesigner_widgetbox_p.h +++ b/tools/designer/src/lib/shared/qdesigner_widgetbox_p.h @@ -70,7 +70,7 @@ class QDESIGNER_SHARED_EXPORT QDesignerWidgetBox : public QDesignerWidgetBoxInte public: enum LoadMode { LoadMerge, LoadReplace, LoadCustomWidgetsOnly }; - QDesignerWidgetBox(QWidget *parent = 0, Qt::WindowFlags flags = 0); + explicit QDesignerWidgetBox(QWidget *parent = 0, Qt::WindowFlags flags = 0); LoadMode loadMode() const; void setLoadMode(LoadMode lm); diff --git a/tools/designer/src/lib/shared/qtresourceview_p.h b/tools/designer/src/lib/shared/qtresourceview_p.h index 26c4754..8da2975 100644 --- a/tools/designer/src/lib/shared/qtresourceview_p.h +++ b/tools/designer/src/lib/shared/qtresourceview_p.h @@ -68,7 +68,7 @@ class QDESIGNER_SHARED_EXPORT QtResourceView : public QWidget { Q_OBJECT public: - QtResourceView(QDesignerFormEditorInterface *core, QWidget *parent = 0); + explicit QtResourceView(QDesignerFormEditorInterface *core, QWidget *parent = 0); ~QtResourceView(); void setDragEnabled(bool dragEnabled); @@ -120,7 +120,7 @@ class QDESIGNER_SHARED_EXPORT QtResourceViewDialog : public QDialog { Q_OBJECT public: - QtResourceViewDialog(QDesignerFormEditorInterface *core, QWidget *parent = 0); + explicit QtResourceViewDialog(QDesignerFormEditorInterface *core, QWidget *parent = 0); virtual ~QtResourceViewDialog(); QString selectedResource() const; diff --git a/tools/designer/src/lib/shared/richtexteditor_p.h b/tools/designer/src/lib/shared/richtexteditor_p.h index 4157d2c..44023ef 100644 --- a/tools/designer/src/lib/shared/richtexteditor_p.h +++ b/tools/designer/src/lib/shared/richtexteditor_p.h @@ -72,7 +72,7 @@ class QDESIGNER_SHARED_EXPORT RichTextEditorDialog : public QDialog { Q_OBJECT public: - RichTextEditorDialog(QDesignerFormEditorInterface *core, QWidget *parent = 0); + explicit RichTextEditorDialog(QDesignerFormEditorInterface *core, QWidget *parent = 0); ~RichTextEditorDialog(); int showDialog(); diff --git a/tools/designer/src/lib/shared/shared_settings.cpp b/tools/designer/src/lib/shared/shared_settings.cpp index d6fd4bc..281b5c6 100644 --- a/tools/designer/src/lib/shared/shared_settings.cpp +++ b/tools/designer/src/lib/shared/shared_settings.cpp @@ -161,7 +161,7 @@ QStringList QDesignerSharedSettings::additionalFormTemplatePaths() const { // get template paths excluding internal ones QStringList rc = formTemplatePaths(); - foreach (QString internalTemplatePath, defaultFormTemplatePaths()) { + foreach (const QString &internalTemplatePath, defaultFormTemplatePaths()) { const int index = rc.indexOf(internalTemplatePath); if (index != -1) rc.removeAt(index); diff --git a/tools/designer/src/lib/shared/textpropertyeditor_p.h b/tools/designer/src/lib/shared/textpropertyeditor_p.h index 5b913ac..48f7898 100644 --- a/tools/designer/src/lib/shared/textpropertyeditor_p.h +++ b/tools/designer/src/lib/shared/textpropertyeditor_p.h @@ -90,7 +90,7 @@ namespace qdesigner_internal { UpdateOnFinished }; - TextPropertyEditor(QWidget *parent = 0, EmbeddingMode embeddingMode = EmbeddingNone, TextPropertyValidationMode validationMode = ValidationMultiLine); + explicit TextPropertyEditor(QWidget *parent = 0, EmbeddingMode embeddingMode = EmbeddingNone, TextPropertyValidationMode validationMode = ValidationMultiLine); TextPropertyValidationMode textPropertyValidationMode() const { return m_validationMode; } void setTextPropertyValidationMode(TextPropertyValidationMode vm); diff --git a/tools/designer/src/lib/shared/widgetdatabase_p.h b/tools/designer/src/lib/shared/widgetdatabase_p.h index 0e99999..873e79b 100644 --- a/tools/designer/src/lib/shared/widgetdatabase_p.h +++ b/tools/designer/src/lib/shared/widgetdatabase_p.h @@ -74,8 +74,8 @@ namespace qdesigner_internal { class QDESIGNER_SHARED_EXPORT WidgetDataBaseItem: public QDesignerWidgetDataBaseItemInterface { public: - WidgetDataBaseItem(const QString &name = QString(), - const QString &group = QString()); + explicit WidgetDataBaseItem(const QString &name = QString(), + const QString &group = QString()); QString name() const; void setName(const QString &name); @@ -159,7 +159,7 @@ class QDESIGNER_SHARED_EXPORT WidgetDataBase: public QDesignerWidgetDataBaseInte { Q_OBJECT public: - WidgetDataBase(QDesignerFormEditorInterface *core, QObject *parent = 0); + explicit WidgetDataBase(QDesignerFormEditorInterface *core, QObject *parent = 0); virtual ~WidgetDataBase(); virtual QDesignerFormEditorInterface *core() const; diff --git a/tools/designer/src/lib/uilib/abstractformbuilder.cpp b/tools/designer/src/lib/uilib/abstractformbuilder.cpp index 1d2d6f8..a0c9e83 100644 --- a/tools/designer/src/lib/uilib/abstractformbuilder.cpp +++ b/tools/designer/src/lib/uilib/abstractformbuilder.cpp @@ -364,7 +364,7 @@ QWidget *QAbstractFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidge const QStringList zOrderNames = ui_widget->elementZOrder(); if (!zOrderNames.isEmpty()) { QList<QWidget *> zOrder = qVariantValue<QWidgetList>(w->property("_q_zOrder")); - foreach (QString widgetName, zOrderNames) { + foreach (const QString &widgetName, zOrderNames) { if (QWidget *child = qFindChild<QWidget*>(w, widgetName)) { if (child->parentWidget() == w) { zOrder.removeAll(child); diff --git a/tools/designer/src/lib/uilib/formbuilder.cpp b/tools/designer/src/lib/uilib/formbuilder.cpp index cc8483f..c97daac 100644 --- a/tools/designer/src/lib/uilib/formbuilder.cpp +++ b/tools/designer/src/lib/uilib/formbuilder.cpp @@ -494,7 +494,7 @@ void QFormBuilder::updateCustomWidgets() { m_customWidgets.clear(); - foreach (QString path, m_pluginPaths) { + foreach (const QString &path, m_pluginPaths) { const QDir dir(path); const QStringList candidates = dir.entryList(QDir::Files); diff --git a/tools/designer/src/plugins/activeqt/qaxwidgetextrainfo.h b/tools/designer/src/plugins/activeqt/qaxwidgetextrainfo.h index c48449c..9f3c252 100644 --- a/tools/designer/src/plugins/activeqt/qaxwidgetextrainfo.h +++ b/tools/designer/src/plugins/activeqt/qaxwidgetextrainfo.h @@ -77,7 +77,7 @@ class QAxWidgetExtraInfoFactory: public QExtensionFactory { Q_OBJECT public: - QAxWidgetExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); + explicit QAxWidgetExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); protected: virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; diff --git a/tools/designer/src/plugins/activeqt/qdesigneraxwidget.h b/tools/designer/src/plugins/activeqt/qdesigneraxwidget.h index 1308fe2..50132a6 100644 --- a/tools/designer/src/plugins/activeqt/qdesigneraxwidget.h +++ b/tools/designer/src/plugins/activeqt/qdesigneraxwidget.h @@ -105,7 +105,7 @@ private: class QDesignerAxPluginWidget : public QDesignerAxWidget { - // No Q_OBJECT here! - meta functionality is overriden + // No Q_OBJECT here! - meta functionality is overridden public: explicit QDesignerAxPluginWidget(QWidget *parent); virtual ~QDesignerAxPluginWidget(); diff --git a/tools/designer/src/plugins/widgets/q3iconview/q3iconview_extrainfo.h b/tools/designer/src/plugins/widgets/q3iconview/q3iconview_extrainfo.h index 49a8a40..4f2b3b2 100644 --- a/tools/designer/src/plugins/widgets/q3iconview/q3iconview_extrainfo.h +++ b/tools/designer/src/plugins/widgets/q3iconview/q3iconview_extrainfo.h @@ -81,7 +81,7 @@ class Q3IconViewExtraInfoFactory: public QExtensionFactory { Q_OBJECT public: - Q3IconViewExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); + explicit Q3IconViewExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); protected: virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; diff --git a/tools/designer/src/plugins/widgets/q3iconview/q3iconview_plugin.h b/tools/designer/src/plugins/widgets/q3iconview/q3iconview_plugin.h index 19213d8..e20e344 100644 --- a/tools/designer/src/plugins/widgets/q3iconview/q3iconview_plugin.h +++ b/tools/designer/src/plugins/widgets/q3iconview/q3iconview_plugin.h @@ -51,7 +51,7 @@ class Q3IconViewPlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3IconViewPlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3IconViewPlugin(const QIcon &icon, QObject *parent = 0); virtual QString name() const; virtual QString group() const; diff --git a/tools/designer/src/plugins/widgets/q3listbox/q3listbox_extrainfo.h b/tools/designer/src/plugins/widgets/q3listbox/q3listbox_extrainfo.h index 7e291b6..bfb6738 100644 --- a/tools/designer/src/plugins/widgets/q3listbox/q3listbox_extrainfo.h +++ b/tools/designer/src/plugins/widgets/q3listbox/q3listbox_extrainfo.h @@ -79,7 +79,7 @@ class Q3ListBoxExtraInfoFactory: public QExtensionFactory { Q_OBJECT public: - Q3ListBoxExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); + explicit Q3ListBoxExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); protected: virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; diff --git a/tools/designer/src/plugins/widgets/q3listbox/q3listbox_plugin.h b/tools/designer/src/plugins/widgets/q3listbox/q3listbox_plugin.h index 66002f5..68d6913 100644 --- a/tools/designer/src/plugins/widgets/q3listbox/q3listbox_plugin.h +++ b/tools/designer/src/plugins/widgets/q3listbox/q3listbox_plugin.h @@ -51,7 +51,7 @@ class Q3ListBoxPlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3ListBoxPlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3ListBoxPlugin(const QIcon &icon, QObject *parent = 0); virtual QString name() const; virtual QString group() const; diff --git a/tools/designer/src/plugins/widgets/q3listview/q3listview_extrainfo.h b/tools/designer/src/plugins/widgets/q3listview/q3listview_extrainfo.h index f14f256..e5222ed 100644 --- a/tools/designer/src/plugins/widgets/q3listview/q3listview_extrainfo.h +++ b/tools/designer/src/plugins/widgets/q3listview/q3listview_extrainfo.h @@ -82,7 +82,7 @@ class Q3ListViewExtraInfoFactory: public QExtensionFactory { Q_OBJECT public: - Q3ListViewExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); + explicit Q3ListViewExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); protected: virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; diff --git a/tools/designer/src/plugins/widgets/q3listview/q3listview_plugin.h b/tools/designer/src/plugins/widgets/q3listview/q3listview_plugin.h index 7127a57..f9c82a2 100644 --- a/tools/designer/src/plugins/widgets/q3listview/q3listview_plugin.h +++ b/tools/designer/src/plugins/widgets/q3listview/q3listview_plugin.h @@ -51,7 +51,7 @@ class Q3ListViewPlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3ListViewPlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3ListViewPlugin(const QIcon &icon, QObject *parent = 0); virtual QString name() const; virtual QString group() const; diff --git a/tools/designer/src/plugins/widgets/q3mainwindow/q3mainwindow_plugin.h b/tools/designer/src/plugins/widgets/q3mainwindow/q3mainwindow_plugin.h index de2a75e..4ac7daa 100644 --- a/tools/designer/src/plugins/widgets/q3mainwindow/q3mainwindow_plugin.h +++ b/tools/designer/src/plugins/widgets/q3mainwindow/q3mainwindow_plugin.h @@ -51,7 +51,7 @@ class Q3MainWindowPlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3MainWindowPlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3MainWindowPlugin(const QIcon &icon, QObject *parent = 0); virtual QString name() const; virtual QString group() const; diff --git a/tools/designer/src/plugins/widgets/q3table/q3table_extrainfo.h b/tools/designer/src/plugins/widgets/q3table/q3table_extrainfo.h index 40222bd..4de8b71 100644 --- a/tools/designer/src/plugins/widgets/q3table/q3table_extrainfo.h +++ b/tools/designer/src/plugins/widgets/q3table/q3table_extrainfo.h @@ -79,7 +79,7 @@ class Q3TableExtraInfoFactory: public QExtensionFactory { Q_OBJECT public: - Q3TableExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); + explicit Q3TableExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); protected: virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; diff --git a/tools/designer/src/plugins/widgets/q3textedit/q3textedit_extrainfo.h b/tools/designer/src/plugins/widgets/q3textedit/q3textedit_extrainfo.h index 94f663a..beeaf3b 100644 --- a/tools/designer/src/plugins/widgets/q3textedit/q3textedit_extrainfo.h +++ b/tools/designer/src/plugins/widgets/q3textedit/q3textedit_extrainfo.h @@ -79,7 +79,7 @@ class Q3TextEditExtraInfoFactory: public QExtensionFactory { Q_OBJECT public: - Q3TextEditExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); + explicit Q3TextEditExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); protected: virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; diff --git a/tools/designer/src/plugins/widgets/q3textedit/q3textedit_plugin.h b/tools/designer/src/plugins/widgets/q3textedit/q3textedit_plugin.h index 28e0386..77bfb58 100644 --- a/tools/designer/src/plugins/widgets/q3textedit/q3textedit_plugin.h +++ b/tools/designer/src/plugins/widgets/q3textedit/q3textedit_plugin.h @@ -51,7 +51,7 @@ class Q3TextEditPlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3TextEditPlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3TextEditPlugin(const QIcon &icon, QObject *parent = 0); virtual QString name() const; virtual QString group() const; diff --git a/tools/designer/src/plugins/widgets/q3toolbar/q3toolbar_extrainfo.h b/tools/designer/src/plugins/widgets/q3toolbar/q3toolbar_extrainfo.h index f3ed995..22562b1 100644 --- a/tools/designer/src/plugins/widgets/q3toolbar/q3toolbar_extrainfo.h +++ b/tools/designer/src/plugins/widgets/q3toolbar/q3toolbar_extrainfo.h @@ -78,7 +78,7 @@ class Q3ToolBarExtraInfoFactory: public QExtensionFactory { Q_OBJECT public: - Q3ToolBarExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); + explicit Q3ToolBarExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); protected: virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; diff --git a/tools/designer/src/plugins/widgets/q3widgets/q3widget_plugins.h b/tools/designer/src/plugins/widgets/q3widgets/q3widget_plugins.h index c79390c..c750cfe 100644 --- a/tools/designer/src/plugins/widgets/q3widgets/q3widget_plugins.h +++ b/tools/designer/src/plugins/widgets/q3widgets/q3widget_plugins.h @@ -51,7 +51,7 @@ class Q3ButtonGroupPlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3ButtonGroupPlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3ButtonGroupPlugin(const QIcon &icon, QObject *parent = 0); virtual ~Q3ButtonGroupPlugin(); virtual QString name() const; @@ -80,7 +80,7 @@ class Q3ComboBoxPlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3ComboBoxPlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3ComboBoxPlugin(const QIcon &icon, QObject *parent = 0); virtual ~Q3ComboBoxPlugin(); virtual QString name() const; @@ -109,7 +109,7 @@ class Q3DateEditPlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3DateEditPlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3DateEditPlugin(const QIcon &icon, QObject *parent = 0); virtual QString name() const; virtual QString group() const; @@ -157,7 +157,7 @@ class Q3FramePlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3FramePlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3FramePlugin(const QIcon &icon, QObject *parent = 0); virtual ~Q3FramePlugin(); virtual QString name() const; @@ -215,7 +215,7 @@ class Q3ProgressBarPlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3ProgressBarPlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3ProgressBarPlugin(const QIcon &icon, QObject *parent = 0); virtual QString name() const; virtual QString group() const; @@ -263,7 +263,7 @@ class Q3TimeEditPlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3TimeEditPlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3TimeEditPlugin(const QIcon &icon, QObject *parent = 0); virtual QString name() const; virtual QString group() const; diff --git a/tools/designer/src/plugins/widgets/q3wizard/q3wizard_container.h b/tools/designer/src/plugins/widgets/q3wizard/q3wizard_container.h index 524f3fd..e8cf4fa 100644 --- a/tools/designer/src/plugins/widgets/q3wizard/q3wizard_container.h +++ b/tools/designer/src/plugins/widgets/q3wizard/q3wizard_container.h @@ -59,7 +59,7 @@ class Q3WizardHelper : public QObject { Q_OBJECT public: - Q3WizardHelper(Q3Wizard *wizard); + explicit Q3WizardHelper(Q3Wizard *wizard); private slots: void slotCurrentChanged(); private: diff --git a/tools/designer/src/plugins/widgets/q3wizard/q3wizard_plugin.h b/tools/designer/src/plugins/widgets/q3wizard/q3wizard_plugin.h index 1837769..c9fff40 100644 --- a/tools/designer/src/plugins/widgets/q3wizard/q3wizard_plugin.h +++ b/tools/designer/src/plugins/widgets/q3wizard/q3wizard_plugin.h @@ -51,7 +51,7 @@ class Q3WizardPlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3WizardPlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3WizardPlugin(const QIcon &icon, QObject *parent = 0); virtual QString name() const; virtual QString group() const; diff --git a/tools/designer/src/src.pro b/tools/designer/src/src.pro index e1710b8..78665b7 100644 --- a/tools/designer/src/src.pro +++ b/tools/designer/src/src.pro @@ -9,6 +9,4 @@ SUBDIRS = \ CONFIG(shared,shared|static):SUBDIRS += plugins -wince*: SUBDIRS -= designer plugins -symbian: SUBDIRS = uitools -contains(DEFINES, QT_NO_CURSOR): SUBDIRS -= lib components
\ No newline at end of file +symbian|wince*: SUBDIRS = uitools diff --git a/tools/linguist/lrelease/main.cpp b/tools/linguist/lrelease/main.cpp index 7834b06..266474e 100644 --- a/tools/linguist/lrelease/main.cpp +++ b/tools/linguist/lrelease/main.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include "translator.h" -#include "proreader.h" +#include "profileevaluator.h" #ifndef QT_BOOTSTRAPPED #include <QtCore/QCoreApplication> @@ -246,24 +246,31 @@ int main(int argc, char **argv) foreach (const QString &inputFile, inputFiles) { if (inputFile.endsWith(QLatin1String(".pro"), Qt::CaseInsensitive) || inputFile.endsWith(QLatin1String(".pri"), Qt::CaseInsensitive)) { - QHash<QByteArray, QStringList> varMap; - bool ok = evaluateProFile(inputFile, cd.isVerbose(), &varMap); - if (ok) { - QStringList translations = varMap.value("TRANSLATIONS"); - if (translations.isEmpty()) { - qWarning("lrelease warning: Met no 'TRANSLATIONS' entry in" - " project file '%s'\n", - qPrintable(inputFile)); - } else { - foreach (const QString &trans, translations) - if (!releaseTsFile(trans, cd, removeIdentical)) - return 1; - } + QFileInfo fi(inputFile); + ProFile pro(fi.absoluteFilePath()); + + ProFileEvaluator visitor; + visitor.setVerbose(cd.isVerbose()); + + if (!visitor.queryProFile(&pro)) { + qWarning("lrelease error: cannot read project file '%s'.", qPrintable(inputFile)); + continue; + } + if (!visitor.accept(&pro)) { + qWarning("lrelease error: cannot process project file '%s'.", qPrintable(inputFile)); + continue; + } + + QStringList translations = visitor.values(QLatin1String("TRANSLATIONS")); + if (translations.isEmpty()) { + qWarning("lrelease warning: Met no 'TRANSLATIONS' entry in" + " project file '%s'\n", + qPrintable(inputFile)); } else { - qWarning("error: lrelease encountered project file functionality that is currently not supported.\n" - "You might want to consider using TS files as input instead of a project file.\n" - "Try the following syntax:\n" - " lrelease [options] ts-files [-qm qm-file]\n"); + QDir proDir(fi.absolutePath()); + foreach (const QString &trans, translations) + if (!releaseTsFile(QFileInfo(proDir, trans).filePath(), cd, removeIdentical)) + return 1; } } else { if (outputFile.isEmpty()) { diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp index 0b21c5f..2a1128e 100644 --- a/tools/linguist/lupdate/main.cpp +++ b/tools/linguist/lupdate/main.cpp @@ -43,7 +43,6 @@ #include <translator.h> #include <profileevaluator.h> -#include <proreader.h> #include <QtCore/QCoreApplication> #include <QtCore/QDebug> @@ -118,21 +117,26 @@ static void printUsage() " -disable-heuristic {sametext|similartext|number}\n" " Disable the named merge heuristic. Can be specified multiple times.\n" " -pro <filename>\n" - " Name of a .pro file. Useful for files with .pro\n" - " file syntax but different file suffix\n" + " Name of a .pro file. Useful for files with .pro file syntax but\n" + " different file suffix. Projects are recursed into and merged.\n" " -source-language <language>[_<region>]\n" " Specify the language of the source strings for new files.\n" " Defaults to POSIX if not specified.\n" " -target-language <language>[_<region>]\n" " Specify the language of the translations for new files.\n" " Guessed from the file name if not specified.\n" + " -ts <ts-file>...\n" + " Specify the output file(s). This will override the TRANSLATIONS\n" + " and nullify the CODECFORTR from possibly specified project files.\n" + " -codecfortr <codec>\n" + " Specify the codec assumed for tr() calls. Effective only with -ts.\n" " -version\n" " Display the version of lupdate and exit.\n" ).arg(m_defaultExtensions)); } static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFileNames, - const QByteArray &codecForTr, const QString &sourceLanguage, const QString &targetLanguage, + bool setCodec, const QString &sourceLanguage, const QString &targetLanguage, UpdateOptions options, bool *fail) { QDir dir; @@ -150,10 +154,10 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil } tor.resolveDuplicates(); cd.clearErrors(); - if (!codecForTr.isEmpty() && codecForTr != tor.codecName()) + if (setCodec && fetchedTor.codec() != tor.codec()) qWarning("lupdate warning: Codec for tr() '%s' disagrees with " "existing file's codec '%s'. Expect trouble.", - codecForTr.constData(), tor.codecName().constData()); + fetchedTor.codecName().constData(), tor.codecName().constData()); if (!targetLanguage.isEmpty() && targetLanguage != tor.languageCode()) qWarning("lupdate warning: Specified target language '%s' disagrees with " "existing file's language '%s'. Ignoring.", @@ -163,8 +167,8 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil "existing file's language '%s'. Ignoring.", qPrintable(sourceLanguage), qPrintable(tor.sourceLanguageCode())); } else { - if (!codecForTr.isEmpty()) - tor.setCodecName(codecForTr); + if (setCodec) + tor.setCodec(fetchedTor.codec()); if (!targetLanguage.isEmpty()) tor.setLanguageCode(targetLanguage); else @@ -186,8 +190,8 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil if (tor.locationsType() == Translator::NoLocations) // Could be set from file theseOptions |= NoLocations; Translator out = merge(tor, fetchedTor, theseOptions, err); - if (!codecForTr.isEmpty()) - out.setCodecName(codecForTr); + if (setCodec) + out.setCodec(fetchedTor.codec()); if ((options & Verbose) && !err.isEmpty()) { printOut(err); @@ -214,16 +218,198 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil } } +static QStringList getSources(const char *var, const char *vvar, const QStringList &baseVPaths, + const QString &projectDir, const ProFileEvaluator &visitor) +{ + QStringList vPaths = visitor.absolutePathValues(QLatin1String(vvar), projectDir); + vPaths += baseVPaths; + vPaths.removeDuplicates(); + return visitor.absoluteFileValues(QLatin1String(var), projectDir, vPaths, 0); +} + +static QStringList getSources(const ProFileEvaluator &visitor, const QString &projectDir) +{ + QStringList baseVPaths; + baseVPaths += visitor.absolutePathValues(QLatin1String("VPATH"), projectDir); + baseVPaths << projectDir; // QMAKE_ABSOLUTE_SOURCE_PATH + baseVPaths += visitor.absolutePathValues(QLatin1String("DEPENDPATH"), projectDir); + baseVPaths.removeDuplicates(); + + QStringList sourceFiles; + + // app/lib template + sourceFiles += getSources("SOURCES", "VPATH_SOURCES", baseVPaths, projectDir, visitor); + + sourceFiles += getSources("FORMS", "VPATH_FORMS", baseVPaths, projectDir, visitor); + sourceFiles += getSources("FORMS3", "VPATH_FORMS3", baseVPaths, projectDir, visitor); + + QStringList vPathsInc = baseVPaths; + vPathsInc += visitor.absolutePathValues(QLatin1String("INCLUDEPATH"), projectDir); + vPathsInc.removeDuplicates(); + sourceFiles += visitor.absoluteFileValues(QLatin1String("HEADERS"), projectDir, vPathsInc, 0); + + sourceFiles.removeDuplicates(); + sourceFiles.sort(); + + return sourceFiles; +} + +static void processSources(Translator &fetchedTor, + const QStringList &sourceFiles, ConversionData &cd) +{ + QStringList sourceFilesCpp; + for (QStringList::const_iterator it = sourceFiles.begin(); it != sourceFiles.end(); ++it) { + if (it->endsWith(QLatin1String(".java"), Qt::CaseInsensitive)) + loadJava(fetchedTor, *it, cd); + else if (it->endsWith(QLatin1String(".ui"), Qt::CaseInsensitive) + || it->endsWith(QLatin1String(".jui"), Qt::CaseInsensitive)) + loadUI(fetchedTor, *it, cd); + else if (it->endsWith(QLatin1String(".js"), Qt::CaseInsensitive) + || it->endsWith(QLatin1String(".qs"), Qt::CaseInsensitive)) + loadQScript(fetchedTor, *it, cd); + else if (it->endsWith(QLatin1String(".qml"), Qt::CaseInsensitive)) + loadQml(fetchedTor, *it, cd); + else + sourceFilesCpp << *it; + } + loadCPP(fetchedTor, sourceFilesCpp, cd); + if (!cd.error().isEmpty()) + printOut(cd.error()); +} + +static void processProjects( + bool topLevel, bool nestComplain, const QStringList &proFiles, + UpdateOptions options, const QByteArray &codecForSource, + const QString &targetLanguage, const QString &sourceLanguage, + Translator *parentTor, bool *fail); + +static void processProject( + bool nestComplain, const QFileInfo &pfi, ProFileEvaluator &visitor, + UpdateOptions options, const QByteArray &_codecForSource, + const QString &targetLanguage, const QString &sourceLanguage, + Translator *fetchedTor, bool *fail) +{ + QByteArray codecForSource = _codecForSource; + QStringList tmp = visitor.values(QLatin1String("CODECFORSRC")); + if (!tmp.isEmpty()) { + codecForSource = tmp.last().toLatin1(); + if (!QTextCodec::codecForName(codecForSource)) { + qWarning("lupdate warning: Codec for source '%s' is invalid. " + "Falling back to codec for tr().", codecForSource.constData()); + codecForSource.clear(); + } + } + if (visitor.templateType() == ProFileEvaluator::TT_Subdirs) { + QStringList subProFiles; + QDir proDir(pfi.absoluteDir()); + foreach (const QString &subdir, visitor.values(QLatin1String("SUBDIRS"))) { + QString subPro = QDir::cleanPath(proDir.absoluteFilePath(subdir)); + QFileInfo subInfo(subPro); + if (subInfo.isDir()) + subProFiles << (subPro + QLatin1Char('/') + + subInfo.fileName() + QLatin1String(".pro")); + else + subProFiles << subPro; + } + processProjects(false, nestComplain, subProFiles, options, codecForSource, + targetLanguage, sourceLanguage, fetchedTor, fail); + } else { + ConversionData cd; + cd.m_noUiLines = options & NoUiLines; + cd.m_codecForSource = codecForSource; + cd.m_includePath = visitor.values(QLatin1String("INCLUDEPATH")); + QStringList sourceFiles = getSources(visitor, pfi.absolutePath()); + QSet<QString> sourceDirs; + sourceDirs.insert(QDir::cleanPath(pfi.absolutePath()) + QLatin1Char('/')); + foreach (const QString &sf, sourceFiles) + sourceDirs.insert(sf.left(sf.lastIndexOf(QLatin1Char('/')) + 1)); + QStringList rootList = sourceDirs.toList(); + rootList.sort(); + for (int prev = 0, curr = 1; curr < rootList.length(); ) + if (rootList.at(curr).startsWith(rootList.at(prev))) + rootList.removeAt(curr); + else + prev = curr++; + cd.m_projectRoots = QSet<QString>::fromList(rootList); + processSources(*fetchedTor, sourceFiles, cd); + } +} + +static void processProjects( + bool topLevel, bool nestComplain, const QStringList &proFiles, + UpdateOptions options, const QByteArray &codecForSource, + const QString &targetLanguage, const QString &sourceLanguage, + Translator *parentTor, bool *fail) +{ + foreach (const QString &proFile, proFiles) { + ProFileEvaluator visitor; + visitor.setVerbose(options & Verbose); + + QFileInfo pfi(proFile); + ProFile pro(pfi.absoluteFilePath()); + if (!visitor.queryProFile(&pro) || !visitor.accept(&pro)) { + if (topLevel) + *fail = true; + continue; + } + + if (visitor.contains(QLatin1String("TRANSLATIONS"))) { + if (parentTor) { + if (topLevel) { + std::cerr << "lupdate warning: TS files from command line " + "will override TRANSLATIONS in " << qPrintable(proFile) << ".\n"; + goto noTrans; + } else if (nestComplain) { + std::cerr << "lupdate warning: TS files from command line " + "prevent recursing into " << qPrintable(proFile) << ".\n"; + continue; + } + } + QStringList tsFiles; + QDir proDir(pfi.absolutePath()); + foreach (const QString &tsFile, visitor.values(QLatin1String("TRANSLATIONS"))) + tsFiles << QFileInfo(proDir, tsFile).filePath(); + if (tsFiles.isEmpty()) { + // This might mean either a buggy PRO file or an intentional detach - + // we can't know without seeing the actual RHS of the assignment ... + // Just assume correctness and be silent. + continue; + } + Translator tor; + bool setCodec = false; + QStringList tmp = visitor.values(QLatin1String("CODEC")) + + visitor.values(QLatin1String("DEFAULTCODEC")) + + visitor.values(QLatin1String("CODECFORTR")); + if (!tmp.isEmpty()) { + tor.setCodecName(tmp.last().toLatin1()); + setCodec = true; + } + processProject(false, pfi, visitor, options, codecForSource, + targetLanguage, sourceLanguage, &tor, fail); + updateTsFiles(tor, tsFiles, setCodec, sourceLanguage, targetLanguage, options, fail); + continue; + } + noTrans: + if (!parentTor) { + if (topLevel) + std::cerr << "lupdate warning: no TS files specified. Only diagnostics " + "will be produced for '" << qPrintable(proFile) << "'.\n"; + Translator tor; + processProject(nestComplain, pfi, visitor, options, codecForSource, + targetLanguage, sourceLanguage, &tor, fail); + } else { + processProject(nestComplain, pfi, visitor, options, codecForSource, + targetLanguage, sourceLanguage, parentTor, fail); + } + } +} + int main(int argc, char **argv) { QCoreApplication app(argc, argv); m_defaultExtensions = QLatin1String("ui,c,c++,cc,cpp,cxx,ch,h,h++,hh,hpp,hxx"); QStringList args = app.arguments(); - QString defaultContext; // This was QLatin1String("@default") before. - Translator fetchedTor; - QByteArray codecForTr; - QByteArray codecForSource; QStringList tsFileNames; QStringList proFiles; QMultiHash<QString, QString> allCSources; @@ -232,6 +418,7 @@ int main(int argc, char **argv) QStringList includePath; QString targetLanguage; QString sourceLanguage; + QByteArray codecForTr; UpdateOptions options = Verbose | // verbose is on by default starting with Qt 4.2 @@ -330,6 +517,14 @@ int main(int argc, char **argv) } else if (arg == QLatin1String("-version")) { printOut(QObject::tr("lupdate version %1\n").arg(QLatin1String(QT_VERSION_STR))); return 0; + } else if (arg == QLatin1String("-codecfortr")) { + ++i; + if (i == argc) { + qWarning("The -codecfortr option should be followed by a codec name."); + return 1; + } + codecForTr = args[i].toLatin1(); + continue; } else if (arg == QLatin1String("-ts")) { metTsFlag = true; continue; @@ -367,11 +562,6 @@ int main(int argc, char **argv) return 1; } - numFiles++; - - codecForTr.clear(); - codecForSource.clear(); - if (metTsFlag) { bool found = false; foreach (const Translator::FileFormat &fmt, Translator::registeredFileFormats()) { @@ -395,6 +585,7 @@ int main(int argc, char **argv) } else if (arg.endsWith(QLatin1String(".pro"), Qt::CaseInsensitive) || arg.endsWith(QLatin1String(".pri"), Qt::CaseInsensitive)) { proFiles << arg; + numFiles++; } else { QFileInfo fi(arg); if (!fi.exists()) { @@ -440,107 +631,53 @@ int main(int argc, char **argv) } else { sourceFiles << QDir::cleanPath(fi.absoluteFilePath());; } + numFiles++; } } // for args - foreach (const QString &proFile, proFiles) - projectRoots.insert(QDir::cleanPath(QFileInfo(proFile).absolutePath()) + QLatin1Char('/')); + if (numFiles == 0) { + printUsage(); + return 1; + } + + if (!targetLanguage.isEmpty() && tsFileNames.count() != 1) + std::cerr << "lupdate warning: -target-language usually only " + "makes sense with exactly one TS file.\n"; + if (!codecForTr.isEmpty() && tsFileNames.isEmpty()) + std::cerr << "lupdate warning: -codecfortr has no effect without -ts.\n"; - bool firstPass = true; bool fail = false; - while (firstPass || !proFiles.isEmpty()) { + if (proFiles.isEmpty()) { + if (tsFileNames.isEmpty()) + std::cerr << "lupdate warning: no TS files specified. " + "Only diagnostics will be produced.\n"; + + Translator fetchedTor; ConversionData cd; - cd.m_defaultContext = defaultContext; cd.m_noUiLines = options & NoUiLines; cd.m_projectRoots = projectRoots; cd.m_includePath = includePath; cd.m_allCSources = allCSources; - - QStringList tsFiles = tsFileNames; - if (proFiles.count() > 0) { - QFileInfo pfi(proFiles.takeFirst()); - QHash<QByteArray, QStringList> variables; - - ProFileEvaluator visitor; - visitor.setVerbose(options & Verbose); - - ProFile pro(pfi.absoluteFilePath()); - if (!visitor.queryProFile(&pro)) - return 2; - if (!visitor.accept(&pro)) - return 2; - - if (visitor.templateType() == ProFileEvaluator::TT_Subdirs) { - QDir proDir(pfi.absoluteDir()); - foreach (const QString &subdir, visitor.values(QLatin1String("SUBDIRS"))) { - QString subPro = QDir::cleanPath(proDir.absoluteFilePath(subdir)); - QFileInfo subInfo(subPro); - if (subInfo.isDir()) - proFiles << (subPro + QLatin1Char('/') - + subInfo.fileName() + QLatin1String(".pro")); - else - proFiles << subPro; - } - continue; - } - - cd.m_includePath += visitor.values(QLatin1String("INCLUDEPATH")); - - evaluateProFile(visitor, &variables, pfi.absolutePath()); - - sourceFiles = variables.value("SOURCES"); - - QStringList tmp = variables.value("CODECFORTR"); - if (!tmp.isEmpty() && !tmp.first().isEmpty()) { - codecForTr = tmp.first().toLatin1(); - fetchedTor.setCodecName(codecForTr); - cd.m_outputCodec = codecForTr; - } - tmp = variables.value("CODECFORSRC"); - if (!tmp.isEmpty() && !tmp.first().isEmpty()) { - codecForSource = tmp.first().toLatin1(); - if (!QTextCodec::codecForName(codecForSource)) - qWarning("lupdate warning: Codec for source '%s' is invalid. Falling back to codec for tr().", - codecForSource.constData()); - else - cd.m_codecForSource = codecForSource; - } - - tsFiles += variables.value("TRANSLATIONS"); + fetchedTor.setCodecName(codecForTr); + processSources(fetchedTor, sourceFiles, cd); + updateTsFiles(fetchedTor, tsFileNames, !codecForTr.isEmpty(), + sourceLanguage, targetLanguage, options, &fail); + } else { + if (!sourceFiles.isEmpty() || !includePath.isEmpty()) { + qWarning("lupdate error: Both project and source files / include paths specified.\n"); + return 1; } - - QStringList sourceFilesCpp; - for (QStringList::iterator it = sourceFiles.begin(); it != sourceFiles.end(); ++it) { - if (it->endsWith(QLatin1String(".java"), Qt::CaseInsensitive)) - loadJava(fetchedTor, *it, cd); - else if (it->endsWith(QLatin1String(".ui"), Qt::CaseInsensitive) - || it->endsWith(QLatin1String(".jui"), Qt::CaseInsensitive)) - loadUI(fetchedTor, *it, cd); - else if (it->endsWith(QLatin1String(".js"), Qt::CaseInsensitive) - || it->endsWith(QLatin1String(".qs"), Qt::CaseInsensitive)) - loadQScript(fetchedTor, *it, cd); - else if (it->endsWith(QLatin1String(".qml"), Qt::CaseInsensitive)) - loadQml(fetchedTor, *it, cd); - else - sourceFilesCpp << *it; + if (!tsFileNames.isEmpty()) { + Translator fetchedTor; + fetchedTor.setCodecName(codecForTr); + processProjects(true, true, proFiles, options, QByteArray(), + targetLanguage, sourceLanguage, &fetchedTor, &fail); + updateTsFiles(fetchedTor, tsFileNames, !codecForTr.isEmpty(), + sourceLanguage, targetLanguage, options, &fail); + } else { + processProjects(true, false, proFiles, options, QByteArray(), + targetLanguage, sourceLanguage, 0, &fail); } - loadCPP(fetchedTor, sourceFilesCpp, cd); - if (!cd.error().isEmpty()) - printOut(cd.error()); - - tsFiles.sort(); - tsFiles.removeDuplicates(); - - if (!tsFiles.isEmpty()) - updateTsFiles(fetchedTor, tsFiles, codecForTr, sourceLanguage, targetLanguage, options, &fail); - - firstPass = false; - } - - if (numFiles == 0) { - printUsage(); - return 1; } - return fail ? 1 : 0; } diff --git a/tools/linguist/shared/proparser.pri b/tools/linguist/shared/proparser.pri index 99d32e7..372247e 100644 --- a/tools/linguist/shared/proparser.pri +++ b/tools/linguist/shared/proparser.pri @@ -2,13 +2,11 @@ INCLUDEPATH *= $$PWD HEADERS += \ - $$PWD/proreader.h \ $$PWD/abstractproitemvisitor.h \ $$PWD/proitems.h \ $$PWD/profileevaluator.h \ $$PWD/proparserutils.h SOURCES += \ - $$PWD/proreader.cpp \ $$PWD/proitems.cpp \ $$PWD/profileevaluator.cpp diff --git a/tools/linguist/shared/proreader.cpp b/tools/linguist/shared/proreader.cpp deleted file mode 100644 index 4a621a8..0000000 --- a/tools/linguist/shared/proreader.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Linguist of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "profileevaluator.h" - -#include <QtCore/QDir> -#include <QtCore/QFileInfo> - -QT_BEGIN_NAMESPACE - -static QStringList getSources(const char *var, const char *vvar, const QStringList &baseVPaths, - const QString &projectDir, const ProFileEvaluator &visitor) -{ - QStringList vPaths = - visitor.absolutePathValues(QLatin1String(vvar), projectDir); - vPaths += baseVPaths; - vPaths.removeDuplicates(); - return visitor.absoluteFileValues(QLatin1String(var), projectDir, vPaths, 0); -} - -void evaluateProFile(const ProFileEvaluator &visitor, QHash<QByteArray, QStringList> *varMap, - const QString &projectDir) -{ - QStringList baseVPaths; - baseVPaths += visitor.absolutePathValues(QLatin1String("VPATH"), projectDir); - baseVPaths << projectDir; // QMAKE_ABSOLUTE_SOURCE_PATH - baseVPaths += visitor.absolutePathValues(QLatin1String("DEPENDPATH"), projectDir); - baseVPaths.removeDuplicates(); - - QStringList sourceFiles; - QString codecForTr; - QString codecForSource; - QStringList tsFileNames; - - // app/lib template - sourceFiles += getSources("SOURCES", "VPATH_SOURCES", baseVPaths, projectDir, visitor); - - sourceFiles += getSources("FORMS", "VPATH_FORMS", baseVPaths, projectDir, visitor); - sourceFiles += getSources("FORMS3", "VPATH_FORMS3", baseVPaths, projectDir, visitor); - - QStringList vPathsInc = baseVPaths; - vPathsInc += visitor.absolutePathValues(QLatin1String("INCLUDEPATH"), projectDir); - vPathsInc.removeDuplicates(); - sourceFiles += visitor.absoluteFileValues(QLatin1String("HEADERS"), projectDir, vPathsInc, 0); - - QDir proDir(projectDir); - foreach (const QString &tsFile, visitor.values(QLatin1String("TRANSLATIONS"))) - tsFileNames << QFileInfo(proDir, tsFile).filePath(); - - QStringList trcodec = visitor.values(QLatin1String("CODEC")) - + visitor.values(QLatin1String("DEFAULTCODEC")) - + visitor.values(QLatin1String("CODECFORTR")); - if (!trcodec.isEmpty()) - codecForTr = trcodec.last(); - - QStringList srccodec = visitor.values(QLatin1String("CODECFORSRC")); - if (!srccodec.isEmpty()) - codecForSource = srccodec.last(); - - sourceFiles.sort(); - sourceFiles.removeDuplicates(); - tsFileNames.sort(); - tsFileNames.removeDuplicates(); - - varMap->insert("SOURCES", sourceFiles); - varMap->insert("CODECFORTR", QStringList() << codecForTr); - varMap->insert("CODECFORSRC", QStringList() << codecForSource); - varMap->insert("TRANSLATIONS", tsFileNames); -} - -bool evaluateProFile(const QString &fileName, bool verbose, QHash<QByteArray, QStringList> *varMap) -{ - QFileInfo fi(fileName); - if (!fi.exists()) - return false; - - ProFile pro(fi.absoluteFilePath()); - - ProFileEvaluator visitor; - visitor.setVerbose(verbose); - - if (!visitor.queryProFile(&pro)) - return false; - - if (!visitor.accept(&pro)) - return false; - - evaluateProFile(visitor, varMap, fi.absolutePath()); - - return true; -} - -QT_END_NAMESPACE diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h index 0fcd598..0b88c07 100644 --- a/tools/linguist/shared/translator.h +++ b/tools/linguist/shared/translator.h @@ -153,6 +153,7 @@ public: void reportDuplicates(const Duplicates &dupes, const QString &fileName, bool verbose); void setCodecName(const QByteArray &name); + void setCodec(QTextCodec *codec) { m_codec = codec; } QByteArray codecName() const; QTextCodec *codec() const { return m_codec; } diff --git a/tools/qmldebugger/standalone/engines.qml b/tools/qmldebugger/standalone/engines.qml index 1e9335b..0b2b7ac 100644 --- a/tools/qmldebugger/standalone/engines.qml +++ b/tools/qmldebugger/standalone/engines.qml @@ -2,7 +2,7 @@ import Qt 4.6 Item { height: 100 - id: Root + id: root signal engineClicked(int id) signal refreshEngines() @@ -13,18 +13,18 @@ Item { Item { width: 100; height: 100; Image { - id: EngineIcon; + id: engineIcon; source: "qrc:/engine.png" anchors.horizontalCenter: parent.horizontalCenter } Text { - anchors.top: EngineIcon.bottom; + anchors.top: engineIcon.bottom; text: modelData.name + "(" + modelData.engineId + ")" anchors.horizontalCenter: parent.horizontalCenter } MouseRegion { anchors.fill: parent - onClicked: Root.engineClicked(modelData.engineId); + onClicked: root.engineClicked(modelData.engineId); } } } @@ -40,7 +40,7 @@ Item { anchors.right: parent.right MouseRegion { anchors.fill: parent - onClicked: Root.refreshEngines() + onClicked: root.refreshEngines() } } } diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index 71ba81c..2b69d97 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -349,9 +349,9 @@ public: QMutexLocker lock(&mutex); QNetworkAccessManager *manager = new QNetworkAccessManager(parent); if (!cookieJar) - cookieJar = new PersistentCookieJar(this); + cookieJar = new PersistentCookieJar(manager); manager->setCookieJar(cookieJar); - cookieJar->setParent(this); + cookieJar->setParent(0); setupProxy(manager); if (cacheSize > 0) { QNetworkDiskCache *cache = new QNetworkDiskCache; @@ -405,7 +405,6 @@ public: void setCacheSize(int size) { if (size != cacheSize) { cacheSize = size; - invalidate(); } } @@ -691,7 +690,6 @@ void QmlViewer::showProxySettings() void QmlViewer::proxySettingsChanged() { - namFactory->invalidate(); reload (); } diff --git a/tools/shared/findwidget/texteditfindwidget.h b/tools/shared/findwidget/texteditfindwidget.h index 3034a42..a051f0e 100644 --- a/tools/shared/findwidget/texteditfindwidget.h +++ b/tools/shared/findwidget/texteditfindwidget.h @@ -53,7 +53,7 @@ class TextEditFindWidget : public AbstractFindWidget Q_OBJECT public: - TextEditFindWidget(FindFlags flags = FindFlags(), QWidget *parent = 0); + explicit TextEditFindWidget(FindFlags flags = FindFlags(), QWidget *parent = 0); QTextEdit *textEdit() const { return m_textEdit; } diff --git a/tools/shared/fontpanel/fontpanel.cpp b/tools/shared/fontpanel/fontpanel.cpp index 0b6f394..ad297df 100644 --- a/tools/shared/fontpanel/fontpanel.cpp +++ b/tools/shared/fontpanel/fontpanel.cpp @@ -217,7 +217,7 @@ void FontPanel::updateFamily(const QString &family) const QString normalStyle = QLatin1String("Normal"); if (hasStyles) { - foreach (QString style, styles) { + foreach (const QString &style, styles) { // try to maintain selection or select 'normal' preferably const int newIndex = m_styleComboBox->count(); m_styleComboBox->addItem(style); diff --git a/tools/shared/qtgradienteditor/qtgradientutils.cpp b/tools/shared/qtgradienteditor/qtgradientutils.cpp index 9fa0324..083ba89 100644 --- a/tools/shared/qtgradienteditor/qtgradientutils.cpp +++ b/tools/shared/qtgradienteditor/qtgradientutils.cpp @@ -395,7 +395,7 @@ static QStringList styleSheetParameters(const QGradient &gradient) static QStringList styleSheetStops(const QGradient &gradient) { QStringList result; - foreach (QGradientStop stop, gradient.stops()) { + foreach (const QGradientStop &stop, gradient.stops()) { const QColor color = stop.second; const QString stopDescription = QLatin1String("stop:") + QString::number(stop.first) + QLatin1String(" rgba(") diff --git a/tools/shared/qttoolbardialog/qttoolbardialog.h b/tools/shared/qttoolbardialog/qttoolbardialog.h index a1c099a..e182368 100644 --- a/tools/shared/qttoolbardialog/qttoolbardialog.h +++ b/tools/shared/qttoolbardialog/qttoolbardialog.h @@ -68,7 +68,7 @@ class QtToolBarManager : public QObject Q_OBJECT public: - QtToolBarManager(QObject *parent = 0); + explicit QtToolBarManager(QObject *parent = 0); ~QtToolBarManager(); void setMainWindow(QMainWindow *mainWindow); @@ -100,7 +100,7 @@ class QtToolBarDialog : public QDialog Q_OBJECT public: - QtToolBarDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0); + explicit QtToolBarDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0); ~QtToolBarDialog(); void setToolBarManager(QtToolBarManager *toolBarManager); |