summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarius Bugge Monsen <mmonsen@trolltech.com>2009-08-20 13:21:02 +0200
committerMarius Bugge Monsen <mmonsen@trolltech.com>2009-08-20 13:21:02 +0200
commita71653d1494c89c6545275d8fb0d7410bb9b7620 (patch)
tree5400ce2c05905b99c37cc521b9fc74f771cf2cac
parentb84dc392a5b18c9c5279c0d579710d8577e0f047 (diff)
Remove the experimental QGraphicsScrollArea. It has been moved into another repository.
-rw-r--r--src/experimental/qgraphicsscrollarea.cpp362
-rw-r--r--src/experimental/qgraphicsscrollarea.h110
-rw-r--r--src/experimental/qgraphicsscrollarea_p.h84
-rw-r--r--src/src.pro3
4 files changed, 0 insertions, 559 deletions
diff --git a/src/experimental/qgraphicsscrollarea.cpp b/src/experimental/qgraphicsscrollarea.cpp
deleted file mode 100644
index 701dc47..0000000
--- a/src/experimental/qgraphicsscrollarea.cpp
+++ /dev/null
@@ -1,362 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the Itemviews NG project on Trolltech Labs.
-**
-** This file may be used under the terms of the GNU General Public
-** License version 2.0 or 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of
-** this file. Please review the following information to ensure GNU
-** General Public Licensing requirements will be met:
-** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-****************************************************************************/
-
-#include "qgraphicsscrollarea.h"
-#include "qgraphicsscrollarea_p.h"
-#include <qgraphicssceneevent.h>
-#include <qevent.h>
-#include <qdatetime.h>
-#include <qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-QtGraphicsScrollAreaPrivate::QtGraphicsScrollAreaPrivate()
- : q_ptr(0), viewport(0),
- horizontalOffset(0), verticalOffset(0),
- timerId(0), timerInterval(50), timestamp(0),
- horizontalVelocity(0), verticalVelocity(0),
- maximumScrollVelocity(50), frictionFactor(0.85),
- velocityThreshold(0.05), movementThreshold(5),
- horizontalOvershoot(false), verticalOvershoot(false)
-{
-}
-
-QtGraphicsScrollAreaPrivate::~QtGraphicsScrollAreaPrivate()
-{
-}
-
-bool QtGraphicsScrollAreaPrivate::updateHorizontalOffset()
-{
- Q_Q(QtGraphicsScrollArea);
- qreal offset = horizontalOffset;
- bool cont = kineticUpdateOffset(&offset, &horizontalVelocity, q->maximumHorizontalOffset(), horizontalOvershoot);
- q->setHorizontalOffset(offset);
- return cont;
-}
-
-bool QtGraphicsScrollAreaPrivate::updateVerticalOffset()
-{
- Q_Q(QtGraphicsScrollArea);
- qreal offset = verticalOffset;
- bool cont = kineticUpdateOffset(&offset, &verticalVelocity, q->maximumVerticalOffset(), verticalOvershoot);
- q->setVerticalOffset(offset);
- return cont;
-}
-
-/*!
- \internal
- Update the offset and the velocity.
-
- return true if the timer should be continued
- */
-
-bool QtGraphicsScrollAreaPrivate::kineticUpdateOffset(qreal *offset, qreal *velocity, qreal max, bool overshoot)
-{
- static const qreal k = -0.5; //spring constant
-
- *offset += *velocity;
-
- // check for overshoot at the top
- if (*offset <= 0) {
- if (overshoot) {
- *velocity = qMin(k * *offset, *velocity + k * *offset);
- } else {
- *offset = 0;
- *velocity = 0;
- return false;
- }
- }
-
- // check for overshoot at the bottom
- if (*offset >= max) {
- if (overshoot) {
- *velocity = qMax(k * (*offset - max), *velocity + k * (*offset - max));
- } else {
- *velocity = 0;
- *offset = max;
- return false;
- }
- }
-
- *velocity *= frictionFactor;
- if (qAbs<qreal>(*velocity) < velocityThreshold) {
- *velocity = 0;
- return false;
- }
- return true;
-}
-
-void QtGraphicsScrollAreaPrivate::startTimer()
-{
- Q_Q(QtGraphicsScrollArea);
- if (timerId == 0)
- timerId = q->startTimer(timerInterval);
-}
-
-int QtGraphicsScrollAreaPrivate::currentTime() const
-{
- QTime t = QTime::currentTime();
- return t.hour() * 3600000 + t.minute() * 60000 + t.second() * 1000 + t.msec();
-}
-
-QtGraphicsScrollArea::QtGraphicsScrollArea(QGraphicsItem *parent, Qt::WindowFlags flags)
- : QGraphicsWidget(parent, flags), d_ptr(new QtGraphicsScrollAreaPrivate)
-{
- d_ptr->q_ptr = this;
- setFlag(QGraphicsItem::ItemClipsChildrenToShape, true);
- //setViewport(new QGraphicsWidget(this));
-}
-
-QtGraphicsScrollArea::~QtGraphicsScrollArea()
-{
- delete d_ptr;
-}
-
-void QtGraphicsScrollArea::setViewport(QGraphicsWidget *widget)
-{
- Q_D(QtGraphicsScrollArea);
- delete d->viewport;
- d->viewport = widget;
-// widget->setParent(this);
-// widget->setParentItem(this);
-}
-
-QGraphicsWidget *QtGraphicsScrollArea::viewport() const
-{
- Q_D(const QtGraphicsScrollArea);
- return d->viewport;
-}
-
-void QtGraphicsScrollArea::setHorizontalOffset(qreal offset)
-{
- Q_D(QtGraphicsScrollArea);
- qreal oldOffset = d->horizontalOffset;
- if (d->horizontalOvershoot) {
- d->horizontalOffset = offset;
- } else {
- qreal max = maximumHorizontalOffset();
- d->horizontalOffset = qBound<qreal>(0, offset, max);
- }
- if (d->horizontalOffset != oldOffset) {
- if (d->viewport)
- d->viewport->setPos(-d->horizontalOffset, d->viewport->pos().y());
- emit horizontalOffsetChanged(offset);
- }
-}
-
-qreal QtGraphicsScrollArea::horizontalOffset() const
-{
- Q_D(const QtGraphicsScrollArea);
- return d->horizontalOffset;
-}
-
-void QtGraphicsScrollArea::setVerticalOffset(qreal offset)
-{
- Q_D(QtGraphicsScrollArea);
- qreal oldOffset = d->verticalOffset;
- if (d->verticalOvershoot) {
- d->verticalOffset = offset;
- } else {
- qreal max = maximumVerticalOffset();
- d->verticalOffset = qBound<qreal>(0, offset, max);
- }
- if (d->verticalOffset != oldOffset) {
- if (d->viewport)
- d->viewport->setPos(d->viewport->pos().x(), -d->verticalOffset);
- emit verticalOffsetChanged(offset);
- }
-}
-
-qreal QtGraphicsScrollArea::verticalOffset() const
-{
- Q_D(const QtGraphicsScrollArea);
- return d->verticalOffset;
-}
-
-qreal QtGraphicsScrollArea::maximumHorizontalOffset() const
-{
- Q_D(const QtGraphicsScrollArea);
- return d->viewport ? d->viewport->rect().width() - rect().width() : 0;
-}
-
-qreal QtGraphicsScrollArea::maximumVerticalOffset() const
-{
- Q_D(const QtGraphicsScrollArea);
- return d->viewport ? d->viewport->rect().height() - rect().height() : 0;
-}
-
-void QtGraphicsScrollArea::scrollHorizontallyBy(qreal delta)
-{
- setHorizontalOffset(horizontalOffset() + delta);
-}
-
-void QtGraphicsScrollArea::scrollVerticallyBy(qreal delta)
-{
- setVerticalOffset(verticalOffset() + delta);
-}
-
-void QtGraphicsScrollArea::setHorizontalScrollVelocity(qreal velocity)
-{
- Q_D(QtGraphicsScrollArea);
- d->horizontalVelocity = qMin(velocity, d->maximumScrollVelocity);
- d->startTimer();
-}
-
-qreal QtGraphicsScrollArea::horizontalScrollVelocity() const
-{
- Q_D(const QtGraphicsScrollArea);
- return d->horizontalVelocity;
-}
-
-void QtGraphicsScrollArea::setVerticalScrollVelocity(qreal velocity)
-{
- Q_D(QtGraphicsScrollArea);
- d->verticalVelocity = qMin(velocity, d->maximumScrollVelocity);
- d->startTimer();
-}
-
-qreal QtGraphicsScrollArea::verticalScrollVelocity() const
-{
- Q_D(const QtGraphicsScrollArea);
- return d->verticalVelocity;
-}
-
-void QtGraphicsScrollArea::setMaximumScrollVelocity(qreal velocity)
-{
- Q_D(QtGraphicsScrollArea);
- d->maximumScrollVelocity = velocity;
-}
-
-qreal QtGraphicsScrollArea::maximumScrollVelocity() const
-{
- Q_D(const QtGraphicsScrollArea);
- return d->maximumScrollVelocity;
-}
-
-void QtGraphicsScrollArea::setHorizontalOvershootEnabled(bool enabled)
-{
- Q_D(QtGraphicsScrollArea);
- d->horizontalOvershoot = enabled;
-}
-
-bool QtGraphicsScrollArea::isHorizontalOvershootEnabled() const
-{
- Q_D(const QtGraphicsScrollArea);
- return d->horizontalOvershoot;
-}
-
-void QtGraphicsScrollArea::setVerticalOvershootEnabled(bool enabled)
-{
- Q_D(QtGraphicsScrollArea);
- d->verticalOvershoot = enabled;
-}
-
-bool QtGraphicsScrollArea::isVerticalOvershootEnabled() const
-{
- Q_D(const QtGraphicsScrollArea);
- return d->verticalOvershoot;
-}
-
-void QtGraphicsScrollArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QtGraphicsScrollArea);
- int oldTimestamp = d->timestamp;
- d->timestamp = d->currentTime();
- d->timeDelta = d->timestamp - oldTimestamp;
- d->movement = event->lastPos() - event->pos();
- scrollHorizontallyBy(d->movement.x());
- scrollVerticallyBy(d->movement.y());
-}
-
-void QtGraphicsScrollArea::mousePressEvent(QGraphicsSceneMouseEvent *)
-{
- Q_D(QtGraphicsScrollArea);
- setHorizontalScrollVelocity(0);
- setVerticalScrollVelocity(0);
- killTimer(d->timerId);
- d->timerId = 0;
- d->timestamp = d->currentTime();
- d->timeDelta = 0;
- d->movement = QPointF();
-}
-
-void QtGraphicsScrollArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QtGraphicsScrollArea);
- qreal dt = qreal(d->timeDelta) / qreal(d->timerInterval);
- QPointF totalMovement = event->pos() - event->buttonDownPos(event->button());
-
- if (qAbs<qreal>(totalMovement.x()) > d->movementThreshold)
- setHorizontalScrollVelocity(d->movement.x() / dt);
- else if (d->horizontalOffset < 0 || d->horizontalOffset > maximumHorizontalOffset())
- d->startTimer();
-
- if (qAbs<qreal>(totalMovement.y()) > d->movementThreshold)
- setVerticalScrollVelocity(d->movement.y() / dt);
- else if (d->verticalOffset < 0 || d->verticalOffset > maximumVerticalOffset())
- d->startTimer();
-}
-
-void QtGraphicsScrollArea::wheelEvent(QGraphicsSceneWheelEvent *event)
-{
- Q_D(QtGraphicsScrollArea);
- if (event->orientation() == Qt::Horizontal)
- setHorizontalScrollVelocity(d->horizontalVelocity - event->delta()/8.);
- if (event->orientation() == Qt::Vertical)
- setVerticalScrollVelocity(d->verticalVelocity - event->delta()/8.);
-}
-
-void QtGraphicsScrollArea::timerEvent(QTimerEvent *event)
-{
- Q_D(QtGraphicsScrollArea);
- if (event->timerId() == d->timerId) {
- bool h = d->updateHorizontalOffset();
- bool v = d->updateVerticalOffset();
- if (!h && !v) {
- killTimer(d->timerId);
- d->timerId = 0;
- }
- }
-}
-
-bool QtGraphicsScrollArea::event(QEvent *event)
-{
- Q_D(QtGraphicsScrollArea);
- // ### hack to set the viewport
- if (event->type() == QEvent::ChildAdded) {
- QChildEvent *childEvent = static_cast<QChildEvent *>(event);
- if (QGraphicsWidget *widget = qobject_cast<QGraphicsWidget *>(childEvent->child())) {
- if (d->viewport != widget)
- setViewport(widget);
- }
- } else if (event->type() == QEvent::ChildRemoved) {
- QChildEvent *childEvent = static_cast<QChildEvent *>(event);
- if (QGraphicsWidget *widget = qobject_cast<QGraphicsWidget *>(childEvent->child())) {
- if (d->viewport == widget)
- setViewport(0);
- }
- }
- return QGraphicsWidget::event(event);
-}
-
-QT_END_NAMESPACE
diff --git a/src/experimental/qgraphicsscrollarea.h b/src/experimental/qgraphicsscrollarea.h
deleted file mode 100644
index 984b958..0000000
--- a/src/experimental/qgraphicsscrollarea.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the Itemviews NG project on Trolltech Labs.
-**
-** This file may be used under the terms of the GNU General Public
-** License version 2.0 or 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of
-** this file. Please review the following information to ensure GNU
-** General Public Licensing requirements will be met:
-** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSSCROLLAREA_H
-#define QGRAPHICSSCROLLAREA_H
-
-#include <QtGui/qgraphicswidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QPainter;
-class QStyleOptionGraphicsItem;
-
-class QtGraphicsScrollAreaPrivate;
-class Q_ITEMVIEWSNG_EXPORT QtGraphicsScrollArea : public QGraphicsWidget
-{
- Q_OBJECT
- Q_PROPERTY(QGraphicsWidget* viewport READ viewport WRITE setViewport)
- Q_PROPERTY(qreal horizontalOffset READ horizontalOffset WRITE setHorizontalOffset NOTIFY horizontalOffsetChanged)
- Q_PROPERTY(qreal verticalOffset READ verticalOffset WRITE setVerticalOffset NOTIFY verticalOffsetChanged)
- Q_PROPERTY(qreal horizontalScrollVelocity READ horizontalScrollVelocity WRITE setHorizontalScrollVelocity)
- Q_PROPERTY(qreal verticalScrollVelocity READ verticalScrollVelocity WRITE setVerticalScrollVelocity)
- Q_PROPERTY(qreal maximumScrollVelocity READ maximumScrollVelocity WRITE setMaximumScrollVelocity)
- Q_PROPERTY(bool horizontalOvershootEnabled READ isHorizontalOvershootEnabled WRITE setHorizontalOvershootEnabled)
- Q_PROPERTY(bool verticalOvershootEnabled READ isVerticalOvershootEnabled WRITE setVerticalOvershootEnabled)
-
-public:
- QtGraphicsScrollArea(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
- ~QtGraphicsScrollArea();
-
- void setViewport(QGraphicsWidget *widget);
- QGraphicsWidget *viewport() const;
-
- qreal horizontalOffset() const;
- qreal verticalOffset() const;
-
- virtual qreal maximumHorizontalOffset() const;
- virtual qreal maximumVerticalOffset() const;
-
- void scrollHorizontallyBy(qreal delta);
- void scrollVerticallyBy(qreal delta);
-
- void setHorizontalScrollVelocity(qreal velocity);
- qreal horizontalScrollVelocity() const;
-
- void setVerticalScrollVelocity(qreal velocity);
- qreal verticalScrollVelocity() const;
-
- void setMaximumScrollVelocity(qreal velocity);
- qreal maximumScrollVelocity() const;
-
- void setHorizontalOvershootEnabled(bool enabled);
- bool isHorizontalOvershootEnabled() const;
-
- void setVerticalOvershootEnabled(bool enabled);
- bool isVerticalOvershootEnabled() const;
-
-Q_SIGNALS:
- void horizontalOffsetChanged(qreal offset);
- void verticalOffsetChanged(qreal offset);
-
-public Q_SLOTS:
- void setHorizontalOffset(qreal offset);
- void setVerticalOffset(qreal offset);
-
-protected:
- void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
- void mousePressEvent(QGraphicsSceneMouseEvent *event);
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
- void wheelEvent(QGraphicsSceneWheelEvent *event);
-
- void timerEvent(QTimerEvent *event);
- bool event(QEvent *event);
-
- QtGraphicsScrollAreaPrivate *d_ptr;
-
-private:
- Q_DISABLE_COPY(QtGraphicsScrollArea)
- Q_DECLARE_PRIVATE(QtGraphicsScrollArea)
-};
-
-QT_END_HEADER
-
-QT_END_NAMESPACE
-
-#endif // QGRAPHICSSCROLLAREA_H
diff --git a/src/experimental/qgraphicsscrollarea_p.h b/src/experimental/qgraphicsscrollarea_p.h
deleted file mode 100644
index b17fffc..0000000
--- a/src/experimental/qgraphicsscrollarea_p.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the Itemviews NG project on Trolltech Labs.
-**
-** This file may be used under the terms of the GNU General Public
-** License version 2.0 or 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of
-** this file. Please review the following information to ensure GNU
-** General Public Licensing requirements will be met:
-** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSSCROLLAREA_P_H
-#define QGRAPHICSSCROLLAREA_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-QT_BEGIN_NAMESPACE
-
-class QGraphicsWidget;
-
-class QtGraphicsScrollAreaPrivate
-{
- Q_DECLARE_PUBLIC(QtGraphicsScrollArea)
-public:
- QtGraphicsScrollAreaPrivate();
- ~QtGraphicsScrollAreaPrivate();
-
- bool updateHorizontalOffset();
- bool updateVerticalOffset();
- bool kineticUpdateOffset(qreal *offset, qreal *velocity, qreal max, bool overshoot);
-
- void startTimer();
- int currentTime() const;
-
- QtGraphicsScrollArea *q_ptr;
-
- QGraphicsWidget *viewport;
- qreal horizontalOffset;
- qreal verticalOffset;
-
- // kinetic scrolling
- int timerId;
- int timerInterval;
- int timestamp;
- qreal horizontalVelocity;
- qreal verticalVelocity;
- qreal maximumScrollVelocity;
- qreal frictionFactor;
- qreal velocityThreshold;
-
- // user movement
- int timeDelta;
- QPointF movement;
- qreal movementThreshold;
-
- // bounceback
- bool horizontalOvershoot;
- bool verticalOvershoot;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGRAPHICSSCROLLAREA_P_H
diff --git a/src/src.pro b/src/src.pro
index f089a44..c33a608 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -52,8 +52,6 @@ HEADERS += qgraphicsscrollbar.h \
experimental/qgraphicsgridview.h \
experimental/qkineticlistcontroller.h \
experimental/qkineticlistcontroller_p.h \
- experimental/qgraphicsscrollarea.h \
- experimental/qgraphicsscrollarea_p.h \
# experimental/qprinterlistview.h \
# experimental/qprinterlistview_p.h \
# experimental/qprintertableview.h \
@@ -87,7 +85,6 @@ SOURCES += qgraphicsscrollbar.cpp \
experimental/qgraphicspathview.cpp \
experimental/qgraphicsgridview.cpp \
experimental/qkineticlistcontroller.cpp \
- experimental/qgraphicsscrollarea.cpp \
# experimental/qprinterlistview.cpp \
# experimental/qprintertableview.cpp \