summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Walters <ian.walters@nokia.com>2009-04-23 01:39:04 (GMT)
committerIan Walters <ian.walters@nokia.com>2009-04-23 01:39:04 (GMT)
commit5c532f8bcb183e70bca39471edd2183c8e400f25 (patch)
tree931bd9e73fd5900ad7e40e19eaa80f963c12456b
parent49256dbed86b2ad2fde52c45808ab9ddd7159506 (diff)
parent5377045c74c65aeb18d169bcd4a165417c0f4c02 (diff)
downloadQt-5c532f8bcb183e70bca39471edd2183c8e400f25.zip
Qt-5c532f8bcb183e70bca39471edd2183c8e400f25.tar.gz
Qt-5c532f8bcb183e70bca39471edd2183c8e400f25.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--bin/snapshot122
-rw-r--r--examples/animation/animatedtiles/main.cpp1
-rw-r--r--examples/animation/sub-attaq/boat.cpp1
-rw-r--r--examples/animation/sub-attaq/boat.h2
-rw-r--r--examples/animation/sub-attaq/qanimationstate.cpp3
-rw-r--r--examples/animation/sub-attaq/submarine.cpp9
-rw-r--r--examples/declarative/listview/content/pics/moreDown.pngbin0 -> 217 bytes
-rw-r--r--examples/declarative/listview/content/pics/moreUp.pngbin0 -> 212 bytes
-rw-r--r--examples/declarative/listview/recipes.qml34
-rw-r--r--src/corelib/animation/qpropertyanimation.cpp22
-rw-r--r--src/corelib/animation/qvariantanimation_p.h14
-rw-r--r--src/corelib/kernel/qvariant.cpp99
-rw-r--r--src/corelib/kernel/qvariant.h17
-rw-r--r--src/corelib/kernel/qvariant_p.h51
-rw-r--r--src/declarative/util/qmlanimation.cpp4
-rw-r--r--src/gui/animation/qguivariantanimation.cpp5
-rw-r--r--src/opengl/opengl.pro4
-rw-r--r--tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp22
18 files changed, 241 insertions, 169 deletions
diff --git a/bin/snapshot b/bin/snapshot
index 783d15c..b9a64e1 100644
--- a/bin/snapshot
+++ b/bin/snapshot
@@ -14,6 +14,40 @@ use strict;
my $targetPath = "";
my $qtdir = $ENV{"QTDIR"};
+my @class_renames = (
+ "QAbstractAnimation",
+ "QAnimationGroup",
+ "QParallelAnimationGroup",
+ "QSequentialAnimationGroup",
+ "QEasingCurve",
+ "QVariantAnimation",
+ "QPropertyAnimation",
+ "QItemAnimation",
+ "QPauseAnimation",
+ "QAbstractState",
+ "QAbstractStateGroup",
+ "QAbstractTransition",
+ "QActionState",
+ "QEventTransition",
+ "QFinalState",
+ "QHistoryState",
+ "QParallelStateGroup",
+ "QSignalEvent",
+ "QSignalTransition",
+ "QState",
+ "QStateAction",
+ "QStateInvokeMethodAction",
+ "QStateFinishedEvent",
+ "QStateFinishedTransition",
+ "QStateMachine",
+ "QTransition",
+ "QMouseEventTransition",
+ "QBasicMouseEventTransition",
+ "QKeyEventTransition",
+ "QBasicKeyEventTransition",
+ "QGraphicsWidget",
+ "QBoundEvent");
+
my @files = (
"3rdparty/easing/easing.cpp",
"corelib/tools/qeasingcurve.h",
@@ -40,6 +74,8 @@ my @files = (
"corelib/animation/qsequentialanimationgroup.h",
"corelib/animation/qsequentialanimationgroup_p.h",
"gui/animation/qguivariantanimation.cpp",
+ "gui/animation/animation.pri",
+
"corelib/statemachine/statemachine.pri",
"corelib/statemachine/qabstractstate.cpp",
"corelib/statemachine/qabstractstate.h",
@@ -110,13 +146,13 @@ open(OXML, "> " . $projectXML) || die "Could not open $projectXML for writing (n
print "COPYING SOURCES...\n";
foreach my $files(@files) {
- copyFile("$qtdir/src/$files","$targetPath/src");
+ copyFile("$qtdir/src/$files","$targetPath/src", 1);
}
-copyFile("$qtdir/doc/src/animation.qdoc","$targetPath/doc");
-copyFile("$qtdir/doc/src/statemachine.qdoc","$targetPath/doc");
-copyFile("$qtdir/src/3rdparty/easing/legal.qdoc","$targetPath/doc");
+copyFile("$qtdir/doc/src/animation.qdoc","$targetPath/doc", 0);
+copyFile("$qtdir/doc/src/statemachine.qdoc","$targetPath/doc", 0);
+copyFile("$qtdir/src/3rdparty/easing/legal.qdoc","$targetPath/doc", 0);
-copyFile("$qtdir/doc/src/snippets/code/src_corelib_tools_qeasingcurve.cpp","$targetPath/doc/src/snippets/code");
+copyFile("$qtdir/doc/src/snippets/code/src_corelib_tools_qeasingcurve.cpp","$targetPath/doc/src/snippets/code", 0);
my %animation_examples = (
@@ -150,7 +186,9 @@ my %animation_examples = (
"mainwindow.cpp",
"mainwindow.h",
"pics/scalable/*",
- "pics/big/*",
+ "pics/big/*.png",
+ "pics/big/explosion/boat/*",
+ "pics/big/explosion/submarine/*",
"pics/small/*",
"pics/welcome/*",
"pixmapitem.cpp",
@@ -161,8 +199,11 @@ my %animation_examples = (
"submarine_p.h",
"states.cpp",
"states.h",
+ "qanimationstate.cpp",
+ "qanimationstate.h",
"torpedo.cpp",
- "torpedo.h"],
+ "torpedo.h",
+ "data.xml"],
"stickman" => ["stickman.pro",
"main.cpp",
"animation.cpp",
@@ -175,6 +216,7 @@ my %animation_examples = (
"node.h",
"stickman.cpp",
"stickman.h",
+ "editor/*",
"animations/chilling",
"animations/dancing",
"animations/dead",
@@ -193,7 +235,7 @@ for $exDir ( keys %animation_examples ) {
my $glob = 0;
if (index($ex_file,"/") > 0) {
my($basefile, $fullPath) = fileparse("$targetPath/examples/$exDir/$ex_file");
- if ($basefile eq "*") {
+ if (index($basefile, "*") >= 0) {
$glob = 1;
}
mkpath "$fullPath", 0777 unless(-e "$fullPath");
@@ -209,20 +251,25 @@ for $exDir ( keys %animation_examples ) {
if ($glob eq 1) {
my @globFiles = < $qtdir/examples/animation/$exDir/$ex_file >;
foreach my $globFile(@globFiles) {
- copyFile("$globFile", "$copyTargetPath");
+ copyFile("$globFile", "$copyTargetPath", 0);
}
} else {
- copyFile("$qtdir/examples/animation/$exDir/$ex_file", "$copyTargetPath");
+ copyFile("$qtdir/examples/animation/$exDir/$ex_file", "$copyTargetPath", 0);
}
}
}
close OXML;
print("Finished!");
+
+
######################################################################
# Syntax: copyFile(gitfile, destinationPath)
# Params: gitfile, string, filename to create duplicate for
# destinationPath, string, destination name of duplicate
+# autoRename, int, 0: Don't rename
+# 1: The file should be renamed to have the "qt" prefix
+#
#
# Purpose: Copies to the solutions area.
# Returns: --
@@ -230,7 +277,7 @@ print("Finished!");
######################################################################
sub copyFile
{
- my ($gitfile, $destinationPath) = @_;
+ my ($gitfile, $destinationPath, $autoRename) = @_;
# Bi-directional synchronization
open( I, "< " . $gitfile ) || die "Could not open $gitfile for reading";
local $/;
@@ -239,44 +286,20 @@ sub copyFile
my ($baseFileName, $path, $ext) = fileparse($gitfile, qr/\.[^.]*/);
if ($ext eq ".h" or $ext eq ".cpp" or $ext eq ".qdoc") {
# both public and private classes
- $filecontents =~s/QAbstractAnimation/QtAbstractAnimation/g;
- $filecontents =~s/QAnimationGroup/QtAnimationGroup/g;
- $filecontents =~s/QParallelAnimationGroup/QtParallelAnimationGroup/g;
- $filecontents =~s/QSequentialAnimationGroup/QtSequentialAnimationGroup/g;
- $filecontents =~s/QEasingCurve/QtEasingCurve/g;
- $filecontents =~s/QVariantAnimation/QtVariantAnimation/g;
- $filecontents =~s/QPropertyAnimation/QtPropertyAnimation/g;
- $filecontents =~s/QItemAnimation/QtItemAnimation/g;
- $filecontents =~s/QPauseAnimation/QtPauseAnimation/g;
- $filecontents =~s/QAbstractState/QtAbstractState/g;
- $filecontents =~s/QAbstractStateGroup/QtAbstractStateGroup/g;
- $filecontents =~s/QAbstractTransition/QtAbstractTransition/g;
- $filecontents =~s/QActionState/QtActionState/g;
- $filecontents =~s/QEventTransition/QtEventTransition/g;
- $filecontents =~s/QFinalState/QtFinalState/g;
- $filecontents =~s/QHistoryState/QtHistoryState/g;
- $filecontents =~s/QParallelStateGroup/QtParallelStateGroup/g;
- $filecontents =~s/QSignalEvent/QtSignalEvent/g;
- $filecontents =~s/QSignalTransition/QtSignalTransition/g;
- $filecontents =~s/QState/QtState/g;
- $filecontents =~s/QStateAction/QtStateAction/g;
- $filecontents =~s/QStateInvokeMethodAction/QtStateInvokeMethodAction/g;
- $filecontents =~s/QStateFinishedEvent/QtStateFinishedEvent/g;
- $filecontents =~s/QStateFinishedTransition/QtStateFinishedTransition/g;
- $filecontents =~s/QStateMachine/QtStateMachine/g;
- $filecontents =~s/QActionTransition/QtActionTransition/g;
- $filecontents =~s/QMouseEventTransition/QtMouseEventTransition/g;
- $filecontents =~s/QKeyEventTransition/QtKeyEventTransition/g;
- $filecontents =~s/QGraphicsWidget/QtGraphicsWidget/g;
+ foreach my $qtClass(@class_renames) {
+ my $solutionClass = $qtClass;
+ $solutionClass =~s/^Q/Qt/g;
+ $filecontents =~s/$qtClass/$solutionClass/g;
+ my $qtFilename = lc($qtClass);
+ my $solutionFilename = lc($solutionClass);
+ $filecontents =~s/(#\s*include\s+["])$qtFilename/${1}$solutionFilename/g;
+ }
+
$filecontents =~s/Q_CORE_EXPORT/Q_ANIMATION_EXPORT/g;
$filecontents =~s/Q_GUI_EXPORT/Q_ANIMATION_EXPORT/g;
- $filecontents =~s/QBoundEvent/QtBoundEvent/g;
-
$filecontents =~s/class Q_GUI_EXPORT/class/g;
$filecontents =~s/class Q_AUTOTEST_EXPORT/class/g;
- $filecontents =~s/(#\s*include\s+["])q/${1}qt/g;
-
# moc stuff
$filecontents =~s/(#\s*include\s+["])moc_q/${1}moc_qt/g;
@@ -300,7 +323,14 @@ sub copyFile
if (index($gitfile, "gui/statemachine") >= 0) {
$baseFileName = "gui_statemachine";
}
-
+ }
+ if ($baseFileName eq "animation") {
+ if (index($gitfile, "corelib/animation") >= 0) {
+ $baseFileName = "corelib_animation";
+ }
+ if (index($gitfile, "gui/animation") >= 0) {
+ $baseFileName = "gui_animation";
+ }
}
}
@@ -312,7 +342,7 @@ sub copyFile
mkpath $destinationPath, 0777 unless(-e "$destinationPath");
- if ($ext eq ".h" or $ext eq ".cpp" or $ext eq ".qdoc") {
+ if ($autoRename eq 1 and ($ext eq ".h" or $ext eq ".cpp" or $ext eq ".qdoc")) {
$baseFileName =~s/^q/qt/g;
}
my $targetFile = "$destinationPath/$baseFileName$ext";
diff --git a/examples/animation/animatedtiles/main.cpp b/examples/animation/animatedtiles/main.cpp
index cfaa4ce..9b0b0a5 100644
--- a/examples/animation/animatedtiles/main.cpp
+++ b/examples/animation/animatedtiles/main.cpp
@@ -7,6 +7,7 @@
# include "qgraphicswidget.h"
# include "qparallelanimationgroup.h"
# include "qpropertyanimation.h"
+# include "qsignaltransition.h"
#else
#include <QtCore/qstate.h>
#endif
diff --git a/examples/animation/sub-attaq/boat.cpp b/examples/animation/sub-attaq/boat.cpp
index 633e1b1..5721485 100644
--- a/examples/animation/sub-attaq/boat.cpp
+++ b/examples/animation/sub-attaq/boat.cpp
@@ -56,6 +56,7 @@
# include "qhistorystate.h"
# include "qfinalstate.h"
# include "qstate.h"
+# include "qpauseanimation.h"
#include "qsequentialanimationgroup.h"
#else
#include <QPropertyAnimation>
diff --git a/examples/animation/sub-attaq/boat.h b/examples/animation/sub-attaq/boat.h
index 4c4a737..b8d5772 100644
--- a/examples/animation/sub-attaq/boat.h
+++ b/examples/animation/sub-attaq/boat.h
@@ -49,7 +49,7 @@
#include <QDebug>
#if defined(QT_EXPERIMENTAL_SOLUTION)
-# include "qgraphicswidget.h"
+# include "qtgraphicswidget.h"
#else
# include <QtGui/QGraphicsWidget>
#endif
diff --git a/examples/animation/sub-attaq/qanimationstate.cpp b/examples/animation/sub-attaq/qanimationstate.cpp
index 70285a8..3659657 100644
--- a/examples/animation/sub-attaq/qanimationstate.cpp
+++ b/examples/animation/sub-attaq/qanimationstate.cpp
@@ -43,11 +43,12 @@
#if defined(QT_EXPERIMENTAL_SOLUTION)
# include "qstate.h"
+# include "qstate_p.h"
#else
# include <QtCore/qstate.h>
+# include <private/qstate_p.h>
#endif
-#include <private/qstate_p.h>
QT_BEGIN_NAMESPACE
diff --git a/examples/animation/sub-attaq/submarine.cpp b/examples/animation/sub-attaq/submarine.cpp
index e64ffdd..555617c 100644
--- a/examples/animation/sub-attaq/submarine.cpp
+++ b/examples/animation/sub-attaq/submarine.cpp
@@ -50,10 +50,11 @@
#include "qanimationstate.h"
#if defined(QT_EXPERIMENTAL_SOLUTION)
-#include "qpropertyanimation.h"
-#include "qstatemachine.h"
-#include "qfinalstate.h"
-#include "qsequentialanimationgroup.h"
+# include "qpropertyanimation.h"
+# include "qstatemachine.h"
+# include "qfinalstate.h"
+# include "qsequentialanimationgroup.h"
+# include "qpauseanimation.h"
#else
#include <QPropertyAnimation>
#include <QStateMachine>
diff --git a/examples/declarative/listview/content/pics/moreDown.png b/examples/declarative/listview/content/pics/moreDown.png
new file mode 100644
index 0000000..31a35d5
--- /dev/null
+++ b/examples/declarative/listview/content/pics/moreDown.png
Binary files differ
diff --git a/examples/declarative/listview/content/pics/moreUp.png b/examples/declarative/listview/content/pics/moreUp.png
new file mode 100644
index 0000000..fefb9c9
--- /dev/null
+++ b/examples/declarative/listview/content/pics/moreUp.png
Binary files differ
diff --git a/examples/declarative/listview/recipes.qml b/examples/declarative/listview/recipes.qml
index 7d32532..6826b78 100644
--- a/examples/declarative/listview/recipes.qml
+++ b/examples/declarative/listview/recipes.qml
@@ -1,6 +1,6 @@
<!-- This example illustrates expanding a list item to show a more detailed view -->
<?qtfx namespacepath:=content ?>
-<Rect id="page" width="400" height="280" color="black">
+<Rect id="page" width="400" height="240" color="black">
<resources>
<!--
Delegate for the recipes. This delegate has two modes:
@@ -8,7 +8,7 @@
2. the details mode, which also shows the ingredients and method.
-->
<Component id="recipeDelegate">
- <Item id="wrapper" x="10" width="{List.width-20}">
+ <Item id="wrapper" width="{List.width}">
<!--
Create a property to contain the visibility of the details.
We can bind multiple element's opacity to this one property,
@@ -29,20 +29,23 @@
bottom. Note that elements that should not be visible in the list
mode have their opacity set to wrapper.detailsOpacity.
-->
- <VerticalLayout id="topLayout" width="{parent.width-20}" margin="10" spacing="10">
- <HorizontalLayout spacing="10" height="{recipePic.height}">
- <Image id="recipePic" src="{picture}" width="48" height="48"/>
- <VerticalLayout height="{recipePic.height}" spacing="5" width="{background.width-recipePic.width-20}">
- <Text id="name" text="{title}" font.bold="true" font.size="16"/>
- <Text opacity="{wrapper.detailsOpacity}" text="Ingredients" font.size="12" font.bold="true"/>
- <Text opacity="{wrapper.detailsOpacity}" text="{ingredients}" wrap="true" width="{parent.width}"/>
- </VerticalLayout>
- </HorizontalLayout>
- <VerticalLayout id="details" opacity="{wrapper.detailsOpacity}">
- <Text text="Method" font.size="12" font.bold="true"/>
- <Text text="{method}" wrap="true" width="{topLayout.width}"/>
+ <HorizontalLayout id="topLayout" x="10" y="10" spacing="10" height="{recipePic.height}" width="{parent.width}">
+ <Image id="recipePic" src="{picture}" width="48" height="48"/>
+ <VerticalLayout height="{recipePic.height}" spacing="5" width="{background.width-recipePic.width-20}">
+ <Text id="name" text="{title}" font.bold="true" font.size="16"/>
+ <Text opacity="{wrapper.detailsOpacity}" text="Ingredients" font.size="12" font.bold="true"/>
+ <Text opacity="{wrapper.detailsOpacity}" text="{ingredients}" wrap="true" width="{parent.width}"/>
</VerticalLayout>
- </VerticalLayout>
+ </HorizontalLayout>
+ <Item id="details" x="10" width="{parent.width-20}" anchors.top="{topLayout.bottom}" anchors.topMargin="10"
+ anchors.bottom="{parent.bottom}" anchors.bottomMargin="10" opacity="{wrapper.detailsOpacity}">
+ <Text id="methodTitle" text="Method" font.size="12" font.bold="true" anchors.top="{parent.top}"/>
+ <Flickable id="flick" anchors.top="{methodTitle.bottom}" anchors.bottom="{parent.bottom}" width="{parent.width}" viewportHeight="{methodText.height}" clip="true">
+ <Text id="methodText" text="{method}" wrap="true" width="{details.width}"/>
+ </Flickable>
+ <Image anchors.right="{flick.right}" anchors.top="{flick.top}" src="content/pics/moreUp.png" opacity="{flick.atYBeginning ? 0 : 1}"/>
+ <Image anchors.right="{flick.right}" anchors.bottom="{flick.bottom}" src="content/pics/moreDown.png" opacity="{flick.atYEnd ? 0 : 1}"/>
+ </Item>
<!-- A button to close the detailed view, i.e. set the state back to default (''). -->
<MediaButton anchors.right="{background.right}" anchors.rightMargin="5" y="10" opacity="{wrapper.detailsOpacity}" text="Close" onClicked="wrapper.state = ''"/>
<!-- Make the default height equal the hight of the picture, plus margin. -->
@@ -57,7 +60,6 @@
<SetProperties target="{wrapper}" detailsOpacity="1" x="0"/>
<!-- Make the detailed view fill the entire list area -->
<SetProperty target="{wrapper}" property="height" value="{List.height}"/>
- <SetProperty target="{wrapper}" property="width" value="{List.width}"/>
<!-- Move the list so that this item is at the top. -->
<SetProperty target="{wrapper.ListView.view}" property="yPosition" value="{wrapper.y}"/>
<!-- Disallow flicking while we're in detailed view -->
diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp
index edcabaa..9a0c5bc 100644
--- a/src/corelib/animation/qpropertyanimation.cpp
+++ b/src/corelib/animation/qpropertyanimation.cpp
@@ -49,7 +49,7 @@
by itself as a simple animation class, or as part of more complex
animations through QAnimationGroup.
- The most common way to use QPropertyAnimation is to construct an instance
+ The most common way to use QPropertyAnimation is to construct an instance
of it by passing a pointer to a QObject or a QWidget, and the name of the
property you would like to animate to QPropertyAnimation's constructor.
@@ -220,11 +220,20 @@ void QPropertyAnimation::updateCurrentValue(const QVariant &value)
/*!
\reimp
+
+ If the startValue is not defined when the state of the animation changes from Stopped to Running,
+ the current property value is used as the initial value for the animation.
*/
void QPropertyAnimation::updateState(QAbstractAnimation::State oldState,
QAbstractAnimation::State newState)
{
Q_D(QPropertyAnimation);
+
+ if (!d->target) {
+ qWarning("QPropertyAnimation::updateState: Changing state of an animation without target");
+ return;
+ }
+
QVariantAnimation::updateState(oldState, newState);
QMutexLocker locker(guardHashLock());
QPropertyAnimationHash * hash = _q_runningAnimations();
@@ -235,20 +244,19 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State oldState,
if (oldAnim) {
// try to stop the top level group
QAbstractAnimation *current = oldAnim;
- while(current->group() && current->state() != Stopped) current = current->group();
+ while (current->group() && current->state() != Stopped)
+ current = current->group();
current->stop();
}
hash->insert(key, this);
- // Initialize start value
- // ### review this line below, d->atEnd() ?
- // ### avoid entering a state where start value is not set
- if (d->target && (d->atBeginning() || d->atEnd())) {
+
+ // update the default start value
+ if (oldState == Stopped) {
d->setDefaultStartValue(d->target->property(d->propertyName.constData()));
}
} else if (hash->value(key) == this) {
hash->remove(key);
}
-
}
#include "moc_qpropertyanimation.cpp"
diff --git a/src/corelib/animation/qvariantanimation_p.h b/src/corelib/animation/qvariantanimation_p.h
index 66910c1..14a3ef6 100644
--- a/src/corelib/animation/qvariantanimation_p.h
+++ b/src/corelib/animation/qvariantanimation_p.h
@@ -88,18 +88,6 @@ public:
return q->d_func();
}
-
- //some helper functions
- bool atBeginning() const
- {
- return currentTime == 0;
- }
-
- bool atEnd() const
- {
- return currentTime == duration && currentLoop == (loopCount - 1);
- }
-
void setDefaultStartValue(const QVariant &value);
int duration;
@@ -109,7 +97,7 @@ public:
QVariant currentValue;
QVariant defaultStartValue;
bool hasStartValue;
-
+
//this is used to keep track of the KeyValue interval in which we currently are
struct
{
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index ea66658..b4427c0 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -71,6 +71,27 @@ QT_BEGIN_NAMESPACE
# define FLT_DIG 6
#endif
+
+static const void *constDataHelper(const QVariant::Private &d)
+{
+ switch (d.type) {
+ case QVariant::Int:
+ return &d.data.i;
+ case QVariant::UInt:
+ return &d.data.u;
+ case QVariant::Bool:
+ return &d.data.b;
+ case QVariant::LongLong:
+ return &d.data.ll;
+ case QVariant::ULongLong:
+ return &d.data.ull;
+ case QVariant::Double:
+ return &d.data.d;
+ default:
+ return d.is_shared ? d.data.shared->ptr : reinterpret_cast<const void *>(&d.data.ptr);
+ }
+}
+
static void construct(QVariant::Private *x, const void *copy)
{
x->is_shared = false;
@@ -158,9 +179,6 @@ static void construct(QVariant::Private *x, const void *copy)
case QVariant::Double:
x->data.d = copy ? *static_cast<const double*>(copy) : 0.0;
break;
- case QMetaType::Float:
- x->data.f = copy ? *static_cast<const float*>(copy) : 0.0f;
- break;
case QVariant::LongLong:
x->data.ll = copy ? *static_cast<const qlonglong *>(copy) : Q_INT64_C(0);
break;
@@ -256,7 +274,6 @@ static void clear(QVariant::Private *d)
case QVariant::LongLong:
case QVariant::ULongLong:
case QVariant::Double:
- case QMetaType::Float:
break;
case QVariant::Invalid:
case QVariant::UserType:
@@ -474,7 +491,7 @@ static qlonglong qMetaTypeNumber(const QVariant::Private *d)
case QMetaType::Long:
return qlonglong(*static_cast<long *>(d->data.shared->ptr));
case QMetaType::Float:
- return qRound64(d->data.f);
+ return qRound64(*static_cast<float *>(d->data.shared->ptr));
case QVariant::Double:
return qRound64(d->data.d);
}
@@ -611,7 +628,7 @@ static bool convert(const QVariant::Private *d, QVariant::Type t, void *result,
*str = QString::number(qMetaTypeUNumber(d));
break;
case QMetaType::Float:
- *str = QString::number(d->data.f, 'g', FLT_DIG);
+ *str = QString::number(*static_cast<float *>(d->data.shared->ptr), 'g', FLT_DIG);
break;
case QVariant::Double:
*str = QString::number(d->data.d, 'g', DBL_DIG);
@@ -782,7 +799,7 @@ static bool convert(const QVariant::Private *d, QVariant::Type t, void *result,
*ba = QByteArray::number(d->data.d, 'g', DBL_DIG);
break;
case QMetaType::Float:
- *ba = QByteArray::number(d->data.f, 'g', FLT_DIG);
+ *ba = QByteArray::number(*static_cast<float *>(d->data.shared->ptr), 'g', FLT_DIG);
break;
case QMetaType::Char:
case QMetaType::UChar:
@@ -884,7 +901,7 @@ static bool convert(const QVariant::Private *d, QVariant::Type t, void *result,
*f = double(d->data.b);
break;
case QMetaType::Float:
- *f = double(d->data.f);
+ *f = *static_cast<float *>(d->data.shared->ptr);
break;
case QVariant::LongLong:
case QVariant::Int:
@@ -1338,7 +1355,7 @@ void QVariant::create(int type, const void *copy)
QVariant::~QVariant()
{
- if (d.type > Char && d.type != QMetaType::Float && (!d.is_shared || !d.data.shared->ref.deref()))
+ if (d.type > Char && (!d.is_shared || !d.data.shared->ref.deref()))
handler->clear(&d);
}
@@ -1354,7 +1371,7 @@ QVariant::QVariant(const QVariant &p)
{
if (d.is_shared) {
d.data.shared->ref.ref();
- } else if (p.d.type > Char && p.d.type != QMetaType::Float) {
+ } else if (p.d.type > Char) {
handler->construct(&d, p.constData());
d.is_null = p.d.is_null;
}
@@ -1548,12 +1565,6 @@ QVariant::QVariant(const char *val)
*/
/*!
- \fn QVariant::QVariant(float val)
-
- Constructs a new variant with a floating point value, \a val.
-*/
-
-/*!
\fn QVariant::QVariant(const QList<QVariant> &val)
Constructs a new variant with a list value, \a val.
@@ -1608,44 +1619,44 @@ QVariant::QVariant(double val)
{ d.is_null = false; d.type = Double; d.data.d = val; }
QVariant::QVariant(const QByteArray &val)
-{ d.is_null = false; d.type = ByteArray; v_construct<QByteArray>(&d, val); }
+{ create(ByteArray, &val); }
QVariant::QVariant(const QBitArray &val)
-{ d.is_null = false; d.type = BitArray; v_construct<QBitArray>(&d, val); }
+{ create(BitArray, &val); }
QVariant::QVariant(const QString &val)
-{ d.is_null = false; d.type = String; v_construct<QString>(&d, val); }
+{ create(String, &val); }
QVariant::QVariant(const QChar &val)
-{ d.is_null = false; d.type = Char; v_construct<QChar>(&d, val); }
+{ create (Char, &val); }
QVariant::QVariant(const QLatin1String &val)
-{ QString str(val); d.is_null = false; d.type = String; v_construct<QString>(&d, str); }
+{ QString str(val); create(String, &str); }
QVariant::QVariant(const QStringList &val)
-{ d.is_null = false; d.type = StringList; v_construct<QStringList>(&d, val); }
+{ create(StringList, &val); }
QVariant::QVariant(const QDate &val)
-{ d.is_null = false; d.type = Date; v_construct<QDate>(&d, val); }
+{ create(Date, &val); }
QVariant::QVariant(const QTime &val)
-{ d.is_null = false; d.type = Time; v_construct<QTime>(&d, val); }
+{ create(Time, &val); }
QVariant::QVariant(const QDateTime &val)
-{ d.is_null = false; d.type = DateTime; v_construct<QDateTime>(&d, val); }
+{ create(DateTime, &val); }
QVariant::QVariant(const QList<QVariant> &list)
-{ d.is_null = false; d.type = List; v_construct<QVariantList>(&d, list); }
+{ create(List, &list); }
QVariant::QVariant(const QMap<QString, QVariant> &map)
-{ d.is_null = false; d.type = Map; v_construct<QVariantMap>(&d, map); }
+{ create(Map, &map); }
QVariant::QVariant(const QHash<QString, QVariant> &hash)
-{ d.is_null = false; d.type = Hash; v_construct<QVariantHash>(&d, hash); }
+{ create(Hash, &hash); }
#ifndef QT_NO_GEOM_VARIANT
-QVariant::QVariant(const QPoint &pt) { d.is_null = false; d.type = Point; v_construct<QPoint>(&d, pt); }
-QVariant::QVariant(const QPointF &pt) { d.is_null = false; d.type = PointF; v_construct<QPointF>(&d, pt); }
-QVariant::QVariant(const QRectF &r) { d.is_null = false; d.type = RectF; v_construct<QRectF>(&d, r); }
-QVariant::QVariant(const QLineF &l) { d.is_null = false; d.type = LineF; v_construct<QLineF>(&d, l); }
-QVariant::QVariant(const QLine &l) { d.is_null = false; d.type = Line; v_construct<QLine>(&d, l); }
-QVariant::QVariant(const QRect &r) { d.is_null = false; d.type = Rect; v_construct<QRect>(&d, r); }
-QVariant::QVariant(const QSize &s) { d.is_null = false; d.type = Size; v_construct<QSize>(&d, s); }
-QVariant::QVariant(const QSizeF &s) { d.is_null = false; d.type = SizeF; v_construct<QSizeF>(&d, s); }
+QVariant::QVariant(const QPoint &pt) { create(Point, &pt); }
+QVariant::QVariant(const QPointF &pt) { create (PointF, &pt); }
+QVariant::QVariant(const QRectF &r) { create (RectF, &r); }
+QVariant::QVariant(const QLineF &l) { create (LineF, &l); }
+QVariant::QVariant(const QLine &l) { create (Line, &l); }
+QVariant::QVariant(const QRect &r) { create(Rect, &r); }
+QVariant::QVariant(const QSize &s) { create(Size, &s); }
+QVariant::QVariant(const QSizeF &s) { create(SizeF, &s); }
#endif
-QVariant::QVariant(const QUrl &u) { d.is_null = false; d.type = Url; v_construct<QUrl>(&d, u); }
-QVariant::QVariant(const QLocale &l) { d.is_null = false; d.type = Locale; v_construct<QLocale>(&d, l); }
+QVariant::QVariant(const QUrl &u) { create(Url, &u); }
+QVariant::QVariant(const QLocale &l) { create(Locale, &l); }
#ifndef QT_NO_REGEXP
-QVariant::QVariant(const QRegExp &regExp) { d.is_null = false; d.type = RegExp; v_construct<QRegExp>(&d, regExp); }
+QVariant::QVariant(const QRegExp &regExp) { create(RegExp, &regExp); }
#endif
QVariant::QVariant(Qt::GlobalColor color) { create(62, &color); }
@@ -1710,7 +1721,7 @@ QVariant& QVariant::operator=(const QVariant &variant)
if (variant.d.is_shared) {
variant.d.data.shared->ref.ref();
d = variant.d;
- } else if (variant.d.type > Char && variant.d.type != QMetaType::Float) {
+ } else if (variant.d.type > Char) {
d.type = variant.d.type;
handler->construct(&d, variant.constData());
d.is_null = variant.d.is_null;
@@ -1896,7 +1907,7 @@ void QVariant::load(QDataStream &s)
}
// const cast is safe since we operate on a newly constructed variant
- if (!QMetaType::load(s, d.type, const_cast<void *>(constData()))) {
+ if (!QMetaType::load(s, d.type, const_cast<void *>(constDataHelper(d)))) {
s.setStatus(QDataStream::ReadCorruptData);
qWarning("QVariant::load: unable to load type %d.", d.type);
}
@@ -1936,7 +1947,7 @@ void QVariant::save(QDataStream &s) const
return;
}
- if (!QMetaType::save(s, d.type, constData())) {
+ if (!QMetaType::save(s, d.type, constDataHelper(d))) {
Q_ASSERT_X(false, "QVariant::save", "Invalid type to save");
qWarning("QVariant::save: unable to save type %d.", d.type);
}
@@ -2715,7 +2726,7 @@ bool QVariant::cmp(const QVariant &v) const
const void *QVariant::constData() const
{
- return d.is_shared ? d.data.shared->ptr : reinterpret_cast<const void *>(&d.data.ptr);
+ return constDataHelper(d);
}
/*!
@@ -2728,7 +2739,7 @@ const void *QVariant::constData() const
void* QVariant::data()
{
detach();
- return const_cast<void *>(constData());
+ return const_cast<void *>(constDataHelper(d));
}
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index d73fcbc..580b101 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -128,7 +128,7 @@ class Q_CORE_EXPORT QVariant
LineF = 24,
Point = 25,
PointF = 26,
- RegExp = 27,
+ RegExp = 27,
Hash = 28,
LastCoreType = Hash,
@@ -181,7 +181,6 @@ class Q_CORE_EXPORT QVariant
QVariant(qulonglong ull);
QVariant(bool b);
QVariant(double d);
- QVariant(float f) { d.is_null = false; d.type = QMetaType::Float; d.data.f = f; }
#ifndef QT_NO_CAST_FROM_ASCII
QT_ASCII_CAST_WARN_CONSTRUCTOR QVariant(const char *str);
#endif
@@ -350,7 +349,6 @@ class Q_CORE_EXPORT QVariant
uint u;
bool b;
double d;
- float f;
qlonglong ll;
qulonglong ull;
void *ptr;
@@ -445,18 +443,7 @@ inline QVariant qVariantFromValue(const QVariant &t) { return t; }
template <typename T>
inline void qVariantSetValue(QVariant &v, const T &t)
{
- //if possible we reuse the current QVariant private
- const int type = qMetaTypeId<T>(reinterpret_cast<T *>(0));
- QVariant::Private &d = v.data_ptr();
- if (type <= int(QVariant::Char) || (type == d.type && v.isDetached())) {
- d.type = type;
- T *old = reinterpret_cast<T*>(d.is_shared ? d.data.shared->ptr : &d.data.ptr);
- if (QTypeInfo<T>::isComplex)
- old->~T();
- new (old) T(t); //call the copy constructor
- } else {
- v = QVariant(type, &t);
- }
+ v = QVariant(qMetaTypeId<T>(reinterpret_cast<T *>(0)), &t);
}
inline QVariant::QVariant() {}
diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h
index 727a390..0764fe3 100644
--- a/src/corelib/kernel/qvariant_p.h
+++ b/src/corelib/kernel/qvariant_p.h
@@ -60,6 +60,8 @@
QT_BEGIN_NAMESPACE
+extern Q_CORE_EXPORT const QVariant::Handler *qExtendedVariantHandler;
+
#ifdef Q_CC_SUN // Sun CC picks the wrong overload, so introduce awful hack
template <typename T>
@@ -68,7 +70,7 @@ inline T *v_cast(const QVariant::Private *nd, T * = 0)
QVariant::Private *d = const_cast<QVariant::Private *>(nd);
return ((sizeof(T) > sizeof(QVariant::Private::Data))
? static_cast<T *>(d->data.shared->ptr)
- : static_cast<T *>(static_cast<void *>(&d->data.c)));
+ : reinterpret_cast<T*>(&d->data.c));
}
#else // every other compiler in this world
@@ -78,7 +80,7 @@ inline const T *v_cast(const QVariant::Private *d, T * = 0)
{
return ((sizeof(T) > sizeof(QVariant::Private::Data))
? static_cast<const T *>(d->data.shared->ptr)
- : static_cast<const T *>(static_cast<const void *>(&d->data.c)));
+ : reinterpret_cast<const T *>(&d->data.c));
}
template <typename T>
@@ -86,37 +88,56 @@ inline T *v_cast(QVariant::Private *d, T * = 0)
{
return ((sizeof(T) > sizeof(QVariant::Private::Data))
? static_cast<T *>(d->data.shared->ptr)
- : static_cast<T *>(static_cast<void *>(&d->data.c)));
+ : reinterpret_cast<T *>(&d->data.c));
}
#endif
+//a simple template that avoids to allocate 2 buffers when creating a QVariant
+template <class T> class QVariantPrivateSharedEx : public QVariant::PrivateShared
+{
+public:
+ QVariantPrivateSharedEx(const T&t) : QVariant::PrivateShared(&m_t), m_t(t) { }
+
+private:
+ T m_t;
+};
+
// constructs a new variant if copy is 0, otherwise copy-constructs
template <class T>
-inline void v_construct(QVariant::Private *x, const void *copy, T * = 0)
+inline void v_construct(QVariant::Private *x, const T& t)
{
+ x->type = qMetaTypeId<T>(reinterpret_cast<T *>(0));
if (sizeof(T) > sizeof(QVariant::Private::Data)) {
- x->data.shared = copy ? new QVariant::PrivateShared(new T(*static_cast<const T *>(copy)))
- : new QVariant::PrivateShared(new T);
+ x->data.shared = new QVariantPrivateSharedEx<T>(t);
x->is_shared = true;
} else {
- if (copy)
- new (&x->data.ptr) T(*static_cast<const T *>(copy));
- else
- new (&x->data.ptr) T;
+ x->is_shared = false;
+ new (&x->data.ptr) T(t);
+ }
+}
+
+template <class T>
+inline void v_construct(QVariant::Private *x, const void *copy, T * = 0)
+{
+ if (copy) {
+ v_construct<T>(x, *reinterpret_cast<const T*>(copy));
+ } else {
+ T t;
+ v_construct<T>(x, t);
}
}
+
// deletes the internal structures
template <class T>
inline void v_clear(QVariant::Private *d, T* = 0)
{
- if (sizeof(T) > sizeof(QVariant::Private::Data)) {
- delete v_cast<T>(d);
+ //now we need to call the destructor in any case
+ //because QVariant::PrivateShared doesn't have a virtual destructor
+ v_cast<T>(d)->~T();
+ if (sizeof(T) > sizeof(QVariant::Private::Data))
delete d->data.shared;
- } else {
- v_cast<T>(d)->~T();
- }
}
QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index 803f2b2..729d53a 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -323,8 +323,8 @@ void QmlAbstractAnimation::setRepeat(bool r)
return;
d->repeat = r;
- int ic = r ? -1 : 1;
- qtAnimation()->setIterationCount(ic);
+ int lc = r ? -1 : 1;
+ qtAnimation()->setLoopCount(lc);
emit repeatChanged(r);
}
diff --git a/src/gui/animation/qguivariantanimation.cpp b/src/gui/animation/qguivariantanimation.cpp
index 46ba251..ed18caa 100644
--- a/src/gui/animation/qguivariantanimation.cpp
+++ b/src/gui/animation/qguivariantanimation.cpp
@@ -41,8 +41,6 @@
#ifndef QT_NO_ANIMATION
-QT_BEGIN_NAMESPACE
-
#ifdef QT_EXPERIMENTAL_SOLUTION
# include "qvariantanimation.h"
# include "qvariantanimation_p.h"
@@ -51,6 +49,9 @@ QT_BEGIN_NAMESPACE
#include <private/qvariantanimation_p.h>
#endif
+#include <QtGui/qcolor.h>
+
+QT_BEGIN_NAMESPACE
template<> Q_INLINE_TEMPLATE QColor _q_interpolate(const QColor &f,const QColor &t, qreal progress)
{
diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro
index f9fa0d0..ad75a5f 100644
--- a/src/opengl/opengl.pro
+++ b/src/opengl/opengl.pro
@@ -25,7 +25,6 @@ HEADERS += qgl.h \
qglcolormap.h \
qglpixelbuffer.h \
qglframebufferobject.h \
- qglpixmapfilter_p.h \
qglshaderprogram.h
SOURCES += qgl.cpp \
@@ -33,11 +32,10 @@ SOURCES += qgl.cpp \
qglpixelbuffer.cpp \
qglframebufferobject.cpp \
qglextensions.cpp \
- qglpixmapfilter.cpp \
qglshaderprogram.cpp
!contains(QT_CONFIG, opengles2) {
- HEADERS += qpaintengine_opengl_p.h qglpixmapfilter_p.h
+ HEADERS += qpaintengine_opengl_p.h qglpixmapfilter_p.h
SOURCES += qpaintengine_opengl.cpp qglpixmapfilter.cpp
}
diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
index 437c862..f0deab5 100644
--- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
+++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
@@ -84,6 +84,7 @@ private slots:
void deletion3();
void duration0();
void noStartValue();
+ void noStartValueWithLoop();
void startWhenAnotherIsRunning();
void easingcurve_data();
void easingcurve();
@@ -416,6 +417,27 @@ void tst_QPropertyAnimation::noStartValue()
QCOMPARE(o.values.last(), 420);
}
+void tst_QPropertyAnimation::noStartValueWithLoop()
+{
+ StartValueTester o;
+ o.setProperty("ole", 42);
+ o.values.clear();
+
+ QPropertyAnimation a(&o, "ole");
+ a.setEndValue(420);
+ a.setDuration(250);
+ a.setLoopCount(2);
+ a.start();
+
+ a.setCurrentTime(250);
+ QCOMPARE(o.values.first(), 42);
+ QCOMPARE(a.currentValue().toInt(), 42);
+ QCOMPARE(o.values.last(), 42);
+
+ a.setCurrentTime(500);
+ QCOMPARE(a.currentValue().toInt(), 420);
+}
+
void tst_QPropertyAnimation::startWhenAnotherIsRunning()
{
StartValueTester o;