summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-11-05 10:18:08 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-11-05 10:18:08 (GMT)
commit1ead772e1d4c80723f40ec4562c196e63197bfc0 (patch)
treec761aee465c6d08572184f39fe895f695c746391
parent39b3fcba96d6f9d7d7b96d3c875ef569a3083898 (diff)
parentcf1f8532934cefb15cc76ef355706e9909527632 (diff)
downloadQt-1ead772e1d4c80723f40ec4562c196e63197bfc0.zip
Qt-1ead772e1d4c80723f40ec4562c196e63197bfc0.tar.gz
Qt-1ead772e1d4c80723f40ec4562c196e63197bfc0.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslistview.cpp4
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsparticles.cpp22
-rw-r--r--tests/auto/declarative/listview/tst_listview.cpp6
-rw-r--r--tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp6
-rw-r--r--tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp4
-rw-r--r--tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp6
6 files changed, 31 insertions, 17 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
index f9d4190..1f5d51d 100644
--- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
@@ -1461,6 +1461,10 @@ void QmlGraphicsListView::setSectionExpression(const QString &expression)
}
}
+/*!
+ \qmlproperty string ListView::currentSection
+ This property holds the section that is currently at the beginning of the view.
+*/
QString QmlGraphicsListView::currentSection() const
{
Q_D(const QmlGraphicsListView);
diff --git a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp
index 92943e8..4ac02b4 100644
--- a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp
@@ -302,7 +302,7 @@ void QmlGraphicsParticleMotionWander::advance(QmlGraphicsParticle &p, int interv
qreal xdiff = p.x_velocity - d->x_targetV;
if ((xdiff > d->x_peak && d->x_var > 0.0) || (xdiff < -d->x_peak && d->x_var < 0.0)) {
d->x_var = -d->x_var;
- d->x_peak = _xvariance + _xvariance * qreal(rand()) / RAND_MAX;
+ d->x_peak = _xvariance + _xvariance * qreal(qrand()) / RAND_MAX;
}
p.x_velocity += d->x_var * interval;
}
@@ -312,7 +312,7 @@ void QmlGraphicsParticleMotionWander::advance(QmlGraphicsParticle &p, int interv
qreal ydiff = p.y_velocity - d->y_targetV;
if ((ydiff > d->y_peak && d->y_var > 0.0) || (ydiff < -d->y_peak && d->y_var < 0.0)) {
d->y_var = -d->y_var;
- d->y_peak = _yvariance + _yvariance * qreal(rand()) / RAND_MAX;
+ d->y_peak = _yvariance + _yvariance * qreal(qrand()) / RAND_MAX;
}
p.y_velocity += d->y_var * interval;
}
@@ -329,8 +329,8 @@ void QmlGraphicsParticleMotionWander::created(QmlGraphicsParticle &p)
d->y_targetV = p.y_velocity;
d->x_peak = _xvariance;
d->y_peak = _yvariance;
- d->x_var = _pace * qreal(rand()) / RAND_MAX / 1000.0;
- d->y_var = _pace * qreal(rand()) / RAND_MAX / 1000.0;
+ d->x_var = _pace * qreal(qrand()) / RAND_MAX / 1000.0;
+ d->y_var = _pace * qreal(qrand()) / RAND_MAX / 1000.0;
}
}
@@ -456,7 +456,7 @@ void QmlGraphicsParticlesPrivate::tick(int time)
if (emissionRate != -1){
qreal variance = 1.;
if (emissionVariance > 0.){
- variance += (qreal(rand())/RAND_MAX) * emissionVariance * (rand()%2?-1.:1.);
+ variance += (qreal(qrand())/RAND_MAX) * emissionVariance * (qrand()%2?-1.:1.);
}
qreal emission = emissionRate * (qreal(interval)/1000.);
emission = emission * variance + emissionCarry;
@@ -478,7 +478,7 @@ void QmlGraphicsParticlesPrivate::tick(int time)
}else{
qreal variance = 1.;
if (emissionVariance > 0.){
- variance += (qreal(rand())/RAND_MAX) * emissionVariance * (rand()%2?-1.:1.);
+ variance += (qreal(qrand())/RAND_MAX) * emissionVariance * (qrand()%2?-1.:1.);
}
qreal workingEmission = bursts[i].second * (qreal(interval)/1000.);
workingEmission *= variance;
@@ -510,11 +510,11 @@ void QmlGraphicsParticlesPrivate::createParticle(int time)
#endif
Q_Q(QmlGraphicsParticles);
QmlGraphicsParticle p(time);
- p.x = q->x() + q->width() * qreal(rand()) / RAND_MAX - image.width()/2.0;
- p.y = q->y() + q->height() * qreal(rand()) / RAND_MAX - image.height()/2.0;
+ p.x = q->x() + q->width() * qreal(qrand()) / RAND_MAX - image.width()/2.0;
+ p.y = q->y() + q->height() * qreal(qrand()) / RAND_MAX - image.height()/2.0;
p.lifeSpan = lifeSpan;
if (lifeSpanDev)
- p.lifeSpan += int(lifeSpanDev/2 - lifeSpanDev * qreal(rand()) / RAND_MAX);
+ p.lifeSpan += int(lifeSpanDev/2 - lifeSpanDev * qreal(qrand()) / RAND_MAX);
p.fadeOutAge = p.lifeSpan - fadeOutDur;
if (fadeInDur == 0.) {
p.state= QmlGraphicsParticle::Solid;
@@ -522,12 +522,12 @@ void QmlGraphicsParticlesPrivate::createParticle(int time)
}
qreal a = angle;
if (angleDev)
- a += angleDev/2 - angleDev * qreal(rand()) / RAND_MAX;
+ a += angleDev/2 - angleDev * qreal(qrand()) / RAND_MAX;
if (a > M_PI)
a = a - 2 * M_PI;
qreal v = velocity;
if (velocityDev)
- v += velocityDev/2 - velocityDev * qreal(rand()) / RAND_MAX;
+ v += velocityDev/2 - velocityDev * qreal(qrand()) / RAND_MAX;
p.x_velocity = v * fastCos(a);
p.y_velocity = v * fastSin(a);
particles.append(p);
diff --git a/tests/auto/declarative/listview/tst_listview.cpp b/tests/auto/declarative/listview/tst_listview.cpp
index b8f87b7..5575ace 100644
--- a/tests/auto/declarative/listview/tst_listview.cpp
+++ b/tests/auto/declarative/listview/tst_listview.cpp
@@ -671,6 +671,7 @@ void tst_QmlGraphicsListView::spacing()
}
listview->setSpacing(10);
+ QVERIFY(listview->spacing() == 10);
// Confirm items positioned correctly
itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
@@ -723,6 +724,11 @@ void tst_QmlGraphicsListView::sections()
QCOMPARE(item->y(), qreal(i*20 + ((i+4)/5) * 20));
}
+ QVERIFY(listview->currentSection() == "0");
+
+ listview->setViewportY(140);
+ QVERIFY(listview->currentSection() == "1");
+
delete canvas;
}
diff --git a/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp b/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp
index 7bc6121..19d5998 100644
--- a/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp
+++ b/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include <qtest.h>
#include "../../../shared/util.h"
+#include <math.h>
#include <QFile>
#include <QTextDocument>
#include <QtDeclarative/qmlengine.h>
@@ -183,8 +184,9 @@ void tst_qfxtextedit::width()
for (int i = 0; i < standard.size(); i++)
{
QFont f;
- QFontMetrics fm(f);
- int metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
+ QFontMetricsF fm(f);
+ qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
+ metricWidth = floor(metricWidth);
QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + standard.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
diff --git a/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp b/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp
index 2dc096d..8eeb22d 100644
--- a/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp
+++ b/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp
@@ -132,8 +132,8 @@ void tst_qfxtextinput::width()
for (int i = 0; i < standard.size(); i++)
{
QFont f;
- QFontMetrics fm(f);
- int metricWidth = fm.width(standard.at(i));
+ QFontMetricsF fm(f);
+ qreal metricWidth = fm.width(standard.at(i));
QString componentStr = "import Qt 4.6\nTextInput { text: \"" + standard.at(i) + "\" }";
QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
diff --git a/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp b/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp
index ba5c835..2a3cdde 100644
--- a/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp
+++ b/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp
@@ -45,6 +45,7 @@
#include <private/qmlgraphicstext_p.h>
#include <private/qmlvaluetype_p.h>
#include <QFontMetrics>
+#include <math.h>
class tst_qmlgraphicstext : public QObject
@@ -201,8 +202,9 @@ void tst_qmlgraphicstext::width()
QVERIFY(!Qt::mightBeRichText(standard.at(i))); // self-test
QFont f;
- QFontMetrics fm(f);
- int metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
+ QFontMetricsF fm(f);
+ qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
+ metricWidth = floor(metricWidth);
QString componentStr = "import Qt 4.6\nText { text: \"" + standard.at(i) + "\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));