summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Griebl <rgriebl@trolltech.com>2010-04-19 13:48:59 +0200
committerRobert Griebl <rgriebl@trolltech.com>2010-04-19 13:48:59 +0200
commit9f0f67985982b08660c44ee921fdf5d05f46d712 (patch)
tree3200366eac9bbc167e1fc8d1bd42ea96dce78d47
parente5e41d0c981777236ce407e2c0131715e83d498b (diff)
cleanup
-rw-r--r--.gitignore8
-rw-r--r--plotwidget.cpp68
-rw-r--r--plotwidget.h44
-rw-r--r--qkineticscroller.cpp51
-rw-r--r--settingswidget.cpp43
-rw-r--r--settingswidget.h41
6 files changed, 209 insertions, 46 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..484f1df
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,8 @@
+*~
+*.bak
+moc_*
+*.o
+*.moc
+Makefile
+kineticscroller
+kineticscroller.app
diff --git a/plotwidget.cpp b/plotwidget.cpp
index 41a2f72..0564df2 100644
--- a/plotwidget.cpp
+++ b/plotwidget.cpp
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** 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 QtGui 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 <QtGui>
#include "plotwidget.h"
@@ -11,18 +52,18 @@ PlotWidget::PlotWidget(QKineticScroller *scroller)
m_clear = new QPushButton(QLatin1String("Clear"), this);
connect(m_clear, SIGNAL(clicked()), this, SLOT(reset()));
- m_legend = new QLabel(QLatin1String("Legend"), this);
- QString tooltip;
- QTextStream ts(&tooltip);
+ m_legend = new QLabel(this);
+ QString legend;
+ QTextStream ts(&legend);
ts << "<table border=\"0\">";
- ts << "<tr><td width=\"30\" bgcolor=\"" << QColor(Qt::red).dark().name() << "\" /><td>releaseVelocity X</td></tr>";
- ts << "<tr><td width=\"30\" bgcolor=\"" << QColor(Qt::red).light().name() << "\" /><td>releaseVelocity Y</td></tr>";
- ts << "<tr><td width=\"30\" bgcolor=\"" << QColor(Qt::green).dark().name() << "\" /><td>Content Position X</td></tr>";
- ts << "<tr><td width=\"30\" bgcolor=\"" << QColor(Qt::green).light().name() << "\" /><td>Content Position Y</td></tr>";
- ts << "<tr><td width=\"30\" bgcolor=\"" << QColor(Qt::blue).dark().name() << "\" /><td>Overshoot Position X</td></tr>";
- ts << "<tr><td width=\"30\" bgcolor=\"" << QColor(Qt::blue).light().name() << "\" /><td>Overshoot Position Y</td></tr>";
+ ts << "<tr><td width=\"30\" bgcolor=\"" << QColor(Qt::red).light().name() << "\" /><td>releaseVelocity X</td></tr>";
+ ts << "<tr><td width=\"30\" bgcolor=\"" << QColor(Qt::red).dark().name() << "\" /><td>releaseVelocity Y</td></tr>";
+ ts << "<tr><td width=\"30\" bgcolor=\"" << QColor(Qt::green).light().name() << "\" /><td>Content Position X</td></tr>";
+ ts << "<tr><td width=\"30\" bgcolor=\"" << QColor(Qt::green).dark().name() << "\" /><td>Content Position Y</td></tr>";
+ ts << "<tr><td width=\"30\" bgcolor=\"" << QColor(Qt::blue).light().name() << "\" /><td>Overshoot Position X</td></tr>";
+ ts << "<tr><td width=\"30\" bgcolor=\"" << QColor(Qt::blue).dark().name() << "\" /><td>Overshoot Position Y</td></tr>";
ts << "</table>";
- m_legend->setToolTip(tooltip);
+ m_legend->setText(legend);
}
void PlotWidget::debugHook(void *user, const QPointF &releaseVelocity, const QPointF &contentPosition, const QPointF &overshootPosition)
@@ -89,12 +130,7 @@ void PlotWidget::paintEvent(QPaintEvent *)
if (offset > 0)
it += (offset - 1);
-// PlotItem &last = const_cast<PlotItem &>(*it++);
-// PlotItem dummy;
- const PlotItem *last = &(*it++);
-// last = *it++;
-
-// qWarning() << "lastOp[0].y = " << last.overshootPosition.y() << m_plotitems.at(1).overshootPosition.y();
+ const PlotItem *last = &(*it++);
while (it != m_plotitems.constEnd()) {
p.setPen(rvColor.light());
diff --git a/plotwidget.h b/plotwidget.h
index c555b13..80e76ad 100644
--- a/plotwidget.h
+++ b/plotwidget.h
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** 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 QtGui 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 PLOTWIDGET_H
#define PLOTWIDGET_H
@@ -33,7 +74,8 @@ private:
QKineticScroller *m_scroller;
QList<PlotItem> m_plotitems;
qreal minMaxVelocity, minMaxPosition;
- QWidget *m_clear, *m_legend;
+ QPushButton *m_clear;
+ QLabel *m_legend;
};
#endif
diff --git a/qkineticscroller.cpp b/qkineticscroller.cpp
index 951b9f7..b9c31a8 100644
--- a/qkineticscroller.cpp
+++ b/qkineticscroller.cpp
@@ -331,7 +331,7 @@ bool QKineticScroller::handleInput(Input input, const QPointF &position, qint64
Q_D(QKineticScroller);
-qKSDebug() << __PRETTY_FUNCTION__ << input << "pos: " << position << "timestamp: " << timestamp;
+ qKSDebug() << "QKS::handleInput(" << input << ", " << position << ", " << timestamp << ")";
struct statechange {
State state;
Input input;
@@ -498,7 +498,7 @@ void QKineticScroller::setDpiFromWidget(QWidget *widget)
void QKineticScrollerPrivate::updateVelocity(const QPointF &deltaPixelRaw, qint64 deltaTime)
{
- qKSDebug() << "updateVelocity(dP = " << deltaPixelRaw << " [pix], dT = " << deltaTime << " [ms]) -- velocity: " << releaseVelocity << "[m/s]";
+ qKSDebug() << "QKS::updateVelocity(" << deltaPixelRaw << " [delta pix], " << deltaTime << " [delta ms])";
QPointF deltaPixel = deltaPixelRaw;
@@ -517,7 +517,7 @@ void QKineticScrollerPrivate::updateVelocity(const QPointF &deltaPixelRaw, qint6
if (deltaPixel.y())
releaseVelocity.setY(qBound(-maximumVelocity, newv.y(), maximumVelocity));
- qKSDebug() << "resulting new velocity:" << releaseVelocity;
+ qKSDebug() << " --> new velocity:" << releaseVelocity;
}
qreal QKineticScrollerPrivate::decelerate(qreal v, qreal t)
@@ -597,7 +597,7 @@ void QKineticScrollerPrivate::handleDrag(const QPointF &position, qint64 timesta
if (dx || dy) {
bool vertical = (dy > dx);
qreal alpha = qreal(vertical ? dx : dy) / qreal(vertical ? dy : dx);
- //qKSDebug() << "axis lock: " << alpha << " / " << axisLockThreshold << " - isvertical: " << vertical << " - dx: " << dx << " - dy: " << dy;
+ //qKSDebug() << "QKS::handleDrag() -- axis lock:" << alpha << " / " << axisLockThreshold << "- isvertical:" << vertical << "- dx:" << dx << "- dy:" << dy;
if (alpha <= axisLockThreshold) {
if (vertical)
deltaPixel.setX(0);
@@ -721,7 +721,7 @@ bool QKineticScrollerPrivate::moveWhileDragging(QKineticScroller::Input, const Q
void QKineticScrollerPrivate::timerEventWhileDragging()
{
if (!dragDistance.isNull()) {
- qDebug() << "timerEventWhileDragging" << dragDistance;
+ qKSDebug() << "QKS::timerEventWhileDragging() -- dragDistance:" << dragDistance;
setContentPositionHelper(-dragDistance);
dragDistance = QPointF(0, 0);
@@ -769,7 +769,7 @@ bool QKineticScrollerPrivate::releaseWhileDragging(QKineticScroller::Input, cons
}
- qKSDebug() << "release While dragging, velocity: "<<releaseVelocity<<"minimum velocity"<<minimumVelocity;
+ qKSDebug() << "QKS::releaseWhileDragging() -- velocity:" << releaseVelocity << "-- minimum velocity:" << minimumVelocity;
if (overshootX || overshootY)
setState(QKineticScroller::StateScrolling);
else if (releaseVelocity >= minimumVelocity)
@@ -794,7 +794,7 @@ void QKineticScrollerPrivate::timerEventWhileScrolling()
if (!deltaPos.isNull())
setContentPositionHelper(deltaPos);
- qWarning() << "DeltaPos: " << deltaPos << " - newVel: " << newVelocity << " - Time: " << time << " - PPM: " << pixelPerMeter;
+ qKSDebug() << "QKS::timerEventWhileScrolling() -- DeltaPos:" << deltaPos << "- NewVel:" << newVelocity << "- Time:" << time;
if (newVelocity.isNull() ||
(releaseVelocity.isNull() && !scrollToX && !scrollToY && !overshootX && !overshootY))
@@ -815,7 +815,7 @@ void QKineticScrollerPrivate::setState(QKineticScroller::State newstate)
if (state == newstate)
return;
- qWarning() << "Switching to state " << stateName(newstate);
+ qKSDebug() << "QKS::setState(" << stateName(newstate) << ")";
switch (newstate) {
case QKineticScroller::StateInactive:
@@ -824,7 +824,7 @@ void QKineticScrollerPrivate::setState(QKineticScroller::State newstate)
killTimer(timerId);
timerId = 0;
} else {
- qWarning() << "State change from " << stateName(state) << " to " << stateName(newstate) << ", but timer is not active.";
+ qKSDebug() << " --> state change from " << stateName(state) << " to " << stateName(newstate) << ", but timer is not active.";
}
}
releaseVelocity = QPointF(0, 0);
@@ -848,7 +848,7 @@ void QKineticScrollerPrivate::setState(QKineticScroller::State newstate)
if (!timerId) {
timerId = startTimer(1000 / framesPerSecond);
} else {
- qWarning() << "State change from " << stateName(state) << " to " << stateName(newstate) << ", but timer is already active.";
+ qKSDebug() << " --> state change from " << stateName(state) << " to " << stateName(newstate) << ", but timer is already active.";
}
}
@@ -894,6 +894,8 @@ void QKineticScroller::scrollTo(const QPointF &pos, int scrollTime)
if (scrollTime <= 0)
scrollTime = 1;
+ qKSDebug() << "QKS::scrollTo(" << pos << " [pix], " << scrollTime << " [ms])";
+
qreal time = qreal(scrollTime) / 1000;
if ((pos == contentPosition()) ||
@@ -904,21 +906,17 @@ void QKineticScroller::scrollTo(const QPointF &pos, int scrollTime)
// estimate the minimal start velocity
// if the start velocity is below that then the scrolling would stop before scrollTime.
- qreal vMin = d->linearDecelerationFactor * time / qPow(d->exponentialDecelerationBase, time);
+ //qreal vMin = d->linearDecelerationFactor * time / qPow(d->exponentialDecelerationBase, time);
/*
// estimate of the distance passed within the vMin time during scrollTime
qreal distMin = qreal(scrollTime) * vMin / 2.0;
- qKSDebug() << "QAbstractKineticScroller::scrollTo v, dis(" << vMin << ", " << distMin;
-
QPointF v = QPointF((pos.x()-contentPosition().x()) / distMin * vMin,
(pos.y()-contentPosition().y()) / distMin * vMin);
*/
- // qKSDebug() << "QAbstractKineticScroller::scrollTo(" << pos << ", " << v;
-
// v(t) = vstart * exponentialDecelerationBase ^ t - linearDecelerationFactor * t
// pos(t) = integrate(v(t) * dt)
// pos(t) = vstart * (eDB ^ t / ln(eDB) + C) - lDF / 2 * t ^ 2
@@ -927,8 +925,8 @@ void QKineticScroller::scrollTo(const QPointF &pos, int scrollTime)
// vstart = ((lDF / 2) * time ^ 2 + (pos - contentPos())) / (eDB ^ time / ln(eDB) + C)
// (for C = -1/ln(eDB) )
- QPointF scrollDir(qSign(pos.x()-contentPosition().x()),
- qSign(pos.y()-contentPosition().y()));
+ QPointF scrollDir(qSign(pos.x() - contentPosition().x()),
+ qSign(pos.y() - contentPosition().y()));
QPointF v = (scrollDir * (d->linearDecelerationFactor / qreal(2)) * qreal(time) * qreal(time) + (pos - contentPosition()) / d->pixelPerMeter);
if (d->exponentialDecelerationBase != qreal(1))
@@ -936,13 +934,6 @@ void QKineticScroller::scrollTo(const QPointF &pos, int scrollTime)
else
v /= time;
- qKSDebug() << "QAbstractKineticScroller::scrollTo pos:" << pos << "v:" << v <<"minV:"<<vMin;
- qKSDebug() << "QAbstr " << d->linearDecelerationFactor <<" 1: "<< (qreal(2) * qreal(time) * qreal(scrollTime)) << " 2: " << (pos - contentPosition()) << " 3: " <<
- qLn(d->exponentialDecelerationBase) << "4: " << qPow(d->exponentialDecelerationBase, time)
- << " 5: "<<((qPow(d->exponentialDecelerationBase, time) - 1) / qLn(d->exponentialDecelerationBase));
-
-
- // start the scrolling
d->scrollToPosition = pos;
d->scrollToX = true;
d->scrollToY = true;
@@ -968,7 +959,8 @@ void QKineticScroller::ensureVisible(const QPointF &pos, int xmargin, int ymargi
QSizeF visible = viewportSize();
QPointF currentPos = contentPosition();
- qKSDebug() << "QAbstractKineticScroller::ensureVisible(" << pos << ", " << xmargin << ", " << ymargin << ") - position: " << contentPosition();
+ qKSDebug() << "QKS::ensureVisible(" << pos << " [pix], " << xmargin << " [pix], " << ymargin << " [pix], " << scrollTime << "[ms])";
+ qKSDebug() << " --> content position:" << contentPosition();
QRectF posRect(pos.x() - xmargin, pos.y() - ymargin, 2 * xmargin, 2 * ymargin);
QRectF visibleRect(currentPos, visible);
@@ -1016,7 +1008,8 @@ void QKineticScrollerPrivate::setContentPositionHelper(const QPointF &deltaPos)
QPointF oldScrollToDist = scrollToPosition - oldPos;
QPointF newScrollToDist = scrollToPosition - newPos;
- qDebug() << "setContentPositionHelper overshoot:"<<overshootPosition<<"delta:"<<deltaPos<<"old:" << oldPos << " new:" << newPos;
+ qKSDebug() << "QKS::setContentPositionHelper(" << deltaPos << " [pix])";
+ qKSDebug() << " --> overshoot:" << overshootPosition << "- old pos:" << oldPos << "- new pos:" << newPos;
QPointF oldClampedPos;
oldClampedPos.setX(qBound(qreal(0), oldPos.x(), maxPos.x()));
@@ -1063,7 +1056,7 @@ void QKineticScrollerPrivate::setContentPositionHelper(const QPointF &deltaPos)
scrollToY = false;
// --- handle crossing over borders (scrollTo and overshoot)
- qDebug() << "oldOver: " << oldOvershootY << " newOver: " << newOvershootY;
+ qKSDebug() << " --> old overshoot Y:" << oldOvershootY << "- new overshoot Y:" << newOvershootY;
// -- x axis
if (scrollToX && qSign(oldScrollToDist.x()) != qSign(newScrollToDist.x())) {
newClampedPos.setX(scrollToPosition.x());
@@ -1134,8 +1127,8 @@ void QKineticScrollerPrivate::setContentPositionHelper(const QPointF &deltaPos)
if (debugHook)
debugHook(debugHookUser, calculateVelocity(qreal(scrollAbsoluteTimer.elapsed()) / 1000), newClampedPos, overshootPosition);
- qDebug() << "setContentPositionHelper" << newClampedPos << " overshoot:" << overshootPosition<<
- "Overshoot: "<<overshootX<<","<<overshootY<<"ScrollTo:"<<scrollToX<<","<<scrollToY;
+ qKSDebug() << " --> new position:" << newClampedPos << "- new overshoot:" << overshootPosition <<
+ "- overshoot x/y?:" << overshootX << "/" << overshootY << "- scrollto x/y?:" << scrollToX << "/" << scrollToY;
}
diff --git a/settingswidget.cpp b/settingswidget.cpp
index e31a6fb..7f41a7b 100644
--- a/settingswidget.cpp
+++ b/settingswidget.cpp
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** 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 QtGui 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 <QtGui>
#include "settingswidget.h"
@@ -176,6 +217,7 @@ MetricItem items[QKineticScroller::ScrollMetricCount] = {
QGridLayout *SettingsWidget::createMetricsItemGrid()
{
QGridLayout *grid = new QGridLayout();
+ grid->setVerticalSpacing(2);
int row = 0;
for (int i = 0; i < QKineticScroller::ScrollMetricCount; i++) {
@@ -214,6 +256,7 @@ SettingsWidget::SettingsWidget(QKineticScroller *scroller)
grp = new QGroupBox(QLatin1String("General"));
grid = new QGridLayout();
+ grid->setVerticalSpacing(2);
QCheckBox *onoff = new QCheckBox(QLatin1String("Enabled"));
onoff->setChecked(m_scroller->isEnabled());
connect(onoff, SIGNAL(toggled(bool)), this, SLOT(enabledChanged(bool)));
diff --git a/settingswidget.h b/settingswidget.h
index a426bdd..22ec6aa 100644
--- a/settingswidget.h
+++ b/settingswidget.h
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** 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 QtGui 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 SETTINGSWIDGET_H
#define SETTINGSWIDGET_H