summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/src/examples/wheel.qdoc109
-rw-r--r--examples/examples.pro1
-rw-r--r--examples/scroller/graphicsview/graphicsview.pro8
-rw-r--r--examples/scroller/graphicsview/main.cpp295
-rw-r--r--examples/scroller/plot/main.cpp221
-rw-r--r--examples/scroller/plot/plot.pro13
-rw-r--r--examples/scroller/plot/plotwidget.cpp204
-rw-r--r--examples/scroller/plot/plotwidget.h88
-rw-r--r--examples/scroller/plot/settingswidget.cpp689
-rw-r--r--examples/scroller/plot/settingswidget.h108
-rw-r--r--examples/scroller/scroller.pro11
-rw-r--r--examples/scroller/wheel/main.cpp122
-rw-r--r--examples/scroller/wheel/wheel.pro11
-rw-r--r--examples/scroller/wheel/wheelwidget.cpp275
-rw-r--r--examples/scroller/wheel/wheelwidget.h103
-rw-r--r--src/corelib/global/qnamespace.h6
-rw-r--r--src/corelib/kernel/qcoreevent.cpp2
-rw-r--r--src/corelib/kernel/qcoreevent.h3
-rw-r--r--src/gui/image/qpixmap_mac.cpp11
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp44
-rw-r--r--src/gui/itemviews/qabstractitemview.h3
-rw-r--r--src/gui/itemviews/qabstractitemview_p.h7
-rw-r--r--src/gui/kernel/qapplication_x11.cpp3
-rw-r--r--src/gui/kernel/qevent.cpp219
-rw-r--r--src/gui/kernel/qevent.h46
-rw-r--r--src/gui/kernel/qevent_p.h28
-rw-r--r--src/gui/kernel/qt_x11_p.h2
-rw-r--r--src/gui/kernel/qwidget.cpp10
-rw-r--r--src/gui/kernel/qwidget_mac.mm22
-rw-r--r--src/gui/painting/qcolor.cpp3
-rw-r--r--src/gui/painting/qgraphicssystemfactory.cpp2
-rw-r--r--src/gui/painting/qpaintbuffer.cpp6
-rw-r--r--src/gui/painting/qpainter.cpp27
-rw-r--r--src/gui/painting/qpainter.h4
-rw-r--r--src/gui/painting/qunifiedtoolbarsurface_mac_p.h33
-rw-r--r--src/gui/text/qfont_mac.cpp7
-rw-r--r--src/gui/text/qfontengine_coretext.mm2
-rw-r--r--src/gui/text/qfontengine_coretext_p.h2
-rw-r--r--src/gui/text/qfontengine_ft.cpp2
-rw-r--r--src/gui/text/qglyphrun.cpp (renamed from src/gui/text/qglyphs.cpp)123
-rw-r--r--src/gui/text/qglyphrun.h (renamed from src/gui/text/qglyphs.h)32
-rw-r--r--src/gui/text/qglyphrun_p.h (renamed from src/gui/text/qglyphs_p.h)16
-rw-r--r--src/gui/text/qrawfont.cpp78
-rw-r--r--src/gui/text/qrawfont.h2
-rw-r--r--src/gui/text/qtextcursor.cpp18
-rw-r--r--src/gui/text/qtextcursor.h4
-rw-r--r--src/gui/text/qtextdocument.cpp14
-rw-r--r--src/gui/text/qtextdocument.h6
-rw-r--r--src/gui/text/qtextdocument_p.cpp2
-rw-r--r--src/gui/text/qtextdocument_p.h2
-rw-r--r--src/gui/text/qtextengine_p.h2
-rw-r--r--src/gui/text/qtextlayout.cpp36
-rw-r--r--src/gui/text/qtextlayout.h10
-rw-r--r--src/gui/text/qtextobject.cpp10
-rw-r--r--src/gui/text/qtextobject.h4
-rw-r--r--src/gui/text/text.pri10
-rw-r--r--src/gui/util/qflickgesture.cpp715
-rw-r--r--src/gui/util/qflickgesture_p.h113
-rw-r--r--src/gui/util/qscroller.cpp2056
-rw-r--r--src/gui/util/qscroller.h155
-rw-r--r--src/gui/util/qscroller_mac.mm71
-rw-r--r--src/gui/util/qscroller_p.h209
-rw-r--r--src/gui/util/qscrollerproperties.cpp393
-rw-r--r--src/gui/util/qscrollerproperties.h140
-rw-r--r--src/gui/util/qscrollerproperties_p.h94
-rw-r--r--src/gui/util/util.pri12
-rw-r--r--src/gui/widgets/qabstractscrollarea.cpp107
-rw-r--r--src/gui/widgets/qabstractscrollarea_p.h2
-rw-r--r--src/gui/widgets/qlinecontrol.cpp2
-rw-r--r--src/gui/widgets/qlinecontrol_p.h8
-rw-r--r--src/gui/widgets/qlineedit.cpp8
-rw-r--r--src/gui/widgets/qlineedit.h5
-rw-r--r--src/network/socket/qabstractsocket.cpp2
-rw-r--r--src/opengl/qglfunctions.cpp33
-rw-r--r--tests/auto/gui.pro3
-rw-r--r--tests/auto/qcolor/tst_qcolor.cpp2
-rw-r--r--tests/auto/qcomplextext/tst_qcomplextext.cpp2
-rw-r--r--tests/auto/qglyphrun/qglyphrun.pro (renamed from tests/auto/qglyphs/qglyphs.pro)4
-rw-r--r--tests/auto/qglyphrun/test.ttf (renamed from tests/auto/qglyphs/test.ttf)bin3712 -> 3712 bytes
-rw-r--r--tests/auto/qglyphrun/tst_qglyphrun.cpp (renamed from tests/auto/qglyphs/tst_qglyphs.cpp)154
-rw-r--r--tests/auto/qlineedit/tst_qlineedit.cpp4
-rw-r--r--tests/auto/qrawfont/tst_qrawfont.cpp52
-rw-r--r--tests/auto/qscroller/qscroller.pro3
-rw-r--r--tests/auto/qscroller/tst_qscroller.cpp537
-rw-r--r--tests/auto/qsslsocket/tst_qsslsocket.cpp15
-rw-r--r--tests/auto/qtcpsocket/tst_qtcpsocket.cpp36
-rw-r--r--tests/auto/qtextdocument/tst_qtextdocument.cpp26
-rw-r--r--tests/auto/qtextedit/tst_qtextedit.cpp4
-rw-r--r--tests/auto/qvariant/tst_qvariant.cpp1
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp45
-rw-r--r--tools/qml/texteditautoresizer_maemo5.h12
91 files changed, 579 insertions, 7567 deletions
diff --git a/doc/src/examples/wheel.qdoc b/doc/src/examples/wheel.qdoc
deleted file mode 100644
index 995ff87..0000000
--- a/doc/src/examples/wheel.qdoc
+++ /dev/null
@@ -1,109 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of this
-** file.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example scroller/wheel
- \title Wheel Scroller Example
-
- The Wheel Scroller Example shows how to use QScroller, QScrollEvent
- and QScrollPrepareEvent to implement smooth scrolling for a
- custom Widget.
-
- \section1 Basics
-
- The QScroller class is the main part of the smooth scrolling
- mechanism in Qt. It keeps track of the current scroll position and
- speed and updates the object through events.
- QScroller will get touch events via the QFlickGesture.
- It will query the target object through a QScrollPrepareEvent for
- the scroll area and other information.
- QScroller will send QScrollEvents to inform the target object about
- the current scroll position.
- The target object (usually a QWidget or a QGraphicsObject) will
- then need to update it's graphical representation to reflect the
- new scroll position.
-
- \section1 The Wheel Widget class
-
- To demonstrate how to use the QScroller we implement a QWidget that
- looks and works like the wheel of a slot machine.
- The wheel can be started via touch events and will continue getting
- slower.
- Additionally the wheel should appear as if no border exists (which
- would seem unnatural) and the scrolling should snap to center one
- item.
-
- In the widget we need to grab the QFlickGesture. The gesture itself
- will setAcceptTouchEvents for us, so we don't need to do that here.
-
- \snippet examples/scroller/wheel/wheelwidget.cpp 0
-
- The widget will get gesture events but in addition we also will
- get the events from QScroller.
- We will need to accept the QScrollPrepareEvent to indicate that
- a scrolling should really be started from the given position.
-
- \snippet examples/scroller/wheel/wheelwidget.cpp 1
-
- We should call all three set functions form QScrollPrepareEvent.
-
- \list
- \o \c setViewportSize to indicate our viewport size. Actually the
- given code could be improved by giving our size minus the borders.
- \o \c setMaxContentPos to indicate the maximum values for the scroll
- position. The minimum values are implicitely set to 0.
- In our example we give a very high number here and hope that the user
- is not patient enough to scroll until the very end.
- \o \c setContentPos to indicate the current scroll position.
- We give a position in the middle of the huge scroll area.
- Actually we give this position every time a new scroll is started so
- the user will only reach the end if he continuously scrolls in one
- direction which is not very likely.
- \endlist
-
- The handling of the QScrollEvent is a lengthly code not fully shown here.
- \snippet examples/scroller/wheel/wheelwidget.cpp 2
-
- In principle it does three steps.
- \list
- \o It calculates and updates the current scroll position as given by
- QScroller.
- \o It repaints the widget so that the new position is shown.
- \o It centers the item as soon as the scrolling stopps.
- \endlist
-
- The following code does the centering.
- \snippet examples/scroller/wheel/wheelwidget.cpp 3
-
- We check if the scrolling is finished which is indicated in the
- QScrollEvent by the \c isLast flag.
- We then check if the item is not already centered and if not start a new
- scroll by calling QScroller::scrollTo.
-
- As you can see the QScroller can be used for other things besides simple
- scroll areas.
-*/
diff --git a/examples/examples.pro b/examples/examples.pro
index 968740d..f233aba 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -20,7 +20,6 @@ SUBDIRS = \
mainwindows \
painting \
richtext \
- scroller \
sql \
tools \
tutorials \
diff --git a/examples/scroller/graphicsview/graphicsview.pro b/examples/scroller/graphicsview/graphicsview.pro
deleted file mode 100644
index dcebe62..0000000
--- a/examples/scroller/graphicsview/graphicsview.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-TEMPLATE = app
-SOURCES = main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/scroller/graphicsview
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS graphicsview.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/scroller/graphicsview
-INSTALLS += target sources
diff --git a/examples/scroller/graphicsview/main.cpp b/examples/scroller/graphicsview/main.cpp
deleted file mode 100644
index 738a824..0000000
--- a/examples/scroller/graphicsview/main.cpp
+++ /dev/null
@@ -1,295 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore>
-#include <QtGui>
-
-#define NUM_ITEMS 100
-#define NUM_LISTS 10
-
-/*!
- \class RectObject
- Note that it needs to be a QGraphicsObject or else the gestures will not work correctly.
-*/
-class RectObject : public QGraphicsObject
-{
- Q_OBJECT
-
-public:
-
- RectObject(const QString &text, qreal x, qreal y, qreal width, qreal height, QBrush brush, QGraphicsItem *parent = 0)
- : QGraphicsObject(parent)
- , m_text(text)
- , m_rect(x, y, width, height)
- , m_pen(brush.color().lighter(), 3.0)
- , m_brush(brush)
- {
- setFlag(QGraphicsItem::ItemClipsToShape, true);
- }
-
- QRectF boundingRect() const
- {
- // here we only want the size of the children and not the size of the children of the children...
- qreal halfpw = m_pen.widthF() / 2;
- QRectF rect = m_rect;
- if (halfpw > 0.0)
- rect.adjust(-halfpw, -halfpw, halfpw, halfpw);
-
- return rect;
- }
-
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
- {
- Q_UNUSED(option);
- Q_UNUSED(widget);
- painter->setPen(m_pen);
- painter->setBrush(m_brush);
- painter->drawRect(m_rect);
-
- painter->setPen(Qt::black);
- QFont f;
- f.setPixelSize(m_rect.height());
- painter->setFont(f);
- painter->drawText(m_rect, Qt::AlignCenter, m_text);
- }
-
- QString m_text;
- QRectF m_rect;
- QPen m_pen;
- QBrush m_brush;
-};
-
-class ViewObject : public QGraphicsObject
-{
- Q_OBJECT
-public:
- ViewObject(QGraphicsObject *parent)
- : QGraphicsObject(parent)
- { }
-
- QRectF boundingRect() const
- {
- QRectF rect;
- foreach (QGraphicsItem *item, childItems())
- rect |= item->boundingRect().translated(item->pos());
- return rect;
- }
-
- void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*)
- { }
-};
-
-class ListObject : public QGraphicsObject
-{
- Q_OBJECT
-
-public:
- ListObject(const QSizeF &size, bool useTouch)
- {
- m_size = size;
- setFlag(QGraphicsItem::ItemClipsChildrenToShape, true);
- // grab gesture via Touch or Mouse events
- QScroller::grabGesture(this, useTouch ? QScroller::TouchGesture : QScroller::LeftMouseButtonGesture);
-
- // this needs to be QGraphicsOBJECT - otherwise gesture recognition
- // will not work for the parent of the viewport (in this case the
- // list)
- m_viewport = new ViewObject(this);
-
- }
-
- QGraphicsObject *viewport() const
- {
- return m_viewport;
- }
-
- bool event(QEvent *e)
- {
- switch (e->type()) {
-// ![2]
- case QEvent::ScrollPrepare: {
- QScrollPrepareEvent *se = static_cast<QScrollPrepareEvent *>(e);
- se->setViewportSize(m_size);
- QRectF br = m_viewport->boundingRect();
- se->setContentPosRange(QRectF(0, 0,
- qMax(qreal(0), br.width() - m_size.width()),
- qMax(qreal(0), br.height() - m_size.height())));
- se->setContentPos(-m_viewport->pos());
- se->accept();
- return true;
- }
-// ![1]
-// ![2]
- case QEvent::Scroll: {
- QScrollEvent *se = static_cast<QScrollEvent *>(e);
- m_viewport->setPos(-se->contentPos() - se->overshootDistance());
- return true;
- }
-// ![2]
- default:
- break;
- }
- return QGraphicsObject::event(e);
- }
-
- bool sceneEvent(QEvent *e)
- {
- switch (e->type()) {
- case QEvent::TouchBegin: {
- // We need to return true for the TouchBegin here in the
- // top-most graphics object - otherwise gestures in our parent
- // objects will NOT work at all (the accept() flag is already
- // set due to our setAcceptTouchEvents(true) call in the c'tor
- return true;
-
- }
- case QEvent::GraphicsSceneMousePress: {
- // We need to return true for the MousePress here in the
- // top-most graphics object - otherwise gestures in our parent
- // objects will NOT work at all (the accept() flag is already
- // set to true by Qt)
- return true;
-
- }
- default:
- break;
- }
- return QGraphicsObject::sceneEvent(e);
- }
-
- QRectF boundingRect() const
- {
- return QRectF(0, 0, m_size.width() + 3, m_size.height());
- }
-
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
- {
- Q_UNUSED(option);
- Q_UNUSED(widget);
- painter->setPen(QPen(QColor(100, 100, 100), 3.0));
- painter->drawRect(QRect(1.5, 1.5, m_size.width() - 3, m_size.height() - 3));
- }
-
- QSizeF m_size;
- ViewObject *m_viewport;
-};
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow(bool useTouch)
- {
- m_scene = new QGraphicsScene();
-
- // -- make the main list
- ListObject *mainList = new ListObject(QSizeF(780, 400), useTouch);
- mainList->setObjectName(QLatin1String("MainList"));
- m_scene->addItem(mainList);
-// ![3]
- for (int i=0; i<NUM_LISTS; i++) {
- ListObject *childList = new ListObject(QSizeF(mainList->m_size.width()/3, mainList->m_size.height()), useTouch);
- childList->setObjectName(QString("ChildList %1").arg(i));
- fillList(childList);
- childList->setParentItem(mainList->viewport());
- childList->setPos(i*mainList->m_size.width()/3, 0);
- }
- mainList->viewport()->setPos(0, 0);
-
-
- /*
- list1->setTransformOriginPoint(200, 200);
- list1->setRotation(135);
- list1->setPos(20 + 200 * .41, 20 + 200 * .41);
- */
-// ![3]
-
- m_view = new QGraphicsView(m_scene);
- setCentralWidget(m_view);
- setWindowTitle(tr("Gesture example"));
- m_scene->setSceneRect(0, 0, m_view->viewport()->width(), m_view->viewport()->height());
- }
-
- /**
- * Fills the list object \a list with RectObjects.
- */
- void fillList(ListObject *list)
- {
- qreal h = list->m_size.height() / 10;
- for (int i=0; i<NUM_ITEMS; i++) {
- QColor color = QColor(255*i/NUM_ITEMS, 255*(NUM_ITEMS-i)/NUM_ITEMS, 127*(i%2)+64*(i/2%2));
- QString text = QLatin1String("Item #") + QString::number(i);
- QGraphicsItem *rect = new RectObject(text, 0, 0, list->m_size.width() - 6, h - 3, QBrush(color), list->viewport());
- rect->setPos(3, h*i+3);
- }
- list->viewport()->setPos(0, 0);
- }
-
-
-protected:
- void resizeEvent(QResizeEvent *e)
- {
- // resize the scene according to our own size to prevent scrolling
- m_scene->setSceneRect(0, 0, m_view->viewport()->width(), m_view->viewport()->height());
- QMainWindow::resizeEvent(e);
- }
-
- QGraphicsScene *m_scene;
- QGraphicsView *m_view;
-};
-
-int main(int argc, char *argv[])
-{
- QApplication a(argc, argv);
- bool touch = (a.arguments().contains(QLatin1String("--touch")));
- MainWindow mw(touch);
-#ifdef Q_WS_S60
- mw.showMaximized();
-#else
- mw.show();
-#endif
-#ifdef Q_WS_MAC
- mw.raise();
-#endif
- return a.exec();
-}
-
-#include "main.moc"
diff --git a/examples/scroller/plot/main.cpp b/examples/scroller/plot/main.cpp
deleted file mode 100644
index 178a094..0000000
--- a/examples/scroller/plot/main.cpp
+++ /dev/null
@@ -1,221 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include <QListWidget>
-#include <QListWidgetItem>
-#include <QSplitter>
-#include <QStackedWidget>
-#include <QSignalMapper>
-#include <QMainWindow>
-#include <QMenuBar>
-#include <QActionGroup>
-#include <QWebView>
-#include <QTimer>
-#include <QScroller>
-
-#include <QtDebug>
-
-#include <QGesture>
-
-#include "settingswidget.h"
-#include "plotwidget.h"
-
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-public:
- MainWindow(bool smallscreen, bool touch)
- : QMainWindow(), m_touch(touch)
- {
- m_list = new QListWidget();
- m_list->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
- m_list_scroller = installKineticScroller(m_list);
-
- for (int i = 0; i < 1000; ++i)
- new QListWidgetItem(QString("This is a test text %1 %2").arg(i).arg(QString("--------").left(i % 8)), m_list);
-
- connect(m_list, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(listItemActivated(QListWidgetItem*)));
- connect(m_list, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(listItemClicked(QListWidgetItem*)));
- connect(m_list, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(listItemPressed(QListWidgetItem*)));
- connect(m_list, SIGNAL(itemSelectionChanged()), this, SLOT(listItemSelectionChanged()));
- connect(m_list, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(listItemCurrentChanged(QListWidgetItem*)));
-
- m_web = new QWebView();
- m_web_scroller = installKineticScroller(m_web);
-
- QTimer::singleShot(1000, this, SLOT(loadUrl()));
-
- m_settings = new SettingsWidget(smallscreen);
- installKineticScroller(m_settings);
- m_plot = new PlotWidget(smallscreen);
-
- QStackedWidget *stack = new QStackedWidget();
- stack->addWidget(m_list);
- stack->addWidget(m_web);
-
- QActionGroup *pages = new QActionGroup(this);
- pages->setExclusive(true);
- QSignalMapper *mapper = new QSignalMapper(this);
- connect(mapper, SIGNAL(mapped(int)), stack, SLOT(setCurrentIndex(int)));
-
- createAction("List", pages, mapper, 0, true);
- createAction("Web", pages, mapper, 1);
-
- if (smallscreen) {
- stack->addWidget(m_settings);
- stack->addWidget(m_plot);
-
- createAction("Settings", pages, mapper, 2);
- createAction("Plot", pages, mapper, 3);
-
- setCentralWidget(stack);
- } else {
- QSplitter *split = new QSplitter();
- m_settings->setMinimumWidth(m_settings->sizeHint().width());
- split->addWidget(stack);
- split->addWidget(m_settings);
- split->addWidget(m_plot);
- setCentralWidget(split);
- }
- menuBar()->addMenu(QLatin1String("Pages"))->addActions(pages->actions());
- connect(stack, SIGNAL(currentChanged(int)), this, SLOT(pageChanged(int)));
- pageChanged(0);
- }
-
-private slots:
- void pageChanged(int page)
- {
- if (page < 0 || page > 1)
- return;
- switch (page) {
- case 0:
- m_settings->setScroller(m_list);
- m_plot->setScroller(m_list);
- break;
- case 1:
- m_settings->setScroller(m_web);
- m_plot->setScroller(m_web);
- break;
- default:
- break;
- }
- }
-
- void loadUrl()
- {
- m_web->load(QUrl("http://www.google.com"));
- }
-
- void listItemActivated(QListWidgetItem *lwi) { qWarning() << "Item ACTIVATED: " << lwi->text(); }
- void listItemClicked(QListWidgetItem *lwi) { qWarning() << "Item CLICKED: " << lwi->text(); }
- void listItemPressed(QListWidgetItem *lwi) { qWarning() << "Item PRESSED: " << lwi->text(); }
- void listItemCurrentChanged(QListWidgetItem *lwi) { qWarning() << "Item CURRENT: " << (lwi ? lwi->text() : QString("(none)")); }
- void listItemSelectionChanged()
- {
- int n = m_list->selectedItems().count();
- qWarning("Item%s SELECTED: %d", n == 1 ? "" : "s", n);
- foreach (QListWidgetItem *lwi, m_list->selectedItems())
- qWarning() << " " << lwi->text();
- }
-
-private:
- QAction *createAction(const char *text, QActionGroup *group, QSignalMapper *mapper, int mapping, bool checked = false)
- {
- QAction *a = new QAction(QLatin1String(text), group);
- a->setCheckable(true);
- a->setChecked(checked);
-#if defined(Q_WS_MAC)
- a->setMenuRole(QAction::NoRole);
-#endif
- mapper->setMapping(a, mapping);
- connect(a, SIGNAL(toggled(bool)), mapper, SLOT(map()));
- return a;
- }
-
- QScroller *installKineticScroller(QWidget *w)
- {
- if (QAbstractScrollArea *area = qobject_cast<QAbstractScrollArea *>(w)) {
- QScroller::grabGesture(area->viewport(), m_touch ? QScroller::TouchGesture : QScroller::LeftMouseButtonGesture);
- return QScroller::scroller(area->viewport());
- } else if (QWebView *web = qobject_cast<QWebView *>(w)) {
- QScroller::grabGesture(web, m_touch ? QScroller::TouchGesture : QScroller::LeftMouseButtonGesture);
- }
- return QScroller::scroller(w);
- }
-
-private:
- QListWidget *m_list;
- QWebView *m_web;
- QScroller *m_list_scroller, *m_web_scroller;
- SettingsWidget *m_settings;
- PlotWidget *m_plot;
- bool m_touch;
-};
-
-int main(int argc, char **argv)
-{
- QApplication a(argc, argv);
-
-#if defined(Q_WS_MAEMO_5) || defined(Q_WS_S60) || defined(Q_WS_WINCE)
- bool smallscreen = true;
-#else
- bool smallscreen = false;
-#endif
- bool touch = false;
-
- if (a.arguments().contains(QLatin1String("--small")))
- smallscreen = true;
- if (a.arguments().contains(QLatin1String("--touch")))
- touch = true;
-
- MainWindow mw(smallscreen, touch);
- if (smallscreen)
- mw.showMaximized();
- else
- mw.show();
-#if defined(Q_WS_MAC)
- mw.raise();
-#endif
- return a.exec();
-}
-
-#include "main.moc"
diff --git a/examples/scroller/plot/plot.pro b/examples/scroller/plot/plot.pro
deleted file mode 100644
index 04fdf70..0000000
--- a/examples/scroller/plot/plot.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-HEADERS = settingswidget.h \
- plotwidget.h
-SOURCES = settingswidget.cpp \
- plotwidget.cpp \
- main.cpp
-
-QT += webkit
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/scroller/plot
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS plot.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/scroller/plot
-INSTALLS += target sources
diff --git a/examples/scroller/plot/plotwidget.cpp b/examples/scroller/plot/plotwidget.cpp
deleted file mode 100644
index e600652..0000000
--- a/examples/scroller/plot/plotwidget.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QPushButton>
-#include <QTextStream>
-#include <QColor>
-#include <QPainter>
-#include <QLabel>
-#include <QResizeEvent>
-#include <QPlastiqueStyle>
-#include <QAbstractScrollArea>
-
-#include "plotwidget.h"
-#include "qscroller.h"
-
-PlotWidget::PlotWidget(bool /*smallscreen*/)
- : QWidget(), m_widget(0)
-{
- setWindowTitle(QLatin1String("Plot"));
- m_clear = new QPushButton(QLatin1String("Clear"), this);
-#if defined(Q_WS_MAEMO_5)
- m_clear->setStyle(new QPlastiqueStyle());
- m_clear->setFixedHeight(55);
-#endif
- connect(m_clear, SIGNAL(clicked()), this, SLOT(reset()));
- m_legend = new QLabel(this);
- QString legend;
- QTextStream ts(&legend);
- // ok. this wouldn't pass the w3c html verification...
- ts << "<table style=\"color:#000;\" border=\"0\">";
- ts << "<tr><td width=\"30\" bgcolor=\"" << QColor(Qt::red).light().name() << "\" /><td>Velocity X</td></tr>";
- ts << "<tr><td width=\"30\" bgcolor=\"" << QColor(Qt::red).dark().name() << "\" /><td>Velocity 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->setText(legend);
-}
-
-void PlotWidget::setScroller(QWidget *widget)
-{
- if (QAbstractScrollArea *area = qobject_cast<QAbstractScrollArea *>(widget))
- widget = area->viewport();
-
- if (m_widget)
- m_widget->removeEventFilter(this);
- m_widget = widget;
- reset();
- if (m_widget)
- m_widget->installEventFilter(this);
-}
-
-bool PlotWidget::eventFilter(QObject *obj, QEvent *ev)
-{
- if (ev->type() == QEvent::Scroll) {
- QScrollEvent *se = static_cast<QScrollEvent *>(ev);
- QScroller *scroller = QScroller::scroller(m_widget);
-
- QPointF v = scroller->velocity();
- //v.rx() *= scroller->pixelPerMeter().x();
- //v.ry() *= scroller->pixelPerMeter().y();
-
- PlotItem pi = { v, se->contentPos(), se->overshootDistance() };
- addPlotItem(pi);
- }
-
- return QWidget::eventFilter(obj, ev);
-}
-
-static inline void doMaxMin(const QPointF &v, qreal &minmaxv)
-{
- minmaxv = qMax(minmaxv, qMax(qAbs(v.x()), qAbs(v.y())));
-}
-
-void PlotWidget::addPlotItem(const PlotItem &pi)
-{
- m_plotitems.append(pi);
- minMaxVelocity = minMaxPosition = 0;
-
- while (m_plotitems.size() > 500)
- m_plotitems.removeFirst();
-
- foreach (const PlotItem &pi, m_plotitems) {
- doMaxMin(pi.velocity, minMaxVelocity);
- doMaxMin(pi.contentPosition, minMaxPosition);
- doMaxMin(pi.overshootPosition, minMaxPosition);
- }
- update();
-}
-
-void PlotWidget::reset()
-{
- m_plotitems.clear();
- minMaxVelocity = minMaxPosition = 0;
- update();
-}
-
-void PlotWidget::resizeEvent(QResizeEvent *)
-{
- QSize cs = m_clear->sizeHint();
- QSize ls = m_legend->sizeHint();
- m_clear->setGeometry(4, 4, cs.width(), cs.height());
- m_legend->setGeometry(4, height() - ls.height() - 4, ls.width(), ls.height());
-}
-
-void PlotWidget::paintEvent(QPaintEvent *)
-{
-#define SCALE(v, mm) ((qreal(1) - (v / mm)) * qreal(0.5) * height())
-
- QColor rvColor = Qt::red;
- QColor cpColor = Qt::green;
- QColor opColor = Qt::blue;
-
-
- QPainter p(this);
- //p.setRenderHints(QPainter::Antialiasing); //too slow for 60fps
- p.fillRect(rect(), Qt::white);
-
- p.setPen(Qt::black);
- p.drawLine(0, SCALE(0, 1), width(), SCALE(0, 1));
-
- if (m_plotitems.isEmpty())
- return;
-
- int x = 2;
- int offset = m_plotitems.size() - width() / 2;
- QList<PlotItem>::const_iterator it = m_plotitems.constBegin();
- if (offset > 0)
- it += (offset - 1);
-
- const PlotItem *last = &(*it++);
-
- while (it != m_plotitems.constEnd()) {
- p.setPen(rvColor.light());
- p.drawLine(qreal(x - 2), SCALE(last->velocity.x(), minMaxVelocity),
- qreal(x), SCALE(it->velocity.x(), minMaxVelocity));
- p.setPen(rvColor.dark());
- p.drawLine(qreal(x - 2), SCALE(last->velocity.y(), minMaxVelocity),
- qreal(x), SCALE(it->velocity.y(), minMaxVelocity));
-
- p.setPen(cpColor.light());
- p.drawLine(qreal(x - 2), SCALE(last->contentPosition.x(), minMaxPosition),
- qreal(x), SCALE(it->contentPosition.x(), minMaxPosition));
- p.setPen(cpColor.dark());
- p.drawLine(qreal(x - 2), SCALE(last->contentPosition.y(), minMaxPosition),
- qreal(x), SCALE(it->contentPosition.y(), minMaxPosition));
-
- p.setPen(opColor.light());
- p.drawLine(qreal(x - 2), SCALE(last->overshootPosition.x(), minMaxPosition),
- qreal(x), SCALE(it->overshootPosition.x(), minMaxPosition));
- p.setPen(opColor.dark());
- p.drawLine(qreal(x - 2), SCALE(last->overshootPosition.y(), minMaxPosition),
- qreal(x), SCALE(it->overshootPosition.y(), minMaxPosition));
-
- last = &(*it++);
- x += 2;
- }
-
- QString toptext = QString("%1 [m/s] / %2 [pix]").arg(minMaxVelocity, 0, 'f', 2).arg(minMaxPosition, 0, 'f', 2);
- QString bottomtext = QString("-%1 [m/s] / -%2 [pix]").arg(minMaxVelocity, 0, 'f', 2).arg(minMaxPosition, 0, 'f', 2);
-
- p.setPen(Qt::black);
- p.drawText(rect(), Qt::AlignTop | Qt::AlignHCenter, toptext);
- p.drawText(rect(), Qt::AlignBottom | Qt::AlignHCenter, bottomtext);
-#undef SCALE
-}
diff --git a/examples/scroller/plot/plotwidget.h b/examples/scroller/plot/plotwidget.h
deleted file mode 100644
index 3c36be9..0000000
--- a/examples/scroller/plot/plotwidget.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef PLOTWIDGET_H
-#define PLOTWIDGET_H
-
-#include <QWidget>
-#include <QPointF>
-
-QT_BEGIN_NAMESPACE
-class QPushButton;
-class QLabel;
-class QScroller;
-QT_END_NAMESPACE
-
-class PlotWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- PlotWidget(bool smallscreen = false);
-
- void setScroller(QWidget *widget);
-
-public slots:
- void reset();
-
-protected:
- void resizeEvent(QResizeEvent *);
- void paintEvent(QPaintEvent *);
-
- bool eventFilter(QObject *obj, QEvent *ev);
-
-private:
-
- struct PlotItem {
- QPointF velocity;
- QPointF contentPosition;
- QPointF overshootPosition;
- };
-
- void addPlotItem(const PlotItem &pi);
-
- QWidget *m_widget;
- QList<PlotItem> m_plotitems;
- qreal minMaxVelocity, minMaxPosition;
- QPushButton *m_clear;
- QLabel *m_legend;
-};
-
-#endif
diff --git a/examples/scroller/plot/settingswidget.cpp b/examples/scroller/plot/settingswidget.cpp
deleted file mode 100644
index c9de008..0000000
--- a/examples/scroller/plot/settingswidget.cpp
+++ /dev/null
@@ -1,689 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QVariant>
-#include <QSlider>
-#include <QHBoxLayout>
-#include <QLabel>
-#include <QPushButton>
-#include <QComboBox>
-#include <QSpinBox>
-#include <QGroupBox>
-#include <QToolButton>
-#include <QCheckBox>
-#include <QScrollBar>
-#include <QPainter>
-#include <QScrollArea>
-#include <QScrollPrepareEvent>
-#include <QApplication>
-#include <QPlainTextEdit>
-#include <QTextBlock>
-#include <qnumeric.h>
-
-#include <QEasingCurve>
-
-#include <QDebug>
-
-#include "math.h"
-
-#include "settingswidget.h"
-#include "qscroller.h"
-#include "qscrollerproperties.h"
-
-class SnapOverlay : public QWidget
-{
- Q_OBJECT
-public:
- SnapOverlay(QWidget *w)
- : QWidget(w)
- {
- setAttribute(Qt::WA_TransparentForMouseEvents);
-
- if (QAbstractScrollArea *area = qobject_cast<QAbstractScrollArea *>(w)) {
- connect(area->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(update()));
- connect(area->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(update()));
- area->viewport()->installEventFilter(this);
- }
- }
- void clear(Qt::Orientation o)
- {
- m_snap[o].clear();
- update();
- }
-
- void set(Qt::Orientation o, qreal first, qreal step)
- {
- m_snap[o] = QList<qreal>() << -Q_INFINITY << first << step;
- update();
- }
-
- void set(Qt::Orientation o, const QList<qreal> &list)
- {
- m_snap[o] = list;
- update();
- }
-
-protected:
- bool eventFilter(QObject *o, QEvent *e)
- {
- if (QAbstractScrollArea *area = qobject_cast<QAbstractScrollArea *>(parentWidget())) {
- if (area->viewport() == o) {
- if (e->type() == QEvent::Move || e->type() == QEvent::Resize) {
- setGeometry(area->viewport()->rect());
- }
- }
- }
- return false;
- }
-
- void paintEvent(QPaintEvent *e)
- {
- if (QAbstractScrollArea *area = qobject_cast<QAbstractScrollArea *>(parentWidget())) {
- int dx = area->horizontalScrollBar()->value();
- int dy = area->verticalScrollBar()->value();
-
- QPainter paint(this);
- paint.fillRect(e->rect(), Qt::transparent);
- paint.setPen(QPen(Qt::red, 9));
-
- if (m_snap[Qt::Horizontal].isEmpty()) {
- } else if (m_snap[Qt::Horizontal][0] == -Q_INFINITY) {
- int start = int(m_snap[Qt::Horizontal][1]);
- int step = int(m_snap[Qt::Horizontal][2]);
- if (step > 0) {
- for (int i = start; i < area->horizontalScrollBar()->maximum(); i += step)
- paint.drawPoint(i - dx, 5);
- }
- } else {
- foreach (qreal r, m_snap[Qt::Horizontal])
- paint.drawPoint(int(r) - dx, 5);
- }
- paint.setPen(QPen(Qt::green, 9));
- if (m_snap[Qt::Vertical].isEmpty()) {
- } else if (m_snap[Qt::Vertical][0] == -Q_INFINITY) {
- int start = int(m_snap[Qt::Vertical][1]);
- int step = int(m_snap[Qt::Vertical][2]);
- if (step > 0) {
- for (int i = start; i < area->verticalScrollBar()->maximum(); i += step)
- paint.drawPoint(5, i - dy);
- }
- } else {
- foreach (qreal r, m_snap[Qt::Vertical])
- paint.drawPoint(5, int(r) - dy);
- }
- }
- }
-
-private:
- QMap<Qt::Orientation, QList<qreal> > m_snap;
-};
-
-struct MetricItem
-{
- QScrollerProperties::ScrollMetric metric;
- const char *name;
- int scaling;
- const char *unit;
- QVariant min, max;
- QVariant step;
-};
-
-class MetricItemUpdater : public QObject
-{
- Q_OBJECT
-public:
- MetricItemUpdater(MetricItem *item)
- : m_item(item)
- , m_widget(0)
- , m_slider(0)
- , m_combo(0)
- , m_valueLabel(0)
- {
- m_frameRateType = QVariant::fromValue(QScrollerProperties::Standard).userType();
- m_overshootPolicyType = QVariant::fromValue(QScrollerProperties::OvershootWhenScrollable).userType();
-
- if (m_item->min.type() == QVariant::EasingCurve) {
- m_combo = new QComboBox();
- m_combo->addItem("OutQuad", QEasingCurve::OutQuad);
- m_combo->addItem("OutCubic", QEasingCurve::OutCubic);
- m_combo->addItem("OutQuart", QEasingCurve::OutQuart);
- m_combo->addItem("OutQuint", QEasingCurve::OutQuint);
- m_combo->addItem("OutExpo", QEasingCurve::OutExpo);
- m_combo->addItem("OutSine", QEasingCurve::OutSine);
- m_combo->addItem("OutCirc", QEasingCurve::OutCirc);
- } else if (m_item->min.userType() == m_frameRateType) {
- m_combo = new QComboBox();
- m_combo->addItem("Standard", QScrollerProperties::Standard);
- m_combo->addItem("60 FPS", QScrollerProperties::Fps60);
- m_combo->addItem("30 FPS", QScrollerProperties::Fps30);
- m_combo->addItem("20 FPS", QScrollerProperties::Fps20);
- } else if (m_item->min.userType() == m_overshootPolicyType) {
- m_combo = new QComboBox();
- m_combo->addItem("When Scrollable", QScrollerProperties::OvershootWhenScrollable);
- m_combo->addItem("Always On", QScrollerProperties::OvershootAlwaysOn);
- m_combo->addItem("Always Off", QScrollerProperties::OvershootAlwaysOff);
- } else {
- m_slider = new QSlider(Qt::Horizontal);
- m_slider->setSingleStep(1);
- m_slider->setMinimum(-1);
- m_slider->setMaximum(qRound((m_item->max.toReal() - m_item->min.toReal()) / m_item->step.toReal()));
- m_slider->setValue(-1);
- m_valueLabel = new QLabel();
- }
- m_nameLabel = new QLabel(QLatin1String(m_item->name));
- if (m_item->unit && m_item->unit[0])
- m_nameLabel->setText(m_nameLabel->text() + QLatin1String(" [") + QLatin1String(m_item->unit) + QLatin1String("]"));
- m_resetButton = new QToolButton();
- m_resetButton->setText(QLatin1String("Reset"));
- m_resetButton->setEnabled(false);
-
- connect(m_resetButton, SIGNAL(clicked()), this, SLOT(reset()));
- if (m_slider) {
- connect(m_slider, SIGNAL(valueChanged(int)), this, SLOT(controlChanged(int)));
- m_slider->setMinimum(0);
- } else if (m_combo) {
- connect(m_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(controlChanged(int)));
- }
- }
-
- void setScroller(QWidget *widget)
- {
- m_widget = widget;
- QScroller *scroller = QScroller::scroller(widget);
- QScrollerProperties properties = QScroller::scroller(widget)->scrollerProperties();
-
- if (m_slider)
- m_slider->setEnabled(scroller);
- if (m_combo)
- m_combo->setEnabled(scroller);
- m_nameLabel->setEnabled(scroller);
- if (m_valueLabel)
- m_valueLabel->setEnabled(scroller);
- m_resetButton->setEnabled(scroller);
-
- if (!scroller)
- return;
-
- m_default_value = properties.scrollMetric(m_item->metric);
- valueChanged(m_default_value);
- }
-
- QWidget *nameLabel() { return m_nameLabel; }
- QWidget *valueLabel() { return m_valueLabel; }
- QWidget *valueControl() { if (m_combo) return m_combo; else return m_slider; }
- QWidget *resetButton() { return m_resetButton; }
-
-private slots:
- void valueChanged(const QVariant &v)
- {
- m_value = v;
- if (m_slider) {
- switch (m_item->min.type()) {
- case QMetaType::Float:
- case QVariant::Double: {
- m_slider->setValue(qRound((m_value.toReal() * m_item->scaling - m_item->min.toReal()) / m_item->step.toReal()));
- break;
- }
- case QVariant::Int: {
- m_slider->setValue(qRound((m_value.toInt() * m_item->scaling - m_item->min.toInt()) / m_item->step.toInt()));
- break;
- }
- default: break;
- }
- } else if (m_combo) {
- if (m_item->min.type() == QVariant::EasingCurve) {
- m_combo->setCurrentIndex(m_combo->findData(v.toEasingCurve().type()));
- } else if (m_item->min.userType() == m_overshootPolicyType) {
- m_combo->setCurrentIndex(m_combo->findData(v.value<QScrollerProperties::OvershootPolicy>()));
- } else if (m_item->min.userType() == m_frameRateType) {
- m_combo->setCurrentIndex(m_combo->findData(v.value<QScrollerProperties::FrameRates>()));
- }
- }
- }
-
- void controlChanged(int value)
- {
- bool combo = (m_combo && (sender() == m_combo));
- QString text;
-
- if (m_slider && !combo) {
- switch (m_item->min.type()) {
- case QMetaType::Float:
- case QVariant::Double: {
- qreal d = m_item->min.toReal() + qreal(value) * m_item->step.toReal();
- text = QString::number(d);
- m_value = d / qreal(m_item->scaling);
- break;
- }
- case QVariant::Int: {
- int i = m_item->min.toInt() + qRound(qreal(value) * m_item->step.toReal());
- text = QString::number(i);
- m_value = i / m_item->scaling;
- break;
- }
- default: break;
- }
- } else if (m_combo && combo) {
- if (m_item->min.type() == QVariant::EasingCurve) {
- m_value = QVariant(QEasingCurve(static_cast<QEasingCurve::Type>(m_combo->itemData(value).toInt())));
- } else if (m_item->min.userType() == m_overshootPolicyType) {
- m_value = QVariant::fromValue(static_cast<QScrollerProperties::OvershootPolicy>(m_combo->itemData(value).toInt()));
- } else if (m_item->min.userType() == m_frameRateType) {
- m_value = QVariant::fromValue(static_cast<QScrollerProperties::FrameRates>(m_combo->itemData(value).toInt()));
- }
- }
- if (m_valueLabel)
- m_valueLabel->setText(text);
- if (m_widget && QScroller::scroller(m_widget)) {
- QScrollerProperties properties = QScroller::scroller(m_widget)->scrollerProperties();
- properties.setScrollMetric(m_item->metric, m_value);
- QScroller::scroller(m_widget)->setScrollerProperties(properties);
- }
-
- m_resetButton->setEnabled(m_value != m_default_value);
- }
-
- void reset()
- {
- QScrollerProperties properties = QScroller::scroller(m_widget)->scrollerProperties();
- properties.setScrollMetric(m_item->metric, m_value);
- QScroller::scroller(m_widget)->setScrollerProperties(properties);
- valueChanged(m_default_value);
- }
-
-private:
- MetricItem *m_item;
- int m_frameRateType;
- int m_overshootPolicyType;
-
- QWidget *m_widget;
- QSlider *m_slider;
- QComboBox *m_combo;
- QLabel *m_nameLabel, *m_valueLabel;
- QToolButton *m_resetButton;
-
- QVariant m_value, m_default_value;
-};
-
-#define METRIC(x) QScrollerProperties::x, #x
-
-MetricItem items[] = {
- { METRIC(MousePressEventDelay), 1000, "ms", qreal(0), qreal(2000), qreal(10) },
- { METRIC(DragStartDistance), 1000, "mm", qreal(1), qreal(20), qreal(0.1) },
- { METRIC(DragVelocitySmoothingFactor), 1, "", qreal(0), qreal(1), qreal(0.1) },
- { METRIC(AxisLockThreshold), 1, "", qreal(0), qreal(1), qreal(0.01) },
-
- { METRIC(ScrollingCurve), 1, "", QEasingCurve(), 0, 0 },
- { METRIC(DecelerationFactor), 1, "", qreal(0), qreal(3), qreal(0.01) },
-
- { METRIC(MinimumVelocity), 1, "m/s", qreal(0), qreal(7), qreal(0.01) },
- { METRIC(MaximumVelocity), 1, "m/s", qreal(0), qreal(7), qreal(0.01) },
- { METRIC(MaximumClickThroughVelocity), 1, "m/s", qreal(0), qreal(7), qreal(0.01) },
-
- { METRIC(AcceleratingFlickMaximumTime), 1000, "ms", qreal(100), qreal(5000), qreal(100) },
- { METRIC(AcceleratingFlickSpeedupFactor), 1, "", qreal(1), qreal(7), qreal(0.1) },
-
- { METRIC(SnapPositionRatio), 1, "", qreal(0.1), qreal(0.9), qreal(0.1) },
- { METRIC(SnapTime), 1000, "ms", qreal(0), qreal(2000), qreal(10) },
-
- { METRIC(OvershootDragResistanceFactor), 1, "", qreal(0), qreal(1), qreal(0.01) },
- { METRIC(OvershootDragDistanceFactor), 1, "", qreal(0), qreal(1), qreal(0.01) },
- { METRIC(OvershootScrollDistanceFactor), 1, "", qreal(0), qreal(1), qreal(0.01) },
- { METRIC(OvershootScrollTime), 1000, "ms", qreal(0), qreal(2000), qreal(10) },
-
- { METRIC(HorizontalOvershootPolicy), 1, "", QVariant::fromValue(QScrollerProperties::OvershootWhenScrollable), 0, 0 },
- { METRIC(VerticalOvershootPolicy), 1, "", QVariant::fromValue(QScrollerProperties::OvershootWhenScrollable), 0, 0 },
- { METRIC(FrameRate), 1, "", QVariant::fromValue(QScrollerProperties::Standard), 0, 0 },
-};
-
-#undef METRIC
-
-void SettingsWidget::addToGrid(QGridLayout *grid, QWidget *label, int widgetCount, ...)
-{
- va_list args;
- va_start(args, widgetCount);
-
- int rows = grid->rowCount();
- int cols = grid->columnCount();
-
- if (label) {
- if (m_smallscreen)
- grid->addWidget(label, rows++, 0, 1, qMax(cols, widgetCount));
- else
- grid->addWidget(label, rows, 0);
- }
- for (int i = 0; i < widgetCount; i++) {
- if (QWidget *w = va_arg(args, QWidget *))
- grid->addWidget(w, rows, m_smallscreen ? i : i + 1);
- }
- va_end(args);
-}
-
-SettingsWidget::SettingsWidget(bool smallscreen)
- : QScrollArea()
- , m_widget(0)
- , m_snapoverlay(0)
- , m_smallscreen(smallscreen)
-{
- setWindowTitle(QLatin1String("Settings"));
- QWidget *view = new QWidget();
- QVBoxLayout *layout = new QVBoxLayout(view);
- QGroupBox *grp;
- QGridLayout *grid;
-
- // GROUP: SCROLL METRICS
-
- grp = new QGroupBox(QLatin1String("Scroll Metrics"));
- grid = new QGridLayout();
- grid->setVerticalSpacing(m_smallscreen ? 4 : 2);
-
- for (int i = 0; i < int(sizeof(items) / sizeof(items[0])); i++) {
- MetricItemUpdater *u = new MetricItemUpdater(items + i);
- u->setParent(this);
- addToGrid(grid, u->nameLabel(), 3, u->valueControl(), u->valueLabel(), u->resetButton());
- m_metrics.append(u);
- }
- grp->setLayout(grid);
- layout->addWidget(grp);
-
- // GROUP: SCROLL TO
-
- grp = new QGroupBox(QLatin1String("Scroll To"));
- grid = new QGridLayout();
- grid->setVerticalSpacing(m_smallscreen ? 4 : 2);
-
- m_scrollx = new QSpinBox();
- m_scrolly = new QSpinBox();
- m_scrolltime = new QSpinBox();
- m_scrolltime->setRange(0, 10000);
- m_scrolltime->setValue(1000);
- m_scrolltime->setSuffix(QLatin1String(" ms"));
- QPushButton *go = new QPushButton(QLatin1String("Go"));
- connect(go, SIGNAL(clicked()), this, SLOT(scrollTo()));
- connect(m_scrollx, SIGNAL(editingFinished()), this, SLOT(scrollTo()));
- connect(m_scrolly, SIGNAL(editingFinished()), this, SLOT(scrollTo()));
- connect(m_scrolltime, SIGNAL(editingFinished()), this, SLOT(scrollTo()));
- grid->addWidget(new QLabel(QLatin1String("X:")), 0, 0);
- grid->addWidget(m_scrollx, 0, 1);
- grid->addWidget(new QLabel(QLatin1String("Y:")), 0, 2);
- grid->addWidget(m_scrolly, 0, 3);
- int row = smallscreen ? 1 : 0;
- int col = smallscreen ? 0 : 4;
- grid->addWidget(new QLabel(QLatin1String("in")), row, col++);
- grid->addWidget(m_scrolltime, row, col++);
- if (smallscreen) {
- grid->addWidget(go, row, col + 1);
- } else {
- grid->addWidget(go, row, col);
- grid->setColumnStretch(5, 1);
- grid->setColumnStretch(6, 1);
- }
- grid->setColumnStretch(1, 1);
- grid->setColumnStretch(3, 1);
- grp->setLayout(grid);
- layout->addWidget(grp);
-
- QLayout *snapbox = new QHBoxLayout();
-
- // GROUP: SNAP POINTS X
-
- grp = new QGroupBox(QLatin1String("Snap Positions X"));
- QBoxLayout *vbox = new QVBoxLayout();
- vbox->setSpacing(m_smallscreen ? 4 : 2);
- m_snapx = new QComboBox();
- m_snapx->addItem(QLatin1String("No Snapping"), NoSnap);
- m_snapx->addItem(QLatin1String("Snap to Interval"), SnapToInterval);
- m_snapx->addItem(QLatin1String("Snap to List"), SnapToList);
- connect(m_snapx, SIGNAL(currentIndexChanged(int)), this, SLOT(snapModeChanged(int)));
- vbox->addWidget(m_snapx);
-
- m_snapxinterval = new QWidget();
- grid = new QGridLayout();
- grid->setVerticalSpacing(m_smallscreen ? 4 : 2);
- m_snapxfirst = new QSpinBox();
- connect(m_snapxfirst, SIGNAL(valueChanged(int)), this, SLOT(snapPositionsChanged()));
- grid->addWidget(new QLabel("First:"), 0, 0);
- grid->addWidget(m_snapxfirst, 0, 1);
- m_snapxstep = new QSpinBox();
- connect(m_snapxstep, SIGNAL(valueChanged(int)), this, SLOT(snapPositionsChanged()));
- grid->addWidget(new QLabel("Interval:"), 0, 2);
- grid->addWidget(m_snapxstep, 0, 3);
- m_snapxinterval->setLayout(grid);
- vbox->addWidget(m_snapxinterval);
- m_snapxinterval->hide();
-
- m_snapxlist = new QPlainTextEdit();
- m_snapxlist->setToolTip(QLatin1String("One snap position per line. Empty lines are ignored."));
- m_snapxlist->installEventFilter(this);
- connect(m_snapxlist, SIGNAL(textChanged()), this, SLOT(snapPositionsChanged()));
- vbox->addWidget(m_snapxlist);
- m_snapxlist->hide();
-
- vbox->addStretch(100);
- grp->setLayout(vbox);
- snapbox->addWidget(grp);
-
- // GROUP: SNAP POINTS Y
-
- grp = new QGroupBox(QLatin1String("Snap Positions Y"));
- vbox = new QVBoxLayout();
- vbox->setSpacing(m_smallscreen ? 4 : 2);
- m_snapy = new QComboBox();
- m_snapy->addItem(QLatin1String("No Snapping"), NoSnap);
- m_snapy->addItem(QLatin1String("Snap to Interval"), SnapToInterval);
- m_snapy->addItem(QLatin1String("Snap to List"), SnapToList);
- connect(m_snapy, SIGNAL(currentIndexChanged(int)), this, SLOT(snapModeChanged(int)));
- vbox->addWidget(m_snapy);
-
- m_snapyinterval = new QWidget();
- grid = new QGridLayout();
- grid->setVerticalSpacing(m_smallscreen ? 4 : 2);
- m_snapyfirst = new QSpinBox();
- connect(m_snapyfirst, SIGNAL(valueChanged(int)), this, SLOT(snapPositionsChanged()));
- grid->addWidget(new QLabel("First:"), 0, 0);
- grid->addWidget(m_snapyfirst, 0, 1);
- m_snapystep = new QSpinBox();
- connect(m_snapystep, SIGNAL(valueChanged(int)), this, SLOT(snapPositionsChanged()));
- grid->addWidget(new QLabel("Interval:"), 0, 2);
- grid->addWidget(m_snapystep, 0, 3);
- m_snapyinterval->setLayout(grid);
- vbox->addWidget(m_snapyinterval);
- m_snapyinterval->hide();
-
- m_snapylist = new QPlainTextEdit();
- m_snapylist->setToolTip(QLatin1String("One snap position per line. Empty lines are ignored."));
- m_snapylist->installEventFilter(this);
- connect(m_snapylist, SIGNAL(textChanged()), this, SLOT(snapPositionsChanged()));
- vbox->addWidget(m_snapylist);
- m_snapylist->hide();
-
- vbox->addStretch(100);
- grp->setLayout(vbox);
- snapbox->addWidget(grp);
-
- layout->addLayout(snapbox);
-
- layout->addStretch(100);
- setWidget(view);
- setWidgetResizable(true);
-}
-
-void SettingsWidget::setScroller(QWidget *widget)
-{
- delete m_snapoverlay;
- if (m_widget)
- m_widget->removeEventFilter(this);
- QAbstractScrollArea *area = qobject_cast<QAbstractScrollArea *>(widget);
- if (area)
- widget = area->viewport();
- m_widget = widget;
- m_widget->installEventFilter(this);
- m_snapoverlay = new SnapOverlay(area);
- QScrollerProperties properties = QScroller::scroller(widget)->scrollerProperties();
-
- QMutableListIterator<MetricItemUpdater *> it(m_metrics);
- while (it.hasNext())
- it.next()->setScroller(widget);
-
- if (!widget)
- return;
-
- updateScrollRanges();
-}
-
-bool SettingsWidget::eventFilter(QObject *o, QEvent *e)
-{
- if (o == m_widget && e->type() == QEvent::Resize)
- updateScrollRanges();
- return false;
-}
-
-void SettingsWidget::updateScrollRanges()
-{
- QScrollPrepareEvent spe(QPoint(0, 0));
- QApplication::sendEvent(m_widget, &spe);
-
- QSizeF vp = spe.viewportSize();
- QRectF maxc = spe.contentPosRange();
-
- m_scrollx->setRange(qRound(-vp.width()), qRound(maxc.width() + vp.width()));
- m_scrolly->setRange(qRound(-vp.height()), qRound(maxc.height() + vp.height()));
-
- m_snapxfirst->setRange(maxc.left(), maxc.right());
- m_snapxstep->setRange(0, maxc.width());
- m_snapyfirst->setRange(maxc.top(), maxc.bottom());
- m_snapystep->setRange(0, maxc.height());
-}
-
-void SettingsWidget::scrollTo()
-{
- if (QApplication::activePopupWidget())
- return;
- if ((sender() == m_scrollx) && !m_scrollx->hasFocus())
- return;
- if ((sender() == m_scrolly) && !m_scrolly->hasFocus())
- return;
- if ((sender() == m_scrolltime) && !m_scrolltime->hasFocus())
- return;
-
- if (QScroller *scroller = QScroller::scroller(m_widget))
- scroller->scrollTo(QPointF(m_scrollx->value(), m_scrolly->value()), m_scrolltime->value());
-}
-
-void SettingsWidget::snapModeChanged(int mode)
-{
- if (sender() == m_snapx) {
- m_snapxmode = static_cast<SnapMode>(mode);
- m_snapxinterval->setVisible(mode == SnapToInterval);
- m_snapxlist->setVisible(mode == SnapToList);
- snapPositionsChanged();
- } else if (sender() == m_snapy) {
- m_snapymode = static_cast<SnapMode>(mode);
- m_snapyinterval->setVisible(mode == SnapToInterval);
- m_snapylist->setVisible(mode == SnapToList);
- snapPositionsChanged();
- }
-}
-
-void SettingsWidget::snapPositionsChanged()
-{
- QScroller *s = QScroller::scroller(m_widget);
- if (!s)
- return;
-
- switch (m_snapxmode) {
- case NoSnap:
- s->setSnapPositionsX(QList<qreal>());
- m_snapoverlay->clear(Qt::Horizontal);
- break;
- case SnapToInterval:
- s->setSnapPositionsX(m_snapxfirst->value(), m_snapxstep->value());
- m_snapoverlay->set(Qt::Horizontal, m_snapxfirst->value(), m_snapxstep->value());
- break;
- case SnapToList:
- s->setSnapPositionsX(toPositionList(m_snapxlist, m_snapxfirst->minimum(), m_snapxfirst->maximum()));
- m_snapoverlay->set(Qt::Horizontal, toPositionList(m_snapxlist, m_snapxfirst->minimum(), m_snapxfirst->maximum()));
- break;
- }
- switch (m_snapymode) {
- case NoSnap:
- s->setSnapPositionsY(QList<qreal>());
- m_snapoverlay->clear(Qt::Vertical);
- break;
- case SnapToInterval:
- s->setSnapPositionsY(m_snapyfirst->value(), m_snapystep->value());
- m_snapoverlay->set(Qt::Vertical, m_snapyfirst->value(), m_snapystep->value());
- break;
- case SnapToList:
- s->setSnapPositionsY(toPositionList(m_snapylist, m_snapyfirst->minimum(), m_snapyfirst->maximum()));
- m_snapoverlay->set(Qt::Vertical, toPositionList(m_snapylist, m_snapyfirst->minimum(), m_snapyfirst->maximum()));
- break;
- }
-}
-
-QList<qreal> SettingsWidget::toPositionList(QPlainTextEdit *list, int vmin, int vmax)
-{
- QList<qreal> snaps;
- QList<QTextEdit::ExtraSelection> extrasel;
- QTextEdit::ExtraSelection uline;
- uline.format.setUnderlineColor(Qt::red);
- uline.format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
- int line = 0;
-
- foreach (const QString &str, list->toPlainText().split(QLatin1Char('\n'))) {
- ++line;
- if (str.isEmpty())
- continue;
- bool ok = false;
- double d = str.toDouble(&ok);
- if (ok && d >= vmin && d <= vmax) {
- snaps << d;
- } else {
- QTextEdit::ExtraSelection esel = uline;
- esel.cursor = QTextCursor(list->document()->findBlockByLineNumber(line - 1));
- esel.cursor.select(QTextCursor::LineUnderCursor);
- extrasel << esel;
- }
- }
- list->setExtraSelections(extrasel);
- return snaps;
-}
-
-#include "settingswidget.moc"
diff --git a/examples/scroller/plot/settingswidget.h b/examples/scroller/plot/settingswidget.h
deleted file mode 100644
index fc0acff..0000000
--- a/examples/scroller/plot/settingswidget.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef SETTINGSWIDGET_H
-#define SETTINGSWIDGET_H
-
-#include <QScrollArea>
-
-QT_BEGIN_NAMESPACE
-class QScroller;
-class QGridLayout;
-class QSpinBox;
-class QComboBox;
-class QCheckBox;
-class QPlainTextEdit;
-QT_END_NAMESPACE
-
-class MetricItemUpdater;
-class SnapOverlay;
-
-class SettingsWidget : public QScrollArea
-{
- Q_OBJECT
-
-public:
- SettingsWidget(bool smallscreen = false);
-
- void setScroller(QWidget *widget);
-
-protected:
- bool eventFilter(QObject *, QEvent *);
-
-private slots:
- void scrollTo();
- void snapModeChanged(int);
- void snapPositionsChanged();
-
-private:
- enum SnapMode {
- NoSnap,
- SnapToInterval,
- SnapToList
- };
-
- void addToGrid(QGridLayout *grid, QWidget *label, int widgetCount, ...);
- QList<qreal> toPositionList(QPlainTextEdit *list, int vmin, int vmax);
- void updateScrollRanges();
-
- QWidget *m_widget;
- QSpinBox *m_scrollx, *m_scrolly, *m_scrolltime;
- QList<MetricItemUpdater *> m_metrics;
-
- SnapMode m_snapxmode;
- QComboBox *m_snapx;
- QWidget *m_snapxinterval;
- QPlainTextEdit *m_snapxlist;
- QSpinBox *m_snapxfirst;
- QSpinBox *m_snapxstep;
-
- SnapMode m_snapymode;
- QComboBox *m_snapy;
- QWidget *m_snapyinterval;
- QPlainTextEdit *m_snapylist;
- QSpinBox *m_snapyfirst;
- QSpinBox *m_snapystep;
- SnapOverlay *m_snapoverlay;
-
- bool m_smallscreen;
-};
-
-#endif
diff --git a/examples/scroller/scroller.pro b/examples/scroller/scroller.pro
deleted file mode 100644
index 9a9991a..0000000
--- a/examples/scroller/scroller.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS = graphicsview
-
-contains(QT_CONFIG, webkit):SUBDIRS += plot wheel
-
-# install
-sources.files = *.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/scroller
-INSTALLS += sources
-
-symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/scroller/wheel/main.cpp b/examples/scroller/wheel/main.cpp
deleted file mode 100644
index 4205baf..0000000
--- a/examples/scroller/wheel/main.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtGui>
-#include <qmath.h>
-
-#include "wheelwidget.h"
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-public:
- MainWindow(bool touch)
- : QMainWindow()
- {
- makeSlotMachine(touch);
- setCentralWidget(m_slotMachine);
- }
-
- void makeSlotMachine(bool touch)
- {
- if (QApplication::desktop()->width() > 1000) {
- QFont f = font();
- f.setPointSize(f.pointSize() * 2);
- setFont(f);
- }
-
- m_slotMachine = new QWidget(this);
- QGridLayout *grid = new QGridLayout(m_slotMachine);
- grid->setSpacing(20);
-
- QStringList colors;
- colors << "Red" << "Magenta" << "Peach" << "Orange" << "Yellow" << "Citro" << "Green" << "Cyan" << "Blue" << "Violet";
-
- m_wheel1 = new StringWheelWidget(touch);
- m_wheel1->setItems( colors );
- grid->addWidget( m_wheel1, 0, 0 );
-
- m_wheel2 = new StringWheelWidget(touch);
- m_wheel2->setItems( colors );
- grid->addWidget( m_wheel2, 0, 1 );
-
- m_wheel3 = new StringWheelWidget(touch);
- m_wheel3->setItems( colors );
- grid->addWidget( m_wheel3, 0, 2 );
-
- QPushButton *shakeButton = new QPushButton(tr("Shake"));
- connect(shakeButton, SIGNAL(clicked()), this, SLOT(rotateRandom()));
-
- grid->addWidget( shakeButton, 1, 0, 1, 3 );
- }
-
-private slots:
- void rotateRandom()
- {
- m_wheel1->scrollTo(m_wheel1->currentIndex() + (qrand() % 200));
- m_wheel2->scrollTo(m_wheel2->currentIndex() + (qrand() % 200));
- m_wheel3->scrollTo(m_wheel3->currentIndex() + (qrand() % 200));
- }
-
-private:
- QWidget *m_slotMachine;
-
- StringWheelWidget *m_wheel1;
- StringWheelWidget *m_wheel2;
- StringWheelWidget *m_wheel3;
-};
-
-int main(int argc, char **argv)
-{
- QApplication a(argc, argv);
- bool touch = a.arguments().contains(QLatin1String("--touch"));
- MainWindow mw(touch);
-#ifdef Q_WS_S60
- mw.showMaximized();
-#else
- mw.show();
-#endif
-#ifdef Q_WS_MAC
- mw.raise();
-#endif
- return a.exec();
-}
-
-#include "main.moc"
diff --git a/examples/scroller/wheel/wheel.pro b/examples/scroller/wheel/wheel.pro
deleted file mode 100644
index 48fe171..0000000
--- a/examples/scroller/wheel/wheel.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-HEADERS = wheelwidget.h
-SOURCES = wheelwidget.cpp \
- main.cpp
-
-QT += webkit
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/scroller/wheel
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS wheel.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/scroller/wheel
-INSTALLS += target sources
diff --git a/examples/scroller/wheel/wheelwidget.cpp b/examples/scroller/wheel/wheelwidget.cpp
deleted file mode 100644
index 10eaefb..0000000
--- a/examples/scroller/wheel/wheelwidget.cpp
+++ /dev/null
@@ -1,275 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtGui>
-
-#include "wheelwidget.h"
-
-#define WHEEL_SCROLL_OFFSET 50000.0
-
-AbstractWheelWidget::AbstractWheelWidget(bool touch, QWidget *parent)
- : QWidget(parent)
- , m_currentItem(0)
- , m_itemOffset(0)
-{
-// ![0]
- QScroller::grabGesture(this, touch ? QScroller::TouchGesture : QScroller::LeftMouseButtonGesture);
-// ![0]
-}
-
-AbstractWheelWidget::~AbstractWheelWidget()
-{ }
-
-int AbstractWheelWidget::currentIndex() const
-{
- return m_currentItem;
-}
-
-void AbstractWheelWidget::setCurrentIndex(int index)
-{
- if (index >= 0 && index < itemCount()) {
- m_currentItem = index;
- m_itemOffset = 0;
- update();
- }
-}
-
-bool AbstractWheelWidget::event(QEvent *e)
-{
- switch (e->type()) {
-// ![1]
- case QEvent::ScrollPrepare:
- {
- // We set the snap positions as late as possible so that we are sure
- // we get the correct itemHeight
- QScroller *scroller = QScroller::scroller(this);
- scroller->setSnapPositionsY( WHEEL_SCROLL_OFFSET, itemHeight() );
-
- QScrollPrepareEvent *se = static_cast<QScrollPrepareEvent *>(e);
- se->setViewportSize(QSizeF(size()));
- // we claim a huge scrolling area and a huge content position and
- // hope that the user doesn't notice that the scroll area is restricted
- se->setContentPosRange(QRectF(0.0, 0.0, 0.0, WHEEL_SCROLL_OFFSET * 2));
- se->setContentPos(QPointF(0.0, WHEEL_SCROLL_OFFSET + m_currentItem * itemHeight() + m_itemOffset));
- se->accept();
- return true;
- }
-// ![1]
-// ![2]
- case QEvent::Scroll:
- {
- QScrollEvent *se = static_cast<QScrollEvent *>(e);
-
- qreal y = se->contentPos().y();
- int iy = y - WHEEL_SCROLL_OFFSET;
- int ih = itemHeight();
-
-// ![2]
-
- // -- calculate the current item position and offset and redraw the widget
- int ic = itemCount();
- if (ic>0) {
- m_currentItem = iy / ih % ic;
- m_itemOffset = iy % ih;
-
- // take care when scrolling backwards. Modulo returns negative numbers
- if (m_itemOffset < 0) {
- m_itemOffset += ih;
- m_currentItem--;
- }
-
- if (m_currentItem < 0)
- m_currentItem += ic;
- }
- // -- repaint
- update();
-
- se->accept();
- return true;
- }
- default:
- return QWidget::event(e);
- }
- return true;
-}
-
-void AbstractWheelWidget::paintEvent(QPaintEvent* event)
-{
- Q_UNUSED( event );
-
- // -- first calculate size and position.
- int w = width();
- int h = height();
-
- QPainter painter(this);
- QPalette palette = QApplication::palette();
- QPalette::ColorGroup colorGroup = isEnabled() ? QPalette::Active : QPalette::Disabled;
-
- // linear gradient brush
- QLinearGradient grad(0.5, 0, 0.5, 1.0);
- grad.setColorAt(0, palette.color(colorGroup, QPalette::ButtonText));
- grad.setColorAt(0.2, palette.color(colorGroup, QPalette::Button));
- grad.setColorAt(0.8, palette.color(colorGroup, QPalette::Button));
- grad.setColorAt(1.0, palette.color(colorGroup, QPalette::ButtonText));
- grad.setCoordinateMode( QGradient::ObjectBoundingMode );
- QBrush gBrush( grad );
-
- // paint a border and background
- painter.setPen(palette.color(colorGroup, QPalette::ButtonText));
- painter.setBrush(gBrush);
- // painter.setBrushOrigin( QPointF( 0.0, 0.0 ) );
- painter.drawRect( 0, 0, w-1, h-1 );
-
- // paint inner border
- painter.setPen(palette.color(colorGroup, QPalette::Button));
- painter.setBrush(Qt::NoBrush);
- painter.drawRect( 1, 1, w-3, h-3 );
-
- // paint the items
- painter.setClipRect( QRect( 3, 3, w-6, h-6 ) );
- painter.setPen(palette.color(colorGroup, QPalette::ButtonText));
-
- int iH = itemHeight();
- int iC = itemCount();
- if (iC > 0) {
-
- m_itemOffset = m_itemOffset % iH;
-
- for (int i=-h/2/iH; i<=h/2/iH+1; i++) {
-
- int itemNum = m_currentItem + i;
- while (itemNum < 0)
- itemNum += iC;
- while (itemNum >= iC)
- itemNum -= iC;
-
- paintItem(&painter, itemNum, QRect(6, h/2 +i*iH - m_itemOffset - iH/2, w-6, iH ));
- }
- }
-
- // draw a transparent bar over the center
- QColor highlight = palette.color(colorGroup, QPalette::Highlight);
- highlight.setAlpha(150);
-
- QLinearGradient grad2(0.5, 0, 0.5, 1.0);
- grad2.setColorAt(0, highlight);
- grad2.setColorAt(1.0, highlight.lighter());
- grad2.setCoordinateMode( QGradient::ObjectBoundingMode );
- QBrush gBrush2( grad2 );
-
- QLinearGradient grad3(0.5, 0, 0.5, 1.0);
- grad3.setColorAt(0, highlight);
- grad3.setColorAt(1.0, highlight.darker());
- grad3.setCoordinateMode( QGradient::ObjectBoundingMode );
- QBrush gBrush3( grad3 );
-
- painter.fillRect( QRect( 0, h/2 - iH/2, w, iH/2 ), gBrush2 );
- painter.fillRect( QRect( 0, h/2, w, iH/2 ), gBrush3 );
-}
-
-/*!
- Rotates the wheel widget to a given index.
- You can also give an index greater than itemCount or less than zero in which
- case the wheel widget will scroll in the given direction and end up with
- (index % itemCount)
-*/
-void AbstractWheelWidget::scrollTo(int index)
-{
- QScroller *scroller = QScroller::scroller(this);
-
- scroller->scrollTo(QPointF(0, WHEEL_SCROLL_OFFSET + index * itemHeight()), 5000);
-}
-
-/*!
- \class StringWheelWidget
- \brief The StringWheelWidget class is an implementation of the AbstractWheelWidget class that draws QStrings as items.
- \sa AbstractWheelWidget
-*/
-
-StringWheelWidget::StringWheelWidget(bool touch)
- : AbstractWheelWidget(touch)
-{ }
-
-QStringList StringWheelWidget::items() const
-{
- return m_items;
-}
-
-void StringWheelWidget::setItems( const QStringList &items )
-{
- m_items = items;
- if (m_currentItem >= items.count())
- m_currentItem = items.count()-1;
- update();
-}
-
-
-QSize StringWheelWidget::sizeHint() const
-{
- // determine font size
- QFontMetrics fm(font());
-
- return QSize( fm.width("m") * 10 + 6, fm.height() * 7 + 6 );
-}
-
-QSize StringWheelWidget::minimumSizeHint() const
-{
- QFontMetrics fm(font());
-
- return QSize( fm.width("m") * 5 + 6, fm.height() * 3 + 6 );
-}
-
-void StringWheelWidget::paintItem(QPainter* painter, int index, const QRect &rect)
-{
- painter->drawText(rect, Qt::AlignCenter, m_items.at(index));
-}
-
-int StringWheelWidget::itemHeight() const
-{
- QFontMetrics fm(font());
- return fm.height();
-}
-
-int StringWheelWidget::itemCount() const
-{
- return m_items.count();
-}
-
-
diff --git a/examples/scroller/wheel/wheelwidget.h b/examples/scroller/wheel/wheelwidget.h
deleted file mode 100644
index 96dcebf..0000000
--- a/examples/scroller/wheel/wheelwidget.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef WHEELWIDGET_H
-#define WHEELWIDGET_H
-
-#include <QWidget>
-#include <QStringList>
-
-QT_BEGIN_NAMESPACE
-class QPainter;
-class QRect;
-QT_END_NAMESPACE
-
-class AbstractWheelWidget : public QWidget {
- Q_OBJECT
-
-public:
- AbstractWheelWidget(bool touch, QWidget *parent = 0);
- virtual ~AbstractWheelWidget();
-
- int currentIndex() const;
- void setCurrentIndex(int index);
-
- bool event(QEvent*);
- void paintEvent(QPaintEvent *e);
- virtual void paintItem(QPainter* painter, int index, const QRect &rect) = 0;
-
- virtual int itemHeight() const = 0;
- virtual int itemCount() const = 0;
-
-public slots:
- void scrollTo(int index);
-
-signals:
- void stopped(int index);
-
-protected:
- int m_currentItem;
- int m_itemOffset; // 0-itemHeight()
- qreal m_lastY;
-};
-
-
-class StringWheelWidget : public AbstractWheelWidget {
- Q_OBJECT
-
-public:
- StringWheelWidget(bool touch);
-
- QStringList items() const;
- void setItems( const QStringList &items );
-
- QSize sizeHint() const;
- QSize minimumSizeHint() const;
-
- void paintItem(QPainter* painter, int index, const QRect &rect);
-
- int itemHeight() const;
- int itemCount() const;
-
-private:
- QStringList m_items;
-};
-
-#endif // WHEELWIDGET_H
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 75ce68a..f086513 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -94,6 +94,7 @@ Qt {
Q_ENUMS(GestureState)
Q_ENUMS(GestureType)
#endif
+ Q_ENUMS(CursorMoveStyle)
#endif // (defined(Q_MOC_RUN) || defined(QT_JAMBI_RUN))
#if defined(Q_MOC_RUN)
@@ -1784,6 +1785,11 @@ public:
NavigationModeCursorAuto,
NavigationModeCursorForceVisible
};
+
+ enum CursorMoveStyle {
+ LogicalMoveStyle,
+ VisualMoveStyle
+ };
}
#ifdef Q_MOC_RUN
;
diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp
index fbb08fa..a8cf5f1 100644
--- a/src/corelib/kernel/qcoreevent.cpp
+++ b/src/corelib/kernel/qcoreevent.cpp
@@ -231,8 +231,6 @@ QT_BEGIN_NAMESPACE
\value WinIdChange The window system identifer for this native widget has changed
\value Gesture A gesture was triggered (QGestureEvent)
\value GestureOverride A gesture override was triggered (QGestureEvent)
- \value ScrollPrepare The object needs to fill in its geometry information (QScrollPrepareEvent)
- \value Scroll The object needs to scroll to the supplied position (QScrollEvent)
User events should have values between \c User and \c{MaxUser}:
diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h
index c9d311a..c151c5e 100644
--- a/src/corelib/kernel/qcoreevent.h
+++ b/src/corelib/kernel/qcoreevent.h
@@ -288,9 +288,6 @@ public:
Gesture = 198,
GestureOverride = 202,
#endif
- ScrollPrepare = 204,
- Scroll = 205,
-
// 512 reserved for Qt Jambi's MetaCall event
// 513 reserved for Qt Jambi's DeleteOnMainThread event
diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp
index 72e2aa6..e107d88 100644
--- a/src/gui/image/qpixmap_mac.cpp
+++ b/src/gui/image/qpixmap_mac.cpp
@@ -54,6 +54,7 @@
#include <private/qpaintengine_mac_p.h>
#include <private/qt_mac_p.h>
#include <private/qt_cocoa_helpers_mac_p.h>
+#include <private/qapplication_p.h>
#include <limits.h>
#include <string.h>
@@ -73,12 +74,18 @@ static int qt_pixmap_serial = 0;
Q_GUI_EXPORT quint32 *qt_mac_pixmap_get_base(const QPixmap *pix)
{
- return static_cast<QMacPixmapData*>(pix->data.data())->pixels;
+ if (QApplicationPrivate::graphics_system_name == QLatin1String("raster"))
+ return reinterpret_cast<quint32 *>(static_cast<QRasterPixmapData*>(pix->data.data())->buffer()->bits());
+ else
+ return static_cast<QMacPixmapData*>(pix->data.data())->pixels;
}
Q_GUI_EXPORT int qt_mac_pixmap_get_bytes_per_line(const QPixmap *pix)
{
- return static_cast<QMacPixmapData*>(pix->data.data())->bytesPerRow;
+ if (QApplicationPrivate::graphics_system_name == QLatin1String("raster"))
+ return static_cast<QRasterPixmapData*>(pix->data.data())->buffer()->bytesPerLine();
+ else
+ return static_cast<QMacPixmapData*>(pix->data.data())->bytesPerRow;
}
void qt_mac_cgimage_data_free(void *info, const void *memoryToFree, size_t)
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index d671496..0bf85c6 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -62,9 +62,6 @@
#include <qaccessible.h>
#endif
#include <private/qsoftkeymanager_p.h>
-#ifndef QT_NO_GESTURE
-# include <qscroller.h>
-#endif
QT_BEGIN_NAMESPACE
@@ -194,40 +191,6 @@ void QAbstractItemViewPrivate::checkMouseMove(const QPersistentModelIndex &index
}
}
-#ifndef QT_NO_GESTURES
-
-// stores and restores the selection and current item when flicking
-void QAbstractItemViewPrivate::_q_scrollerStateChanged()
-{
- Q_Q(QAbstractItemView);
-
- if (QScroller *scroller = QScroller::scroller(viewport)) {
- switch (scroller->state()) {
- case QScroller::Pressed:
- // store the current selection in case we start scrolling
- if (q->selectionModel()) {
- oldSelection = q->selectionModel()->selection();
- oldCurrent = q->selectionModel()->currentIndex();
- }
- break;
-
- case QScroller::Dragging:
- // restore the old selection if we really start scrolling
- if (q->selectionModel()) {
- q->selectionModel()->select(oldSelection, QItemSelectionModel::ClearAndSelect);
- q->selectionModel()->setCurrentIndex(oldCurrent, QItemSelectionModel::NoUpdate);
- }
- // fall through
-
- default:
- oldSelection = QItemSelection();
- oldCurrent = QModelIndex();
- break;
- }
- }
-}
-
-#endif // QT_NO_GESTURES
/*!
\class QAbstractItemView
@@ -1662,13 +1625,6 @@ bool QAbstractItemView::viewportEvent(QEvent *event)
case QEvent::WindowDeactivate:
d->viewport->update();
break;
- case QEvent::ScrollPrepare:
- executeDelayedItemsLayout();
-#ifndef QT_NO_GESTURES
- connect(QScroller::scroller(d->viewport), SIGNAL(stateChanged(QScroller::State)), this, SLOT(_q_scrollerStateChanged()), Qt::UniqueConnection);
-#endif
- break;
-
default:
break;
}
diff --git a/src/gui/itemviews/qabstractitemview.h b/src/gui/itemviews/qabstractitemview.h
index f11f209..7043a5f 100644
--- a/src/gui/itemviews/qabstractitemview.h
+++ b/src/gui/itemviews/qabstractitemview.h
@@ -359,9 +359,6 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_modelDestroyed())
Q_PRIVATE_SLOT(d_func(), void _q_layoutChanged())
Q_PRIVATE_SLOT(d_func(), void _q_headerDataChanged())
-#ifndef QT_NO_GESTURES
- Q_PRIVATE_SLOT(d_func(), void _q_scrollerStateChanged())
-#endif
friend class QTreeViewPrivate; // needed to compile with MSVC
friend class QAccessibleItemRow;
diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h
index 6041e5e..d5a0d37 100644
--- a/src/gui/itemviews/qabstractitemview_p.h
+++ b/src/gui/itemviews/qabstractitemview_p.h
@@ -114,7 +114,6 @@ public:
virtual void _q_modelDestroyed();
virtual void _q_layoutChanged();
void _q_headerDataChanged() { doDelayedItemsLayout(); }
- void _q_scrollerStateChanged();
void fetchMore();
@@ -415,12 +414,6 @@ public:
QAbstractItemView::ScrollMode verticalScrollMode;
QAbstractItemView::ScrollMode horizontalScrollMode;
-#ifndef QT_NO_GESTURES
- // the selection before the last mouse down. In case we have to restore it for scrolling
- QItemSelection oldSelection;
- QModelIndex oldCurrent;
-#endif
-
bool currentIndexSet;
bool wrapItemText;
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index 20542ea..577d93b 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -2018,15 +2018,12 @@ void qt_init(QApplicationPrivate *priv, int,
(PtrXRRRootToScreen) xrandrLib.resolve("XRRRootToScreen");
X11->ptrXRRQueryExtension =
(PtrXRRQueryExtension) xrandrLib.resolve("XRRQueryExtension");
- X11->ptrXRRSizes =
- (PtrXRRSizes) xrandrLib.resolve("XRRSizes");
}
# else
X11->ptrXRRSelectInput = XRRSelectInput;
X11->ptrXRRUpdateConfiguration = XRRUpdateConfiguration;
X11->ptrXRRRootToScreen = XRRRootToScreen;
X11->ptrXRRQueryExtension = XRRQueryExtension;
- X11->ptrXRRSizes = XRRSizes;
# endif
if (X11->ptrXRRQueryExtension
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 277a5e8..807c385 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -4629,223 +4629,4 @@ const QGestureEventPrivate *QGestureEvent::d_func() const
#endif // QT_NO_GESTURES
-/*!
- \class QScrollPrepareEvent
- \since 4.8
- \ingroup events
-
- \brief The QScrollPrepareEvent class is send in preparation of a scrolling.
-
- The scroll prepare event is send before scrolling (usually by QScroller) is started.
- The object receiving this event should set viewportSize, maxContentPos and contentPos.
- It also should accept this event to indicate that scrolling should be started.
-
- It is not guaranteed that a QScrollEvent will be send after an acceepted
- QScrollPrepareEvent, e.g. in a case where the maximum content position is (0,0).
-
- \sa QScrollEvent, QScroller
-*/
-
-/*!
- Creates new QScrollPrepareEvent
- The \a startPos is the position of a touch or mouse event that started the scrolling.
-*/
-QScrollPrepareEvent::QScrollPrepareEvent(const QPointF &startPos)
- : QEvent(QEvent::ScrollPrepare)
-{
- d = reinterpret_cast<QEventPrivate *>(new QScrollPrepareEventPrivate());
- d_func()->startPos = startPos;
-}
-
-/*!
- Destroys QScrollEvent.
-*/
-QScrollPrepareEvent::~QScrollPrepareEvent()
-{
- delete reinterpret_cast<QScrollPrepareEventPrivate *>(d);
-}
-
-/*!
- Returns the position of the touch or mouse event that started the scrolling.
-*/
-QPointF QScrollPrepareEvent::startPos() const
-{
- return d_func()->startPos;
-}
-
-/*!
- Returns size of the area that is to be scrolled as set by setViewportSize
-
- \sa setViewportSize()
-*/
-QSizeF QScrollPrepareEvent::viewportSize() const
-{
- return d_func()->viewportSize;
-}
-
-/*!
- Returns the range of coordinates for the content as set by setContentPosRange().
-*/
-QRectF QScrollPrepareEvent::contentPosRange() const
-{
- return d_func()->contentPosRange;
-}
-
-/*!
- Returns the current position of the content as set by setContentPos.
-*/
-QPointF QScrollPrepareEvent::contentPos() const
-{
- return d_func()->contentPos;
-}
-
-
-/*!
- Sets the size of the area that is to be scrolled to \a size.
-
- \sa viewportSize()
-*/
-void QScrollPrepareEvent::setViewportSize(const QSizeF &size)
-{
- d_func()->viewportSize = size;
-}
-
-/*!
- Sets the range of content coordinates to \a rect.
-
- \sa contentPosRange()
-*/
-void QScrollPrepareEvent::setContentPosRange(const QRectF &rect)
-{
- d_func()->contentPosRange = rect;
-}
-
-/*!
- Sets the current content position to \a pos.
-
- \sa contentPos()
-*/
-void QScrollPrepareEvent::setContentPos(const QPointF &pos)
-{
- d_func()->contentPos = pos;
-}
-
-
-/*!
- \internal
-*/
-QScrollPrepareEventPrivate *QScrollPrepareEvent::d_func()
-{
- return reinterpret_cast<QScrollPrepareEventPrivate *>(d);
-}
-
-/*!
- \internal
-*/
-const QScrollPrepareEventPrivate *QScrollPrepareEvent::d_func() const
-{
- return reinterpret_cast<const QScrollPrepareEventPrivate *>(d);
-}
-
-/*!
- \class QScrollEvent
- \since 4.8
- \ingroup events
-
- \brief The QScrollEvent class is send when scrolling.
-
- The scroll event is send to indicate that the receiver should be scrolled.
- Usually the receiver should be something visual like QWidget or QGraphicsObject.
-
- Some care should be taken that no conflicting QScrollEvents are sent from two
- sources. Using QScroller::scrollTo is save however.
-
- \sa QScrollPrepareEvent, QScroller
-*/
-
-/*!
- \enum QScrollEvent::ScrollState
-
- This enum describes the states a scroll event can have.
-
- \value ScrollStarted Set for the first scroll event of a scroll activity.
-
- \value ScrollUpdated Set for all but the first and the last scroll event of a scroll activity.
-
- \value ScrollFinished Set for the last scroll event of a scroll activity.
-
- \sa QScrollEvent::scrollState()
-*/
-
-/*!
- Creates a new QScrollEvent
- \a contentPos is the new content position, \a overshootDistance is the
- new overshoot distance while \a scrollState indicates if this scroll
- event is the first one, the last one or some event in between.
-*/
-QScrollEvent::QScrollEvent(const QPointF &contentPos, const QPointF &overshootDistance, ScrollState scrollState)
- : QEvent(QEvent::Scroll)
-{
- d = reinterpret_cast<QEventPrivate *>(new QScrollEventPrivate());
- d_func()->contentPos = contentPos;
- d_func()->overshoot= overshootDistance;
- d_func()->state = scrollState;
-}
-
-/*!
- Destroys QScrollEvent.
-*/
-QScrollEvent::~QScrollEvent()
-{
- delete reinterpret_cast<QScrollEventPrivate *>(d);
-}
-
-/*!
- Returns the new scroll position.
-*/
-QPointF QScrollEvent::contentPos() const
-{
- return d_func()->contentPos;
-}
-
-/*!
- Returns the new overshoot distance.
- See QScroller for an explanation of the term overshoot.
-
- \sa QScroller
-*/
-QPointF QScrollEvent::overshootDistance() const
-{
- return d_func()->overshoot;
-}
-
-/*!
- Returns the current scroll state as a combination of ScrollStateFlag values.
- ScrollStarted (or ScrollFinished) will be set, if this scroll event is the first (or last) event in a scrolling activity.
- Please note that both values can be set at the same time, if the activity consists of a single QScrollEvent.
- All other scroll events in between will have their state set to ScrollUpdated.
-
- A widget could for example revert selections when scrolling is started and stopped.
-*/
-QScrollEvent::ScrollState QScrollEvent::scrollState() const
-{
- return d_func()->state;
-}
-
-/*!
- \internal
-*/
-QScrollEventPrivate *QScrollEvent::d_func()
-{
- return reinterpret_cast<QScrollEventPrivate *>(d);
-}
-
-/*!
- \internal
-*/
-const QScrollEventPrivate *QScrollEvent::d_func() const
-{
- return reinterpret_cast<const QScrollEventPrivate *>(d);
-}
-
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index 93c2bc5..830f037 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -889,52 +889,6 @@ private:
};
#endif // QT_NO_GESTURES
-class QScrollPrepareEventPrivate;
-class Q_GUI_EXPORT QScrollPrepareEvent : public QEvent
-{
-public:
- QScrollPrepareEvent(const QPointF &startPos);
- ~QScrollPrepareEvent();
-
- QPointF startPos() const;
-
- QSizeF viewportSize() const;
- QRectF contentPosRange() const;
- QPointF contentPos() const;
-
- void setViewportSize(const QSizeF &size);
- void setContentPosRange(const QRectF &rect);
- void setContentPos(const QPointF &pos);
-
-private:
- QScrollPrepareEventPrivate *d_func();
- const QScrollPrepareEventPrivate *d_func() const;
-};
-
-
-class QScrollEventPrivate;
-class Q_GUI_EXPORT QScrollEvent : public QEvent
-{
-public:
- enum ScrollState
- {
- ScrollStarted,
- ScrollUpdated,
- ScrollFinished
- };
-
- QScrollEvent(const QPointF &contentPos, const QPointF &overshoot, ScrollState scrollState);
- ~QScrollEvent();
-
- QPointF contentPos() const;
- QPointF overshootDistance() const;
- ScrollState scrollState() const;
-
-private:
- QScrollEventPrivate *d_func();
- const QScrollEventPrivate *d_func() const;
-};
-
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h
index b79f372..36655e8 100644
--- a/src/gui/kernel/qevent_p.h
+++ b/src/gui/kernel/qevent_p.h
@@ -186,34 +186,6 @@ public:
#endif
};
-
-class QScrollPrepareEventPrivate
-{
-public:
- inline QScrollPrepareEventPrivate()
- : target(0)
- {
- }
-
- QObject* target;
- QPointF startPos;
- QSizeF viewportSize;
- QRectF contentPosRange;
- QPointF contentPos;
-};
-
-class QScrollEventPrivate
-{
-public:
- inline QScrollEventPrivate()
- {
- }
-
- QPointF contentPos;
- QPointF overshoot;
- QScrollEvent::ScrollState state;
-};
-
QT_END_NAMESPACE
#endif // QEVENT_P_H
diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h
index 69079cf..8ab129c 100644
--- a/src/gui/kernel/qt_x11_p.h
+++ b/src/gui/kernel/qt_x11_p.h
@@ -226,7 +226,6 @@ typedef void (*PtrXRRSelectInput)(Display *, Window, int);
typedef int (*PtrXRRUpdateConfiguration)(XEvent *);
typedef int (*PtrXRRRootToScreen)(Display *, Window);
typedef Bool (*PtrXRRQueryExtension)(Display *, int *, int *);
-typedef XRRScreenSize *(*PtrXRRSizes)(Display *, int, int *);
#endif // QT_NO_XRANDR
#ifndef QT_NO_XINPUT
@@ -711,7 +710,6 @@ struct QX11Data
PtrXRRUpdateConfiguration ptrXRRUpdateConfiguration;
PtrXRRRootToScreen ptrXRRRootToScreen;
PtrXRRQueryExtension ptrXRRQueryExtension;
- PtrXRRSizes ptrXRRSizes;
#endif // QT_NO_XRANDR
};
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 80d7b85..4c1a6dd 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -1389,16 +1389,6 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
QApplication::postEvent(q, new QEvent(QEvent::PolishRequest));
extraPaintEngine = 0;
-
-#ifdef QT_MAC_USE_COCOA
- // If we add a child to the unified toolbar, we have to redirect the painting.
- if (parentWidget && parentWidget->d_func() && parentWidget->d_func()->isInUnifiedToolbar) {
- if (parentWidget->d_func()->unifiedSurface) {
- QWidget *toolbar = parentWidget->d_func()->toolbar_ancestor;
- parentWidget->d_func()->unifiedSurface->recursiveRedirect(toolbar, toolbar, toolbar->d_func()->toolbar_offset);
- }
- }
-#endif // QT_MAC_USE_COCOA
}
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 354f05b..468de22 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -2733,7 +2733,7 @@ QWidget::macCGHandle() const
return handle();
}
-void qt_mac_repaintParentUnderAlienWidget(QWidget *alienWidget)
+void qt_mac_updateParentUnderAlienWidget(QWidget *alienWidget)
{
QWidget *nativeParent = alienWidget->nativeParentWidget();
if (!nativeParent)
@@ -2741,7 +2741,7 @@ void qt_mac_repaintParentUnderAlienWidget(QWidget *alienWidget)
QPoint globalPos = alienWidget->mapToGlobal(QPoint(0, 0));
QRect dirtyRect = QRect(nativeParent->mapFromGlobal(globalPos), alienWidget->size());
- nativeParent->repaint(dirtyRect);
+ nativeParent->update(dirtyRect);
}
void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
@@ -2752,7 +2752,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
if (!isWindow() && parentWidget())
parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry()));
if (!internalWinId())
- qt_mac_repaintParentUnderAlienWidget(this);
+ qt_mac_updateParentUnderAlienWidget(this);
d->deactivateWidgetCleanup();
qt_mac_event_release(this);
if(testAttribute(Qt::WA_WState_Created)) {
@@ -3032,6 +3032,16 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
q->setAttribute(Qt::WA_WState_Hidden);
q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden);
+#ifdef QT_MAC_USE_COCOA
+ // If we add a child to the unified toolbar, we have to redirect the painting.
+ if (parent && parent->d_func() && parent->d_func()->isInUnifiedToolbar) {
+ if (parent->d_func()->unifiedSurface) {
+ QWidget *toolbar = parent->d_func()->toolbar_ancestor;
+ parent->d_func()->unifiedSurface->recursiveRedirect(toolbar, toolbar, toolbar->d_func()->toolbar_offset);
+ }
+ }
+#endif // QT_MAC_USE_COCOA
+
if (wasCreated) {
transferChildren();
#ifndef QT_MAC_USE_COCOA
@@ -3526,8 +3536,8 @@ void QWidgetPrivate::show_sys()
// INVARIANT: q is native. Just show the view:
[view setHidden:NO];
} else {
- // INVARIANT: q is alien. Repaint q instead:
- q->repaint();
+ // INVARIANT: q is alien. Update q instead:
+ q->update();
}
#endif
}
@@ -3683,7 +3693,7 @@ void QWidgetPrivate::hide_sys()
[view setHidden:YES];
} else {
// INVARIANT: q is alien. Repaint where q is placed instead:
- qt_mac_repaintParentUnderAlienWidget(q);
+ qt_mac_updateParentUnderAlienWidget(q);
}
#endif
}
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index ff6c24e..cd87d21 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -532,8 +532,7 @@ QString QColor::name() const
void QColor::setNamedColor(const QString &name)
{
- if (!setColorFromString(name))
- qWarning("QColor::setNamedColor: Unknown color name '%s'", name.toLatin1().constData());
+ setColorFromString(name);
}
/*!
diff --git a/src/gui/painting/qgraphicssystemfactory.cpp b/src/gui/painting/qgraphicssystemfactory.cpp
index 62a60d7..6212674 100644
--- a/src/gui/painting/qgraphicssystemfactory.cpp
+++ b/src/gui/painting/qgraphicssystemfactory.cpp
@@ -74,7 +74,7 @@ QGraphicsSystem *QGraphicsSystemFactory::create(const QString& key)
if (system.isEmpty()) {
system = QLatin1String("runtime");
}
-#elif defined (QT_GRAPHICSSYSTEM_RASTER) && !defined(Q_WS_WIN) && !defined(Q_OS_SYMBIAN) || defined(Q_WS_X11)
+#elif defined (QT_GRAPHICSSYSTEM_RASTER) && !defined(Q_WS_WIN) && !defined(Q_OS_SYMBIAN) || defined(Q_WS_X11) || (defined (Q_WS_MAC) && defined(QT_MAC_USE_COCOA))
if (system.isEmpty()) {
system = QLatin1String("raster");
}
diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp
index 51171c5..6f6cd6f 100644
--- a/src/gui/painting/qpaintbuffer.cpp
+++ b/src/gui/painting/qpaintbuffer.cpp
@@ -1768,12 +1768,12 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd)
rawFontD->fontEngine = fontD->engineForScript(QUnicodeTables::Common);
rawFontD->fontEngine->ref.ref();
- QGlyphs glyphs;
- glyphs.setFont(rawFont);
+ QGlyphRun glyphs;
+ glyphs.setRawFont(rawFont);
glyphs.setGlyphIndexes(glyphIndexes);
glyphs.setPositions(positions);
- painter->drawGlyphs(QPointF(), glyphs);
+ painter->drawGlyphRun(QPointF(), glyphs);
break;
}
#endif
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 3fd4c5b..a965c15 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -62,7 +62,7 @@
#include "qthread.h"
#include "qvarlengtharray.h"
#include "qstatictext.h"
-#include "qglyphs.h"
+#include "qglyphrun.h"
#include <private/qfontengine_p.h>
#include <private/qpaintengine_p.h>
@@ -73,7 +73,7 @@
#include <private/qpaintengine_raster_p.h>
#include <private/qmath_p.h>
#include <private/qstatictext_p.h>
-#include <private/qglyphs_p.h>
+#include <private/qglyphrun_p.h>
#include <private/qstylehelper_p.h>
#include <private/qrawfont_p.h>
@@ -5798,19 +5798,19 @@ void QPainter::drawImage(const QRectF &targetRect, const QImage &image, const QR
\since 4.8
- \sa QGlyphs::setFont(), QGlyphs::setPositions(), QGlyphs::setGlyphIndexes()
+ \sa QGlyphRun::setRawFont(), QGlyphRun::setPositions(), QGlyphRun::setGlyphIndexes()
*/
#if !defined(QT_NO_RAWFONT)
-void QPainter::drawGlyphs(const QPointF &position, const QGlyphs &glyphs)
+void QPainter::drawGlyphRun(const QPointF &position, const QGlyphRun &glyphRun)
{
Q_D(QPainter);
- QRawFont font = glyphs.font();
+ QRawFont font = glyphRun.rawFont();
if (!font.isValid())
return;
- QVector<quint32> glyphIndexes = glyphs.glyphIndexes();
- QVector<QPointF> glyphPositions = glyphs.positions();
+ QVector<quint32> glyphIndexes = glyphRun.glyphIndexes();
+ QVector<QPointF> glyphPositions = glyphRun.positions();
int count = qMin(glyphIndexes.size(), glyphPositions.size());
QVarLengthArray<QFixedPoint, 128> fixedPointPositions(count);
@@ -5819,6 +5819,13 @@ void QPainter::drawGlyphs(const QPointF &position, const QGlyphs &glyphs)
d->extended != 0
? qt_paintengine_supports_transformations(d->extended->type())
: qt_paintengine_supports_transformations(d->engine->type());
+
+ // If the matrix is not affine, the paint engine will fall back to
+ // drawing the glyphs as paths, which in turn means we should not
+ // preprocess the glyph positions
+ if (!d->state->matrix.isAffine())
+ paintEngineSupportsTransformations = true;
+
for (int i=0; i<count; ++i) {
QPointF processedPosition = position + glyphPositions.at(i);
if (!paintEngineSupportsTransformations)
@@ -5826,8 +5833,8 @@ void QPainter::drawGlyphs(const QPointF &position, const QGlyphs &glyphs)
fixedPointPositions[i] = QFixedPoint::fromPointF(processedPosition);
}
- d->drawGlyphs(glyphIndexes.data(), fixedPointPositions.data(), count, font, glyphs.overline(),
- glyphs.underline(), glyphs.strikeOut());
+ d->drawGlyphs(glyphIndexes.data(), fixedPointPositions.data(), count, font, glyphRun.overline(),
+ glyphRun.underline(), glyphRun.strikeOut());
}
void QPainterPrivate::drawGlyphs(quint32 *glyphArray, QFixedPoint *positions, int glyphCount,
@@ -5862,7 +5869,7 @@ void QPainterPrivate::drawGlyphs(quint32 *glyphArray, QFixedPoint *positions, in
QFixed width = rightMost - leftMost;
- if (extended != 0) {
+ if (extended != 0 && state->matrix.isAffine()) {
QStaticTextItem staticTextItem;
staticTextItem.color = state->pen.color();
staticTextItem.font = state->font;
diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h
index 1a432e6..601c386 100644
--- a/src/gui/painting/qpainter.h
+++ b/src/gui/painting/qpainter.h
@@ -79,7 +79,7 @@ class QTextItem;
class QMatrix;
class QTransform;
class QStaticText;
-class QGlyphs;
+class QGlyphRun;
class QPainterPrivateDeleter;
@@ -400,7 +400,7 @@ public:
Qt::LayoutDirection layoutDirection() const;
#if !defined(QT_NO_RAWFONT)
- void drawGlyphs(const QPointF &position, const QGlyphs &glyphs);
+ void drawGlyphRun(const QPointF &position, const QGlyphRun &glyphRun);
#endif
void drawStaticText(const QPointF &topLeftPosition, const QStaticText &staticText);
diff --git a/src/gui/painting/qunifiedtoolbarsurface_mac_p.h b/src/gui/painting/qunifiedtoolbarsurface_mac_p.h
index 0a7ebf1..ce07f5c 100644
--- a/src/gui/painting/qunifiedtoolbarsurface_mac_p.h
+++ b/src/gui/painting/qunifiedtoolbarsurface_mac_p.h
@@ -65,6 +65,39 @@ QT_BEGIN_NAMESPACE
class QNativeImage;
+//
+// This is the implementation of the unified toolbar on Mac OS X
+// with the graphics system raster.
+//
+// General idea:
+// -------------
+// We redirect the painting of widgets inside the unified toolbar
+// to a special window surface, the QUnifiedToolbarSurface.
+// We need a separate window surface because the unified toolbar
+// is out of the content view.
+// The input system is the same as for the unified toolbar with the
+// native (CoreGraphics) engine.
+//
+// Execution flow:
+// ---------------
+// The unified toolbar is triggered by QMainWindow::setUnifiedTitleAndToolBarOnMac().
+// It calls QMainWindowLayout::insertIntoMacToolbar() which will
+// set all the appropriate variables (offsets, redirection, ...).
+// When Qt tells a widget to repaint, QWidgetPrivate::drawWidget()
+// checks if the widget is inside the unified toolbar and exits without
+// painting is that is the case.
+// We trigger the rendering of the unified toolbar in QWidget::repaint()
+// and QWidget::update().
+// We keep track of flush requests via "flushRequested" variable. That
+// allow flush() to be a no-op if no repaint occurred for a widget.
+// We rely on the needsDisplay: and drawRect: mecanism for drawing our
+// content into the graphics context.
+//
+// Notes:
+// ------
+// The painting of items inside the unified toolbar is expensive.
+// Too many repaints will drastically slow down the whole application.
+//
class QUnifiedToolbarSurfacePrivate
{
diff --git a/src/gui/text/qfont_mac.cpp b/src/gui/text/qfont_mac.cpp
index daf68c0..044fd84 100644
--- a/src/gui/text/qfont_mac.cpp
+++ b/src/gui/text/qfont_mac.cpp
@@ -43,6 +43,7 @@
#include "qfont_p.h"
#include "qfontengine_p.h"
#include "qfontengine_mac_p.h"
+#include "qfontengine_coretext_p.h"
#include "qfontinfo.h"
#include "qfontmetrics.h"
#include "qpaintdevice.h"
@@ -119,10 +120,10 @@ quint32 QFont::macFontID() const // ### need 64-bit version
// Returns an ATSUFonFamilyRef
Qt::HANDLE QFont::handle() const
{
-#if 0
+#ifdef QT_MAC_USE_COCOA
QFontEngine *fe = d->engineForScript(QUnicodeTables::Common);
- if (fe && fe->type() == QFontEngine::Mac)
- return (Qt::HANDLE)static_cast<QFontEngineMacMulti*>(fe)->fontFamilyRef();
+ if (fe && fe->type() == QFontEngine::Multi)
+ return (Qt::HANDLE)static_cast<QCoreTextFontEngineMulti*>(fe)->macFontID();
#endif
return 0;
}
diff --git a/src/gui/text/qfontengine_coretext.mm b/src/gui/text/qfontengine_coretext.mm
index d4df218..cbf51e6 100644
--- a/src/gui/text/qfontengine_coretext.mm
+++ b/src/gui/text/qfontengine_coretext.mm
@@ -871,7 +871,7 @@ QFontEngine *QCoreTextFontEngine::cloneWithSize(qreal pixelSize) const
newFontDef.pixelSize = pixelSize;
newFontDef.pointSize = pixelSize * 72.0 / qt_defaultDpi();
- return new QCoreTextFontEngine(cgFont, fontDef);
+ return new QCoreTextFontEngine(cgFont, newFontDef);
}
QT_END_NAMESPACE
diff --git a/src/gui/text/qfontengine_coretext_p.h b/src/gui/text/qfontengine_coretext_p.h
index bb80a9b..3775bc6 100644
--- a/src/gui/text/qfontengine_coretext_p.h
+++ b/src/gui/text/qfontengine_coretext_p.h
@@ -124,6 +124,8 @@ public:
QScriptItem *si) const;
virtual const char *name() const { return "CoreText"; }
+ inline CTFontRef macFontID() const { return ctfont; }
+
protected:
virtual void loadEngine(int at);
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 237cde4..4dae2a3 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -1597,7 +1597,7 @@ void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlag
FT_Face face = 0;
bool design = (default_hint_style == HintNone ||
default_hint_style == HintLight ||
- (flags & HB_ShaperFlag_UseDesignMetrics));
+ (flags & HB_ShaperFlag_UseDesignMetrics)) && FT_IS_SCALABLE(freetype->face);
for (int i = 0; i < glyphs->numGlyphs; i++) {
Glyph *g = defaultGlyphSet.getGlyph(glyphs->glyphs[i]);
if (g) {
diff --git a/src/gui/text/qglyphs.cpp b/src/gui/text/qglyphrun.cpp
index cfea6ec..ea52788 100644
--- a/src/gui/text/qglyphs.cpp
+++ b/src/gui/text/qglyphrun.cpp
@@ -43,14 +43,14 @@
#if !defined(QT_NO_RAWFONT)
-#include "qglyphs.h"
-#include "qglyphs_p.h"
+#include "qglyphrun.h"
+#include "qglyphrun_p.h"
QT_BEGIN_NAMESPACE
/*!
- \class QGlyphs
- \brief The QGlyphs class provides direct access to the internal glyphs in a font.
+ \class QGlyphRun
+ \brief The QGlyphRun class provides direct access to the internal glyphs in a font.
\since 4.8
\ingroup text
@@ -67,42 +67,43 @@ QT_BEGIN_NAMESPACE
Under certain circumstances, it can be useful as an application developer to have more low-level
control over which glyphs in a specific font are drawn to the screen. This could for instance
be the case in applications that use an external font engine and text shaper together with Qt.
- QGlyphs provides an interface to the raw data needed to get text on the screen. It
+ QGlyphRun provides an interface to the raw data needed to get text on the screen. It
contains a list of glyph indexes, a position for each glyph and a font.
It is the user's responsibility to ensure that the selected font actually contains the
provided glyph indexes.
- QTextLayout::glyphs() or QTextFragment::glyphs() can be used to convert unicode encoded text
- into a list of QGlyphs objects, and QPainter::drawGlyphs() can be used to draw the glyphs.
+ QTextLayout::glyphRuns() or QTextFragment::glyphRuns() can be used to convert unicode encoded
+ text into a list of QGlyphRun objects, and QPainter::drawGlyphRun() can be used to draw the
+ glyphs.
\note Please note that QRawFont is considered local to the thread in which it is constructed.
- This in turn means that a new QRawFont will have to be created and set on the QGlyphs if it is
- moved to a different thread. If the QGlyphs contains a reference to a QRawFont from a different
+ This in turn means that a new QRawFont will have to be created and set on the QGlyphRun if it is
+ moved to a different thread. If the QGlyphRun contains a reference to a QRawFont from a different
thread than the current, it will not be possible to draw the glyphs using a QPainter, as the
QRawFont is considered invalid and inaccessible in this case.
*/
/*!
- Constructs an empty QGlyphs object.
+ Constructs an empty QGlyphRun object.
*/
-QGlyphs::QGlyphs() : d(new QGlyphsPrivate)
+QGlyphRun::QGlyphRun() : d(new QGlyphRunPrivate)
{
}
/*!
- Constructs a QGlyphs object which is a copy of \a other.
+ Constructs a QGlyphRun object which is a copy of \a other.
*/
-QGlyphs::QGlyphs(const QGlyphs &other)
+QGlyphRun::QGlyphRun(const QGlyphRun &other)
{
d = other.d;
}
/*!
- Destroys the QGlyphs.
+ Destroys the QGlyphRun.
*/
-QGlyphs::~QGlyphs()
+QGlyphRun::~QGlyphRun()
{
// Required for QExplicitlySharedDataPointer
}
@@ -110,26 +111,26 @@ QGlyphs::~QGlyphs()
/*!
\internal
*/
-void QGlyphs::detach()
+void QGlyphRun::detach()
{
if (d->ref != 1)
d.detach();
}
/*!
- Assigns \a other to this QGlyphs object.
+ Assigns \a other to this QGlyphRun object.
*/
-QGlyphs &QGlyphs::operator=(const QGlyphs &other)
+QGlyphRun &QGlyphRun::operator=(const QGlyphRun &other)
{
d = other.d;
return *this;
}
/*!
- Compares \a other to this QGlyphs object. Returns true if the list of glyph indexes,
+ Compares \a other to this QGlyphRun object. Returns true if the list of glyph indexes,
the list of positions and the font are all equal, otherwise returns false.
*/
-bool QGlyphs::operator==(const QGlyphs &other) const
+bool QGlyphRun::operator==(const QGlyphRun &other) const
{
return ((d == other.d)
|| (d->glyphIndexes == other.d->glyphIndexes
@@ -137,14 +138,14 @@ bool QGlyphs::operator==(const QGlyphs &other) const
&& d->overline == other.d->overline
&& d->underline == other.d->underline
&& d->strikeOut == other.d->strikeOut
- && d->font == other.d->font));
+ && d->rawFont == other.d->rawFont));
}
/*!
- Compares \a other to this QGlyphs object. Returns true if any of the list of glyph
+ Compares \a other to this QGlyphRun object. Returns true if any of the list of glyph
indexes, the list of positions or the font are different, otherwise returns false.
*/
-bool QGlyphs::operator!=(const QGlyphs &other) const
+bool QGlyphRun::operator!=(const QGlyphRun &other) const
{
return !(*this == other);
}
@@ -152,13 +153,13 @@ bool QGlyphs::operator!=(const QGlyphs &other) const
/*!
\internal
- Adds together the lists of glyph indexes and positions in \a other and this QGlyphs
- object and returns the result. The font in the returned QGlyphs will be the same as in
- this QGlyphs object.
+ Adds together the lists of glyph indexes and positions in \a other and this QGlyphRun
+ object and returns the result. The font in the returned QGlyphRun will be the same as in
+ this QGlyphRun object.
*/
-QGlyphs QGlyphs::operator+(const QGlyphs &other) const
+QGlyphRun QGlyphRun::operator+(const QGlyphRun &other) const
{
- QGlyphs ret(*this);
+ QGlyphRun ret(*this);
ret += other;
return ret;
}
@@ -166,10 +167,10 @@ QGlyphs QGlyphs::operator+(const QGlyphs &other) const
/*!
\internal
- Appends the glyph indexes and positions in \a other to this QGlyphs object and returns
+ Appends the glyph indexes and positions in \a other to this QGlyphRun object and returns
a reference to the current object.
*/
-QGlyphs &QGlyphs::operator+=(const QGlyphs &other)
+QGlyphRun &QGlyphRun::operator+=(const QGlyphRun &other)
{
detach();
@@ -180,41 +181,41 @@ QGlyphs &QGlyphs::operator+=(const QGlyphs &other)
}
/*!
- Returns the font selected for this QGlyphs object.
+ Returns the font selected for this QGlyphRun object.
- \sa setFont()
+ \sa setRawFont()
*/
-QRawFont QGlyphs::font() const
+QRawFont QGlyphRun::rawFont() const
{
- return d->font;
+ return d->rawFont;
}
/*!
Sets the font in which to look up the glyph indexes to \a font.
- \sa font(), setGlyphIndexes()
+ \sa rawFont(), setGlyphIndexes()
*/
-void QGlyphs::setFont(const QRawFont &font)
+void QGlyphRun::setRawFont(const QRawFont &rawFont)
{
detach();
- d->font = font;
+ d->rawFont = rawFont;
}
/*!
- Returns the glyph indexes for this QGlyphs object.
+ Returns the glyph indexes for this QGlyphRun object.
\sa setGlyphIndexes(), setPositions()
*/
-QVector<quint32> QGlyphs::glyphIndexes() const
+QVector<quint32> QGlyphRun::glyphIndexes() const
{
return d->glyphIndexes;
}
/*!
- Set the glyph indexes for this QGlyphs object to \a glyphIndexes. The glyph indexes must
+ Set the glyph indexes for this QGlyphRun object to \a glyphIndexes. The glyph indexes must
be valid for the selected font.
*/
-void QGlyphs::setGlyphIndexes(const QVector<quint32> &glyphIndexes)
+void QGlyphRun::setGlyphIndexes(const QVector<quint32> &glyphIndexes)
{
detach();
d->glyphIndexes = glyphIndexes;
@@ -223,7 +224,7 @@ void QGlyphs::setGlyphIndexes(const QVector<quint32> &glyphIndexes)
/*!
Returns the position of the edge of the baseline for each glyph in this set of glyph indexes.
*/
-QVector<QPointF> QGlyphs::positions() const
+QVector<QPointF> QGlyphRun::positions() const
{
return d->glyphPositions;
}
@@ -232,87 +233,87 @@ QVector<QPointF> QGlyphs::positions() const
Sets the positions of the edge of the baseline for each glyph in this set of glyph indexes to
\a positions.
*/
-void QGlyphs::setPositions(const QVector<QPointF> &positions)
+void QGlyphRun::setPositions(const QVector<QPointF> &positions)
{
detach();
d->glyphPositions = positions;
}
/*!
- Clears all data in the QGlyphs object.
+ Clears all data in the QGlyphRun object.
*/
-void QGlyphs::clear()
+void QGlyphRun::clear()
{
detach();
d->glyphPositions = QVector<QPointF>();
d->glyphIndexes = QVector<quint32>();
- d->font = QRawFont();
+ d->rawFont = QRawFont();
d->strikeOut = false;
d->overline = false;
d->underline = false;
}
/*!
- Returns true if this QGlyphs should be painted with an overline decoration.
+ Returns true if this QGlyphRun should be painted with an overline decoration.
\sa setOverline()
*/
-bool QGlyphs::overline() const
+bool QGlyphRun::overline() const
{
return d->overline;
}
/*!
- Indicates that this QGlyphs should be painted with an overline decoration if \a overline is true.
- Otherwise the QGlyphs should be painted with no overline decoration.
+ Indicates that this QGlyphRun should be painted with an overline decoration if \a overline is true.
+ Otherwise the QGlyphRun should be painted with no overline decoration.
\sa overline()
*/
-void QGlyphs::setOverline(bool overline)
+void QGlyphRun::setOverline(bool overline)
{
detach();
d->overline = overline;
}
/*!
- Returns true if this QGlyphs should be painted with an underline decoration.
+ Returns true if this QGlyphRun should be painted with an underline decoration.
\sa setUnderline()
*/
-bool QGlyphs::underline() const
+bool QGlyphRun::underline() const
{
return d->underline;
}
/*!
- Indicates that this QGlyphs should be painted with an underline decoration if \a underline is
- true. Otherwise the QGlyphs should be painted with no underline decoration.
+ Indicates that this QGlyphRun should be painted with an underline decoration if \a underline is
+ true. Otherwise the QGlyphRun should be painted with no underline decoration.
\sa underline()
*/
-void QGlyphs::setUnderline(bool underline)
+void QGlyphRun::setUnderline(bool underline)
{
detach();
d->underline = underline;
}
/*!
- Returns true if this QGlyphs should be painted with a strike out decoration.
+ Returns true if this QGlyphRun should be painted with a strike out decoration.
\sa setStrikeOut()
*/
-bool QGlyphs::strikeOut() const
+bool QGlyphRun::strikeOut() const
{
return d->strikeOut;
}
/*!
- Indicates that this QGlyphs should be painted with an strike out decoration if \a strikeOut is
- true. Otherwise the QGlyphs should be painted with no strike out decoration.
+ Indicates that this QGlyphRun should be painted with an strike out decoration if \a strikeOut is
+ true. Otherwise the QGlyphRun should be painted with no strike out decoration.
\sa strikeOut()
*/
-void QGlyphs::setStrikeOut(bool strikeOut)
+void QGlyphRun::setStrikeOut(bool strikeOut)
{
detach();
d->strikeOut = strikeOut;
diff --git a/src/gui/text/qglyphs.h b/src/gui/text/qglyphrun.h
index 4d7dcaf..dcc166e 100644
--- a/src/gui/text/qglyphs.h
+++ b/src/gui/text/qglyphrun.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef QGLYPHS_H
-#define QGLYPHS_H
+#ifndef QGLYPHRUN_H
+#define QGLYPHRUN_H
#include <QtCore/qsharedpointer.h>
#include <QtCore/qvector.h>
@@ -55,16 +55,16 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
-class QGlyphsPrivate;
-class Q_GUI_EXPORT QGlyphs
+class QGlyphRunPrivate;
+class Q_GUI_EXPORT QGlyphRun
{
public:
- QGlyphs();
- QGlyphs(const QGlyphs &other);
- ~QGlyphs();
+ QGlyphRun();
+ QGlyphRun(const QGlyphRun &other);
+ ~QGlyphRun();
- QRawFont font() const;
- void setFont(const QRawFont &font);
+ QRawFont rawFont() const;
+ void setRawFont(const QRawFont &rawFont);
QVector<quint32> glyphIndexes() const;
void setGlyphIndexes(const QVector<quint32> &glyphIndexes);
@@ -74,9 +74,9 @@ public:
void clear();
- QGlyphs &operator=(const QGlyphs &other);
- bool operator==(const QGlyphs &other) const;
- bool operator!=(const QGlyphs &other) const;
+ QGlyphRun &operator=(const QGlyphRun &other);
+ bool operator==(const QGlyphRun &other) const;
+ bool operator!=(const QGlyphRun &other) const;
void setOverline(bool overline);
bool overline() const;
@@ -88,14 +88,14 @@ public:
bool strikeOut() const;
private:
- friend class QGlyphsPrivate;
+ friend class QGlyphRunPrivate;
friend class QTextLine;
- QGlyphs operator+(const QGlyphs &other) const;
- QGlyphs &operator+=(const QGlyphs &other);
+ QGlyphRun operator+(const QGlyphRun &other) const;
+ QGlyphRun &operator+=(const QGlyphRun &other);
void detach();
- QExplicitlySharedDataPointer<QGlyphsPrivate> d;
+ QExplicitlySharedDataPointer<QGlyphRunPrivate> d;
};
QT_END_NAMESPACE
diff --git a/src/gui/text/qglyphs_p.h b/src/gui/text/qglyphrun_p.h
index 944f777..4aa01d6 100644
--- a/src/gui/text/qglyphs_p.h
+++ b/src/gui/text/qglyphrun_p.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef QGLYPHS_P_H
-#define QGLYPHS_P_H
+#ifndef QGLYPHRUN_P_H
+#define QGLYPHRUN_P_H
//
// W A R N I N G
@@ -53,7 +53,7 @@
// We mean it.
//
-#include "qglyphs.h"
+#include "qglyphrun.h"
#include "qrawfont.h"
#include <qfont.h>
@@ -64,21 +64,21 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-class QGlyphsPrivate: public QSharedData
+class QGlyphRunPrivate: public QSharedData
{
public:
- QGlyphsPrivate()
+ QGlyphRunPrivate()
: overline(false)
, underline(false)
, strikeOut(false)
{
}
- QGlyphsPrivate(const QGlyphsPrivate &other)
+ QGlyphRunPrivate(const QGlyphRunPrivate &other)
: QSharedData(other)
, glyphIndexes(other.glyphIndexes)
, glyphPositions(other.glyphPositions)
- , font(other.font)
+ , rawFont(other.rawFont)
, overline(other.overline)
, underline(other.underline)
, strikeOut(other.strikeOut)
@@ -87,7 +87,7 @@ public:
QVector<quint32> glyphIndexes;
QVector<QPointF> glyphPositions;
- QRawFont font;
+ QRawFont rawFont;
uint overline : 1;
uint underline : 1;
diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp
index 46c892c..44ddfd2 100644
--- a/src/gui/text/qrawfont.cpp
+++ b/src/gui/text/qrawfont.cpp
@@ -78,7 +78,7 @@ QT_BEGIN_NAMESPACE
A QRawFont object represents a single, physical instance of a given font in a given pixel size.
I.e. in the typical case it represents a set of TrueType or OpenType font tables and uses a
user specified pixel size to convert metrics into logical pixel units. In can be used in
- combination with the QGlyphs class to draw specific glyph indexes at specific positions, and
+ combination with the QGlyphRun class to draw specific glyph indexes at specific positions, and
also have accessors to some relevant data in the physical font.
QRawFont only provides support for the main font technologies: GDI and DirectWrite on Windows
@@ -87,9 +87,9 @@ QT_BEGIN_NAMESPACE
QRawFont can be constructed in a number of ways:
\list
- \o \l It can be constructed by calling QTextLayout::glyphs() or QTextFragment::glyphs(). The
- returned QGlyphs objects will contain QRawFont objects which represent the actual fonts
- used to render each portion of the text.
+ \o \l It can be constructed by calling QTextLayout::glyphRuns() or QTextFragment::glyphRuns().
+ The returned QGlyphRun objects will contain QRawFont objects which represent the actual
+ fonts used to render each portion of the text.
\o \l It can be constructed by passing a QFont object to QRawFont::fromFont(). The function
will return a QRawFont object representing the font that will be selected as response to
the QFont query and the selected writing system.
@@ -234,7 +234,7 @@ void QRawFont::loadFromData(const QByteArray &fontData,
the pixel in the rasterization of the glyph. Otherwise, the image will be in the format of
QImage::Format_A8 and each pixel will contain the opacity of the pixel in the rasterization.
- \sa pathForGlyph(), QPainter::drawGlyphs()
+ \sa pathForGlyph(), QPainter::drawGlyphRun()
*/
QImage QRawFont::alphaMapForGlyph(quint32 glyphIndex, AntialiasingType antialiasingType,
const QTransform &transform) const
@@ -426,9 +426,9 @@ int QRawFont::weight() const
underlying font. Note that in cases where there are other tables in the font that affect the
shaping of the text, the returned glyph indexes will not correctly represent the rendering
of the text. To get the correctly shaped text, you can use QTextLayout to lay out and shape the
- text, and then call QTextLayout::glyphs() to get the set of glyph index list and QRawFont pairs.
+ text, and then call QTextLayout::glyphRuns() to get the set of glyph index list and QRawFont pairs.
- \sa advancesForGlyphIndexes(), QGlyphs, QTextLayout::glyphs(), QTextFragment::glyphs()
+ \sa advancesForGlyphIndexes(), glyphIndexesForChars(), QGlyphRun, QTextLayout::glyphRuns(), QTextFragment::glyphRuns()
*/
QVector<quint32> QRawFont::glyphIndexesForString(const QString &text) const
{
@@ -437,11 +437,9 @@ QVector<quint32> QRawFont::glyphIndexesForString(const QString &text) const
int nglyphs = text.size();
QVarLengthGlyphLayoutArray glyphs(nglyphs);
- if (!d->fontEngine->stringToCMap(text.data(), text.size(), &glyphs, &nglyphs,
- QTextEngine::GlyphIndicesOnly)) {
+ if (!glyphIndexesForChars(text.data(), text.size(), glyphs.glyphs, &nglyphs)) {
glyphs.resize(nglyphs);
- if (!d->fontEngine->stringToCMap(text.data(), text.size(), &glyphs, &nglyphs,
- QTextEngine::GlyphIndicesOnly)) {
+ if (!glyphIndexesForChars(text.data(), text.size(), glyphs.glyphs, &nglyphs)) {
Q_ASSERT_X(false, Q_FUNC_INFO, "stringToCMap shouldn't fail twice");
return QVector<quint32>();
}
@@ -455,6 +453,26 @@ QVector<quint32> QRawFont::glyphIndexesForString(const QString &text) const
}
/*!
+ Converts a string of unicode points to glyph indexes using the CMAP table in the
+ underlying font. The function works like glyphIndexesForString() except it take
+ an array (\a chars), the results will be returned though \a glyphIndexes array
+ and number of glyphs will be set in \a numGlyphs. The size of \a glyphIndexes array
+ must be at least \a numChars, if that's still not enough, this function will return
+ false, then you can resize \a glyphIndexes from the size returned in \a numGlyphs.
+
+ \sa glyphIndexesForString(), advancesForGlyphIndexes(), QGlyphs, QTextLayout::glyphs(), QTextFragment::glyphs()
+*/
+bool QRawFont::glyphIndexesForChars(const QChar *chars, int numChars, quint32 *glyphIndexes, int *numGlyphs) const
+{
+ if (!isValid())
+ return false;
+
+ QGlyphLayout glyphs;
+ glyphs.glyphs = glyphIndexes;
+ return d->fontEngine->stringToCMap(chars, numChars, &glyphs, numGlyphs, QTextEngine::GlyphIndicesOnly);
+}
+
+/*!
Returns the QRawFont's advances for each of the \a glyphIndexes in pixel units. The advances
give the distance from the position of a given glyph to where the next glyph should be drawn
to make it appear as if the two glyphs are unspaced.
@@ -480,6 +498,36 @@ QVector<QPointF> QRawFont::advancesForGlyphIndexes(const QVector<quint32> &glyph
}
/*!
+ Returns the QRawFont's advances for each of the \a glyphIndexes in pixel units. The advances
+ give the distance from the position of a given glyph to where the next glyph should be drawn
+ to make it appear as if the two glyphs are unspaced. The glyph indexes are given with the
+ array \a glyphIndexes while the results are returned through \a advances, both of them must
+ have \a numGlyphs elements.
+
+ \sa QTextLine::horizontalAdvance(), QFontMetricsF::width()
+*/
+bool QRawFont::advancesForGlyphIndexes(const quint32 *glyphIndexes, QPointF *advances, int numGlyphs) const
+{
+ if (!isValid())
+ return false;
+
+ QGlyphLayout glyphs;
+ glyphs.glyphs = const_cast<HB_Glyph *>(glyphIndexes);
+ glyphs.numGlyphs = numGlyphs;
+ QVarLengthArray<QFixed> advances_x(numGlyphs);
+ QVarLengthArray<QFixed> advances_y(numGlyphs);
+ glyphs.advances_x = advances_x.data();
+ glyphs.advances_y = advances_y.data();
+
+ d->fontEngine->recalcAdvances(&glyphs, 0);
+
+ for (int i=0; i<numGlyphs; ++i)
+ advances[i] = QPointF(glyphs.advances_x[i].toReal(), glyphs.advances_y[i].toReal());
+
+ return true;
+}
+
+/*!
Returns the hinting preference used to construct this QRawFont.
\sa QFont::hintingPreference()
@@ -587,17 +635,17 @@ QRawFont QRawFont::fromFont(const QFont &font, QFontDatabase::WritingSystem writ
layout.beginLayout();
QTextLine line = layout.createLine();
layout.endLayout();
- QList<QGlyphs> list = layout.glyphs();
+ QList<QGlyphRun> list = layout.glyphRuns();
if (list.size()) {
// Pick the one matches the family name we originally requested,
// if none of them match, just pick the first one
for (int i = 0; i < list.size(); i++) {
- QGlyphs glyphs = list.at(i);
- QRawFont rawfont = glyphs.font();
+ QGlyphRun glyphs = list.at(i);
+ QRawFont rawfont = glyphs.rawFont();
if (rawfont.familyName() == font.family())
return rawfont;
}
- return list.at(0).font();
+ return list.at(0).rawFont();
}
return QRawFont();
#else
diff --git a/src/gui/text/qrawfont.h b/src/gui/text/qrawfont.h
index 900c07a..3875fec 100644
--- a/src/gui/text/qrawfont.h
+++ b/src/gui/text/qrawfont.h
@@ -90,6 +90,8 @@ public:
QVector<quint32> glyphIndexesForString(const QString &text) const;
QVector<QPointF> advancesForGlyphIndexes(const QVector<quint32> &glyphIndexes) const;
+ bool glyphIndexesForChars(const QChar *chars, int numChars, quint32 *glyphIndexes, int *numGlyphs) const;
+ bool advancesForGlyphIndexes(const quint32 *glyphIndexes, QPointF *advances, int numGlyphs) const;
QImage alphaMapForGlyph(quint32 glyphIndex,
AntialiasingType antialiasingType = SubPixelAntialiasing,
diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp
index 4f6857a..17bcc6c 100644
--- a/src/gui/text/qtextcursor.cpp
+++ b/src/gui/text/qtextcursor.cpp
@@ -362,7 +362,7 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor
currentCharFormat = -1;
bool adjustX = true;
QTextBlock blockIt = block();
- bool visualMovement = priv->defaultCursorMoveStyle == QTextCursor::Visual;
+ bool visualMovement = priv->defaultCursorMoveStyle == Qt::VisualMoveStyle;
if (!blockIt.isValid())
return false;
@@ -2568,18 +2568,18 @@ QTextDocument *QTextCursor::document() const
}
/*!
- \enum QTextCursor::MoveStyle
+ \enum Qt::CursorMoveStyle
- This enum describes the movement style available to QTextCursor. The options
+ This enum describes the movement style available to text cursors. The options
are:
- \value Logical Within a left-to-right text block, increase cursor position
- when pressing left arrow key, decrease cursor position when pressing the
- right arrow key. If the text block is right-to-left, the opposite behavior
+ \value LogicalMoveStyle Within a left-to-right text block, decrease cursor
+ position when pressing left arrow key, increase cursor position when pressing
+ the right arrow key. If the text block is right-to-left, the opposite behavior
applies.
- \value Visual Pressing the left arrow key will always cause the cursor to move
- left, regardless of the text's writing direction. The same behavior applies to
- right arrow key.
+ \value VisualMoveStyle Pressing the left arrow key will always cause the cursor
+ to move left, regardless of the text's writing direction. Pressing the right
+ arrow key will always cause the cursor to move right.
*/
QT_END_NAMESPACE
diff --git a/src/gui/text/qtextcursor.h b/src/gui/text/qtextcursor.h
index 9e4c0b8..4eaeb41 100644
--- a/src/gui/text/qtextcursor.h
+++ b/src/gui/text/qtextcursor.h
@@ -86,10 +86,6 @@ public:
MoveAnchor,
KeepAnchor
};
- enum MoveStyle {
- Logical,
- Visual
- };
void setPosition(int pos, MoveMode mode = MoveAnchor);
int position() const;
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index 36f3c6c..0d33912 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -589,9 +589,9 @@ void QTextDocument::setDefaultTextOption(const QTextOption &option)
\since 4.8
The default cursor movement style is used by all QTextCursor objects
- created from the document. The default is QTextCursor::Logical.
+ created from the document. The default is Qt::LogicalMoveStyle.
*/
-QTextCursor::MoveStyle QTextDocument::defaultCursorMoveStyle() const
+Qt::CursorMoveStyle QTextDocument::defaultCursorMoveStyle() const
{
Q_D(const QTextDocument);
return d->defaultCursorMoveStyle;
@@ -602,7 +602,7 @@ QTextCursor::MoveStyle QTextDocument::defaultCursorMoveStyle() const
Set the default cursor movement style.
*/
-void QTextDocument::setDefaultCursorMoveStyle(QTextCursor::MoveStyle style)
+void QTextDocument::setDefaultCursorMoveStyle(Qt::CursorMoveStyle style)
{
Q_D(QTextDocument);
d->defaultCursorMoveStyle = style;
@@ -2099,6 +2099,10 @@ QString QTextHtmlExporter::toHtml(const QByteArray &encoding, ExportMode mode)
html += QLatin1String(" font-size:");
html += QString::number(defaultCharFormat.fontPointSize());
html += QLatin1String("pt;");
+ } else if (defaultCharFormat.hasProperty(QTextFormat::FontPixelSize)) {
+ html += QLatin1String(" font-size:");
+ html += QString::number(defaultCharFormat.intProperty(QTextFormat::FontPixelSize));
+ html += QLatin1String("px;");
}
html += QLatin1String(" font-weight:");
@@ -2179,6 +2183,10 @@ bool QTextHtmlExporter::emitCharFormatStyle(const QTextCharFormat &format)
html += QLatin1Char(';');
attributesEmitted = true;
}
+ } else if (format.hasProperty(QTextFormat::FontPixelSize)) {
+ html += QLatin1String(" font-size:");
+ html += QString::number(format.intProperty(QTextFormat::FontPixelSize));
+ html += QLatin1String("px;");
}
if (format.hasProperty(QTextFormat::FontWeight)
diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h
index e515b36..b826dc1 100644
--- a/src/gui/text/qtextdocument.h
+++ b/src/gui/text/qtextdocument.h
@@ -46,7 +46,6 @@
#include <QtCore/qsize.h>
#include <QtCore/qrect.h>
#include <QtGui/qfont.h>
-#include <QtGui/qtextcursor.h>
QT_BEGIN_HEADER
@@ -70,6 +69,7 @@ class QUrl;
class QVariant;
class QRectF;
class QTextOption;
+class QTextCursor;
template<typename T> class QVector;
@@ -269,8 +269,8 @@ public:
QTextOption defaultTextOption() const;
void setDefaultTextOption(const QTextOption &option);
- QTextCursor::MoveStyle defaultCursorMoveStyle() const;
- void setDefaultCursorMoveStyle(QTextCursor::MoveStyle style);
+ Qt::CursorMoveStyle defaultCursorMoveStyle() const;
+ void setDefaultCursorMoveStyle(Qt::CursorMoveStyle style);
Q_SIGNALS:
void contentsChange(int from, int charsRemoves, int charsAdded);
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index 779b1ff..640f7aa 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -209,7 +209,7 @@ QTextDocumentPrivate::QTextDocumentPrivate()
defaultTextOption.setTabStop(80); // same as in qtextengine.cpp
defaultTextOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
- defaultCursorMoveStyle = QTextCursor::Logical;
+ defaultCursorMoveStyle = Qt::LogicalMoveStyle;
indentWidth = 40;
documentMargin = 4;
diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h
index 6563920..e72d676 100644
--- a/src/gui/text/qtextdocument_p.h
+++ b/src/gui/text/qtextdocument_p.h
@@ -342,7 +342,7 @@ private:
public:
QTextOption defaultTextOption;
- QTextCursor::MoveStyle defaultCursorMoveStyle;
+ Qt::CursorMoveStyle defaultCursorMoveStyle;
#ifndef QT_NO_CSSPARSER
QCss::StyleSheet parsedDefaultStyleSheet;
#endif
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index c476485..e06ca1c 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -598,7 +598,7 @@ public:
inline bool visualCursorMovement() const
{
return (visualMovement ||
- (block.docHandle() ? block.docHandle()->defaultCursorMoveStyle == QTextCursor::Visual : false));
+ (block.docHandle() ? block.docHandle()->defaultCursorMoveStyle == Qt::VisualMoveStyle : false));
}
struct SpecialData {
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 01748b9..07aeb72 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -52,8 +52,8 @@
#include "qtextformat_p.h"
#include "qstyleoption.h"
#include "qpainterpath.h"
-#include "qglyphs.h"
-#include "qglyphs_p.h"
+#include "qglyphrun.h"
+#include "qglyphrun_p.h"
#include "qrawfont.h"
#include "qrawfont_p.h"
#include <limits.h>
@@ -579,27 +579,27 @@ bool QTextLayout::cacheEnabled() const
}
/*!
- Set the visual cursor movement style. If the QTextLayout is backed by
+ Set the cursor movement style. If the QTextLayout is backed by
a document, you can ignore this and use the option in QTextDocument,
this option is for widgets like QLineEdit or custom widgets without
- a QTextDocument. Default value is QTextCursor::Logical.
+ a QTextDocument. Default value is Qt::LogicalMoveStyle.
\sa setCursorMoveStyle()
*/
-void QTextLayout::setCursorMoveStyle(QTextCursor::MoveStyle style)
+void QTextLayout::setCursorMoveStyle(Qt::CursorMoveStyle style)
{
- d->visualMovement = style == QTextCursor::Visual ? true : false;
+ d->visualMovement = style == Qt::VisualMoveStyle ? true : false;
}
/*!
The cursor movement style of this QTextLayout. The default is
- QTextCursor::Logical.
+ Qt::LogicalMoveStyle.
\sa setCursorMoveStyle()
*/
-QTextCursor::MoveStyle QTextLayout::cursorMoveStyle() const
+Qt::CursorMoveStyle QTextLayout::cursorMoveStyle() const
{
- return d->visualMovement ? QTextCursor::Visual : QTextCursor::Logical;
+ return d->visualMovement ? Qt::VisualMoveStyle : Qt::LogicalMoveStyle;
}
/*!
@@ -994,12 +994,12 @@ static inline QRectF clipIfValid(const QRectF &rect, const QRectF &clip)
\since 4.8
- \sa draw(), QPainter::drawGlyphs()
+ \sa draw(), QPainter::drawGlyphRun()
*/
#if !defined(QT_NO_RAWFONT)
-QList<QGlyphs> QTextLayout::glyphs() const
+QList<QGlyphRun> QTextLayout::glyphRuns() const
{
- QList<QGlyphs> glyphs;
+ QList<QGlyphRun> glyphs;
for (int i=0; i<d->lines.size(); ++i)
glyphs += QTextLine(i, d).glyphs(-1, -1);
@@ -2093,15 +2093,15 @@ namespace {
\since 4.8
- \sa QTextLayout::glyphs()
+ \sa QTextLayout::glyphRuns()
*/
#if !defined(QT_NO_RAWFONT)
-QList<QGlyphs> QTextLine::glyphs(int from, int length) const
+QList<QGlyphRun> QTextLine::glyphs(int from, int length) const
{
const QScriptLine &line = eng->lines[i];
if (line.length == 0)
- return QList<QGlyphs>();
+ return QList<QGlyphRun>();
QHash<QFontEngine *, GlyphInfo> glyphLayoutHash;
@@ -2166,7 +2166,7 @@ QList<QGlyphs> QTextLine::glyphs(int from, int length) const
}
}
- QHash<QPair<QFontEngine *, int>, QGlyphs> glyphsHash;
+ QHash<QPair<QFontEngine *, int>, QGlyphRun> glyphsHash;
QList<QFontEngine *> keys = glyphLayoutHash.uniqueKeys();
for (int i=0; i<keys.size(); ++i) {
@@ -2223,14 +2223,14 @@ QList<QGlyphs> QTextLine::glyphs(int from, int length) const
positions.append(positionsArray.at(i).toPointF() + pos);
}
- QGlyphs glyphIndexes;
+ QGlyphRun glyphIndexes;
glyphIndexes.setGlyphIndexes(glyphs);
glyphIndexes.setPositions(positions);
glyphIndexes.setOverline(flags.testFlag(QTextItem::Overline));
glyphIndexes.setUnderline(flags.testFlag(QTextItem::Underline));
glyphIndexes.setStrikeOut(flags.testFlag(QTextItem::StrikeOut));
- glyphIndexes.setFont(font);
+ glyphIndexes.setRawFont(font);
QPair<QFontEngine *, int> key(fontEngine, int(flags));
if (!glyphsHash.contains(key))
diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h
index 6aa81f9..89fbfb2 100644
--- a/src/gui/text/qtextlayout.h
+++ b/src/gui/text/qtextlayout.h
@@ -49,7 +49,7 @@
#include <QtCore/qobject.h>
#include <QtGui/qevent.h>
#include <QtGui/qtextformat.h>
-#include <QtGui/qglyphs.h>
+#include <QtGui/qglyphrun.h>
#include <QtGui/qtextcursor.h>
QT_BEGIN_HEADER
@@ -137,8 +137,8 @@ public:
void setCacheEnabled(bool enable);
bool cacheEnabled() const;
- void setCursorMoveStyle(QTextCursor::MoveStyle style);
- QTextCursor::MoveStyle cursorMoveStyle() const;
+ void setCursorMoveStyle(Qt::CursorMoveStyle style);
+ Qt::CursorMoveStyle cursorMoveStyle() const;
void beginLayout();
void endLayout();
@@ -174,7 +174,7 @@ public:
qreal maximumWidth() const;
#if !defined(QT_NO_RAWFONT)
- QList<QGlyphs> glyphs() const;
+ QList<QGlyphRun> glyphRuns() const;
#endif
QTextEngine *engine() const { return d; }
@@ -249,7 +249,7 @@ private:
void layout_helper(int numGlyphs);
#if !defined(QT_NO_RAWFONT)
- QList<QGlyphs> glyphs(int from, int length) const;
+ QList<QGlyphRun> glyphs(int from, int length) const;
#endif
friend class QTextLayout;
diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp
index 5c1c8b9..8dabcc7 100644
--- a/src/gui/text/qtextobject.cpp
+++ b/src/gui/text/qtextobject.cpp
@@ -1664,25 +1664,25 @@ QTextBlock::iterator &QTextBlock::iterator::operator--()
Returns the glyphs of this text fragment. The positions of the glyphs are
relative to the position of the QTextBlock's layout.
- \sa QGlyphs, QTextBlock::layout(), QTextLayout::position(), QPainter::drawGlyphs()
+ \sa QGlyphRun, QTextBlock::layout(), QTextLayout::position(), QPainter::drawGlyphRun()
*/
#if !defined(QT_NO_RAWFONT)
-QList<QGlyphs> QTextFragment::glyphs() const
+QList<QGlyphRun> QTextFragment::glyphRuns() const
{
if (!p || !n)
- return QList<QGlyphs>();
+ return QList<QGlyphRun>();
int pos = position();
int len = length();
if (len == 0)
- return QList<QGlyphs>();
+ return QList<QGlyphRun>();
int blockNode = p->blockMap().findNode(pos);
const QTextBlockData *blockData = p->blockMap().fragment(blockNode);
QTextLayout *layout = blockData->layout;
- QList<QGlyphs> ret;
+ QList<QGlyphRun> ret;
for (int i=0; i<layout->lineCount(); ++i) {
QTextLine textLine = layout->lineAt(i);
ret += textLine.glyphs(pos, len);
diff --git a/src/gui/text/qtextobject.h b/src/gui/text/qtextobject.h
index ad8e657..1588349 100644
--- a/src/gui/text/qtextobject.h
+++ b/src/gui/text/qtextobject.h
@@ -44,7 +44,7 @@
#include <QtCore/qobject.h>
#include <QtGui/qtextformat.h>
-#include <QtGui/qglyphs.h>
+#include <QtGui/qglyphrun.h>
QT_BEGIN_HEADER
@@ -317,7 +317,7 @@ public:
QString text() const;
#if !defined(QT_NO_RAWFONT)
- QList<QGlyphs> glyphs() const;
+ QList<QGlyphRun> glyphRuns() const;
#endif
private:
diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri
index e5d57d0..b6cdc52 100644
--- a/src/gui/text/text.pri
+++ b/src/gui/text/text.pri
@@ -40,10 +40,10 @@ HEADERS += \
text/qtextodfwriter_p.h \
text/qstatictext_p.h \
text/qstatictext.h \
- text/qglyphs.h \
- text/qglyphs_p.h \
text/qrawfont.h \
- text/qrawfont_p.h
+ text/qrawfont_p.h \
+ text/qglyphrun.h \
+ text/qglyphrun_p.h
SOURCES += \
text/qfont.cpp \
@@ -74,8 +74,8 @@ SOURCES += \
text/qzip.cpp \
text/qtextodfwriter.cpp \
text/qstatictext.cpp \
- text/qglyphs.cpp \
- text/qrawfont.cpp
+ text/qrawfont.cpp \
+ text/qglyphrun.cpp
win32 {
SOURCES += \
diff --git a/src/gui/util/qflickgesture.cpp b/src/gui/util/qflickgesture.cpp
deleted file mode 100644
index f87c84c..0000000
--- a/src/gui/util/qflickgesture.cpp
+++ /dev/null
@@ -1,715 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 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 "qgesture.h"
-#include "qapplication.h"
-#include "qevent.h"
-#include "qwidget.h"
-#include "qgraphicsitem.h"
-#include "qgraphicsscene.h"
-#include "qgraphicssceneevent.h"
-#include "qgraphicsview.h"
-#include "qscroller.h"
-#include "private/qevent_p.h"
-#include "private/qflickgesture_p.h"
-#include "qdebug.h"
-
-#ifndef QT_NO_GESTURES
-
-QT_BEGIN_NAMESPACE
-
-//#define QFLICKGESTURE_DEBUG
-
-#ifdef QFLICKGESTURE_DEBUG
-# define qFGDebug qDebug
-#else
-# define qFGDebug while (false) qDebug
-#endif
-
-extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event);
-
-static QMouseEvent *copyMouseEvent(QEvent *e)
-{
- switch (e->type()) {
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonRelease:
- case QEvent::MouseMove: {
- QMouseEvent *me = static_cast<QMouseEvent *>(e);
- return new QMouseEvent(me->type(), QPoint(0, 0), me->globalPos(), me->button(), me->buttons(), me->modifiers());
- }
-#ifndef QT_NO_GRAPHICSVIEW
- case QEvent::GraphicsSceneMousePress:
- case QEvent::GraphicsSceneMouseRelease:
- case QEvent::GraphicsSceneMouseMove: {
- QGraphicsSceneMouseEvent *me = static_cast<QGraphicsSceneMouseEvent *>(e);
-#if 1
- QEvent::Type met = me->type() == QEvent::GraphicsSceneMousePress ? QEvent::MouseButtonPress :
- (me->type() == QEvent::GraphicsSceneMouseRelease ? QEvent::MouseButtonRelease : QEvent::MouseMove);
- return new QMouseEvent(met, QPoint(0, 0), me->screenPos(), me->button(), me->buttons(), me->modifiers());
-#else
- QGraphicsSceneMouseEvent *copy = new QGraphicsSceneMouseEvent(me->type());
- copy->setPos(me->pos());
- copy->setScenePos(me->scenePos());
- copy->setScreenPos(me->screenPos());
- for (int i = 0x1; i <= 0x10; i <<= 1) {
- Qt::MouseButton button = Qt::MouseButton(i);
- copy->setButtonDownPos(button, me->buttonDownPos(button));
- copy->setButtonDownScenePos(button, me->buttonDownScenePos(button));
- copy->setButtonDownScreenPos(button, me->buttonDownScreenPos(button));
- }
- copy->setLastPos(me->lastPos());
- copy->setLastScenePos(me->lastScenePos());
- copy->setLastScreenPos(me->lastScreenPos());
- copy->setButtons(me->buttons());
- copy->setButton(me->button());
- copy->setModifiers(me->modifiers());
- return copy;
-#endif
- }
-#endif // QT_NO_GRAPHICSVIEW
- default:
- return 0;
- }
-}
-
-class PressDelayHandler : public QObject
-{
-private:
- PressDelayHandler(QObject *parent = 0)
- : QObject(parent)
- , pressDelayTimer(0)
- , sendingEvent(false)
- , mouseButton(Qt::NoButton)
- , mouseTarget(0)
- { }
-
- static PressDelayHandler *inst;
-
-public:
- enum {
- UngrabMouseBefore = 1,
- RegrabMouseAfterwards = 2
- };
-
- static PressDelayHandler *instance()
- {
- static PressDelayHandler *inst = 0;
- if (!inst)
- inst = new PressDelayHandler(QCoreApplication::instance());
- return inst;
- }
-
- bool shouldEventBeIgnored(QEvent *) const
- {
- return sendingEvent;
- }
-
- bool isDelaying() const
- {
- return !pressDelayEvent.isNull();
- }
-
- void pressed(QEvent *e, int delay)
- {
- if (!pressDelayEvent) {
- pressDelayEvent.reset(copyMouseEvent(e));
- pressDelayTimer = startTimer(delay);
- mouseTarget = QApplication::widgetAt(pressDelayEvent->globalPos());
- mouseButton = pressDelayEvent->button();
- qFGDebug() << "QFG: consuming/delaying mouse press";
- } else {
- qFGDebug() << "QFG: NOT consuming/delaying mouse press";
- }
- e->setAccepted(true);
- }
-
- bool released(QEvent *e, bool scrollerWasActive, bool scrollerIsActive)
- {
- // consume this event if the scroller was or is active
- bool result = scrollerWasActive || scrollerIsActive;
-
- // stop the timer
- if (pressDelayTimer) {
- killTimer(pressDelayTimer);
- pressDelayTimer = 0;
- }
- // we still haven't even sent the press, so do it now
- if (pressDelayEvent && mouseTarget && !scrollerIsActive) {
- QScopedPointer<QMouseEvent> releaseEvent(copyMouseEvent(e));
-
- qFGDebug() << "QFG: re-sending mouse press (due to release) for " << mouseTarget;
- sendMouseEvent(pressDelayEvent.data(), UngrabMouseBefore);
-
- qFGDebug() << "QFG: faking mouse release (due to release) for " << mouseTarget;
- sendMouseEvent(releaseEvent.data());
-
- result = true; // consume this event
- } else if (mouseTarget && scrollerIsActive) {
- // we grabbed the mouse expicitly when the scroller became active, so undo that now
- sendMouseEvent(0, UngrabMouseBefore);
- }
- pressDelayEvent.reset(0);
- mouseTarget = 0;
- return result;
- }
-
- void scrollerWasIntercepted()
- {
- qFGDebug() << "QFG: deleting delayed mouse press, since scroller was only intercepted";
- if (pressDelayEvent) {
- // we still haven't even sent the press, so just throw it away now
- if (pressDelayTimer) {
- killTimer(pressDelayTimer);
- pressDelayTimer = 0;
- }
- pressDelayEvent.reset(0);
- }
- mouseTarget = 0;
- }
-
- void scrollerBecameActive()
- {
- if (pressDelayEvent) {
- // we still haven't even sent the press, so just throw it away now
- qFGDebug() << "QFG: deleting delayed mouse press, since scroller is active now";
- if (pressDelayTimer) {
- killTimer(pressDelayTimer);
- pressDelayTimer = 0;
- }
- pressDelayEvent.reset(0);
- mouseTarget = 0;
- } else if (mouseTarget) {
- // we did send a press, so we need to fake a release now
-
- // release all pressed mouse buttons
- /* Qt::MouseButtons mouseButtons = QApplication::mouseButtons();
- for (int i = 0; i < 32; ++i) {
- if (mouseButtons & (1 << i)) {
- Qt::MouseButton b = static_cast<Qt::MouseButton>(1 << i);
- mouseButtons &= ~b;
- QPoint farFarAway(-QWIDGETSIZE_MAX, -QWIDGETSIZE_MAX);
-
- qFGDebug() << "QFG: sending a fake mouse release at far-far-away to " << mouseTarget;
- QMouseEvent re(QEvent::MouseButtonRelease, QPoint(), farFarAway,
- b, mouseButtons, QApplication::keyboardModifiers());
- sendMouseEvent(&re);
- }
- }*/
-
- QPoint farFarAway(-QWIDGETSIZE_MAX, -QWIDGETSIZE_MAX);
-
- qFGDebug() << "QFG: sending a fake mouse release at far-far-away to " << mouseTarget;
- QMouseEvent re(QEvent::MouseButtonRelease, QPoint(), farFarAway,
- mouseButton, QApplication::mouseButtons() & ~mouseButton,
- QApplication::keyboardModifiers());
- sendMouseEvent(&re, RegrabMouseAfterwards);
- // don't clear the mouseTarget just yet, since we need to explicitly ungrab the mouse on release!
- }
- }
-
-protected:
- void timerEvent(QTimerEvent *e)
- {
- if (e->timerId() == pressDelayTimer) {
- if (pressDelayEvent && mouseTarget) {
- qFGDebug() << "QFG: timer event: re-sending mouse press to " << mouseTarget;
- sendMouseEvent(pressDelayEvent.data(), UngrabMouseBefore);
- }
- pressDelayEvent.reset(0);
-
- if (pressDelayTimer) {
- killTimer(pressDelayTimer);
- pressDelayTimer = 0;
- }
- }
- }
-
- void sendMouseEvent(QMouseEvent *me, int flags = 0)
- {
- if (mouseTarget) {
- sendingEvent = true;
-
-#ifndef QT_NO_GRAPHICSVIEW
- QGraphicsItem *grabber = 0;
- if (mouseTarget->parentWidget()) {
- if (QGraphicsView *gv = qobject_cast<QGraphicsView *>(mouseTarget->parentWidget())) {
- if (gv->scene())
- grabber = gv->scene()->mouseGrabberItem();
- }
- }
-
- if (grabber && (flags & UngrabMouseBefore)) {
- // GraphicsView Mouse Handling Workaround #1:
- // we need to ungrab the mouse before re-sending the press,
- // since the scene had already set the mouse grabber to the
- // original (and consumed) event's receiver
- qFGDebug() << "QFG: ungrabbing" << grabber;
- grabber->ungrabMouse();
- }
-#endif // QT_NO_GRAPHICSVIEW
-
- if (me) {
- QMouseEvent copy(me->type(), mouseTarget->mapFromGlobal(me->globalPos()), me->globalPos(), me->button(), me->buttons(), me->modifiers());
- qt_sendSpontaneousEvent(mouseTarget, &copy);
- }
-
-#ifndef QT_NO_GRAPHICSVIEW
- if (grabber && (flags & RegrabMouseAfterwards)) {
- // GraphicsView Mouse Handling Workaround #2:
- // we need to re-grab the mouse after sending a faked mouse
- // release, since we still need the mouse moves for the gesture
- // (the scene will clear the item's mouse grabber status on
- // release).
- qFGDebug() << "QFG: re-grabbing" << grabber;
- grabber->grabMouse();
- }
-#endif
- sendingEvent = false;
- }
- }
-
-
-private:
- int pressDelayTimer;
- QScopedPointer<QMouseEvent> pressDelayEvent;
- bool sendingEvent;
- Qt::MouseButton mouseButton;
- QPointer<QWidget> mouseTarget;
-};
-
-
-/*!
- \internal
- \class QFlickGesture
- \since 4.8
- \brief The QFlickGesture class describes a flicking gesture made by the user.
- \ingroup gestures
- The QFlickGesture is more complex than the QPanGesture that uses QScroller and QScrollerProperties
- to decide if it is triggered.
- This gesture is reacting on touch event as compared to the QMouseFlickGesture.
-
- \sa {Gestures Programming}, QScroller, QScrollerProperties, QMouseFlickGesture
-*/
-
-/*!
- \internal
-*/
-QFlickGesture::QFlickGesture(QObject *receiver, Qt::MouseButton button, QObject *parent)
- : QGesture(*new QFlickGesturePrivate, parent)
-{
- d_func()->q_ptr = this;
- d_func()->receiver = receiver;
- d_func()->receiverScroller = (receiver && QScroller::hasScroller(receiver)) ? QScroller::scroller(receiver) : 0;
- d_func()->button = button;
-}
-
-QFlickGesture::~QFlickGesture()
-{ }
-
-QFlickGesturePrivate::QFlickGesturePrivate()
- : receiverScroller(0), button(Qt::NoButton), macIgnoreWheel(false)
-{ }
-
-
-//
-// QFlickGestureRecognizer
-//
-
-
-QFlickGestureRecognizer::QFlickGestureRecognizer(Qt::MouseButton button)
-{
- this->button = button;
-}
-
-/*! \reimp
- */
-QGesture *QFlickGestureRecognizer::create(QObject *target)
-{
-#ifndef QT_NO_GRAPHICSVIEW
- QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target);
- if (go && button == Qt::NoButton) {
- go->setAcceptTouchEvents(true);
- }
-#endif
- return new QFlickGesture(target, button);
-}
-
-/*! \internal
- The recognize function detects a touch event suitable to start the attached QScroller.
- The QFlickGesture will be triggered as soon as the scroller is no longer in the state
- QScroller::Inactive or QScroller::Pressed. It will be finished or canceled
- at the next QEvent::TouchEnd.
- Note that the QScroller might continue scrolling (kinetically) at this point.
- */
-QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
- QObject *watched,
- QEvent *event)
-{
- Q_UNUSED(watched);
-
- static QElapsedTimer monotonicTimer;
- if (!monotonicTimer.isValid())
- monotonicTimer.start();
-
- QFlickGesture *q = static_cast<QFlickGesture *>(state);
- QFlickGesturePrivate *d = q->d_func();
-
- QScroller *scroller = d->receiverScroller;
- if (!scroller)
- return Ignore; // nothing to do without a scroller?
-
- QWidget *receiverWidget = qobject_cast<QWidget *>(d->receiver);
-#ifndef QT_NO_GRAPHICSVIEW
- QGraphicsObject *receiverGraphicsObject = qobject_cast<QGraphicsObject *>(d->receiver);
-#endif
-
- // this is only set for events that we inject into the event loop via sendEvent()
- if (PressDelayHandler::instance()->shouldEventBeIgnored(event)) {
- //qFGDebug() << state << "QFG: ignored event: " << event->type();
- return Ignore;
- }
-
- const QMouseEvent *me = 0;
-#ifndef QT_NO_GRAPHICSVIEW
- const QGraphicsSceneMouseEvent *gsme = 0;
-#endif
- const QTouchEvent *te = 0;
- QPoint globalPos;
-
- // qFGDebug() << "FlickGesture "<<state<<"watched:"<<watched<<"receiver"<<d->receiver<<"event"<<event->type()<<"button"<<button;
-
- switch (event->type()) {
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonRelease:
- case QEvent::MouseMove:
- if (!receiverWidget)
- return Ignore;
- if (button != Qt::NoButton) {
- me = static_cast<const QMouseEvent *>(event);
- globalPos = me->globalPos();
- }
- break;
-#ifndef QT_NO_GRAPHICSVIEW
- case QEvent::GraphicsSceneMousePress:
- case QEvent::GraphicsSceneMouseRelease:
- case QEvent::GraphicsSceneMouseMove:
- if (!receiverGraphicsObject)
- return Ignore;
- if (button != Qt::NoButton) {
- gsme = static_cast<const QGraphicsSceneMouseEvent *>(event);
- globalPos = gsme->screenPos();
- }
- break;
-#endif
- case QEvent::TouchBegin:
- case QEvent::TouchEnd:
- case QEvent::TouchUpdate:
- if (button == Qt::NoButton) {
- te = static_cast<const QTouchEvent *>(event);
- if (!te->touchPoints().isEmpty())
- globalPos = te->touchPoints().at(0).screenPos().toPoint();
- }
- break;
-
-#if defined(Q_WS_MAC)
- // the only way to distinguish between real mouse wheels and wheel
- // events generated by the native 2 finger swipe gesture is to listen
- // for these events (according to Apple's Cocoa Event-Handling Guide)
-
- case QEvent::NativeGesture: {
- QNativeGestureEvent *nge = static_cast<QNativeGestureEvent *>(event);
- if (nge->gestureType == QNativeGestureEvent::GestureBegin)
- d->macIgnoreWheel = true;
- else if (nge->gestureType == QNativeGestureEvent::GestureEnd)
- d->macIgnoreWheel = false;
- break;
- }
-#endif
-
- // consume all wheel events if the scroller is active
- case QEvent::Wheel:
- if (d->macIgnoreWheel || (scroller->state() != QScroller::Inactive))
- return Ignore | ConsumeEventHint;
- break;
-
- // consume all dbl click events if the scroller is active
- case QEvent::MouseButtonDblClick:
- if (scroller->state() != QScroller::Inactive)
- return Ignore | ConsumeEventHint;
- break;
-
- default:
- break;
- }
-
- if (!me
-#ifndef QT_NO_GRAPHICSVIEW
- && !gsme
-#endif
- && !te) // Neither mouse nor touch
- return Ignore;
-
- // get the current pointer position in local coordinates.
- QPointF point;
- QScroller::Input inputType = (QScroller::Input) 0;
-
- switch (event->type()) {
- case QEvent::MouseButtonPress:
- if (me && me->button() == button && me->buttons() == button) {
- point = me->globalPos();
- inputType = QScroller::InputPress;
- } else if (me) {
- scroller->stop();
- return CancelGesture;
- }
- break;
- case QEvent::MouseButtonRelease:
- if (me && me->button() == button) {
- point = me->globalPos();
- inputType = QScroller::InputRelease;
- }
- break;
- case QEvent::MouseMove:
-#ifdef Q_OS_SYMBIAN
- // Qt on Symbian tracks the button state internally, while Qt on Win/Mac/Unix
- // relies on the windowing system to report the current buttons state.
- if (me && (me->buttons() == button || !me->buttons())) {
-#else
- if (me && me->buttons() == button) {
-#endif
- point = me->globalPos();
- inputType = QScroller::InputMove;
- }
- break;
-
-#ifndef QT_NO_GRAPHICSVIEW
- case QEvent::GraphicsSceneMousePress:
- if (gsme && gsme->button() == button && gsme->buttons() == button) {
- point = gsme->scenePos();
- inputType = QScroller::InputPress;
- } else if (gsme) {
- scroller->stop();
- return CancelGesture;
- }
- break;
- case QEvent::GraphicsSceneMouseRelease:
- if (gsme && gsme->button() == button) {
- point = gsme->scenePos();
- inputType = QScroller::InputRelease;
- }
- break;
- case QEvent::GraphicsSceneMouseMove:
-#ifdef Q_OS_SYMBIAN
- // Qt on Symbian tracks the button state internally, while Qt on Win/Mac/Unix
- // relies on the windowing system to report the current buttons state.
- if (gsme && (gsme->buttons() == button || !me->buttons())) {
-#else
- if (gsme && gsme->buttons() == button) {
-#endif
- point = gsme->scenePos();
- inputType = QScroller::InputMove;
- }
- break;
-#endif
-
- case QEvent::TouchBegin:
- inputType = QScroller::InputPress;
- // fall through
- case QEvent::TouchEnd:
- if (!inputType)
- inputType = QScroller::InputRelease;
- // fallthrough
- case QEvent::TouchUpdate:
- if (!inputType)
- inputType = QScroller::InputMove;
-
- if (te->deviceType() == QTouchEvent::TouchPad) {
- if (te->touchPoints().count() != 2) // 2 fingers on pad
- return Ignore;
-
- point = te->touchPoints().at(0).startScenePos() +
- ((te->touchPoints().at(0).scenePos() - te->touchPoints().at(0).startScenePos()) +
- (te->touchPoints().at(1).scenePos() - te->touchPoints().at(1).startScenePos())) / 2;
- } else { // TouchScreen
- if (te->touchPoints().count() != 1) // 1 finger on screen
- return Ignore;
-
- point = te->touchPoints().at(0).scenePos();
- }
- break;
-
- default:
- break;
- }
-
- // Check for an active scroller at globalPos
- if (inputType == QScroller::InputPress) {
- foreach (QScroller *as, QScroller::activeScrollers()) {
- if (as != scroller) {
- QRegion scrollerRegion;
-
- if (QWidget *w = qobject_cast<QWidget *>(as->target())) {
- scrollerRegion = QRect(w->mapToGlobal(QPoint(0, 0)), w->size());
-#ifndef QT_NO_GRAPHICSVIEW
- } else if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(as->target())) {
- if (go->scene() && !go->scene()->views().isEmpty()) {
- foreach (QGraphicsView *gv, go->scene()->views())
- scrollerRegion |= gv->mapFromScene(go->mapToScene(go->boundingRect()))
- .translated(gv->mapToGlobal(QPoint(0, 0)));
- }
-#endif
- }
- // active scrollers always have priority
- if (scrollerRegion.contains(globalPos))
- return Ignore;
- }
- }
- }
-
- bool scrollerWasDragging = (scroller->state() == QScroller::Dragging);
- bool scrollerWasScrolling = (scroller->state() == QScroller::Scrolling);
-
- if (inputType) {
- if (QWidget *w = qobject_cast<QWidget *>(d->receiver))
- point = w->mapFromGlobal(point.toPoint());
-#ifndef QT_NO_GRAPHICSVIEW
- else if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(d->receiver))
- point = go->mapFromScene(point);
-#endif
-
- // inform the scroller about the new event
- scroller->handleInput(inputType, point, monotonicTimer.elapsed());
- }
-
- // depending on the scroller state return the gesture state
- Result result(0);
- bool scrollerIsActive = (scroller->state() == QScroller::Dragging ||
- scroller->state() == QScroller::Scrolling);
-
- // Consume all mouse events while dragging or scrolling to avoid nasty
- // side effects with Qt's standard widgets.
- if ((me
-#ifndef QT_NO_GRAPHICSVIEW
- || gsme
-#endif
- ) && scrollerIsActive)
- result |= ConsumeEventHint;
-
- // The only problem with this approach is that we consume the
- // MouseRelease when we start the scrolling with a flick gesture, so we
- // have to fake a MouseRelease "somewhere" to not mess with the internal
- // states of Qt's widgets (a QPushButton would stay in 'pressed' state
- // forever, if it doesn't receive a MouseRelease).
- if (me
-#ifndef QT_NO_GRAPHICSVIEW
- || gsme
-#endif
- ) {
- if (!scrollerWasDragging && !scrollerWasScrolling && scrollerIsActive)
- PressDelayHandler::instance()->scrollerBecameActive();
- else if (scrollerWasScrolling && (scroller->state() == QScroller::Dragging || scroller->state() == QScroller::Inactive))
- PressDelayHandler::instance()->scrollerWasIntercepted();
- }
-
- if (!inputType) {
- result |= Ignore;
- } else {
- switch (event->type()) {
- case QEvent::MouseButtonPress:
-#ifndef QT_NO_GRAPHICSVIEW
- case QEvent::GraphicsSceneMousePress:
-#endif
- if (scroller->state() == QScroller::Pressed) {
- int pressDelay = int(1000 * scroller->scrollerProperties().scrollMetric(QScrollerProperties::MousePressEventDelay).toReal());
- if (pressDelay > 0) {
- result |= ConsumeEventHint;
-
- PressDelayHandler::instance()->pressed(event, pressDelay);
- event->accept();
- }
- }
- // fall through
- case QEvent::TouchBegin:
- q->setHotSpot(globalPos);
- result |= scrollerIsActive ? TriggerGesture : MayBeGesture;
- break;
-
- case QEvent::MouseMove:
-#ifndef QT_NO_GRAPHICSVIEW
- case QEvent::GraphicsSceneMouseMove:
-#endif
- if (PressDelayHandler::instance()->isDelaying())
- result |= ConsumeEventHint;
- // fall through
- case QEvent::TouchUpdate:
- result |= scrollerIsActive ? TriggerGesture : Ignore;
- break;
-
-#ifndef QT_NO_GRAPHICSVIEW
- case QEvent::GraphicsSceneMouseRelease:
-#endif
- case QEvent::MouseButtonRelease:
- if (PressDelayHandler::instance()->released(event, scrollerWasDragging || scrollerWasScrolling, scrollerIsActive))
- result |= ConsumeEventHint;
- // fall through
- case QEvent::TouchEnd:
- result |= scrollerIsActive ? FinishGesture : CancelGesture;
- break;
-
- default:
- result |= Ignore;
- break;
- }
- }
- return result;
-}
-
-
-/*! \reimp
- */
-void QFlickGestureRecognizer::reset(QGesture *state)
-{
- QGestureRecognizer::reset(state);
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_GESTURES
diff --git a/src/gui/util/qflickgesture_p.h b/src/gui/util/qflickgesture_p.h
deleted file mode 100644
index 451b579..0000000
--- a/src/gui/util/qflickgesture_p.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 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 QFLICKGESTURE_P_H
-#define QFLICKGESTURE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qevent.h"
-#include "qgesturerecognizer.h"
-#include "private/qgesture_p.h"
-#include "qscroller.h"
-#include "qscopedpointer.h"
-
-#ifndef QT_NO_GESTURES
-
-QT_BEGIN_NAMESPACE
-
-class QFlickGesturePrivate;
-class QGraphicsItem;
-
-class Q_GUI_EXPORT QFlickGesture : public QGesture
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QFlickGesture)
-
-public:
- QFlickGesture(QObject *receiver, Qt::MouseButton button, QObject *parent = 0);
- ~QFlickGesture();
-
- friend class QFlickGestureRecognizer;
-};
-
-class PressDelayHandler;
-
-class QFlickGesturePrivate : public QGesturePrivate
-{
- Q_DECLARE_PUBLIC(QFlickGesture)
-public:
- QFlickGesturePrivate();
-
- QPointer<QObject> receiver;
- QScroller *receiverScroller;
- Qt::MouseButton button; // NoButton == Touch
- bool macIgnoreWheel;
- static PressDelayHandler *pressDelayHandler;
-};
-
-class QFlickGestureRecognizer : public QGestureRecognizer
-{
-public:
- QFlickGestureRecognizer(Qt::MouseButton button);
-
- QGesture *create(QObject *target);
- QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event);
- void reset(QGesture *state);
-
-private:
- Qt::MouseButton button; // NoButton == Touch
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_GESTURES
-
-#endif // QFLICKGESTURE_P_H
diff --git a/src/gui/util/qscroller.cpp b/src/gui/util/qscroller.cpp
deleted file mode 100644
index 870d56f..0000000
--- a/src/gui/util/qscroller.cpp
+++ /dev/null
@@ -1,2056 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 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 "qevent.h"
-#include "qwidget.h"
-#include "qscroller.h"
-#include "private/qflickgesture_p.h"
-#include "private/qscroller_p.h"
-#include "qscrollerproperties.h"
-#include "private/qscrollerproperties_p.h"
-#include "qnumeric.h"
-#include "math.h"
-
-#include <QTime>
-#include <QElapsedTimer>
-#include <QMap>
-#include <QApplication>
-#include <QAbstractScrollArea>
-#include <QGraphicsObject>
-#include <QGraphicsScene>
-#include <QGraphicsView>
-#include <QDesktopWidget>
-#include <QtCore/qmath.h>
-#include <QtGui/qevent.h>
-#include <qnumeric.h>
-
-#include <QtDebug>
-
-#if defined(Q_WS_X11)
-# include "private/qt_x11_p.h"
-#endif
-
-
-QT_BEGIN_NAMESPACE
-
-bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event);
-
-//#define QSCROLLER_DEBUG
-
-#ifdef QSCROLLER_DEBUG
-# define qScrollerDebug qDebug
-#else
-# define qScrollerDebug while (false) qDebug
-#endif
-
-QDebug &operator<<(QDebug &dbg, const QScrollerPrivate::ScrollSegment &s)
-{
- dbg << "\n Time: start:" << s.startTime << " duration:" << s.deltaTime << " stop progress:" << s.stopProgress;
- dbg << "\n Pos: start:" << s.startPos << " delta:" << s.deltaPos << " stop:" << s.stopPos;
- dbg << "\n Curve: type:" << s.curve.type() << "\n";
- return dbg;
-}
-
-
-// a few helper operators to make the code below a lot more readable:
-// otherwise a lot of ifs would have to be multi-line to check both the x
-// and y coordinate separately.
-
-// returns true only if the abs. value of BOTH x and y are <= f
-inline bool operator<=(const QPointF &p, qreal f)
-{
- return (qAbs(p.x()) <= f) && (qAbs(p.y()) <= f);
-}
-
-// returns true only if the abs. value of BOTH x and y are < f
-inline bool operator<(const QPointF &p, qreal f)
-{
- return (qAbs(p.x()) < f) && (qAbs(p.y()) < f);
-}
-
-// returns true if the abs. value of EITHER x or y are >= f
-inline bool operator>=(const QPointF &p, qreal f)
-{
- return (qAbs(p.x()) >= f) || (qAbs(p.y()) >= f);
-}
-
-// returns true if the abs. value of EITHER x or y are > f
-inline bool operator>(const QPointF &p, qreal f)
-{
- return (qAbs(p.x()) > f) || (qAbs(p.y()) > f);
-}
-
-// returns a new point with both coordinates having the abs. value of the original one
-inline QPointF qAbs(const QPointF &p)
-{
- return QPointF(qAbs(p.x()), qAbs(p.y()));
-}
-
-// returns a new point with all components of p1 multiplied by the corresponding components of p2
-inline QPointF operator*(const QPointF &p1, const QPointF &p2)
-{
- return QPointF(p1.x() * p2.x(), p1.y() * p2.y());
-}
-
-// returns a new point with all components of p1 divided by the corresponding components of p2
-inline QPointF operator/(const QPointF &p1, const QPointF &p2)
-{
- return QPointF(p1.x() / p2.x(), p1.y() / p2.y());
-}
-
-inline QPointF clampToRect(const QPointF &p, const QRectF &rect)
-{
- qreal x = qBound(rect.left(), p.x(), rect.right());
- qreal y = qBound(rect.top(), p.y(), rect.bottom());
- return QPointF(x, y);
-}
-
-// returns -1, 0 or +1 according to r being <0, ==0 or >0
-inline int qSign(qreal r)
-{
- return (r < 0) ? -1 : ((r > 0) ? 1 : 0);
-}
-
-// this version is not mathematically exact, but it just works for every
-// easing curve type (even custom ones)
-
-static qreal differentialForProgress(const QEasingCurve &curve, qreal pos)
-{
- const qreal dx = 0.01;
- qreal left = (pos < qreal(0.5)) ? pos : pos - qreal(dx);
- qreal right = (pos >= qreal(0.5)) ? pos : pos + qreal(dx);
- qreal d = (curve.valueForProgress(right) - curve.valueForProgress(left)) / qreal(dx);
-
- //qScrollerDebug() << "differentialForProgress(type: " << curve.type() << ", pos: " << pos << ") = " << d;
-
- return d;
-}
-
-// this version is not mathematically exact, but it just works for every
-// easing curve type (even custom ones)
-
-static qreal progressForValue(const QEasingCurve &curve, qreal value)
-{
- if (curve.type() >= QEasingCurve::InElastic &&
- curve.type() < QEasingCurve::Custom) {
- qWarning("progressForValue(): QEasingCurves of type %d do not have an inverse, since they are not injective.", curve.type());
- return value;
- }
- if (value < qreal(0) || value > qreal(1))
- return value;
-
- qreal progress = value, left(0), right(1);
- for (int iterations = 6; iterations; --iterations) {
- qreal v = curve.valueForProgress(progress);
- if (v < value)
- left = progress;
- else if (v > value)
- right = progress;
- else
- break;
- progress = (left + right) / qreal(2);
- }
- return progress;
-}
-
-
-#ifndef QT_NO_ANIMATION
-class QScrollTimer : public QAbstractAnimation
-{
-public:
- QScrollTimer(QScrollerPrivate *_d)
- : d(_d), ignoreUpdate(false), skip(0)
- { }
-
- int duration() const
- {
- return -1;
- }
-
- void start()
- {
- // QAbstractAnimation::start() will immediately call
- // updateCurrentTime(), but our state is not set correctly yet
- ignoreUpdate = true;
- QAbstractAnimation::start();
- ignoreUpdate = false;
- skip = 0;
- }
-
-protected:
- void updateCurrentTime(int /*currentTime*/)
- {
- if (!ignoreUpdate) {
- if (++skip >= d->frameRateSkip()) {
- skip = 0;
- d->timerTick();
- }
- }
- }
-
-private:
- QScrollerPrivate *d;
- bool ignoreUpdate;
- int skip;
-};
-#endif // QT_NO_ANIMATION
-
-/*!
- \class QScroller
- \brief The QScroller class enables kinetic scrolling for any scrolling widget or graphics item.
- \since 4.8
-
- With kinetic scrolling, the user can push the widget in a given
- direction and it will continue to scroll in this direction until it is
- stopped either by the user or by friction. Aspects of inertia, friction
- and other physical concepts can be changed in order to fine-tune an
- intuitive user experience.
-
- The QScroller object is the object that stores the current position and
- scrolling speed and takes care of updates.
- QScroller can be triggered by a flick gesture
-
- \code
- QWidget *w = ...;
- QScroller::grabGesture(w, QScroller::LeftMouseButtonGesture);
- \endcode
-
- or directly like this:
-
- \code
- QWidget *w = ...;
- QScroller *scroller = QScroller::scroller(w);
- scroller->scrollTo(QPointF(100, 100));
- \endcode
-
- The scrolled QObjects receive a QScrollPrepareEvent whenever the scroller needs to
- update its geometry information and a QScrollEvent whenever the content of the object should
- actually be scrolled.
-
- The scroller uses the global QAbstractAnimation timer to generate its QScrollEvents. This
- can be changed with QScrollerProperties::FrameRate on a per-QScroller basis.
-
- Several examples in the \c scroller examples directory show how QScroller,
- QScrollEvent and the scroller gesture can be used.
-
- Even though this kinetic scroller has a large number of settings available via
- QScrollerProperties, we recommend that you leave them all at their default, platform optimized
- values. Before changing them you can experiment with the \c plot example in
- the \c scroller examples directory.
-
- \sa QScrollEvent, QScrollPrepareEvent, QScrollerProperties
-*/
-
-typedef QMap<QObject *, QScroller *> ScrollerHash;
-typedef QSet<QScroller *> ScrollerSet;
-
-Q_GLOBAL_STATIC(ScrollerHash, qt_allScrollers)
-Q_GLOBAL_STATIC(ScrollerSet, qt_activeScrollers)
-
-/*!
- Returns \c true if a QScroller object was already created for \a target; \c false otherwise.
-
- \sa scroller()
-*/
-bool QScroller::hasScroller(QObject *target)
-{
- return (qt_allScrollers()->value(target));
-}
-
-/*!
- Returns the scroller for the given \a target.
- As long as the object exists this function will always return the same QScroller instance.
- If no QScroller exists for the \a target, one will implicitly be created.
- At no point more than one QScroller will be active on an object.
-
- \sa hasScroller(), target()
-*/
-QScroller *QScroller::scroller(QObject *target)
-{
- if (!target) {
- qWarning("QScroller::scroller() was called with a null target.");
- return 0;
- }
-
- if (qt_allScrollers()->contains(target))
- return qt_allScrollers()->value(target);
-
- QScroller *s = new QScroller(target);
- qt_allScrollers()->insert(target, s);
- return s;
-}
-
-/*!
- \overload
- This is the const version of scroller().
-*/
-const QScroller *QScroller::scroller(const QObject *target)
-{
- return scroller(const_cast<QObject*>(target));
-}
-
-/*!
- Returns an application wide list of currently active QScroller objects.
- Active QScroller objects are in a state() that is not QScroller::Inactive.
- This function is useful when writing your own gesture recognizer.
-*/
-QList<QScroller *> QScroller::activeScrollers()
-{
- return qt_activeScrollers()->toList();
-}
-
-/*!
- Returns the target object of this scroller.
- \sa hasScroller(), scroller()
- */
-QObject *QScroller::target() const
-{
- Q_D(const QScroller);
- return d->target;
-}
-
-/*!
- \fn QScroller::scrollerPropertiesChanged(const QScrollerProperties &newProperties);
-
- QScroller emits this signal whenever its scroller properties change.
- \a newProperties are the new scroller properties.
-
- \sa scrollerProperties
-*/
-
-
-/*! \property QScroller::scrollerProperties
- \brief The scroller properties of this scroller.
- The properties are used by the QScroller to determine its scrolling behavior.
-*/
-QScrollerProperties QScroller::scrollerProperties() const
-{
- Q_D(const QScroller);
- return d->properties;
-}
-
-void QScroller::setScrollerProperties(const QScrollerProperties &sp)
-{
- Q_D(QScroller);
- if (d->properties != sp) {
- d->properties = sp;
- emit scrollerPropertiesChanged(sp);
-
- // we need to force the recalculation here, since the overshootPolicy may have changed and
- // existing segments may include an overshoot animation.
- d->recalcScrollingSegments(true);
- }
-}
-
-#ifndef QT_NO_GESTURES
-
-/*!
- Registers a custom scroll gesture recognizer, grabs it for the \a
- target and returns the resulting gesture type. If \a scrollGestureType is
- set to TouchGesture the gesture triggers on touch events. If it is set to
- one of LeftMouseButtonGesture, RightMouseButtonGesture or
- MiddleMouseButtonGesture it triggers on mouse events of the
- corresponding button.
-
- Only one scroll gesture can be active on a single object at the same
- time. If you call this function twice on the same object, it will
- ungrab the existing gesture before grabbing the new one.
-
- \note To avoid unwanted side-effects, mouse events are consumed while
- the gesture is triggered. Since the initial mouse press event is
- not consumed, the gesture sends a fake mouse release event
- at the global position \c{(INT_MIN, INT_MIN)}. This ensures that
- internal states of the widget that received the original mouse press
- are consistent.
-
- \sa ungrabGesture, grabbedGesture
-*/
-Qt::GestureType QScroller::grabGesture(QObject *target, ScrollerGestureType scrollGestureType)
-{
- // ensure that a scroller for target is created
- QScroller *s = scroller(target);
- if (!s)
- return Qt::GestureType(0);
-
- QScrollerPrivate *sp = s->d_ptr;
- if (sp->recognizer)
- ungrabGesture(target); // ungrab the old gesture
-
- Qt::MouseButton button;
- switch (scrollGestureType) {
- case LeftMouseButtonGesture : button = Qt::LeftButton; break;
- case RightMouseButtonGesture : button = Qt::RightButton; break;
- case MiddleMouseButtonGesture: button = Qt::MiddleButton; break;
- default :
- case TouchGesture : button = Qt::NoButton; break; // NoButton == Touch
- }
-
- sp->recognizer = new QFlickGestureRecognizer(button);
- sp->recognizerType = QGestureRecognizer::registerRecognizer(sp->recognizer);
-
- if (target->isWidgetType()) {
- QWidget *widget = static_cast<QWidget *>(target);
- widget->grabGesture(sp->recognizerType);
- if (scrollGestureType == TouchGesture)
- widget->setAttribute(Qt::WA_AcceptTouchEvents);
-#ifndef QT_NO_GRAPHICSVIEW
- } else if (QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target)) {
- if (scrollGestureType == TouchGesture)
- go->setAcceptTouchEvents(true);
- go->grabGesture(sp->recognizerType);
-#endif // QT_NO_GRAPHICSVIEW
- }
- return sp->recognizerType;
-}
-
-/*!
- Returns the gesture type currently grabbed for the \a target or 0 if no
- gesture is grabbed.
-
- \sa grabGesture, ungrabGesture
-*/
-Qt::GestureType QScroller::grabbedGesture(QObject *target)
-{
- QScroller *s = scroller(target);
- if (s && s->d_ptr)
- return s->d_ptr->recognizerType;
- else
- return Qt::GestureType(0);
-}
-
-/*!
- Ungrabs the gesture for the \a target.
- Does nothing if no gesture is grabbed.
-
- \sa grabGesture, grabbedGesture
-*/
-void QScroller::ungrabGesture(QObject *target)
-{
- QScroller *s = scroller(target);
- if (!s)
- return;
-
- QScrollerPrivate *sp = s->d_ptr;
- if (!sp->recognizer)
- return; // nothing to do
-
- if (target->isWidgetType()) {
- QWidget *widget = static_cast<QWidget *>(target);
- widget->ungrabGesture(sp->recognizerType);
-#ifndef QT_NO_GRAPHICSVIEW
- } else if (QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target)) {
- go->ungrabGesture(sp->recognizerType);
-#endif
- }
-
- QGestureRecognizer::unregisterRecognizer(sp->recognizerType);
- // do not delete the recognizer. The QGestureManager is doing this.
- sp->recognizer = 0;
-}
-
-#endif // QT_NO_GESTURES
-
-/*!
- \internal
-*/
-QScroller::QScroller(QObject *target)
- : d_ptr(new QScrollerPrivate(this, target))
-{
- Q_ASSERT(target); // you can't create a scroller without a target in any normal way
- Q_D(QScroller);
- d->init();
-}
-
-/*!
- \internal
-*/
-QScroller::~QScroller()
-{
- Q_D(QScroller);
-#ifndef QT_NO_GESTURES
- QGestureRecognizer::unregisterRecognizer(d->recognizerType);
- // do not delete the recognizer. The QGestureManager is doing this.
- d->recognizer = 0;
-#endif
- qt_allScrollers()->remove(d->target);
- qt_activeScrollers()->remove(this);
-
- delete d_ptr;
-}
-
-
-/*!
- \fn QScroller::stateChanged(QScroller::State newState);
-
- QScroller emits this signal whenever the state changes. \a newState is the new State.
-
- \sa state
-*/
-
-/*!
- \property QScroller::state
- \brief the state of the scroller
-
- \sa QScroller::State
-*/
-QScroller::State QScroller::state() const
-{
- Q_D(const QScroller);
- return d->state;
-}
-
-/*!
- Stops the scroller and resets its state back to Inactive.
-*/
-void QScroller::stop()
-{
- Q_D(QScroller);
- if (d->state != Inactive) {
- QPointF here = clampToRect(d->contentPosition, d->contentPosRange);
- qreal snapX = d->nextSnapPos(here.x(), 0, Qt::Horizontal);
- qreal snapY = d->nextSnapPos(here.y(), 0, Qt::Vertical);
- QPointF snap = here;
- if (!qIsNaN(snapX))
- snap.setX(snapX);
- if (!qIsNaN(snapY))
- snap.setY(snapY);
- d->contentPosition = snap;
- d->overshootPosition = QPointF(0, 0);
-
- d->setState(Inactive);
- }
-}
-
-/*!
- Returns the pixel per meter metric for the scrolled widget.
-
- The value is reported for both the x and y axis separately by using a QPointF.
-
- \note Please note that this value should be physically correct. The actual DPI settings
- that Qt returns for the display may be reported wrongly on purpose by the underlying
- windowing system, for example on Mac OS X or Maemo 5.
-*/
-QPointF QScroller::pixelPerMeter() const
-{
- Q_D(const QScroller);
- QPointF ppm = d->pixelPerMeter;
-
-#ifndef QT_NO_GRAPHICSVIEW
- if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(d->target)) {
- QTransform viewtr;
- //TODO: the first view isn't really correct - maybe use an additional field in the prepare event?
- if (go->scene() && !go->scene()->views().isEmpty())
- viewtr = go->scene()->views().first()->viewportTransform();
- QTransform tr = go->deviceTransform(viewtr);
- if (tr.isScaling()) {
- QPointF p0 = tr.map(QPointF(0, 0));
- QPointF px = tr.map(QPointF(1, 0));
- QPointF py = tr.map(QPointF(0, 1));
- ppm.rx() /= QLineF(p0, px).length();
- ppm.ry() /= QLineF(p0, py).length();
- }
- }
-#endif // QT_NO_GRAPHICSVIEW
- return ppm;
-}
-
-/*!
- Returns the current scrolling velocity in meter per second when the state is Scrolling or Dragging.
- Returns a zero velocity otherwise.
-
- The velocity is reported for both the x and y axis separately by using a QPointF.
-
- \sa pixelPerMeter()
-*/
-QPointF QScroller::velocity() const
-{
- Q_D(const QScroller);
- const QScrollerPropertiesPrivate *sp = d->properties.d.data();
-
- switch (state()) {
- case Dragging:
- return d->releaseVelocity;
- case Scrolling: {
- QPointF vel;
- qint64 now = d->monotonicTimer.elapsed();
-
- if (!d->xSegments.isEmpty()) {
- const QScrollerPrivate::ScrollSegment &s = d->xSegments.head();
- qreal progress = qreal(now - s.startTime) / qreal(s.deltaTime);
- qreal v = qSign(s.deltaPos) * qreal(s.deltaTime) / qreal(1000) * sp->decelerationFactor * qreal(0.5) * differentialForProgress(s.curve, progress);
- vel.setX(v);
- }
-
- if (!d->ySegments.isEmpty()) {
- const QScrollerPrivate::ScrollSegment &s = d->ySegments.head();
- qreal progress = qreal(now - s.startTime) / qreal(s.deltaTime);
- qreal v = qSign(s.deltaPos) * qreal(s.deltaTime) / qreal(1000) * sp->decelerationFactor * qreal(0.5) * differentialForProgress(s.curve, progress);
- vel.setY(v);
- }
- return vel;
- }
- default:
- return QPointF(0, 0);
- }
-}
-
-/*!
- Returns the estimated final position for the current scroll movement.
- Returns the current position if the scroller state is not Scrolling.
- The result is undefined when the scroller state is Inactive.
-
- The target position is in pixel.
-
- \sa pixelPerMeter(), scrollTo()
-*/
-QPointF QScroller::finalPosition() const
-{
- Q_D(const QScroller);
- return QPointF(d->scrollingSegmentsEndPos(Qt::Horizontal),
- d->scrollingSegmentsEndPos(Qt::Vertical));
-}
-
-/*!
- Starts scrolling the widget so that point \a pos is at the top-left position in
- the viewport.
-
- The behaviour when scrolling outside the valid scroll area is undefined.
- In this case the scroller might or might not overshoot.
-
- The scrolling speed will be calculated so that the given position will
- be reached after a platform-defined time span.
-
- \a pos is given in viewport coordinates.
-
- \sa ensureVisible()
-*/
-void QScroller::scrollTo(const QPointF &pos)
-{
- // we could make this adjustable via QScrollerProperties
- scrollTo(pos, 300);
-}
-
-/*! \overload
-
- This version will reach its destination position in \a scrollTime milliseconds.
-*/
-void QScroller::scrollTo(const QPointF &pos, int scrollTime)
-{
- Q_D(QScroller);
-
- if (d->state == Pressed || d->state == Dragging )
- return;
-
- // no need to resend a prepare event if we are already scrolling
- if (d->state == Inactive && !d->prepareScrolling(QPointF()))
- return;
-
- QPointF newpos = clampToRect(pos, d->contentPosRange);
- qreal snapX = d->nextSnapPos(newpos.x(), 0, Qt::Horizontal);
- qreal snapY = d->nextSnapPos(newpos.y(), 0, Qt::Vertical);
- if (!qIsNaN(snapX))
- newpos.setX(snapX);
- if (!qIsNaN(snapY))
- newpos.setY(snapY);
-
- qScrollerDebug() << "QScroller::scrollTo(req:" << pos << " [pix] / snap:" << newpos << ", " << scrollTime << " [ms])";
-
- if (newpos == d->contentPosition + d->overshootPosition)
- return;
-
- QPointF vel = velocity();
-
- if (scrollTime < 0)
- scrollTime = 0;
- qreal time = qreal(scrollTime) / 1000;
-
- d->createScrollToSegments(vel.x(), time, newpos.x(), Qt::Horizontal, QScrollerPrivate::ScrollTypeScrollTo);
- d->createScrollToSegments(vel.y(), time, newpos.y(), Qt::Vertical, QScrollerPrivate::ScrollTypeScrollTo);
-
- if (!scrollTime)
- d->setContentPositionHelperScrolling();
- d->setState(scrollTime ? Scrolling : Inactive);
-}
-
-/*!
- Starts scrolling so that the rectangle \a rect is visible inside the
- viewport with additional margins specified in pixels by \a xmargin and \a ymargin around
- the rect.
-
- In cases where it is not possible to fit the rect plus margins inside the viewport the contents
- are scrolled so that as much as possible is visible from \a rect.
-
- The scrolling speed is calculated so that the given position is reached after a platform-defined
- time span.
-
- This function performs the actual scrolling by calling scrollTo().
-
- \sa scrollTo
-*/
-void QScroller::ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin)
-{
- // we could make this adjustable via QScrollerProperties
- ensureVisible(rect, xmargin, ymargin, 1000);
-}
-
-/*! \overload
-
- This version will reach its destination position in \a scrollTime milliseconds.
-*/
-void QScroller::ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin, int scrollTime)
-{
- Q_D(QScroller);
-
- if (d->state == Pressed || d->state == Dragging )
- return;
-
- if (d->state == Inactive && !d->prepareScrolling(QPointF()))
- return;
-
- // -- calculate the current pos (or the position after the current scroll)
- QPointF startPos = d->contentPosition + d->overshootPosition;
- startPos = QPointF(d->scrollingSegmentsEndPos(Qt::Horizontal),
- d->scrollingSegmentsEndPos(Qt::Vertical));
-
- QRectF marginRect(rect.x() - xmargin, rect.y() - ymargin,
- rect.width() + 2 * xmargin, rect.height() + 2 * ymargin);
-
- QSizeF visible = d->viewportSize;
- QRectF visibleRect(startPos, visible);
-
- qScrollerDebug() << "QScroller::ensureVisible(" << rect << " [pix], " << xmargin << " [pix], " << ymargin << " [pix], " << scrollTime << "[ms])";
- qScrollerDebug() << " --> content position:" << d->contentPosition;
-
- if (visibleRect.contains(marginRect))
- return;
-
- QPointF newPos = startPos;
-
- if (visibleRect.width() < rect.width()) {
- // at least try to move the rect into view
- if (rect.left() > visibleRect.left())
- newPos.setX(rect.left());
- else if (rect.right() < visibleRect.right())
- newPos.setX(rect.right() - visible.width());
-
- } else if (visibleRect.width() < marginRect.width()) {
- newPos.setX(rect.center().x() - visibleRect.width() / 2);
- } else if (marginRect.left() > visibleRect.left()) {
- newPos.setX(marginRect.left());
- } else if (marginRect.right() < visibleRect.right()) {
- newPos.setX(marginRect.right() - visible.width());
- }
-
- if (visibleRect.height() < rect.height()) {
- // at least try to move the rect into view
- if (rect.top() > visibleRect.top())
- newPos.setX(rect.top());
- else if (rect.bottom() < visibleRect.bottom())
- newPos.setX(rect.bottom() - visible.height());
-
- } else if (visibleRect.height() < marginRect.height()) {
- newPos.setY(rect.center().y() - visibleRect.height() / 2);
- } else if (marginRect.top() > visibleRect.top()) {
- newPos.setY(marginRect.top());
- } else if (marginRect.bottom() < visibleRect.bottom()) {
- newPos.setY(marginRect.bottom() - visible.height());
- }
-
- // clamp to maximum content position
- newPos = clampToRect(newPos, d->contentPosRange);
- if (newPos == startPos)
- return;
-
- scrollTo(newPos, scrollTime);
-}
-
-/*! This function resends the QScrollPrepareEvent.
- Calling resendPrepareEvent triggers a QScrollPrepareEvent from the scroller.
- This allows the receiver to re-set content position and content size while
- scrolling.
- Calling this function while in the Inactive state is useless as the prepare event
- is sent again before scrolling starts.
- */
-void QScroller::resendPrepareEvent()
-{
- Q_D(QScroller);
- d->prepareScrolling(d->pressPosition);
-}
-
-/*! Set the snap positions for the horizontal axis to a list of \a positions.
- This overwrites all previously set snap positions and also a previously
- set snapping interval.
- Snapping can be deactivated by setting an empty list of positions.
- */
-void QScroller::setSnapPositionsX(const QList<qreal> &positions)
-{
- Q_D(QScroller);
- d->snapPositionsX = positions;
- d->snapIntervalX = 0.0;
-
- d->recalcScrollingSegments();
-}
-
-/*! Set the snap positions for the horizontal axis to regular spaced intervals.
- The first snap position is at \a first. The next at \a first + \a interval.
- This can be used to implement a list header.
- This overwrites all previously set snap positions and also a previously
- set snapping interval.
- Snapping can be deactivated by setting an interval of 0.0
- */
-void QScroller::setSnapPositionsX(qreal first, qreal interval)
-{
- Q_D(QScroller);
- d->snapFirstX = first;
- d->snapIntervalX = interval;
- d->snapPositionsX.clear();
-
- d->recalcScrollingSegments();
-}
-
-/*! Set the snap positions for the vertical axis to a list of \a positions.
- This overwrites all previously set snap positions and also a previously
- set snapping interval.
- Snapping can be deactivated by setting an empty list of positions.
- */
-void QScroller::setSnapPositionsY(const QList<qreal> &positions)
-{
- Q_D(QScroller);
- d->snapPositionsY = positions;
- d->snapIntervalY = 0.0;
-
- d->recalcScrollingSegments();
-}
-
-/*! Set the snap positions for the vertical axis to regular spaced intervals.
- The first snap position is at \a first. The next at \a first + \a interval.
- This overwrites all previously set snap positions and also a previously
- set snapping interval.
- Snapping can be deactivated by setting an interval of 0.0
- */
-void QScroller::setSnapPositionsY(qreal first, qreal interval)
-{
- Q_D(QScroller);
- d->snapFirstY = first;
- d->snapIntervalY = interval;
- d->snapPositionsY.clear();
-
- d->recalcScrollingSegments();
-}
-
-
-
-// -------------- private ------------
-
-QScrollerPrivate::QScrollerPrivate(QScroller *q, QObject *_target)
- : target(_target)
-#ifndef QT_NO_GESTURES
- , recognizer(0)
- , recognizerType(Qt::CustomGesture)
-#endif
- , state(QScroller::Inactive)
- , firstScroll(true)
- , pressTimestamp(0)
- , lastTimestamp(0)
- , snapFirstX(-1.0)
- , snapIntervalX(0.0)
- , snapFirstY(-1.0)
- , snapIntervalY(0.0)
-#ifndef QT_NO_ANIMATION
- , scrollTimer(new QScrollTimer(this))
-#endif
- , q_ptr(q)
-{
- connect(target, SIGNAL(destroyed(QObject*)), this, SLOT(targetDestroyed()));
-}
-
-void QScrollerPrivate::init()
-{
- setDpiFromWidget(0);
- monotonicTimer.start();
-}
-
-void QScrollerPrivate::sendEvent(QObject *o, QEvent *e)
-{
- qt_sendSpontaneousEvent(o, e);
-}
-
-const char *QScrollerPrivate::stateName(QScroller::State state)
-{
- switch (state) {
- case QScroller::Inactive: return "inactive";
- case QScroller::Pressed: return "pressed";
- case QScroller::Dragging: return "dragging";
- case QScroller::Scrolling: return "scrolling";
- default: return "(invalid)";
- }
-}
-
-const char *QScrollerPrivate::inputName(QScroller::Input input)
-{
- switch (input) {
- case QScroller::InputPress: return "press";
- case QScroller::InputMove: return "move";
- case QScroller::InputRelease: return "release";
- default: return "(invalid)";
- }
-}
-
-void QScrollerPrivate::targetDestroyed()
-{
-#ifndef QT_NO_ANIMATION
- scrollTimer->stop();
-#endif
- delete q_ptr;
-}
-
-void QScrollerPrivate::timerTick()
-{
- struct timerevent {
- QScroller::State state;
- typedef void (QScrollerPrivate::*timerhandler_t)();
- timerhandler_t handler;
- };
-
- timerevent timerevents[] = {
- { QScroller::Dragging, &QScrollerPrivate::timerEventWhileDragging },
- { QScroller::Scrolling, &QScrollerPrivate::timerEventWhileScrolling },
- };
-
- for (int i = 0; i < int(sizeof(timerevents) / sizeof(*timerevents)); ++i) {
- timerevent *te = timerevents + i;
-
- if (state == te->state) {
- (this->*te->handler)();
- return;
- }
- }
-
-#ifndef QT_NO_ANIMATION
- scrollTimer->stop();
-#endif
-}
-
-/*!
- This function is used by gesture recognizers to inform the scroller about a new input event.
- The scroller changes its internal state() according to the input event and its attached
- scroller properties. The scroller doesn't distinguish between the kind of input device the
- event came from. Therefore the event needs to be split into the \a input type, a \a position and a
- milli-second \a timestamp. The \a position needs to be in the target's coordinate system.
-
- The return value is \c true if the event should be consumed by the calling filter or \c false
- if the event should be forwarded to the control.
-
- \note Using grabGesture() should be sufficient for most use cases.
-*/
-bool QScroller::handleInput(Input input, const QPointF &position, qint64 timestamp)
-{
- Q_D(QScroller);
-
- qScrollerDebug() << "QScroller::handleInput(" << input << ", " << d->stateName(d->state) << ", " << position << ", " << timestamp << ")";
- struct statechange {
- State state;
- Input input;
- typedef bool (QScrollerPrivate::*inputhandler_t)(const QPointF &position, qint64 timestamp);
- inputhandler_t handler;
- };
-
- statechange statechanges[] = {
- { QScroller::Inactive, InputPress, &QScrollerPrivate::pressWhileInactive },
- { QScroller::Pressed, InputMove, &QScrollerPrivate::moveWhilePressed },
- { QScroller::Pressed, InputRelease, &QScrollerPrivate::releaseWhilePressed },
- { QScroller::Dragging, InputMove, &QScrollerPrivate::moveWhileDragging },
- { QScroller::Dragging, InputRelease, &QScrollerPrivate::releaseWhileDragging },
- { QScroller::Scrolling, InputPress, &QScrollerPrivate::pressWhileScrolling }
- };
-
- for (int i = 0; i < int(sizeof(statechanges) / sizeof(*statechanges)); ++i) {
- statechange *sc = statechanges + i;
-
- if (d->state == sc->state && input == sc->input)
- return (d->*sc->handler)(position - d->overshootPosition, timestamp);
- }
- return false;
-}
-
-#if !defined(Q_WS_MAC)
-// the Mac version is implemented in qscroller_mac.mm
-
-QPointF QScrollerPrivate::realDpi(int screen)
-{
-# ifdef Q_WS_MAEMO_5
- Q_UNUSED(screen);
-
- // The DPI value is hardcoded to 96 on Maemo5:
- // https://projects.maemo.org/bugzilla/show_bug.cgi?id=152525
- // This value (260) is only correct for the N900 though, but
- // there's no way to get the real DPI at run time.
- return QPointF(260, 260);
-
-# elif defined(Q_WS_X11) && !defined(QT_NO_XRANDR)
- if (X11 && X11->use_xrandr && X11->ptrXRRSizes && X11->ptrXRRRootToScreen) {
- int nsizes = 0;
- // QDesktopWidget is based on Xinerama screens, which do not always
- // correspond to RandR screens: NVidia's TwinView e.g. will show up
- // as 2 screens in QDesktopWidget, but libXRandR will only see 1 screen.
- // (although with the combined size of the Xinerama screens).
- // Additionally, libXrandr will simply crash when calling XRRSizes
- // for (the non-existent) screen 1 in this scenario.
- Window root = RootWindow(X11->display, screen == -1 ? X11->defaultScreen : screen);
- int randrscreen = (root != XNone) ? X11->ptrXRRRootToScreen(X11->display, root) : -1;
-
- XRRScreenSize *sizes = X11->ptrXRRSizes(X11->display, randrscreen == -1 ? 0 : randrscreen, &nsizes);
- if (nsizes > 0 && sizes && sizes->width && sizes->height && sizes->mwidth && sizes->mheight) {
- qScrollerDebug() << "XRandR DPI:" << QPointF(qreal(25.4) * qreal(sizes->width) / qreal(sizes->mwidth),
- qreal(25.4) * qreal(sizes->height) / qreal(sizes->mheight));
- return QPointF(qreal(25.4) * qreal(sizes->width) / qreal(sizes->mwidth),
- qreal(25.4) * qreal(sizes->height) / qreal(sizes->mheight));
- }
- }
-# endif
-
- QWidget *w = QApplication::desktop()->screen(screen);
- return QPointF(w->physicalDpiX(), w->physicalDpiY());
-}
-
-#endif // !Q_WS_MAC
-
-
-/*! \internal
- Returns the resolution of the used screen.
-*/
-QPointF QScrollerPrivate::dpi() const
-{
- return pixelPerMeter * qreal(0.0254);
-}
-
-/*! \internal
- Sets the resolution used for scrolling.
- This resolution is only used by the kinetic scroller. If you change this
- then the scroller will behave quite different as a lot of the values are
- given in physical distances (millimeter).
-*/
-void QScrollerPrivate::setDpi(const QPointF &dpi)
-{
- pixelPerMeter = dpi / qreal(0.0254);
-}
-
-/*! \internal
- Sets the dpi used for scrolling to the value of the widget.
-*/
-void QScrollerPrivate::setDpiFromWidget(QWidget *widget)
-{
- QDesktopWidget *dw = QApplication::desktop();
- setDpi(realDpi(widget ? dw->screenNumber(widget) : dw->primaryScreen()));
-}
-
-/*! \internal
- Updates the velocity during dragging.
- Sets releaseVelocity.
-*/
-void QScrollerPrivate::updateVelocity(const QPointF &deltaPixelRaw, qint64 deltaTime)
-{
- if (deltaTime <= 0)
- return;
-
- Q_Q(QScroller);
- QPointF ppm = q->pixelPerMeter();
- const QScrollerPropertiesPrivate *sp = properties.d.data();
- QPointF deltaPixel = deltaPixelRaw;
-
- qScrollerDebug() << "QScroller::updateVelocity(" << deltaPixelRaw << " [delta pix], " << deltaTime << " [delta ms])";
-
- // faster than 2.5mm/ms seems bogus (that would be a screen height in ~20 ms)
- if (((deltaPixelRaw / qreal(deltaTime)).manhattanLength() / ((ppm.x() + ppm.y()) / 2) * 1000) > qreal(2.5))
- deltaPixel = deltaPixelRaw * qreal(2.5) * ppm / 1000 / (deltaPixelRaw / qreal(deltaTime)).manhattanLength();
-
- QPointF newv = -deltaPixel / qreal(deltaTime) * qreal(1000) / ppm;
- // around 95% of all updates are in the [1..50] ms range, so make sure
- // to scale the smoothing factor over that range: this way a 50ms update
- // will have full impact, while 5ms update will only have a 10% impact.
- qreal smoothing = sp->dragVelocitySmoothingFactor * qMin(qreal(deltaTime), qreal(50)) / qreal(50);
-
- // only smooth if we already have a release velocity and only if the
- // user hasn't stopped to move his finger for more than 100ms
- if ((releaseVelocity != QPointF(0, 0)) && (deltaTime < 100)) {
- qScrollerDebug() << "SMOOTHED from " << newv << " to " << newv * smoothing + releaseVelocity * (qreal(1) - smoothing);
- // smooth x or y only if the new velocity is either 0 or at least in
- // the same direction of the release velocity
- if (!newv.x() || (qSign(releaseVelocity.x()) == qSign(newv.x())))
- newv.setX(newv.x() * smoothing + releaseVelocity.x() * (qreal(1) - smoothing));
- if (!newv.y() || (qSign(releaseVelocity.y()) == qSign(newv.y())))
- newv.setY(newv.y() * smoothing + releaseVelocity.y() * (qreal(1) - smoothing));
- } else
- qScrollerDebug() << "NO SMOOTHING to " << newv;
-
- releaseVelocity.setX(qBound(-sp->maximumVelocity, newv.x(), sp->maximumVelocity));
- releaseVelocity.setY(qBound(-sp->maximumVelocity, newv.y(), sp->maximumVelocity));
-
- qScrollerDebug() << " --> new velocity:" << releaseVelocity;
-}
-
-void QScrollerPrivate::pushSegment(ScrollType type, qreal deltaTime, qreal stopProgress, qreal startPos, qreal deltaPos, qreal stopPos, QEasingCurve::Type curve, Qt::Orientation orientation)
-{
- if (startPos == stopPos || deltaPos == 0)
- return;
-
- ScrollSegment s;
- if (orientation == Qt::Horizontal && !xSegments.isEmpty())
- s.startTime = xSegments.last().startTime + xSegments.last().deltaTime * xSegments.last().stopProgress;
- else if (orientation == Qt::Vertical && !ySegments.isEmpty())
- s.startTime = ySegments.last().startTime + ySegments.last().deltaTime * ySegments.last().stopProgress;
- else
- s.startTime = monotonicTimer.elapsed();
-
- s.startPos = startPos;
- s.deltaPos = deltaPos;
- s.stopPos = stopPos;
- s.deltaTime = deltaTime * 1000;
- s.stopProgress = stopProgress;
- s.curve.setType(curve);
- s.type = type;
-
- if (orientation == Qt::Horizontal)
- xSegments.enqueue(s);
- else
- ySegments.enqueue(s);
-
- qScrollerDebug() << "+++ Added a new ScrollSegment: " << s;
-}
-
-
-/*! \internal
- Clears the old segments and recalculates them if the current segments are not longer valid
-*/
-void QScrollerPrivate::recalcScrollingSegments(bool forceRecalc)
-{
- Q_Q(QScroller);
- QPointF ppm = q->pixelPerMeter();
-
- releaseVelocity = q->velocity();
-
- if (forceRecalc || !scrollingSegmentsValid(Qt::Horizontal))
- createScrollingSegments(releaseVelocity.x(), contentPosition.x() + overshootPosition.x(), ppm.x(), Qt::Horizontal);
-
- if (forceRecalc || !scrollingSegmentsValid(Qt::Vertical))
- createScrollingSegments(releaseVelocity.y(), contentPosition.y() + overshootPosition.y(), ppm.y(), Qt::Vertical);
-}
-
-/*! \internal
- Returns the end position after the current scroll has finished.
-*/
-qreal QScrollerPrivate::scrollingSegmentsEndPos(Qt::Orientation orientation) const
-{
- if (orientation == Qt::Horizontal) {
- if (xSegments.isEmpty())
- return contentPosition.x() + overshootPosition.x();
- else
- return xSegments.last().stopPos;
- } else {
- if (ySegments.isEmpty())
- return contentPosition.y() + overshootPosition.y();
- else
- return ySegments.last().stopPos;
- }
-}
-
-/*! \internal
- Checks if the scroller segment end in a valid position.
-*/
-bool QScrollerPrivate::scrollingSegmentsValid(Qt::Orientation orientation)
-{
- QQueue<ScrollSegment> *segments;
- qreal minPos;
- qreal maxPos;
-
- if (orientation == Qt::Horizontal) {
- segments = &xSegments;
- minPos = contentPosRange.left();
- maxPos = contentPosRange.right();
- } else {
- segments = &ySegments;
- minPos = contentPosRange.top();
- maxPos = contentPosRange.bottom();
- }
-
- if (segments->isEmpty())
- return true;
-
- const ScrollSegment &last = segments->last();
- qreal stopPos = last.stopPos;
-
- if (last.type == ScrollTypeScrollTo)
- return true; // scrollTo is always valid
-
- if (last.type == ScrollTypeOvershoot &&
- (stopPos != minPos && stopPos != maxPos))
- return false;
-
- if (stopPos < minPos || stopPos > maxPos)
- return false;
-
- if (stopPos == minPos || stopPos == maxPos) // the begin and the end of the list are always ok
- return true;
-
- qreal nextSnap = nextSnapPos(stopPos, 0, orientation);
- if (!qIsNaN(nextSnap) && stopPos != nextSnap)
- return false;
-
- return true;
-}
-
-/*! \internal
- Creates the sections needed to scroll to the specific \a endPos to the segments queue.
-*/
-void QScrollerPrivate::createScrollToSegments(qreal v, qreal deltaTime, qreal endPos, Qt::Orientation orientation, ScrollType type)
-{
- Q_UNUSED(v);
-
- if (orientation == Qt::Horizontal)
- xSegments.clear();
- else
- ySegments.clear();
-
- qScrollerDebug() << "+++ createScrollToSegments: t:" << deltaTime << "ep:" << endPos << "o:" << int(orientation);
-
- const QScrollerPropertiesPrivate *sp = properties.d.data();
-
- qreal startPos = (orientation == Qt::Horizontal) ? contentPosition.x() + overshootPosition.x()
- : contentPosition.y() + overshootPosition.y();
- qreal deltaPos = (endPos - startPos) / 2;
-
- pushSegment(type, deltaTime * qreal(0.3), qreal(1.0), startPos, deltaPos, startPos + deltaPos, QEasingCurve::InQuad, orientation);
- pushSegment(type, deltaTime * qreal(0.7), qreal(1.0), startPos + deltaPos, deltaPos, endPos, sp->scrollingCurve.type(), orientation);
-}
-
-/*! \internal
-*/
-void QScrollerPrivate::createScrollingSegments(qreal v, qreal startPos, qreal ppm, Qt::Orientation orientation)
-{
- const QScrollerPropertiesPrivate *sp = properties.d.data();
-
- QScrollerProperties::OvershootPolicy policy;
- qreal minPos;
- qreal maxPos;
- qreal viewSize;
-
- if (orientation == Qt::Horizontal) {
- xSegments.clear();
- policy = sp->hOvershootPolicy;
- minPos = contentPosRange.left();
- maxPos = contentPosRange.right();
- viewSize = viewportSize.width();
- } else {
- ySegments.clear();
- policy = sp->vOvershootPolicy;
- minPos = contentPosRange.top();
- maxPos = contentPosRange.bottom();
- viewSize = viewportSize.height();
- }
-
- bool alwaysOvershoot = (policy == QScrollerProperties::OvershootAlwaysOn);
- bool noOvershoot = (policy == QScrollerProperties::OvershootAlwaysOff) || !sp->overshootScrollDistanceFactor;
- bool canOvershoot = !noOvershoot && (alwaysOvershoot || maxPos);
-
- qScrollerDebug() << "+++ createScrollingSegments: s:" << startPos << "maxPos:" << maxPos << "o:" << int(orientation);
-
- qScrollerDebug() << "v = " << v << ", decelerationFactor = " << sp->decelerationFactor << ", curveType = " << sp->scrollingCurve.type();
-
- // This is only correct for QEasingCurve::OutQuad (linear velocity,
- // constant deceleration), but the results look and feel ok for OutExpo
- // and OutSine as well
-
- // v(t) = deltaTime * a * 0.5 * differentialForProgress(t / deltaTime)
- // v(0) = vrelease
- // v(deltaTime) = 0
- // deltaTime = (2 * vrelease) / (a * differntial(0))
-
- // pos(t) = integrate(v(t)dt)
- // pos(t) = vrelease * t - 0.5 * a * t * t
- // pos(t) = deltaTime * a * 0.5 * progress(t / deltaTime) * deltaTime
- // deltaPos = pos(deltaTime)
-
- qreal deltaTime = (qreal(2) * qAbs(v)) / (sp->decelerationFactor * differentialForProgress(sp->scrollingCurve, 0));
- qreal deltaPos = qSign(v) * deltaTime * deltaTime * qreal(0.5) * sp->decelerationFactor * ppm;
- qreal endPos = startPos + deltaPos;
-
- qScrollerDebug() << " Real Delta:" << deltaPos;
-
- // -- determine snap points
- qreal nextSnap = nextSnapPos(endPos, 0, orientation);
- qreal lowerSnapPos = nextSnapPos(startPos, -1, orientation);
- qreal higherSnapPos = nextSnapPos(startPos, 1, orientation);
-
- qScrollerDebug() << " Real Delta:" << lowerSnapPos <<"-"<<nextSnap <<"-"<<higherSnapPos;
-
- // - check if we can reach another snap point
- if (nextSnap > higherSnapPos || qIsNaN(higherSnapPos))
- higherSnapPos = nextSnap;
- if (nextSnap < lowerSnapPos || qIsNaN(lowerSnapPos))
- lowerSnapPos = nextSnap;
-
- // -- check if are in overshoot and end in overshoot
- if ((startPos < minPos && endPos < minPos) ||
- (startPos > maxPos && endPos > maxPos)) {
- qreal stopPos = endPos < minPos ? minPos : maxPos;
- qreal oDeltaTime = sp->overshootScrollTime;
-
- pushSegment(ScrollTypeOvershoot, oDeltaTime * qreal(0.7), qreal(1.0), startPos, stopPos - startPos, stopPos, sp->scrollingCurve.type(), orientation);
- return;
- }
-
- if (qAbs(v) < sp->minimumVelocity) {
-
- qScrollerDebug() << "### below minimum Vel" << orientation;
-
- // - no snap points or already at one
- if (qIsNaN(nextSnap) || nextSnap == startPos)
- return; // nothing to do, no scrolling needed.
-
- // - decide which point to use
-
- qreal snapDistance = higherSnapPos - lowerSnapPos;
-
- qreal pressDistance = (orientation == Qt::Horizontal) ?
- lastPosition.x() - pressPosition.x() :
- lastPosition.y() - pressPosition.y();
-
- // if not dragged far enough, pick the next snap point.
- if (sp->snapPositionRatio == 0.0 || qAbs(pressDistance / sp->snapPositionRatio) > snapDistance)
- endPos = nextSnap;
- else if (pressDistance < 0.0)
- endPos = lowerSnapPos;
- else
- endPos = higherSnapPos;
-
- deltaPos = endPos - startPos;
- qreal midPos = startPos + deltaPos * qreal(0.3);
- pushSegment(ScrollTypeFlick, sp->snapTime * qreal(0.3), qreal(1.0), startPos, midPos - startPos, midPos, QEasingCurve::InQuad, orientation);
- pushSegment(ScrollTypeFlick, sp->snapTime * qreal(0.7), qreal(1.0), midPos, endPos - midPos, endPos, sp->scrollingCurve.type(), orientation);
- return;
- }
-
- // - go to the next snappoint if there is one
- if (v > 0 && !qIsNaN(higherSnapPos)) {
- // change the time in relation to the changed end position
- if (endPos - startPos)
- deltaTime *= qAbs((higherSnapPos - startPos) / (endPos - startPos));
- if (deltaTime > sp->snapTime)
- deltaTime = sp->snapTime;
- endPos = higherSnapPos;
-
- } else if (v < 0 && !qIsNaN(lowerSnapPos)) {
- // change the time in relation to the changed end position
- if (endPos - startPos)
- deltaTime *= qAbs((lowerSnapPos - startPos) / (endPos - startPos));
- if (deltaTime > sp->snapTime)
- deltaTime = sp->snapTime;
- endPos = lowerSnapPos;
-
- // -- check if we are overshooting
- } else if (endPos < minPos || endPos > maxPos) {
- qreal stopPos = endPos < minPos ? minPos : maxPos;
-
- qScrollerDebug() << "Overshoot: delta:" << (stopPos - startPos);
-
- qreal stopProgress = progressForValue(sp->scrollingCurve, qAbs((stopPos - startPos) / deltaPos));
-
- if (!canOvershoot) {
- qScrollerDebug() << "Overshoot stopp:" << stopProgress;
-
- pushSegment(ScrollTypeFlick, deltaTime, stopProgress, startPos, endPos, stopPos, sp->scrollingCurve.type(), orientation);
- } else {
- qreal oDeltaTime = sp->overshootScrollTime;
- qreal oStopProgress = qMin(stopProgress + oDeltaTime * qreal(0.3) / deltaTime, qreal(1));
- qreal oDistance = startPos + deltaPos * sp->scrollingCurve.valueForProgress(oStopProgress) - stopPos;
- qreal oMaxDistance = qSign(oDistance) * (viewSize * sp->overshootScrollDistanceFactor);
-
- qScrollerDebug() << "1 oDistance:" << oDistance << "Max:" << oMaxDistance << "stopP/oStopP" << stopProgress << oStopProgress;
-
- if (qAbs(oDistance) > qAbs(oMaxDistance)) {
- oStopProgress = progressForValue(sp->scrollingCurve, qAbs((stopPos + oMaxDistance - startPos) / deltaPos));
- oDistance = oMaxDistance;
- qScrollerDebug() << "2 oDistance:" << oDistance << "Max:" << oMaxDistance << "stopP/oStopP" << stopProgress << oStopProgress;
- }
-
- pushSegment(ScrollTypeFlick, deltaTime, oStopProgress, startPos, deltaPos, stopPos + oDistance, sp->scrollingCurve.type(), orientation);
- pushSegment(ScrollTypeOvershoot, oDeltaTime * qreal(0.7), qreal(1.0), stopPos + oDistance, -oDistance, stopPos, sp->scrollingCurve.type(), orientation);
- }
- return;
- }
-
- pushSegment(ScrollTypeFlick, deltaTime, qreal(1.0), startPos, deltaPos, endPos, sp->scrollingCurve.type(), orientation);
-}
-
-
-/*! \internal
- Prepares scrolling by sending a QScrollPrepareEvent to the receiver widget.
- Returns true if the scrolling was accepted and a target was returned.
-*/
-bool QScrollerPrivate::prepareScrolling(const QPointF &position)
-{
- QScrollPrepareEvent spe(position);
- spe.ignore();
- sendEvent(target, &spe);
-
- qScrollerDebug() << "QScrollPrepareEvent returned from" << target << "with" << spe.isAccepted() << "mcp:" << spe.contentPosRange() << "cp:" << spe.contentPos();
- if (spe.isAccepted()) {
- QPointF oldContentPos = contentPosition + overshootPosition;
- QPointF contentDelta = spe.contentPos() - oldContentPos;
-
- viewportSize = spe.viewportSize();
- contentPosRange = spe.contentPosRange();
- if (contentPosRange.width() < 0)
- contentPosRange.setWidth(0);
- if (contentPosRange.height() < 0)
- contentPosRange.setHeight(0);
- contentPosition = clampToRect(spe.contentPos(), contentPosRange);
- overshootPosition = spe.contentPos() - contentPosition;
-
- // - check if the content position was moved
- if (contentDelta != QPointF(0, 0)) {
- // need to correct all segments
- for (int i = 0; i < xSegments.count(); i++)
- xSegments[i].startPos -= contentDelta.x();
-
- for (int i = 0; i < ySegments.count(); i++)
- ySegments[i].startPos -= contentDelta.y();
- }
-
- if (QWidget *w = qobject_cast<QWidget *>(target))
- setDpiFromWidget(w);
-#ifndef QT_NO_GRAPHICSVIEW
- if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(target)) {
- //TODO: the first view isn't really correct - maybe use an additional field in the prepare event?
- if (go->scene() && !go->scene()->views().isEmpty())
- setDpiFromWidget(go->scene()->views().first());
- }
-#endif
-
- if (state == QScroller::Scrolling) {
- recalcScrollingSegments();
- }
- return true;
- }
-
- return false;
-}
-
-void QScrollerPrivate::handleDrag(const QPointF &position, qint64 timestamp)
-{
- const QScrollerPropertiesPrivate *sp = properties.d.data();
-
- QPointF deltaPixel = position - lastPosition;
- qint64 deltaTime = timestamp - lastTimestamp;
-
- if (sp->axisLockThreshold) {
- int dx = qAbs(deltaPixel.x());
- int dy = qAbs(deltaPixel.y());
- if (dx || dy) {
- bool vertical = (dy > dx);
- qreal alpha = qreal(vertical ? dx : dy) / qreal(vertical ? dy : dx);
- //qScrollerDebug() << "QScroller::handleDrag() -- axis lock:" << alpha << " / " << axisLockThreshold << "- isvertical:" << vertical << "- dx:" << dx << "- dy:" << dy;
- if (alpha <= sp->axisLockThreshold) {
- if (vertical)
- deltaPixel.setX(0);
- else
- deltaPixel.setY(0);
- }
- }
- }
-
- // calculate velocity (if the user would release the mouse NOW)
- updateVelocity(deltaPixel, deltaTime);
-
- // restrict velocity, if content is not scrollable
- QRectF max = contentPosRange;
- bool canScrollX = (max.width() > 0) || (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn);
- bool canScrollY = (max.height() > 0) || (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn);
-
- if (!canScrollX) {
- deltaPixel.setX(0);
- releaseVelocity.setX(0);
- }
- if (!canScrollY) {
- deltaPixel.setY(0);
- releaseVelocity.setY(0);
- }
-
-// if (firstDrag) {
-// // Do not delay the first drag
-// setContentPositionHelper(q->contentPosition() - overshootDistance - deltaPixel);
-// dragDistance = QPointF(0, 0);
-// } else {
- dragDistance += deltaPixel;
-// }
-//qScrollerDebug() << "######################" << deltaPixel << position.y() << lastPosition.y();
- if (canScrollX)
- lastPosition.setX(position.x());
- if (canScrollY)
- lastPosition.setY(position.y());
- lastTimestamp = timestamp;
-}
-
-bool QScrollerPrivate::pressWhileInactive(const QPointF &position, qint64 timestamp)
-{
- if (prepareScrolling(position)) {
- const QScrollerPropertiesPrivate *sp = properties.d.data();
-
- if (!contentPosRange.isNull() ||
- (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn) ||
- (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn)) {
-
- lastPosition = pressPosition = position;
- lastTimestamp = pressTimestamp = timestamp;
- setState(QScroller::Pressed);
- }
- }
- return false;
-}
-
-bool QScrollerPrivate::releaseWhilePressed(const QPointF &, qint64)
-{
- if (overshootPosition != QPointF(0.0, 0.0)) {
- setState(QScroller::Scrolling);
- return true;
- } else {
- setState(QScroller::Inactive);
- return false;
- }
-}
-
-bool QScrollerPrivate::moveWhilePressed(const QPointF &position, qint64 timestamp)
-{
- Q_Q(QScroller);
- const QScrollerPropertiesPrivate *sp = properties.d.data();
- QPointF ppm = q->pixelPerMeter();
-
- QPointF deltaPixel = position - pressPosition;
-
- bool moveAborted = false;
- bool moveStarted = (((deltaPixel / ppm).manhattanLength()) > sp->dragStartDistance);
-
- // check the direction of the mouse drag and abort if it's too much in the wrong direction.
- if (moveStarted) {
- QRectF max = contentPosRange;
- bool canScrollX = (max.width() > 0);
- bool canScrollY = (max.height() > 0);
-
- if (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn)
- canScrollX = true;
- if (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn)
- canScrollY = true;
-
- if (qAbs(deltaPixel.x() / ppm.x()) < qAbs(deltaPixel.y() / ppm.y())) {
- if (!canScrollY)
- moveAborted = true;
- } else {
- if (!canScrollX)
- moveAborted = true;
- }
- }
-
- if (moveAborted) {
- setState(QScroller::Inactive);
- moveStarted = false;
-
- } else if (moveStarted) {
- setState(QScroller::Dragging);
-
- // subtract the dragStartDistance
- deltaPixel = deltaPixel - deltaPixel * (sp->dragStartDistance / deltaPixel.manhattanLength());
-
- if (deltaPixel != QPointF(0, 0)) {
- // handleDrag updates lastPosition, lastTimestamp and velocity
- handleDrag(pressPosition + deltaPixel, timestamp);
- }
- }
- return moveStarted;
-}
-
-bool QScrollerPrivate::moveWhileDragging(const QPointF &position, qint64 timestamp)
-{
- // handleDrag updates lastPosition, lastTimestamp and velocity
- handleDrag(position, timestamp);
- return true;
-}
-
-void QScrollerPrivate::timerEventWhileDragging()
-{
- if (dragDistance != QPointF(0, 0)) {
- qScrollerDebug() << "QScroller::timerEventWhileDragging() -- dragDistance:" << dragDistance;
-
- setContentPositionHelperDragging(-dragDistance);
- dragDistance = QPointF(0, 0);
- }
-}
-
-bool QScrollerPrivate::releaseWhileDragging(const QPointF &position, qint64 timestamp)
-{
- Q_Q(QScroller);
- const QScrollerPropertiesPrivate *sp = properties.d.data();
-
- // handleDrag updates lastPosition, lastTimestamp and velocity
- handleDrag(position, timestamp);
-
- // check if we moved at all - this can happen if you stop a running
- // scroller with a press and release shortly afterwards
- QPointF deltaPixel = position - pressPosition;
- if (((deltaPixel / q->pixelPerMeter()).manhattanLength()) > sp->dragStartDistance) {
-
- // handle accelerating flicks
- if ((oldVelocity != QPointF(0, 0)) && sp->acceleratingFlickMaximumTime &&
- ((timestamp - pressTimestamp) < qint64(sp->acceleratingFlickMaximumTime * 1000))) {
-
- // - determine if the direction was changed
- int signX = 0, signY = 0;
- if (releaseVelocity.x())
- signX = (releaseVelocity.x() > 0) == (oldVelocity.x() > 0) ? 1 : -1;
- if (releaseVelocity.y())
- signY = (releaseVelocity.y() > 0) == (oldVelocity.y() > 0) ? 1 : -1;
-
- if (signX > 0)
- releaseVelocity.setX(qBound(-sp->maximumVelocity,
- oldVelocity.x() * sp->acceleratingFlickSpeedupFactor,
- sp->maximumVelocity));
- if (signY > 0)
- releaseVelocity.setY(qBound(-sp->maximumVelocity,
- oldVelocity.y() * sp->acceleratingFlickSpeedupFactor,
- sp->maximumVelocity));
- }
- }
-
- QPointF ppm = q->pixelPerMeter();
- createScrollingSegments(releaseVelocity.x(), contentPosition.x() + overshootPosition.x(), ppm.x(), Qt::Horizontal);
- createScrollingSegments(releaseVelocity.y(), contentPosition.y() + overshootPosition.y(), ppm.y(), Qt::Vertical);
-
- qScrollerDebug() << "QScroller::releaseWhileDragging() -- velocity:" << releaseVelocity << "-- minimum velocity:" << sp->minimumVelocity << "overshoot" << overshootPosition;
-
- if (xSegments.isEmpty() && ySegments.isEmpty())
- setState(QScroller::Inactive);
- else
- setState(QScroller::Scrolling);
-
- return true;
-}
-
-void QScrollerPrivate::timerEventWhileScrolling()
-{
- qScrollerDebug() << "QScroller::timerEventWhileScrolling()";
-
- setContentPositionHelperScrolling();
- if (xSegments.isEmpty() && ySegments.isEmpty())
- setState(QScroller::Inactive);
-}
-
-bool QScrollerPrivate::pressWhileScrolling(const QPointF &position, qint64 timestamp)
-{
- Q_Q(QScroller);
-
- if ((q->velocity() <= properties.d->maximumClickThroughVelocity) &&
- (overshootPosition == QPointF(0.0, 0.0))) {
- setState(QScroller::Inactive);
- return false;
- } else {
- lastPosition = pressPosition = position;
- lastTimestamp = pressTimestamp = timestamp;
- setState(QScroller::Pressed);
- setState(QScroller::Dragging);
- return true;
- }
-}
-
-/*! \internal
- This function handles all state changes of the scroller.
-*/
-void QScrollerPrivate::setState(QScroller::State newstate)
-{
- Q_Q(QScroller);
- bool sendLastScroll = false;
-
- if (state == newstate)
- return;
-
- qScrollerDebug() << q << "QScroller::setState(" << stateName(newstate) << ")";
-
- switch (newstate) {
- case QScroller::Inactive:
-#ifndef QT_NO_ANIMATION
- scrollTimer->stop();
-#endif
-
- // send the last scroll event (but only after the current state change was finished)
- if (!firstScroll)
- sendLastScroll = true;
-
- releaseVelocity = QPointF(0, 0);
- break;
-
- case QScroller::Pressed:
-#ifndef QT_NO_ANIMATION
- scrollTimer->stop();
-#endif
-
- oldVelocity = releaseVelocity;
- releaseVelocity = QPointF(0, 0);
- break;
-
- case QScroller::Dragging:
- dragDistance = QPointF(0, 0);
-#ifndef QT_NO_ANIMATION
- if (state == QScroller::Pressed)
- scrollTimer->start();
-#endif
- break;
-
- case QScroller::Scrolling:
-#ifndef QT_NO_ANIMATION
- scrollTimer->start();
-#endif
- break;
- }
-
- qSwap(state, newstate);
-
- if (sendLastScroll) {
- QScrollEvent se(contentPosition, overshootPosition, QScrollEvent::ScrollFinished);
- sendEvent(target, &se);
- firstScroll = true;
- }
- if (state == QScroller::Dragging || state == QScroller::Scrolling)
- qt_activeScrollers()->insert(q);
- else
- qt_activeScrollers()->remove(q);
- emit q->stateChanged(state);
-}
-
-
-/*! \internal
- Helps when setting the content position.
- It will try to move the content by the requested delta but stop in case
- when we are coming back from an overshoot or a scrollTo.
- It will also indicate a new overshooting condition by the overshootX and oversthootY flags.
-
- In this cases it will reset the velocity variables and other flags.
-
- Also keeps track of the current over-shooting value in overshootPosition.
-
- \a deltaPos is the amount of pixels the current content position should be moved
-*/
-void QScrollerPrivate::setContentPositionHelperDragging(const QPointF &deltaPos)
-{
- const QScrollerPropertiesPrivate *sp = properties.d.data();
-
- if (sp->overshootDragResistanceFactor)
- overshootPosition /= sp->overshootDragResistanceFactor;
-
- QPointF oldPos = contentPosition + overshootPosition;
- QPointF newPos = oldPos + deltaPos;
-
- qScrollerDebug() << "QScroller::setContentPositionHelperDragging(" << deltaPos << " [pix])";
- qScrollerDebug() << " --> overshoot:" << overshootPosition << "- old pos:" << oldPos << "- new pos:" << newPos;
-
- QPointF oldClampedPos = clampToRect(oldPos, contentPosRange);
- QPointF newClampedPos = clampToRect(newPos, contentPosRange);
-
- // --- handle overshooting and stop if the coordinate is going back inside the normal area
- bool alwaysOvershootX = (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn);
- bool alwaysOvershootY = (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn);
- bool noOvershootX = (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOff) ||
- ((state == QScroller::Dragging) && !sp->overshootDragResistanceFactor) ||
- !sp->overshootDragDistanceFactor;
- bool noOvershootY = (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOff) ||
- ((state == QScroller::Dragging) && !sp->overshootDragResistanceFactor) ||
- !sp->overshootDragDistanceFactor;
- bool canOvershootX = !noOvershootX && (alwaysOvershootX || contentPosRange.width());
- bool canOvershootY = !noOvershootY && (alwaysOvershootY || contentPosRange.height());
-
- qreal oldOvershootX = (canOvershootX) ? oldPos.x() - oldClampedPos.x() : 0;
- qreal oldOvershootY = (canOvershootY) ? oldPos.y() - oldClampedPos.y() : 0;
-
- qreal newOvershootX = (canOvershootX) ? newPos.x() - newClampedPos.x() : 0;
- qreal newOvershootY = (canOvershootY) ? newPos.y() - newClampedPos.y() : 0;
-
- qreal maxOvershootX = viewportSize.width() * sp->overshootDragDistanceFactor;
- qreal maxOvershootY = viewportSize.height() * sp->overshootDragDistanceFactor;
-
- qScrollerDebug() << " --> noOs:" << noOvershootX << "drf:" << sp->overshootDragResistanceFactor << "mdf:" << sp->overshootScrollDistanceFactor << "ossP:"<<sp->hOvershootPolicy;
- qScrollerDebug() << " --> canOS:" << canOvershootX << "newOS:" << newOvershootX << "maxOS:" << maxOvershootX;
-
- if (sp->overshootDragResistanceFactor) {
- oldOvershootX *= sp->overshootDragResistanceFactor;
- oldOvershootY *= sp->overshootDragResistanceFactor;
- newOvershootX *= sp->overshootDragResistanceFactor;
- newOvershootY *= sp->overshootDragResistanceFactor;
- }
-
- // -- stop at the maximum overshoot distance
-
- newOvershootX = qBound(-maxOvershootX, newOvershootX, maxOvershootX);
- newOvershootY = qBound(-maxOvershootY, newOvershootY, maxOvershootY);
-
- overshootPosition.setX(newOvershootX);
- overshootPosition.setY(newOvershootY);
- contentPosition = newClampedPos;
-
- QScrollEvent se(contentPosition, overshootPosition, firstScroll ? QScrollEvent::ScrollStarted : QScrollEvent::ScrollUpdated);
- sendEvent(target, &se);
- firstScroll = false;
-
- qScrollerDebug() << " --> new position:" << newClampedPos << "- new overshoot:" << overshootPosition <<
- "- overshoot x/y?:" << overshootPosition;
-}
-
-
-qreal QScrollerPrivate::nextSegmentPosition(QQueue<ScrollSegment> &segments, qint64 now, qreal oldPos)
-{
- qreal pos = oldPos;
-
- // check the X segments for new positions
- while (!segments.isEmpty()) {
- const ScrollSegment s = segments.head();
-
- if ((s.startTime + s.deltaTime * s.stopProgress) <= now) {
- segments.dequeue();
- pos = s.stopPos;
- } else if (s.startTime <= now) {
- qreal progress = qreal(now - s.startTime) / qreal(s.deltaTime);
- pos = s.startPos + s.deltaPos * s.curve.valueForProgress(progress);
- if (s.deltaPos > 0 ? pos > s.stopPos : pos < s.stopPos) {
- segments.dequeue();
- pos = s.stopPos;
- } else {
- break;
- }
- } else {
- break;
- }
- }
- return pos;
-}
-
-void QScrollerPrivate::setContentPositionHelperScrolling()
-{
- qint64 now = monotonicTimer.elapsed();
- QPointF newPos = contentPosition + overshootPosition;
-
- newPos.setX(nextSegmentPosition(xSegments, now, newPos.x()));
- newPos.setY(nextSegmentPosition(ySegments, now, newPos.y()));
-
- // -- set the position and handle overshoot
- qScrollerDebug() << "QScroller::setContentPositionHelperScrolling()";
- qScrollerDebug() << " --> overshoot:" << overshootPosition << "- new pos:" << newPos;
-
- QPointF newClampedPos = clampToRect(newPos, contentPosRange);
-
- overshootPosition = newPos - newClampedPos;
- contentPosition = newClampedPos;
-
- QScrollEvent se(contentPosition, overshootPosition, firstScroll ? QScrollEvent::ScrollStarted : QScrollEvent::ScrollUpdated);
- sendEvent(target, &se);
- firstScroll = false;
-
- qScrollerDebug() << " --> new position:" << newClampedPos << "- new overshoot:" << overshootPosition;
-}
-
-/*! \internal
- Returns the next snap point in direction.
- If \a direction >0 it will return the next snap point that is larger than the current position.
- If \a direction <0 it will return the next snap point that is smaller than the current position.
- If \a direction ==0 it will return the nearest snap point (or the current position if we are already
- on a snap point.
- Returns the nearest snap position or NaN if no such point could be found.
- */
-qreal QScrollerPrivate::nextSnapPos(qreal p, int dir, Qt::Orientation orientation)
-{
- qreal bestSnapPos = Q_QNAN;
- qreal bestSnapPosDist = Q_INFINITY;
-
- qreal minPos;
- qreal maxPos;
-
- if (orientation == Qt::Horizontal) {
- minPos = contentPosRange.left();
- maxPos = contentPosRange.right();
- } else {
- minPos = contentPosRange.top();
- maxPos = contentPosRange.bottom();
- }
-
- if (orientation == Qt::Horizontal) {
- // the snap points in the list
- foreach (qreal snapPos, snapPositionsX) {
- qreal snapPosDist = snapPos - p;
- if ((dir > 0 && snapPosDist < 0) ||
- (dir < 0 && snapPosDist > 0))
- continue; // wrong direction
- if (snapPos < minPos || snapPos > maxPos )
- continue; // invalid
-
- if (qIsNaN(bestSnapPos) ||
- qAbs(snapPosDist) < bestSnapPosDist ) {
- bestSnapPos = snapPos;
- bestSnapPosDist = qAbs(snapPosDist);
- }
- }
-
- // the snap point interval
- if (snapIntervalX > 0.0) {
- qreal first = minPos + snapFirstX;
- qreal snapPos;
- if (dir > 0)
- snapPos = qCeil((p - first) / snapIntervalX) * snapIntervalX + first;
- else if (dir < 0)
- snapPos = qFloor((p - first) / snapIntervalX) * snapIntervalX + first;
- else if (p <= first)
- snapPos = first;
- else
- {
- qreal last = qFloor((maxPos - first) / snapIntervalX) * snapIntervalX + first;
- if (p >= last)
- snapPos = last;
- else
- snapPos = qRound((p - first) / snapIntervalX) * snapIntervalX + first;
- }
-
- if (snapPos >= first && snapPos <= maxPos ) {
- qreal snapPosDist = snapPos - p;
-
- if (qIsNaN(bestSnapPos) ||
- qAbs(snapPosDist) < bestSnapPosDist ) {
- bestSnapPos = snapPos;
- bestSnapPosDist = qAbs(snapPosDist);
- }
- }
- }
-
- } else { // (orientation == Qt::Vertical)
- // the snap points in the list
- foreach (qreal snapPos, snapPositionsY) {
- qreal snapPosDist = snapPos - p;
- if ((dir > 0 && snapPosDist < 0) ||
- (dir < 0 && snapPosDist > 0))
- continue; // wrong direction
- if (snapPos < minPos || snapPos > maxPos )
- continue; // invalid
-
- if (qIsNaN(bestSnapPos) ||
- qAbs(snapPosDist) < bestSnapPosDist) {
- bestSnapPos = snapPos;
- bestSnapPosDist = qAbs(snapPosDist);
- }
- }
-
- // the snap point interval
- if (snapIntervalY > 0.0) {
- qreal first = minPos + snapFirstY;
- qreal snapPos;
- if (dir > 0)
- snapPos = qCeil((p - first) / snapIntervalY) * snapIntervalY + first;
- else if (dir < 0)
- snapPos = qFloor((p - first) / snapIntervalY) * snapIntervalY + first;
- else if (p <= first)
- snapPos = first;
- else
- {
- qreal last = qFloor((maxPos - first) / snapIntervalY) * snapIntervalY + first;
- if (p >= last)
- snapPos = last;
- else
- snapPos = qRound((p - first) / snapIntervalY) * snapIntervalY + first;
- }
-
- if (snapPos >= first && snapPos <= maxPos ) {
- qreal snapPosDist = snapPos - p;
-
- if (qIsNaN(bestSnapPos) ||
- qAbs(snapPosDist) < bestSnapPosDist) {
- bestSnapPos = snapPos;
- bestSnapPosDist = qAbs(snapPosDist);
- }
- }
- }
- }
-
- return bestSnapPos;
-}
-
-/*!
- \enum QScroller::State
-
- This enum contains the different QScroller states.
-
- \value Inactive The scroller is not scrolling and nothing is pressed.
- \value Pressed A touch event was received or the mouse button was pressed but the scroll area is currently not dragged.
- \value Dragging The scroll area is currently following the touch point or mouse.
- \value Scrolling The scroll area is moving on it's own.
-*/
-
-/*!
- \enum QScroller::ScrollerGestureType
-
- This enum contains the different gesture types that are supported by the QScroller gesture recognizer.
-
- \value TouchGesture The gesture recognizer will only trigger on touch
- events. Specifically it will react on single touch points when using a
- touch screen and dual touch points when using a touchpad.
- \value LeftMouseButtonGesture The gesture recognizer will only trigger on left mouse button events.
- \value MiddleMouseButtonGesture The gesture recognizer will only trigger on middle mouse button events.
- \value RightMouseButtonGesture The gesture recognizer will only trigger on right mouse button events.
-*/
-
-/*!
- \enum QScroller::Input
-
- This enum contains an input device agnostic view of input events that are relevant for QScroller.
-
- \value InputPress The user pressed the input device (e.g. QEvent::MouseButtonPress,
- QEvent::GraphicsSceneMousePress, QEvent::TouchBegin)
-
- \value InputMove The user moved the input device (e.g. QEvent::MouseMove,
- QEvent::GraphicsSceneMouseMove, QEvent::TouchUpdate)
-
- \value InputRelease The user released the input device (e.g. QEvent::MouseButtonRelease,
- QEvent::GraphicsSceneMouseRelease, QEvent::TouchEnd)
-
-*/
-
-QT_END_NAMESPACE
diff --git a/src/gui/util/qscroller.h b/src/gui/util/qscroller.h
deleted file mode 100644
index 1599c7d..0000000
--- a/src/gui/util/qscroller.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 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 QSCROLLER_H
-#define QSCROLLER_H
-
-#include <QtCore/QObject>
-#include <QtCore/QPointF>
-#include <QtGui/QScrollerProperties>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QWidget;
-class QScrollerPrivate;
-class QScrollerProperties;
-#ifndef QT_NO_GESTURES
-class QFlickGestureRecognizer;
-class QMouseFlickGestureRecognizer;
-#endif
-
-class Q_GUI_EXPORT QScroller : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(State state READ state NOTIFY stateChanged)
- Q_PROPERTY(QScrollerProperties scrollerProperties READ scrollerProperties WRITE setScrollerProperties NOTIFY scrollerPropertiesChanged)
- Q_ENUMS(State)
-
-public:
- enum State
- {
- Inactive,
- Pressed,
- Dragging,
- Scrolling
- };
-
- enum ScrollerGestureType
- {
- TouchGesture,
- LeftMouseButtonGesture,
- RightMouseButtonGesture,
- MiddleMouseButtonGesture
- };
-
- enum Input
- {
- InputPress = 1,
- InputMove,
- InputRelease
- };
-
- static bool hasScroller(QObject *target);
-
- static QScroller *scroller(QObject *target);
- static const QScroller *scroller(const QObject *target);
-
-#ifndef QT_NO_GESTURES
- static Qt::GestureType grabGesture(QObject *target, ScrollerGestureType gestureType = TouchGesture);
- static Qt::GestureType grabbedGesture(QObject *target);
- static void ungrabGesture(QObject *target);
-#endif
-
- static QList<QScroller *> activeScrollers();
-
- QObject *target() const;
-
- State state() const;
-
- bool handleInput(Input input, const QPointF &position, qint64 timestamp = 0);
-
- void stop();
- QPointF velocity() const;
- QPointF finalPosition() const;
- QPointF pixelPerMeter() const;
-
- QScrollerProperties scrollerProperties() const;
-
- void setSnapPositionsX( const QList<qreal> &positions );
- void setSnapPositionsX( qreal first, qreal interval );
- void setSnapPositionsY( const QList<qreal> &positions );
- void setSnapPositionsY( qreal first, qreal interval );
-
-public Q_SLOTS:
- void setScrollerProperties(const QScrollerProperties &prop);
- void scrollTo(const QPointF &pos);
- void scrollTo(const QPointF &pos, int scrollTime);
- void ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin);
- void ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin, int scrollTime);
- void resendPrepareEvent();
-
-Q_SIGNALS:
- void stateChanged(QScroller::State newstate);
- void scrollerPropertiesChanged(const QScrollerProperties &);
-
-private:
- QScrollerPrivate *d_ptr;
-
- QScroller(QObject *target);
- virtual ~QScroller();
-
- Q_DISABLE_COPY(QScroller)
- Q_DECLARE_PRIVATE(QScroller)
-
-#ifndef QT_NO_GESTURES
- friend class QFlickGestureRecognizer;
-#endif
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSCROLLER_H
diff --git a/src/gui/util/qscroller_mac.mm b/src/gui/util/qscroller_mac.mm
deleted file mode 100644
index 4bf69c1..0000000
--- a/src/gui/util/qscroller_mac.mm
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 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 <QtCore/qglobal.h>
-
-#ifdef Q_WS_MAC
-
-#import <Cocoa/Cocoa.h>
-
-#include "qscroller_p.h"
-
-QPointF QScrollerPrivate::realDpi(int screen)
-{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- NSArray *nsscreens = [NSScreen screens];
-
- if (screen < 0 || screen >= int([nsscreens count]))
- screen = 0;
-
- NSScreen *nsscreen = [nsscreens objectAtIndex:screen];
- CGDirectDisplayID display = [[[nsscreen deviceDescription] objectForKey:@"NSScreenNumber"] intValue];
-
- CGSize mmsize = CGDisplayScreenSize(display);
- if (mmsize.width > 0 && mmsize.height > 0) {
- return QPointF(CGDisplayPixelsWide(display) / mmsize.width,
- CGDisplayPixelsHigh(display) / mmsize.height) * qreal(25.4);
- } else {
- return QPointF();
- }
- [pool release];
-}
-
-#endif
diff --git a/src/gui/util/qscroller_p.h b/src/gui/util/qscroller_p.h
deleted file mode 100644
index c119615..0000000
--- a/src/gui/util/qscroller_p.h
+++ /dev/null
@@ -1,209 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 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 QSCROLLER_P_H
-#define QSCROLLER_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.
-//
-
-#include <QObject>
-#include <QPointer>
-#include <QQueue>
-#include <QSet>
-#include <QEasingCurve>
-#include <QElapsedTimer>
-#include <QSizeF>
-#include <QPointF>
-#include <QRectF>
-#include <qscroller.h>
-#include <qscrollerproperties.h>
-#include <private/qscrollerproperties_p.h>
-#include <QAbstractAnimation>
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_GESTURES
-class QFlickGestureRecognizer;
-#endif
-
-#ifndef QT_NO_ANIMATION
-class QScrollTimer;
-#endif
-class QScrollerPrivate : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PUBLIC(QScroller)
-
-public:
- QScrollerPrivate(QScroller *q, QObject *target);
- void init();
-
- void sendEvent(QObject *o, QEvent *e);
-
- void setState(QScroller::State s);
-
- enum ScrollType {
- ScrollTypeFlick = 0,
- ScrollTypeScrollTo,
- ScrollTypeOvershoot
- };
-
- struct ScrollSegment {
- qint64 startTime;
- qint64 deltaTime;
- qreal startPos;
- qreal deltaPos;
- QEasingCurve curve;
- qreal stopProgress; // whatever is..
- qreal stopPos; // ..reached first
- ScrollType type;
- };
-
- bool pressWhileInactive(const QPointF &position, qint64 timestamp);
- bool moveWhilePressed(const QPointF &position, qint64 timestamp);
- bool releaseWhilePressed(const QPointF &position, qint64 timestamp);
- bool moveWhileDragging(const QPointF &position, qint64 timestamp);
- bool releaseWhileDragging(const QPointF &position, qint64 timestamp);
- bool pressWhileScrolling(const QPointF &position, qint64 timestamp);
-
- void timerTick();
- void timerEventWhileDragging();
- void timerEventWhileScrolling();
-
- bool prepareScrolling(const QPointF &position);
- void handleDrag(const QPointF &position, qint64 timestamp);
-
- QPointF realDpi(int screen);
- QPointF dpi() const;
- void setDpi(const QPointF &dpi);
- void setDpiFromWidget(QWidget *widget);
-
- void updateVelocity(const QPointF &deltaPixelRaw, qint64 deltaTime);
- void pushSegment(ScrollType type, qreal deltaTime, qreal stopProgress, qreal startPos, qreal deltaPos, qreal stopPos, QEasingCurve::Type curve, Qt::Orientation orientation);
- void recalcScrollingSegments(bool forceRecalc = false);
- qreal scrollingSegmentsEndPos(Qt::Orientation orientation) const;
- bool scrollingSegmentsValid(Qt::Orientation orientation);
- void createScrollToSegments(qreal v, qreal deltaTime, qreal endPos, Qt::Orientation orientation, ScrollType type);
- void createScrollingSegments(qreal v, qreal startPos, qreal ppm, Qt::Orientation orientation);
-
- void setContentPositionHelperDragging(const QPointF &deltaPos);
- void setContentPositionHelperScrolling();
-
- qreal nextSnapPos(qreal p, int dir, Qt::Orientation orientation);
- static qreal nextSegmentPosition(QQueue<ScrollSegment> &segments, qint64 now, qreal oldPos);
-
- inline int frameRateSkip() const { return properties.d.data()->frameRate; }
-
- static const char *stateName(QScroller::State state);
- static const char *inputName(QScroller::Input input);
-
-public slots:
- void targetDestroyed();
-
-public:
- // non static
- QObject *target;
- QScrollerProperties properties;
-#ifndef QT_NO_GESTURES
- QFlickGestureRecognizer *recognizer;
- Qt::GestureType recognizerType;
-#endif
-
- // scroller state:
-
- // QPointer<QObject> scrollTarget;
- QSizeF viewportSize;
- QRectF contentPosRange;
- QPointF contentPosition;
- QPointF overshootPosition; // the number of pixels we are overshooting (before overshootDragResistanceFactor)
-
- // state
-
- bool enabled;
- QScroller::State state;
- bool firstScroll; // true if we haven't already send a scroll event
-
- QPointF oldVelocity; // the release velocity of the last drag
-
- QPointF pressPosition;
- QPointF lastPosition;
- qint64 pressTimestamp;
- qint64 lastTimestamp;
-
- QPointF dragDistance; // the distance we should move during the next drag timer event
-
- QQueue<ScrollSegment> xSegments;
- QQueue<ScrollSegment> ySegments;
-
- // snap positions
- QList<qreal> snapPositionsX;
- qreal snapFirstX;
- qreal snapIntervalX;
- QList<qreal> snapPositionsY;
- qreal snapFirstY;
- qreal snapIntervalY;
-
- QPointF pixelPerMeter;
-
- QElapsedTimer monotonicTimer;
-
- QPointF releaseVelocity; // the starting velocity of the scrolling state
-#ifndef QT_NO_ANIMATION
- QScrollTimer *scrollTimer;
-#endif
-
- QScroller *q_ptr;
-};
-
-
-QT_END_NAMESPACE
-
-#endif // QSCROLLER_P_H
-
diff --git a/src/gui/util/qscrollerproperties.cpp b/src/gui/util/qscrollerproperties.cpp
deleted file mode 100644
index 85e2e82..0000000
--- a/src/gui/util/qscrollerproperties.cpp
+++ /dev/null
@@ -1,393 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 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 <QPointer>
-#include <QObject>
-#include <QtCore/qmath.h>
-#ifdef Q_WS_WIN
-# include <QLibrary>
-#endif
-
-#include "qscrollerproperties.h"
-#include "private/qscrollerproperties_p.h"
-
-QT_BEGIN_NAMESPACE
-
-static QScrollerPropertiesPrivate *userDefaults = 0;
-static QScrollerPropertiesPrivate *systemDefaults = 0;
-
-QScrollerPropertiesPrivate *QScrollerPropertiesPrivate::defaults()
-{
- if (!systemDefaults) {
- QScrollerPropertiesPrivate spp;
- spp.mousePressEventDelay = qreal(0.25);
- spp.dragStartDistance = qreal(5.0 / 1000);
- spp.dragVelocitySmoothingFactor = qreal(0.8);
- spp.axisLockThreshold = qreal(0);
- spp.scrollingCurve.setType(QEasingCurve::OutQuad);
- spp.decelerationFactor = qreal(0.125);
- spp.minimumVelocity = qreal(50.0 / 1000);
- spp.maximumVelocity = qreal(500.0 / 1000);
- spp.maximumClickThroughVelocity = qreal(66.5 / 1000);
- spp.acceleratingFlickMaximumTime = qreal(1.25);
- spp.acceleratingFlickSpeedupFactor = qreal(3.0);
- spp.snapPositionRatio = qreal(0.5);
- spp.snapTime = qreal(0.3);
- spp.overshootDragResistanceFactor = qreal(0.5);
- spp.overshootDragDistanceFactor = qreal(1);
- spp.overshootScrollDistanceFactor = qreal(0.5);
- spp.overshootScrollTime = qreal(0.7);
-# ifdef Q_WS_WIN
- if (QLibrary::resolve(QLatin1String("UxTheme"), "BeginPanningFeedback"))
- spp.overshootScrollTime = qreal(0.35);
-# endif
- spp.hOvershootPolicy = QScrollerProperties::OvershootWhenScrollable;
- spp.vOvershootPolicy = QScrollerProperties::OvershootWhenScrollable;
- spp.frameRate = QScrollerProperties::Standard;
-
- systemDefaults = new QScrollerPropertiesPrivate(spp);
- }
- return new QScrollerPropertiesPrivate(userDefaults ? *userDefaults : *systemDefaults);
-}
-
-/*!
- \class QScrollerProperties
- \brief The QScrollerProperties class stores the settings for a QScroller.
- \since 4.8
-
- The QScrollerProperties class stores the parameters used by QScroller.
-
- The default settings are platform dependent so that Qt emulates the
- platform behaviour for kinetic scrolling.
-
- As a convention the QScrollerProperties are in physical units (meter,
- seconds) and are converted by QScroller using the current DPI.
-
- \sa QScroller
-*/
-
-/*!
- Constructs new scroller properties.
-*/
-QScrollerProperties::QScrollerProperties()
- : d(QScrollerPropertiesPrivate::defaults())
-{
-}
-
-/*!
- Constructs a copy of \a sp.
-*/
-QScrollerProperties::QScrollerProperties(const QScrollerProperties &sp)
- : d(new QScrollerPropertiesPrivate(*sp.d))
-{
-}
-
-/*!
- Assigns \a sp to these scroller properties and returns a reference to these scroller properties.
-*/
-QScrollerProperties &QScrollerProperties::operator=(const QScrollerProperties &sp)
-{
- *d.data() = *sp.d.data();
- return *this;
-}
-
-/*!
- Destroys the scroller properties.
-*/
-QScrollerProperties::~QScrollerProperties()
-{
-}
-
-/*!
- Returns true if these scroller properties are equal to \a sp; otherwise returns false.
-*/
-bool QScrollerProperties::operator==(const QScrollerProperties &sp) const
-{
- return *d.data() == *sp.d.data();
-}
-
-/*!
- Returns true if these scroller properties are different from \a sp; otherwise returns false.
-*/
-bool QScrollerProperties::operator!=(const QScrollerProperties &sp) const
-{
- return !(*d.data() == *sp.d.data());
-}
-
-bool QScrollerPropertiesPrivate::operator==(const QScrollerPropertiesPrivate &p) const
-{
- bool same = true;
- same &= (mousePressEventDelay == p.mousePressEventDelay);
- same &= (dragStartDistance == p.dragStartDistance);
- same &= (dragVelocitySmoothingFactor == p.dragVelocitySmoothingFactor);
- same &= (axisLockThreshold == p.axisLockThreshold);
- same &= (scrollingCurve == p.scrollingCurve);
- same &= (decelerationFactor == p.decelerationFactor);
- same &= (minimumVelocity == p.minimumVelocity);
- same &= (maximumVelocity == p.maximumVelocity);
- same &= (maximumClickThroughVelocity == p.maximumClickThroughVelocity);
- same &= (acceleratingFlickMaximumTime == p.acceleratingFlickMaximumTime);
- same &= (acceleratingFlickSpeedupFactor == p.acceleratingFlickSpeedupFactor);
- same &= (snapPositionRatio == p.snapPositionRatio);
- same &= (snapTime == p.snapTime);
- same &= (overshootDragResistanceFactor == p.overshootDragResistanceFactor);
- same &= (overshootDragDistanceFactor == p.overshootDragDistanceFactor);
- same &= (overshootScrollDistanceFactor == p.overshootScrollDistanceFactor);
- same &= (overshootScrollTime == p.overshootScrollTime);
- same &= (hOvershootPolicy == p.hOvershootPolicy);
- same &= (vOvershootPolicy == p.vOvershootPolicy);
- same &= (frameRate == p.frameRate);
- return same;
-}
-
-/*!
- Sets the scroller properties for all new QScrollerProperties objects to \a sp.
-
- Use this function to override the platform default properties returned by the default
- constructor. If you only want to change the scroller properties of a single scroller, use
- QScroller::setScrollerProperties()
-
- \note Calling this function will not change the content of already existing
- QScrollerProperties objects.
-
- \sa unsetDefaultScrollerProperties()
-*/
-void QScrollerProperties::setDefaultScrollerProperties(const QScrollerProperties &sp)
-{
- if (!userDefaults)
- userDefaults = new QScrollerPropertiesPrivate(*sp.d);
- else
- *userDefaults = *sp.d;
-}
-
-/*!
- Sets the scroller properties returned by the default constructor back to the platform default
- properties.
-
- \sa setDefaultScrollerProperties()
-*/
-void QScrollerProperties::unsetDefaultScrollerProperties()
-{
- delete userDefaults;
- userDefaults = 0;
-}
-
-/*!
- Query the \a metric value of the scroller properties.
-
- \sa setScrollMetric(), ScrollMetric
-*/
-QVariant QScrollerProperties::scrollMetric(ScrollMetric metric) const
-{
- switch (metric) {
- case MousePressEventDelay: return d->mousePressEventDelay;
- case DragStartDistance: return d->dragStartDistance;
- case DragVelocitySmoothingFactor: return d->dragVelocitySmoothingFactor;
- case AxisLockThreshold: return d->axisLockThreshold;
- case ScrollingCurve: return d->scrollingCurve;
- case DecelerationFactor: return d->decelerationFactor;
- case MinimumVelocity: return d->minimumVelocity;
- case MaximumVelocity: return d->maximumVelocity;
- case MaximumClickThroughVelocity: return d->maximumClickThroughVelocity;
- case AcceleratingFlickMaximumTime: return d->acceleratingFlickMaximumTime;
- case AcceleratingFlickSpeedupFactor:return d->acceleratingFlickSpeedupFactor;
- case SnapPositionRatio: return d->snapPositionRatio;
- case SnapTime: return d->snapTime;
- case OvershootDragResistanceFactor: return d->overshootDragResistanceFactor;
- case OvershootDragDistanceFactor: return d->overshootDragDistanceFactor;
- case OvershootScrollDistanceFactor: return d->overshootScrollDistanceFactor;
- case OvershootScrollTime: return d->overshootScrollTime;
- case HorizontalOvershootPolicy: return QVariant::fromValue(d->hOvershootPolicy);
- case VerticalOvershootPolicy: return QVariant::fromValue(d->vOvershootPolicy);
- case FrameRate: return QVariant::fromValue(d->frameRate);
- case ScrollMetricCount: break;
- }
- return QVariant();
-}
-
-/*!
- Set a specific value of the \a metric ScrollerMetric to \a value.
-
- \sa scrollMetric(), ScrollMetric
-*/
-void QScrollerProperties::setScrollMetric(ScrollMetric metric, const QVariant &value)
-{
- switch (metric) {
- case MousePressEventDelay: d->mousePressEventDelay = value.toReal(); break;
- case DragStartDistance: d->dragStartDistance = value.toReal(); break;
- case DragVelocitySmoothingFactor: d->dragVelocitySmoothingFactor = qBound(qreal(0), value.toReal(), qreal(1)); break;
- case AxisLockThreshold: d->axisLockThreshold = qBound(qreal(0), value.toReal(), qreal(1)); break;
- case ScrollingCurve: d->scrollingCurve = value.toEasingCurve(); break;
- case DecelerationFactor: d->decelerationFactor = value.toReal(); break;
- case MinimumVelocity: d->minimumVelocity = value.toReal(); break;
- case MaximumVelocity: d->maximumVelocity = value.toReal(); break;
- case MaximumClickThroughVelocity: d->maximumClickThroughVelocity = value.toReal(); break;
- case AcceleratingFlickMaximumTime: d->acceleratingFlickMaximumTime = value.toReal(); break;
- case AcceleratingFlickSpeedupFactor:d->acceleratingFlickSpeedupFactor = value.toReal(); break;
- case SnapPositionRatio: d->snapPositionRatio = qBound(qreal(0), value.toReal(), qreal(1)); break;
- case SnapTime: d->snapTime = value.toReal(); break;
- case OvershootDragResistanceFactor: d->overshootDragResistanceFactor = value.toReal(); break;
- case OvershootDragDistanceFactor: d->overshootDragDistanceFactor = qBound(qreal(0), value.toReal(), qreal(1)); break;
- case OvershootScrollDistanceFactor: d->overshootScrollDistanceFactor = qBound(qreal(0), value.toReal(), qreal(1)); break;
- case OvershootScrollTime: d->overshootScrollTime = value.toReal(); break;
- case HorizontalOvershootPolicy: d->hOvershootPolicy = value.value<QScrollerProperties::OvershootPolicy>(); break;
- case VerticalOvershootPolicy: d->vOvershootPolicy = value.value<QScrollerProperties::OvershootPolicy>(); break;
- case FrameRate: d->frameRate = value.value<QScrollerProperties::FrameRates>(); break;
- case ScrollMetricCount: break;
- }
-}
-
-/*!
- \enum QScrollerProperties::FrameRates
-
- This enum describes the available frame rates used while dragging or scrolling.
-
- \value Fps60 60 frames per second
- \value Fps30 30 frames per second
- \value Fps20 20 frames per second
- \value Standard the default value is 60 frames per second (which corresponds to QAbstractAnimation).
-*/
-
-/*!
- \enum QScrollerProperties::OvershootPolicy
-
- This enum describes the various modes of overshooting.
-
- \value OvershootWhenScrollable Overshooting is possible when the content is scrollable. This is the
- default.
-
- \value OvershootAlwaysOff Overshooting is never enabled, even when the content is scrollable.
-
- \value OvershootAlwaysOn Overshooting is always enabled, even when the content is not
- scrollable.
-*/
-
-/*!
- \enum QScrollerProperties::ScrollMetric
-
- This enum contains the different scroll metric types. When not indicated otherwise the
- setScrollMetric function expects a QVariant of type qreal.
-
- See the QScroller documentation for further details of the concepts behind the different
- values.
-
- \value MousePressEventDelay This is the time a mouse press event is delayed when starting
- a flick gesture in \c{[s]}. If the gesture is triggered within that time, no mouse press or
- release is sent to the scrolled object. If it triggers after that delay the delayed
- mouse press plus a faked release event at global postion \c{QPoint(-QWIDGETSIZE_MAX,
- -QWIDGETSIZE_MAX)} is sent. If the gesture is canceled, then both the delayed mouse
- press plus the real release event are delivered.
-
- \value DragStartDistance This is the minimum distance the touch or mouse point needs to be
- moved before the flick gesture is triggered in \c m.
-
- \value DragVelocitySmoothingFactor A value that describes to which extent new drag velocities are
- included in the final scrolling velocity. This value should be in the range between \c 0 and
- \c 1. The lower the value, the more smoothing is applied to the dragging velocity.
-
- \value AxisLockThreshold Restricts the movement to one axis if the movement is inside an angle
- around the axis. The threshold must be in the range \c 0 to \c 1.
-
- \value ScrollingCurve The QEasingCurve used when decelerating the scrolling velocity after an
- user initiated flick. Please note that this is the easing curve for the positions, \bold{not}
- the velocity: the default is QEasingCurve::OutQuad, which results in a linear decrease in
- velocity (1st derivative) and a constant deceleration (2nd derivative).
-
- \value DecelerationFactor This factor influences how long it takes the scroller to decelerate
- to 0 velocity. The actual value depends on the chosen ScrollingCurve. For most
- types the value should be in the range from \c 0.1 to \c 2.0
-
- \value MinimumVelocity The minimum velocity that is needed after ending the touch or releasing
- the mouse to start scrolling in \c{m/s}.
-
- \value MaximumVelocity This is the maximum velocity that can be reached in \c{m/s}.
-
- \value MaximumClickThroughVelocity This is the maximum allowed scroll speed for a click-through
- in \c{m/s}. This means that a click on a currently (slowly) scrolling object will not only stop
- the scrolling but the click event will also be delivered to the UI control. This is
- useful when using exponential-type scrolling curves.
-
- \value AcceleratingFlickMaximumTime This is the maximum time in \c seconds that a flick gesture
- can take to be recognized as an accelerating flick. If set to zero no such gesture is
- detected. An "accelerating flick" is a flick gesture executed on an already scrolling object.
- In such cases the scrolling speed is multiplied by AcceleratingFlickSpeedupFactor in order to
- accelerate it.
-
- \value AcceleratingFlickSpeedupFactor The current speed is multiplied by this number if an
- accelerating flick is detected. Should be \c{>= 1}.
-
- \value SnapPositionRatio This is the distance that the user must drag the area beween two snap
- points in order to snap it to the next position. \c{0.33} means that the scroll must only
- reach one third of the distance between two snap points to snap to the next one. The ratio must
- be between \c 0 and \c 1.
-
- \value SnapTime This is the time factor for the scrolling curve. A lower value means that the
- scrolling will take longer. The scrolling distance is independet of this value.
-
- \value OvershootDragResistanceFactor This value is the factor between the mouse dragging and
- the actual scroll area movement (during overshoot). The factor must be between \c 0 and \c 1.
-
- \value OvershootDragDistanceFactor This is the maximum distance for overshoot movements while
- dragging. The actual overshoot distance is calculated by multiplying this value with the
- viewport size of the scrolled object. The factor must be between \c 0 and \c 1.
-
- \value OvershootScrollDistanceFactor This is the maximum distance for overshoot movements while
- scrolling. The actual overshoot distance is calculated by multiplying this value with the
- viewport size of the scrolled object. The factor must be between \c 0 and \c 1.
-
- \value OvershootScrollTime This is the time in \c seconds that is used to play the
- complete overshoot animation.
-
- \value HorizontalOvershootPolicy This is the horizontal overshooting policy (see OvershootPolicy).
-
- \value VerticalOvershootPolicy This is the horizontal overshooting policy (see OvershootPolicy).
-
- \value FrameRate This is the frame rate which should be used while dragging or scrolling.
- QScroller uses a QAbstractAnimation timer internally to sync all scrolling operations to other
- animations that might be active at the same time. If the standard value of 60 frames per
- second is too fast, it can be lowered with this setting,
- while still being in-sync with QAbstractAnimation. Please note that only the values of the
- FrameRates enum are allowed here.
-
- \value ScrollMetricCount This is always the last entry.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/gui/util/qscrollerproperties.h b/src/gui/util/qscrollerproperties.h
deleted file mode 100644
index 75d8932..0000000
--- a/src/gui/util/qscrollerproperties.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 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 QSCROLLERPROPERTIES_H
-#define QSCROLLERPROPERTIES_H
-
-#include <QtCore/QScopedPointer>
-#include <QtCore/QMetaType>
-#include <QtCore/QVariant>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QScroller;
-class QScrollerPrivate;
-class QScrollerPropertiesPrivate;
-
-class Q_GUI_EXPORT QScrollerProperties
-{
-public:
- QScrollerProperties();
- QScrollerProperties(const QScrollerProperties &sp);
- QScrollerProperties &operator=(const QScrollerProperties &sp);
- virtual ~QScrollerProperties();
-
- bool operator==(const QScrollerProperties &sp) const;
- bool operator!=(const QScrollerProperties &sp) const;
-
- static void setDefaultScrollerProperties(const QScrollerProperties &sp);
- static void unsetDefaultScrollerProperties();
-
- enum OvershootPolicy
- {
- OvershootWhenScrollable,
- OvershootAlwaysOff,
- OvershootAlwaysOn
- };
-
- enum FrameRates {
- Standard,
- Fps60,
- Fps30,
- Fps20
- };
-
- enum ScrollMetric
- {
- MousePressEventDelay, // qreal [s]
- DragStartDistance, // qreal [m]
- DragVelocitySmoothingFactor, // qreal [0..1/s] (complex calculation involving time) v = v_new* DASF + v_old * (1-DASF)
- AxisLockThreshold, // qreal [0..1] atan(|min(dx,dy)|/|max(dx,dy)|)
-
- ScrollingCurve, // QEasingCurve
- DecelerationFactor, // slope of the curve
-
- MinimumVelocity, // qreal [m/s]
- MaximumVelocity, // qreal [m/s]
- MaximumClickThroughVelocity, // qreal [m/s]
-
- AcceleratingFlickMaximumTime, // qreal [s]
- AcceleratingFlickSpeedupFactor, // qreal [1..]
-
- SnapPositionRatio, // qreal [0..1]
- SnapTime, // qreal [s]
-
- OvershootDragResistanceFactor, // qreal [0..1]
- OvershootDragDistanceFactor, // qreal [0..1]
- OvershootScrollDistanceFactor, // qreal [0..1]
- OvershootScrollTime, // qreal [s]
-
- HorizontalOvershootPolicy, // enum OvershootPolicy
- VerticalOvershootPolicy, // enum OvershootPolicy
- FrameRate, // enum FrameRates
-
- ScrollMetricCount
- };
-
- QVariant scrollMetric(ScrollMetric metric) const;
- void setScrollMetric(ScrollMetric metric, const QVariant &value);
-
-protected:
- QScopedPointer<QScrollerPropertiesPrivate> d;
-
-private:
- QScrollerProperties(QScrollerPropertiesPrivate &dd);
-
- friend class QScrollerPropertiesPrivate;
- friend class QScroller;
- friend class QScrollerPrivate;
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QScrollerProperties::OvershootPolicy)
-Q_DECLARE_METATYPE(QScrollerProperties::FrameRates)
-
-QT_END_HEADER
-
-#endif // QSCROLLERPROPERTIES_H
diff --git a/src/gui/util/qscrollerproperties_p.h b/src/gui/util/qscrollerproperties_p.h
deleted file mode 100644
index 76d8b0a..0000000
--- a/src/gui/util/qscrollerproperties_p.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 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 QSCROLLERPROPERTIES_P_H
-#define QSCROLLERPROPERTIES_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.
-//
-
-#include <QPointF>
-#include <QEasingCurve>
-#include <qscrollerproperties.h>
-
-QT_BEGIN_NAMESPACE
-
-class QScrollerPropertiesPrivate
-{
-public:
- static QScrollerPropertiesPrivate *defaults();
-
- bool operator==(const QScrollerPropertiesPrivate &) const;
-
- qreal mousePressEventDelay;
- qreal dragStartDistance;
- qreal dragVelocitySmoothingFactor;
- qreal axisLockThreshold;
- QEasingCurve scrollingCurve;
- qreal decelerationFactor;
- qreal minimumVelocity;
- qreal maximumVelocity;
- qreal maximumClickThroughVelocity;
- qreal acceleratingFlickMaximumTime;
- qreal acceleratingFlickSpeedupFactor;
- qreal snapPositionRatio;
- qreal snapTime;
- qreal overshootDragResistanceFactor;
- qreal overshootDragDistanceFactor;
- qreal overshootScrollDistanceFactor;
- qreal overshootScrollTime;
- QScrollerProperties::OvershootPolicy hOvershootPolicy;
- QScrollerProperties::OvershootPolicy vOvershootPolicy;
- QScrollerProperties::FrameRates frameRate;
-};
-
-QT_END_NAMESPACE
-
-#endif // QSCROLLERPROPERTIES_P_H
-
diff --git a/src/gui/util/util.pri b/src/gui/util/util.pri
index 2814a2d..f125f82 100644
--- a/src/gui/util/util.pri
+++ b/src/gui/util/util.pri
@@ -6,11 +6,6 @@ HEADERS += \
util/qcompleter_p.h \
util/qdesktopservices.h \
util/qsystemtrayicon_p.h \
- util/qscroller.h \
- util/qscroller_p.h \
- util/qscrollerproperties.h \
- util/qscrollerproperties_p.h \
- util/qflickgesture_p.h \
util/qundogroup.h \
util/qundostack.h \
util/qundostack_p.h \
@@ -20,9 +15,6 @@ SOURCES += \
util/qsystemtrayicon.cpp \
util/qcompleter.cpp \
util/qdesktopservices.cpp \
- util/qscroller.cpp \
- util/qscrollerproperties.cpp \
- util/qflickgesture.cpp \
util/qundogroup.cpp \
util/qundostack.cpp \
util/qundoview.cpp
@@ -65,7 +57,3 @@ symbian {
DEFINES += USE_SCHEMEHANDLER
}
}
-
-macx {
- OBJECTIVE_SOURCES += util/qscroller_mac.mm
-}
diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp
index dabfec0..2503b99 100644
--- a/src/gui/widgets/qabstractscrollarea.cpp
+++ b/src/gui/widgets/qabstractscrollarea.cpp
@@ -53,8 +53,6 @@
#include "qpainter.h"
#include "qmargins.h"
-#include <QDebug>
-
#include "qabstractscrollarea_p.h"
#include <qwidget.h>
@@ -64,10 +62,6 @@
#include <private/qt_mac_p.h>
#include <private/qt_cocoa_helpers_mac_p.h>
#endif
-#ifdef Q_WS_WIN
-# include <qlibrary.h>
-# include <windows.h>
-#endif
QT_BEGIN_NAMESPACE
@@ -301,14 +295,9 @@ void QAbstractScrollAreaPrivate::init()
q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
layoutChildren();
#ifndef Q_WS_MAC
-# ifndef QT_NO_GESTURES
+#ifndef QT_NO_GESTURES
viewport->grabGesture(Qt::PanGesture);
-# endif
#endif
-#ifdef Q_WS_MAEMO_5
-# ifndef QT_NO_GESTURES
- // viewport->grabGesture(Qt::TouchFlickGesture);
-# endif
#endif
}
@@ -563,11 +552,6 @@ void QAbstractScrollArea::setViewport(QWidget *widget)
d->viewport->grabGesture(Qt::PanGesture);
#endif
#endif
-#ifdef Q_WS_MAEMO_5
-#ifndef QT_NO_GESTURES
-// d->viewport->grabGesture(Qt::TouchFlickGesture);
-#endif
-#endif
d->layoutChildren();
if (isVisible())
d->viewport->show();
@@ -1002,66 +986,6 @@ bool QAbstractScrollArea::event(QEvent *e)
return false;
}
#endif // QT_NO_GESTURES
- case QEvent::ScrollPrepare:
- {
- QScrollPrepareEvent *se = static_cast<QScrollPrepareEvent *>(e);
- if (d->canStartScrollingAt(se->startPos().toPoint())) {
- QScrollBar *hBar = horizontalScrollBar();
- QScrollBar *vBar = verticalScrollBar();
-
- se->setViewportSize(QSizeF(viewport()->size()));
- se->setContentPosRange(QRectF(0, 0, hBar->maximum(), vBar->maximum()));
- se->setContentPos(QPointF(hBar->value(), vBar->value()));
- se->accept();
- return true;
- }
- return false;
- }
- case QEvent::Scroll:
- {
- QScrollEvent *se = static_cast<QScrollEvent *>(e);
-
- QScrollBar *hBar = horizontalScrollBar();
- QScrollBar *vBar = verticalScrollBar();
- hBar->setValue(se->contentPos().x());
- vBar->setValue(se->contentPos().y());
-
-#ifdef Q_WS_WIN
- typedef BOOL (*PtrBeginPanningFeedback)(HWND);
- typedef BOOL (*PtrUpdatePanningFeedback)(HWND, LONG, LONG, BOOL);
- typedef BOOL (*PtrEndPanningFeedback)(HWND, BOOL);
-
- static PtrBeginPanningFeedback ptrBeginPanningFeedback = 0;
- static PtrUpdatePanningFeedback ptrUpdatePanningFeedback = 0;
- static PtrEndPanningFeedback ptrEndPanningFeedback = 0;
-
- if (!ptrBeginPanningFeedback)
- ptrBeginPanningFeedback = (PtrBeginPanningFeedback) QLibrary::resolve(QLatin1String("UxTheme"), "BeginPanningFeedback");
- if (!ptrUpdatePanningFeedback)
- ptrUpdatePanningFeedback = (PtrUpdatePanningFeedback) QLibrary::resolve(QLatin1String("UxTheme"), "UpdatePanningFeedback");
- if (!ptrEndPanningFeedback)
- ptrEndPanningFeedback = (PtrEndPanningFeedback) QLibrary::resolve(QLatin1String("UxTheme"), "EndPanningFeedback");
-
- if (ptrBeginPanningFeedback && ptrUpdatePanningFeedback && ptrEndPanningFeedback) {
- WId wid = window()->winId();
-
- if (!se->overshootDistance().isNull() && d->overshoot.isNull())
- ptrBeginPanningFeedback(wid);
- if (!se->overshootDistance().isNull())
- ptrUpdatePanningFeedback(wid, -se->overshootDistance().x(), -se->overshootDistance().y(), false);
- if (se->overshootDistance().isNull() && !d->overshoot.isNull())
- ptrEndPanningFeedback(wid, true);
- } else
-#endif
- {
- QPoint delta = d->overshoot - se->overshootDistance().toPoint();
- if (!delta.isNull())
- viewport()->move(viewport()->pos() + delta);
- }
- d->overshoot = se->overshootDistance().toPoint();
-
- return true;
- }
case QEvent::StyleChange:
case QEvent::LayoutDirectionChange:
case QEvent::ApplicationLayoutDirectionChange:
@@ -1123,9 +1047,6 @@ bool QAbstractScrollArea::viewportEvent(QEvent *e)
case QEvent::GestureOverride:
return event(e);
#endif
- case QEvent::ScrollPrepare:
- case QEvent::Scroll:
- return event(e);
default:
break;
}
@@ -1382,32 +1303,6 @@ void QAbstractScrollArea::scrollContentsBy(int, int)
viewport()->update();
}
-bool QAbstractScrollAreaPrivate::canStartScrollingAt( const QPoint &startPos )
-{
- Q_Q(QAbstractScrollArea);
-
-#ifndef QT_NO_GRAPHICSVIEW
- // don't start scrolling when a drag mode has been set.
- // don't start scrolling on a movable item.
- if (QGraphicsView *view = qobject_cast<QGraphicsView *>(q)) {
- if (view->dragMode() != QGraphicsView::NoDrag)
- return false;
-
- QGraphicsItem *childItem = view->itemAt(startPos);
-
- if (childItem && (childItem->flags() & QGraphicsItem::ItemIsMovable))
- return false;
- }
-#endif
-
- // don't start scrolling on a QAbstractSlider
- if (qobject_cast<QAbstractSlider *>(q->viewport()->childAt(startPos))) {
- return false;
- }
-
- return true;
-}
-
void QAbstractScrollAreaPrivate::_q_hslide(int x)
{
Q_Q(QAbstractScrollArea);
diff --git a/src/gui/widgets/qabstractscrollarea_p.h b/src/gui/widgets/qabstractscrollarea_p.h
index 76e1c34..85536e3 100644
--- a/src/gui/widgets/qabstractscrollarea_p.h
+++ b/src/gui/widgets/qabstractscrollarea_p.h
@@ -84,13 +84,11 @@ public:
int left, top, right, bottom; // viewport margin
int xoffset, yoffset;
- QPoint overshoot;
void init();
void layoutChildren();
// ### Fix for 4.4, talk to Bjoern E or Girish.
virtual void scrollBarPolicyChanged(Qt::Orientation, Qt::ScrollBarPolicy) {}
- bool canStartScrollingAt( const QPoint &startPos );
void _q_hslide(int);
void _q_vslide(int);
diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp
index 4fb0f0c..2a15555 100644
--- a/src/gui/widgets/qlinecontrol.cpp
+++ b/src/gui/widgets/qlinecontrol.cpp
@@ -1593,7 +1593,7 @@ void QLineControl::processKeyEvent(QKeyEvent* event)
}
bool unknown = false;
- bool visual = cursorMoveStyle() == QTextCursor::Visual;
+ bool visual = cursorMoveStyle() == Qt::VisualMoveStyle;
if (false) {
}
diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h
index 0655276..9764ba9 100644
--- a/src/gui/widgets/qlinecontrol_p.h
+++ b/src/gui/widgets/qlinecontrol_p.h
@@ -160,8 +160,8 @@ public:
int cursorWidth() const { return m_cursorWidth; }
void setCursorWidth(int value) { m_cursorWidth = value; }
- QTextCursor::MoveStyle cursorMoveStyle() const { return m_textLayout.cursorMoveStyle(); }
- void setCursorMoveStyle(QTextCursor::MoveStyle style) { m_textLayout.setCursorMoveStyle(style); }
+ Qt::CursorMoveStyle cursorMoveStyle() const { return m_textLayout.cursorMoveStyle(); }
+ void setCursorMoveStyle(Qt::CursorMoveStyle style) { m_textLayout.setCursorMoveStyle(style); }
void moveCursor(int pos, bool mark = false);
void cursorForward(bool mark, int steps)
@@ -169,11 +169,11 @@ public:
int c = m_cursor;
if (steps > 0) {
while (steps--)
- c = cursorMoveStyle() == QTextCursor::Visual ? m_textLayout.rightCursorPosition(c)
+ c = cursorMoveStyle() == Qt::VisualMoveStyle ? m_textLayout.rightCursorPosition(c)
: m_textLayout.nextCursorPosition(c);
} else if (steps < 0) {
while (steps++)
- c = cursorMoveStyle() == QTextCursor::Visual ? m_textLayout.leftCursorPosition(c)
+ c = cursorMoveStyle() == Qt::VisualMoveStyle ? m_textLayout.leftCursorPosition(c)
: m_textLayout.previousCursorPosition(c);
}
moveCursor(c, mark);
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index 43c3f52..3c9874e 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -1116,24 +1116,24 @@ void QLineEdit::setDragEnabled(bool b)
\brief the movement style of cursor in this line edit
\since 4.8
- When this property is set to QTextCursor::Visual, the line edit will use visual
+ When this property is set to Qt::VisualMoveStyle, the line edit will use visual
movement style. Pressing the left arrow key will always cause the cursor to move
left, regardless of the text's writing direction. The same behavior applies to
right arrow key.
- When the property is QTextCursor::Logical (the default), within a LTR text block,
+ When the property is Qt::LogicalMoveStyle (the default), within a LTR text block,
increase cursor position when pressing left arrow key, decrease cursor position
when pressing the right arrow key. If the text block is right to left, the opposite
behavior applies.
*/
-QTextCursor::MoveStyle QLineEdit::cursorMoveStyle() const
+Qt::CursorMoveStyle QLineEdit::cursorMoveStyle() const
{
Q_D(const QLineEdit);
return d->control->cursorMoveStyle();
}
-void QLineEdit::setCursorMoveStyle(QTextCursor::MoveStyle style)
+void QLineEdit::setCursorMoveStyle(Qt::CursorMoveStyle style)
{
Q_D(QLineEdit);
d->control->setCursorMoveStyle(style);
diff --git a/src/gui/widgets/qlineedit.h b/src/gui/widgets/qlineedit.h
index 73a736c..e88273f 100644
--- a/src/gui/widgets/qlineedit.h
+++ b/src/gui/widgets/qlineedit.h
@@ -85,6 +85,7 @@ class Q_GUI_EXPORT QLineEdit : public QWidget
Q_PROPERTY(bool redoAvailable READ isRedoAvailable)
Q_PROPERTY(bool acceptableInput READ hasAcceptableInput)
Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
+ Q_PROPERTY(Qt::CursorMoveStyle cursorMoveStyle READ cursorMoveStyle WRITE setCursorMoveStyle)
public:
explicit QLineEdit(QWidget* parent=0);
@@ -159,8 +160,8 @@ public:
void setDragEnabled(bool b);
bool dragEnabled() const;
- void setCursorMoveStyle(QTextCursor::MoveStyle style);
- QTextCursor::MoveStyle cursorMoveStyle() const;
+ void setCursorMoveStyle(Qt::CursorMoveStyle style);
+ Qt::CursorMoveStyle cursorMoveStyle() const;
QString inputMask() const;
void setInputMask(const QString &inputMask);
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index fc0bb85..e5af5c6 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -1908,7 +1908,7 @@ bool QAbstractSocket::waitForReadyRead(int msecs)
if (state() != ConnectedState)
return false;
- } while (qt_timeout_value(msecs, stopWatch.elapsed()) > 0);
+ } while (msecs == -1 || qt_timeout_value(msecs, stopWatch.elapsed()) > 0);
return false;
}
diff --git a/src/opengl/qglfunctions.cpp b/src/opengl/qglfunctions.cpp
index be8219a..9137e0f 100644
--- a/src/opengl/qglfunctions.cpp
+++ b/src/opengl/qglfunctions.cpp
@@ -211,19 +211,24 @@ QGLFunctions::QGLFunctions(const QGLContext *context)
static int qt_gl_resolve_features()
{
#if defined(QT_OPENGL_ES_2)
- return QGLFunctions::Multitexture |
- QGLFunctions::Shaders |
- QGLFunctions::Buffers |
- QGLFunctions::Framebuffers |
- QGLFunctions::BlendColor |
- QGLFunctions::BlendEquation |
- QGLFunctions::BlendEquationSeparate |
- QGLFunctions::BlendFuncSeparate |
- QGLFunctions::BlendSubtract |
- QGLFunctions::CompressedTextures |
- QGLFunctions::Multisample |
- QGLFunctions::StencilSeparate |
- QGLFunctions::NPOTTextures;
+ int features = QGLFunctions::Multitexture |
+ QGLFunctions::Shaders |
+ QGLFunctions::Buffers |
+ QGLFunctions::Framebuffers |
+ QGLFunctions::BlendColor |
+ QGLFunctions::BlendEquation |
+ QGLFunctions::BlendEquationSeparate |
+ QGLFunctions::BlendFuncSeparate |
+ QGLFunctions::BlendSubtract |
+ QGLFunctions::CompressedTextures |
+ QGLFunctions::Multisample |
+ QGLFunctions::StencilSeparate;
+ QGLExtensionMatcher extensions;
+ if (extensions.match("GL_OES_texture_npot"))
+ features |= QGLFunctions::NPOTTextures;
+ if (extensions.match("GL_IMG_texture_npot"))
+ features |= QGLFunctions::NPOTTextures;
+ return features;
#elif defined(QT_OPENGL_ES)
int features = QGLFunctions::Multitexture |
QGLFunctions::Buffers |
@@ -240,6 +245,8 @@ static int qt_gl_resolve_features()
features |= QGLFunctions::BlendSubtract;
if (extensions.match("GL_OES_texture_npot"))
features |= QGLFunctions::NPOTTextures;
+ if (extensions.match("GL_IMG_texture_npot"))
+ features |= QGLFunctions::NPOTTextures;
return features;
#else
int features = 0;
diff --git a/tests/auto/gui.pro b/tests/auto/gui.pro
index 22c5e51..17f56f2 100644
--- a/tests/auto/gui.pro
+++ b/tests/auto/gui.pro
@@ -58,7 +58,7 @@ SUBDIRS=\
qfontdialog \
qfontmetrics \
qformlayout \
- qglyphs \
+ qglyphrun \
qgraphicsanchorlayout \
qgraphicsanchorlayout1 \
qgraphicseffect \
@@ -142,7 +142,6 @@ SUBDIRS=\
qregion \
qscrollarea \
qscrollbar \
- qscroller \
qsharedpointer_and_qwidget \
qshortcut \
qsidebar \
diff --git a/tests/auto/qcolor/tst_qcolor.cpp b/tests/auto/qcolor/tst_qcolor.cpp
index d42c26c..b02537e 100644
--- a/tests/auto/qcolor/tst_qcolor.cpp
+++ b/tests/auto/qcolor/tst_qcolor.cpp
@@ -1506,7 +1506,6 @@ void tst_QColor::setallowX11ColorNames()
for (int i = 0; i < x11RgbTblSize; ++i) {
QString colorName = QLatin1String(x11RgbTbl[i].name);
QColor color;
- QTest::ignoreMessage(QtWarningMsg, QString("QColor::setNamedColor: Unknown color name '%1'").arg(colorName).toLatin1());
color.setNamedColor(colorName);
QVERIFY(!color.isValid());
}
@@ -1528,7 +1527,6 @@ void tst_QColor::setallowX11ColorNames()
for (int i = 0; i < x11RgbTblSize; ++i) {
QString colorName = QLatin1String(x11RgbTbl[i].name);
QColor color;
- QTest::ignoreMessage(QtWarningMsg, QString("QColor::setNamedColor: Unknown color name '%1'").arg(colorName).toLatin1());
color.setNamedColor(colorName);
QVERIFY(!color.isValid());
}
diff --git a/tests/auto/qcomplextext/tst_qcomplextext.cpp b/tests/auto/qcomplextext/tst_qcomplextext.cpp
index 58b31b4..ae63bac 100644
--- a/tests/auto/qcomplextext/tst_qcomplextext.cpp
+++ b/tests/auto/qcomplextext/tst_qcomplextext.cpp
@@ -214,7 +214,7 @@ void tst_QComplexText::bidiCursorMovement()
QTextOption option = layout.textOption();
option.setTextDirection(basicDir == QChar::DirL ? Qt::LeftToRight : Qt::RightToLeft);
layout.setTextOption(option);
- layout.setCursorMoveStyle(QTextCursor::Visual);
+ layout.setCursorMoveStyle(Qt::VisualMoveStyle);
bool moved;
int oldPos, newPos = 0;
qreal x, newX;
diff --git a/tests/auto/qglyphs/qglyphs.pro b/tests/auto/qglyphrun/qglyphrun.pro
index 5084cf9..480ad5b 100644
--- a/tests/auto/qglyphs/qglyphs.pro
+++ b/tests/auto/qglyphrun/qglyphrun.pro
@@ -2,10 +2,10 @@ load(qttest_p4)
QT = core gui
SOURCES += \
- tst_qglyphs.cpp
+ tst_qglyphrun.cpp
wince*|symbian*: {
DEFINES += SRCDIR=\\\"\\\"
} else {
DEFINES += SRCDIR=\\\"$$PWD/\\\"
-} \ No newline at end of file
+}
diff --git a/tests/auto/qglyphs/test.ttf b/tests/auto/qglyphrun/test.ttf
index 9043a57..9043a57 100644
--- a/tests/auto/qglyphs/test.ttf
+++ b/tests/auto/qglyphrun/test.ttf
Binary files differ
diff --git a/tests/auto/qglyphs/tst_qglyphs.cpp b/tests/auto/qglyphrun/tst_qglyphrun.cpp
index ffa0d00..aefc228 100644
--- a/tests/auto/qglyphs/tst_qglyphs.cpp
+++ b/tests/auto/qglyphrun/tst_qglyphrun.cpp
@@ -41,14 +41,14 @@
#include <QtTest/QtTest>
-#include <qglyphs.h>
+#include <qglyphrun.h>
#include <qpainter.h>
#include <qtextlayout.h>
#include <qfontdatabase.h>
// #define DEBUG_SAVE_IMAGE
-class tst_QGlyphs: public QObject
+class tst_QGlyphRun: public QObject
{
Q_OBJECT
@@ -82,9 +82,9 @@ private:
#if !defined(QT_NO_RAWFONT)
-Q_DECLARE_METATYPE(QGlyphs);
+Q_DECLARE_METATYPE(QGlyphRun);
-void tst_QGlyphs::initTestCase()
+void tst_QGlyphRun::initTestCase()
{
m_testFontId = QFontDatabase::addApplicationFont(SRCDIR "test.ttf");
QVERIFY(m_testFontId >= 0);
@@ -94,19 +94,19 @@ void tst_QGlyphs::initTestCase()
QCOMPARE(QFontInfo(m_testFont).family(), QString::fromLatin1("QtsSpecialTestFont"));
}
-void tst_QGlyphs::cleanupTestCase()
+void tst_QGlyphRun::cleanupTestCase()
{
QFontDatabase::removeApplicationFont(m_testFontId);
}
-void tst_QGlyphs::constructionAndDestruction()
+void tst_QGlyphRun::constructionAndDestruction()
{
- QGlyphs glyphIndexes;
+ QGlyphRun glyphIndexes;
}
-static QGlyphs make_dummy_indexes()
+static QGlyphRun make_dummy_indexes()
{
- QGlyphs glyphs;
+ QGlyphRun glyphs;
QVector<quint32> glyphIndexes;
QVector<QPointF> positions;
@@ -121,16 +121,16 @@ static QGlyphs make_dummy_indexes()
positions.append(QPointF(3, 4));
positions.append(QPointF(5, 6));
- glyphs.setFont(QRawFont::fromFont(font));
+ glyphs.setRawFont(QRawFont::fromFont(font));
glyphs.setGlyphIndexes(glyphIndexes);
glyphs.setPositions(positions);
return glyphs;
}
-void tst_QGlyphs::copyConstructor()
+void tst_QGlyphRun::copyConstructor()
{
- QGlyphs glyphs;
+ QGlyphRun glyphs;
{
QVector<quint32> glyphIndexes;
@@ -146,40 +146,40 @@ void tst_QGlyphs::copyConstructor()
positions.append(QPointF(3, 4));
positions.append(QPointF(5, 6));
- glyphs.setFont(QRawFont::fromFont(font));
+ glyphs.setRawFont(QRawFont::fromFont(font));
glyphs.setGlyphIndexes(glyphIndexes);
glyphs.setPositions(positions);
}
- QGlyphs otherGlyphs(glyphs);
- QCOMPARE(otherGlyphs.font(), glyphs.font());
+ QGlyphRun otherGlyphs(glyphs);
+ QCOMPARE(otherGlyphs.rawFont(), glyphs.rawFont());
QCOMPARE(glyphs.glyphIndexes(), otherGlyphs.glyphIndexes());
QCOMPARE(glyphs.positions(), otherGlyphs.positions());
}
-void tst_QGlyphs::assignment()
+void tst_QGlyphRun::assignment()
{
- QGlyphs glyphs(make_dummy_indexes());
+ QGlyphRun glyphs(make_dummy_indexes());
- QGlyphs otherGlyphs = glyphs;
- QCOMPARE(otherGlyphs.font(), glyphs.font());
+ QGlyphRun otherGlyphs = glyphs;
+ QCOMPARE(otherGlyphs.rawFont(), glyphs.rawFont());
QCOMPARE(glyphs.glyphIndexes(), otherGlyphs.glyphIndexes());
QCOMPARE(glyphs.positions(), otherGlyphs.positions());
}
-void tst_QGlyphs::equalsOperator_data()
+void tst_QGlyphRun::equalsOperator_data()
{
- QTest::addColumn<QGlyphs>("one");
- QTest::addColumn<QGlyphs>("two");
+ QTest::addColumn<QGlyphRun>("one");
+ QTest::addColumn<QGlyphRun>("two");
QTest::addColumn<bool>("equals");
- QGlyphs one(make_dummy_indexes());
- QGlyphs two(make_dummy_indexes());
+ QGlyphRun one(make_dummy_indexes());
+ QGlyphRun two(make_dummy_indexes());
QTest::newRow("Identical") << one << two << true;
{
- QGlyphs busted(two);
+ QGlyphRun busted(two);
QVector<QPointF> positions = busted.positions();
positions[2] += QPointF(1, 1);
@@ -190,17 +190,17 @@ void tst_QGlyphs::equalsOperator_data()
}
{
- QGlyphs busted(two);
+ QGlyphRun busted(two);
QFont font;
- font.setPixelSize(busted.font().pixelSize() * 2);
- busted.setFont(QRawFont::fromFont(font));
+ font.setPixelSize(busted.rawFont().pixelSize() * 2);
+ busted.setRawFont(QRawFont::fromFont(font));
QTest::newRow("Different fonts") << one << busted << false;
}
{
- QGlyphs busted(two);
+ QGlyphRun busted(two);
QVector<quint32> glyphIndexes = busted.glyphIndexes();
glyphIndexes[2] += 1;
@@ -211,10 +211,10 @@ void tst_QGlyphs::equalsOperator_data()
}
-void tst_QGlyphs::equalsOperator()
+void tst_QGlyphRun::equalsOperator()
{
- QFETCH(QGlyphs, one);
- QFETCH(QGlyphs, two);
+ QFETCH(QGlyphRun, one);
+ QFETCH(QGlyphRun, two);
QFETCH(bool, equals);
QCOMPARE(one == two, equals);
@@ -222,7 +222,7 @@ void tst_QGlyphs::equalsOperator()
}
-void tst_QGlyphs::textLayoutGlyphIndexes()
+void tst_QGlyphRun::textLayoutGlyphIndexes()
{
QString s;
s.append(QLatin1Char('A'));
@@ -234,17 +234,17 @@ void tst_QGlyphs::textLayoutGlyphIndexes()
layout.createLine();
layout.endLayout();
- QList<QGlyphs> listOfGlyphs = layout.glyphs();
+ QList<QGlyphRun> listOfGlyphs = layout.glyphRuns();
QCOMPARE(listOfGlyphs.size(), 1);
- QGlyphs glyphs = listOfGlyphs.at(0);
+ QGlyphRun glyphs = listOfGlyphs.at(0);
QCOMPARE(glyphs.glyphIndexes().size(), 2);
QCOMPARE(glyphs.glyphIndexes().at(0), quint32(2));
QCOMPARE(glyphs.glyphIndexes().at(1), quint32(1));
}
-void tst_QGlyphs::drawExistingGlyphs()
+void tst_QGlyphRun::drawExistingGlyphs()
{
QPixmap textLayoutDraw(1000, 1000);
QPixmap drawGlyphs(1000, 1000);
@@ -267,13 +267,13 @@ void tst_QGlyphs::drawExistingGlyphs()
layout.draw(&p, QPointF(50, 50));
}
- QGlyphs glyphs = layout.glyphs().size() > 0
- ? layout.glyphs().at(0)
- : QGlyphs();
+ QGlyphRun glyphs = layout.glyphRuns().size() > 0
+ ? layout.glyphRuns().at(0)
+ : QGlyphRun();
{
QPainter p(&drawGlyphs);
- p.drawGlyphs(QPointF(50, 50), glyphs);
+ p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@@ -284,7 +284,7 @@ void tst_QGlyphs::drawExistingGlyphs()
QCOMPARE(textLayoutDraw, drawGlyphs);
}
-void tst_QGlyphs::drawNonExistentGlyphs()
+void tst_QGlyphRun::drawNonExistentGlyphs()
{
QVector<quint32> glyphIndexes;
glyphIndexes.append(3);
@@ -292,10 +292,10 @@ void tst_QGlyphs::drawNonExistentGlyphs()
QVector<QPointF> glyphPositions;
glyphPositions.append(QPointF(0, 0));
- QGlyphs glyphs;
+ QGlyphRun glyphs;
glyphs.setGlyphIndexes(glyphIndexes);
glyphs.setPositions(glyphPositions);
- glyphs.setFont(QRawFont::fromFont(m_testFont));
+ glyphs.setRawFont(QRawFont::fromFont(m_testFont));
QPixmap image(1000, 1000);
image.fill(Qt::white);
@@ -303,7 +303,7 @@ void tst_QGlyphs::drawNonExistentGlyphs()
QPixmap imageBefore = image;
{
QPainter p(&image);
- p.drawGlyphs(QPointF(50, 50), glyphs);
+ p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@@ -313,7 +313,7 @@ void tst_QGlyphs::drawNonExistentGlyphs()
QCOMPARE(image, imageBefore); // Should be unchanged
}
-void tst_QGlyphs::drawMultiScriptText1()
+void tst_QGlyphRun::drawMultiScriptText1()
{
QString text;
text += QChar(0x03D0); // Greek, beta
@@ -329,7 +329,7 @@ void tst_QGlyphs::drawMultiScriptText1()
QPixmap drawGlyphs(1000, 1000);
drawGlyphs.fill(Qt::white);
- QList<QGlyphs> glyphsList = textLayout.glyphs();
+ QList<QGlyphRun> glyphsList = textLayout.glyphRuns();
QCOMPARE(glyphsList.size(), 1);
{
@@ -339,8 +339,8 @@ void tst_QGlyphs::drawMultiScriptText1()
{
QPainter p(&drawGlyphs);
- foreach (QGlyphs glyphs, glyphsList)
- p.drawGlyphs(QPointF(50, 50), glyphs);
+ foreach (QGlyphRun glyphs, glyphsList)
+ p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@@ -352,7 +352,7 @@ void tst_QGlyphs::drawMultiScriptText1()
}
-void tst_QGlyphs::drawMultiScriptText2()
+void tst_QGlyphRun::drawMultiScriptText2()
{
QString text;
text += QChar(0x0621); // Arabic, Hamza
@@ -369,7 +369,7 @@ void tst_QGlyphs::drawMultiScriptText2()
QPixmap drawGlyphs(1000, 1000);
drawGlyphs.fill(Qt::white);
- QList<QGlyphs> glyphsList = textLayout.glyphs();
+ QList<QGlyphRun> glyphsList = textLayout.glyphRuns();
QCOMPARE(glyphsList.size(), 2);
{
@@ -379,8 +379,8 @@ void tst_QGlyphs::drawMultiScriptText2()
{
QPainter p(&drawGlyphs);
- foreach (QGlyphs glyphs, glyphsList)
- p.drawGlyphs(QPointF(50, 50), glyphs);
+ foreach (QGlyphRun glyphs, glyphsList)
+ p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@@ -391,13 +391,13 @@ void tst_QGlyphs::drawMultiScriptText2()
QCOMPARE(drawGlyphs, textLayoutDraw);
}
-void tst_QGlyphs::detach()
+void tst_QGlyphRun::detach()
{
- QGlyphs glyphs;
+ QGlyphRun glyphs;
glyphs.setGlyphIndexes(QVector<quint32>() << 1 << 2 << 3);
- QGlyphs otherGlyphs;
+ QGlyphRun otherGlyphs;
otherGlyphs = glyphs;
QCOMPARE(otherGlyphs.glyphIndexes(), glyphs.glyphIndexes());
@@ -408,7 +408,7 @@ void tst_QGlyphs::detach()
QCOMPARE(glyphs.glyphIndexes(), QVector<quint32>() << 1 << 2 << 3);
}
-void tst_QGlyphs::drawStruckOutText()
+void tst_QGlyphRun::drawStruckOutText()
{
QPixmap textLayoutDraw(1000, 1000);
QPixmap drawGlyphs(1000, 1000);
@@ -432,13 +432,13 @@ void tst_QGlyphs::drawStruckOutText()
layout.draw(&p, QPointF(50, 50));
}
- QGlyphs glyphs = layout.glyphs().size() > 0
- ? layout.glyphs().at(0)
- : QGlyphs();
+ QGlyphRun glyphs = layout.glyphRuns().size() > 0
+ ? layout.glyphRuns().at(0)
+ : QGlyphRun();
{
QPainter p(&drawGlyphs);
- p.drawGlyphs(QPointF(50, 50), glyphs);
+ p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@@ -449,7 +449,7 @@ void tst_QGlyphs::drawStruckOutText()
QCOMPARE(textLayoutDraw, drawGlyphs);
}
-void tst_QGlyphs::drawOverlinedText()
+void tst_QGlyphRun::drawOverlinedText()
{
QPixmap textLayoutDraw(1000, 1000);
QPixmap drawGlyphs(1000, 1000);
@@ -473,13 +473,13 @@ void tst_QGlyphs::drawOverlinedText()
layout.draw(&p, QPointF(50, 50));
}
- QGlyphs glyphs = layout.glyphs().size() > 0
- ? layout.glyphs().at(0)
- : QGlyphs();
+ QGlyphRun glyphs = layout.glyphRuns().size() > 0
+ ? layout.glyphRuns().at(0)
+ : QGlyphRun();
{
QPainter p(&drawGlyphs);
- p.drawGlyphs(QPointF(50, 50), glyphs);
+ p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@@ -490,7 +490,7 @@ void tst_QGlyphs::drawOverlinedText()
QCOMPARE(textLayoutDraw, drawGlyphs);
}
-void tst_QGlyphs::drawUnderlinedText()
+void tst_QGlyphRun::drawUnderlinedText()
{
QPixmap textLayoutDraw(1000, 1000);
QPixmap drawGlyphs(1000, 1000);
@@ -514,13 +514,13 @@ void tst_QGlyphs::drawUnderlinedText()
layout.draw(&p, QPointF(50, 50));
}
- QGlyphs glyphs = layout.glyphs().size() > 0
- ? layout.glyphs().at(0)
- : QGlyphs();
+ QGlyphRun glyphs = layout.glyphRuns().size() > 0
+ ? layout.glyphRuns().at(0)
+ : QGlyphRun();
{
QPainter p(&drawGlyphs);
- p.drawGlyphs(QPointF(50, 50), glyphs);
+ p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@@ -531,7 +531,7 @@ void tst_QGlyphs::drawUnderlinedText()
QCOMPARE(textLayoutDraw, drawGlyphs);
}
-void tst_QGlyphs::drawRightToLeft()
+void tst_QGlyphRun::drawRightToLeft()
{
QString s;
s.append(QChar(1575));
@@ -557,13 +557,13 @@ void tst_QGlyphs::drawRightToLeft()
layout.draw(&p, QPointF(50, 50));
}
- QGlyphs glyphs = layout.glyphs().size() > 0
- ? layout.glyphs().at(0)
- : QGlyphs();
+ QGlyphRun glyphs = layout.glyphRuns().size() > 0
+ ? layout.glyphRuns().at(0)
+ : QGlyphRun();
{
QPainter p(&drawGlyphs);
- p.drawGlyphs(QPointF(50, 50), glyphs);
+ p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@@ -577,6 +577,6 @@ void tst_QGlyphs::drawRightToLeft()
#endif // QT_NO_RAWFONT
-QTEST_MAIN(tst_QGlyphs)
-#include "tst_qglyphs.moc"
+QTEST_MAIN(tst_QGlyphRun)
+#include "tst_qglyphrun.moc"
diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp
index f45481c..d5d9029 100644
--- a/tests/auto/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/qlineedit/tst_qlineedit.cpp
@@ -3815,7 +3815,7 @@ void tst_QLineEdit::bidiVisualMovement()
QLineEdit le;
le.setText(logical);
- le.setCursorMoveStyle(QTextCursor::Visual);
+ le.setCursorMoveStyle(Qt::VisualMoveStyle);
le.setCursorPosition(0);
bool moved;
@@ -3863,7 +3863,7 @@ void tst_QLineEdit::bidiLogicalMovement()
QLineEdit le;
le.setText(logical);
- le.setCursorMoveStyle(QTextCursor::Logical);
+ le.setCursorMoveStyle(Qt::LogicalMoveStyle);
le.setCursorPosition(0);
bool moved;
diff --git a/tests/auto/qrawfont/tst_qrawfont.cpp b/tests/auto/qrawfont/tst_qrawfont.cpp
index 4b42c74..8c58407 100644
--- a/tests/auto/qrawfont/tst_qrawfont.cpp
+++ b/tests/auto/qrawfont/tst_qrawfont.cpp
@@ -91,6 +91,9 @@ private slots:
void unsupportedWritingSystem_data();
void unsupportedWritingSystem();
+
+ void rawFontSetPixelSize_data();
+ void rawFontSetPixelSize();
#endif // QT_NO_RAWFONT
};
@@ -293,12 +296,12 @@ void tst_QRawFont::textLayout()
layout.createLine();
layout.endLayout();
- QList<QGlyphs> glyphss = layout.glyphs();
- QCOMPARE(glyphss.size(), 1);
+ QList<QGlyphRun> glyphRuns = layout.glyphRuns();
+ QCOMPARE(glyphRuns.size(), 1);
- QGlyphs glyphs = glyphss.at(0);
+ QGlyphRun glyphs = glyphRuns.at(0);
- QRawFont rawFont = glyphs.font();
+ QRawFont rawFont = glyphs.rawFont();
QVERIFY(rawFont.isValid());
QCOMPARE(rawFont.familyName(), familyName);
QCOMPARE(rawFont.pixelSize(), 18.0);
@@ -792,11 +795,11 @@ void tst_QRawFont::unsupportedWritingSystem()
layout.createLine();
layout.endLayout();
- QList<QGlyphs> glyphss = layout.glyphs();
- QCOMPARE(glyphss.size(), 1);
+ QList<QGlyphRun> glyphRuns = layout.glyphRuns();
+ QCOMPARE(glyphRuns.size(), 1);
- QGlyphs glyphs = glyphss.at(0);
- QRawFont layoutFont = glyphs.font();
+ QGlyphRun glyphs = glyphRuns.at(0);
+ QRawFont layoutFont = glyphs.rawFont();
QVERIFY(layoutFont.familyName() != QString::fromLatin1("QtBidiTestFont"));
QCOMPARE(layoutFont.pixelSize(), 12.0);
@@ -807,6 +810,39 @@ void tst_QRawFont::unsupportedWritingSystem()
fontDatabase.removeApplicationFont(id);
}
+void tst_QRawFont::rawFontSetPixelSize_data()
+{
+ QTest::addColumn<QFont::HintingPreference>("hintingPreference");
+
+ QTest::newRow("Default hinting preference") << QFont::PreferDefaultHinting;
+ QTest::newRow("No hinting preference") << QFont::PreferNoHinting;
+ QTest::newRow("Vertical hinting preference") << QFont::PreferVerticalHinting;
+ QTest::newRow("Full hinting preference") << QFont::PreferFullHinting;
+}
+
+void tst_QRawFont::rawFontSetPixelSize()
+{
+ QFETCH(QFont::HintingPreference, hintingPreference);
+
+ QTextLayout layout("Foobar");
+
+ QFont font = layout.font();
+ font.setHintingPreference(hintingPreference);
+ font.setPixelSize(12);
+ layout.setFont(font);
+
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QGlyphRun glyphs = layout.glyphRuns().at(0);
+ QRawFont rawFont = glyphs.rawFont();
+ QCOMPARE(rawFont.pixelSize(), 12.0);
+
+ rawFont.setPixelSize(24);
+ QCOMPARE(rawFont.pixelSize(), 24.0);
+}
+
#endif // QT_NO_RAWFONT
QTEST_MAIN(tst_QRawFont)
diff --git a/tests/auto/qscroller/qscroller.pro b/tests/auto/qscroller/qscroller.pro
deleted file mode 100644
index 845dcb9..0000000
--- a/tests/auto/qscroller/qscroller.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-load(qttest_p4)
-
-SOURCES += tst_qscroller.cpp
diff --git a/tests/auto/qscroller/tst_qscroller.cpp b/tests/auto/qscroller/tst_qscroller.cpp
deleted file mode 100644
index a9b3d9f..0000000
--- a/tests/auto/qscroller/tst_qscroller.cpp
+++ /dev/null
@@ -1,537 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the $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 <QtTest>
-// #include <QDebug>
-
-class tst_QScrollerWidget : public QWidget
-{
-public:
- tst_QScrollerWidget()
- : QWidget()
- {
- reset();
- }
-
- void reset()
- {
- receivedPrepare = false;
- receivedScroll = false;
- receivedFirst = false;
- receivedLast = false;
- receivedOvershoot = false;
- }
-
- bool event(QEvent *e)
- {
- switch (e->type()) {
- case QEvent::Gesture:
- e->setAccepted(false); // better reject the event or QGestureManager will make trouble
- return false;
-
- case QEvent::ScrollPrepare:
- {
- receivedPrepare = true;
- QScrollPrepareEvent *se = static_cast<QScrollPrepareEvent *>(e);
- se->setViewportSize(QSizeF(100,100));
- se->setContentPosRange(scrollArea);
- se->setContentPos(scrollPosition);
- se->accept();
- return true;
- }
-
- case QEvent::Scroll:
- {
- receivedScroll = true;
- QScrollEvent *se = static_cast<QScrollEvent *>(e);
- // qDebug() << "Scroll for"<<this<<"pos"<<se->scrollPos()<<"ov"<<se->overshoot()<<"first"<<se->isFirst()<<"last"<<se->isLast();
-
- if (se->scrollState() == QScrollEvent::ScrollStarted)
- receivedFirst = true;
- if (se->scrollState() == QScrollEvent::ScrollFinished)
- receivedLast = true;
-
- currentPos = se->contentPos();
- overshoot = se->overshootDistance();
- if (!qFuzzyCompare( overshoot.x() + 1.0, 1.0 ) ||
- !qFuzzyCompare( overshoot.y() + 1.0, 1.0 ))
- receivedOvershoot = true;
- return true;
- }
-
- default:
- return QObject::event(e);
- }
- }
-
-
- QRectF scrollArea;
- QPointF scrollPosition;
-
- bool receivedPrepare;
- bool receivedScroll;
- bool receivedFirst;
- bool receivedLast;
- bool receivedOvershoot;
-
- QPointF currentPos;
- QPointF overshoot;
-};
-
-
-class tst_QScroller : public QObject
-{
- Q_OBJECT
-public:
- tst_QScroller() { }
- ~tst_QScroller() { }
-
-private:
- void kineticScroll( tst_QScrollerWidget *sw, QPointF from, QPoint touchStart, QPoint touchUpdate, QPoint touchEnd);
- void kineticScrollNoTest( tst_QScrollerWidget *sw, QPointF from, QPoint touchStart, QPoint touchUpdate, QPoint touchEnd);
-
-private slots:
- void staticScrollers();
- void scrollerProperties();
- void scrollTo();
- void scroll();
- void overshoot();
-};
-
-/*! \internal
- Generates touchBegin, touchUpdate and touchEnd events to trigger scrolling.
- Tests some in between states but does not wait until scrolling is finished.
-*/
-void tst_QScroller::kineticScroll( tst_QScrollerWidget *sw, QPointF from, QPoint touchStart, QPoint touchUpdate, QPoint touchEnd)
-{
- sw->scrollPosition = from;
- sw->currentPos= from;
-
- QScroller *s1 = QScroller::scroller(sw);
- QCOMPARE( s1->state(), QScroller::Inactive );
-
- QScrollerProperties sp1 = QScroller::scroller(sw)->scrollerProperties();
- int fps = 60;
-
- QTouchEvent::TouchPoint rawTouchPoint;
- rawTouchPoint.setId(0);
-
- // send the touch begin event
- QTouchEvent::TouchPoint touchPoint(0);
- touchPoint.setState(Qt::TouchPointPressed);
- touchPoint.setPos(touchStart);
- touchPoint.setScenePos(touchStart);
- touchPoint.setScreenPos(touchStart);
- QTouchEvent touchEvent1(QEvent::TouchBegin,
- QTouchEvent::TouchScreen,
- Qt::NoModifier,
- Qt::TouchPointPressed,
- (QList<QTouchEvent::TouchPoint>() << touchPoint));
- QApplication::sendEvent(sw, &touchEvent1);
-
- QCOMPARE( s1->state(), QScroller::Pressed );
-
- // send the touch update far enough to trigger a scroll
- QTest::qWait(200); // we need to wait a little or else the speed would be infinite. now we have around 500 pixel per second.
- touchPoint.setPos(touchUpdate);
- touchPoint.setScenePos(touchUpdate);
- touchPoint.setScreenPos(touchUpdate);
- QTouchEvent touchEvent2(QEvent::TouchUpdate,
- QTouchEvent::TouchScreen,
- Qt::NoModifier,
- Qt::TouchPointMoved,
- (QList<QTouchEvent::TouchPoint>() << touchPoint));
- QApplication::sendEvent(sw, &touchEvent2);
-
- QCOMPARE( s1->state(), QScroller::Dragging );
- QCOMPARE( sw->receivedPrepare, true );
-
-
- QTest::qWait(1000 / fps * 2); // wait until the first scroll move
- QCOMPARE( sw->receivedFirst, true );
- QCOMPARE( sw->receivedScroll, true );
- QCOMPARE( sw->receivedOvershoot, false );
-
- // note that the scrolling goes in a different direction than the mouse move
- QPoint calculatedPos = from.toPoint() - touchUpdate - touchStart;
- QVERIFY(qAbs(sw->currentPos.x() - calculatedPos.x()) < 1.0);
- QVERIFY(qAbs(sw->currentPos.y() - calculatedPos.y()) < 1.0);
-
- // send the touch end
- touchPoint.setPos(touchEnd);
- touchPoint.setScenePos(touchEnd);
- touchPoint.setScreenPos(touchEnd);
- QTouchEvent touchEvent5(QEvent::TouchEnd,
- QTouchEvent::TouchScreen,
- Qt::NoModifier,
- Qt::TouchPointReleased,
- (QList<QTouchEvent::TouchPoint>() << touchPoint));
- QApplication::sendEvent(sw, &touchEvent5);
-}
-
-/*! \internal
- Generates touchBegin, touchUpdate and touchEnd events to trigger scrolling.
- This function does not have any in between tests, it does not expect the scroller to actually scroll.
-*/
-void tst_QScroller::kineticScrollNoTest( tst_QScrollerWidget *sw, QPointF from, QPoint touchStart, QPoint touchUpdate, QPoint touchEnd)
-{
- sw->scrollPosition = from;
- sw->currentPos = from;
-
- QScroller *s1 = QScroller::scroller(sw);
- QCOMPARE( s1->state(), QScroller::Inactive );
-
- QScrollerProperties sp1 = s1->scrollerProperties();
- int fps = 60;
-
- QTouchEvent::TouchPoint rawTouchPoint;
- rawTouchPoint.setId(0);
-
- // send the touch begin event
- QTouchEvent::TouchPoint touchPoint(0);
- touchPoint.setState(Qt::TouchPointPressed);
- touchPoint.setPos(touchStart);
- touchPoint.setScenePos(touchStart);
- touchPoint.setScreenPos(touchStart);
- QTouchEvent touchEvent1(QEvent::TouchBegin,
- QTouchEvent::TouchScreen,
- Qt::NoModifier,
- Qt::TouchPointPressed,
- (QList<QTouchEvent::TouchPoint>() << touchPoint));
- QApplication::sendEvent(sw, &touchEvent1);
-
- // send the touch update far enough to trigger a scroll
- QTest::qWait(200); // we need to wait a little or else the speed would be infinite. now we have around 500 pixel per second.
- touchPoint.setPos(touchUpdate);
- touchPoint.setScenePos(touchUpdate);
- touchPoint.setScreenPos(touchUpdate);
- QTouchEvent touchEvent2(QEvent::TouchUpdate,
- QTouchEvent::TouchScreen,
- Qt::NoModifier,
- Qt::TouchPointMoved,
- (QList<QTouchEvent::TouchPoint>() << touchPoint));
- QApplication::sendEvent(sw, &touchEvent2);
-
- QTest::qWait(1000 / fps * 2); // wait until the first scroll move
-
- // send the touch end
- touchPoint.setPos(touchEnd);
- touchPoint.setScenePos(touchEnd);
- touchPoint.setScreenPos(touchEnd);
- QTouchEvent touchEvent5(QEvent::TouchEnd,
- QTouchEvent::TouchScreen,
- Qt::NoModifier,
- Qt::TouchPointReleased,
- (QList<QTouchEvent::TouchPoint>() << touchPoint));
- QApplication::sendEvent(sw, &touchEvent5);
-}
-
-
-void tst_QScroller::staticScrollers()
-{
- // scrollers
- {
- QObject *o1 = new QObject(this);
- QObject *o2 = new QObject(this);
-
- // get scroller for object
- QScroller *s1 = QScroller::scroller(o1);
- QScroller *s2 = QScroller::scroller(o2);
-
- QVERIFY(s1);
- QVERIFY(s2);
- QVERIFY(s1 != s2);
-
- QVERIFY(!QScroller::scroller(static_cast<const QObject*>(0)));
- QCOMPARE(QScroller::scroller(o1), s1);
-
- delete o1;
- delete o2;
- }
-
- // the same for properties
- {
- QObject *o1 = new QObject(this);
- QObject *o2 = new QObject(this);
-
- // get scroller for object
- QScrollerProperties sp1 = QScroller::scroller(o1)->scrollerProperties();
- QScrollerProperties sp2 = QScroller::scroller(o2)->scrollerProperties();
-
- // default properties should be the same
- QVERIFY(sp1 == sp2);
-
- QCOMPARE(QScroller::scroller(o1)->scrollerProperties(), sp1);
-
- delete o1;
- delete o2;
- }
-}
-
-void tst_QScroller::scrollerProperties()
-{
- QObject *o1 = new QObject(this);
- QScrollerProperties sp1 = QScroller::scroller(o1)->scrollerProperties();
-
- QScrollerProperties::ScrollMetric metrics[] =
- {
- QScrollerProperties::MousePressEventDelay, // qreal [s]
- QScrollerProperties::DragStartDistance, // qreal [m]
- QScrollerProperties::DragVelocitySmoothingFactor, // qreal [0..1/s] (complex calculation involving time) v = v_new* DASF + v_old * (1-DASF)
- QScrollerProperties::AxisLockThreshold, // qreal [0..1] atan(|min(dx,dy)|/|max(dx,dy)|)
-
- QScrollerProperties::DecelerationFactor, // slope of the curve
-
- QScrollerProperties::MinimumVelocity, // qreal [m/s]
- QScrollerProperties::MaximumVelocity, // qreal [m/s]
- QScrollerProperties::MaximumClickThroughVelocity, // qreal [m/s]
-
- QScrollerProperties::AcceleratingFlickMaximumTime, // qreal [s]
- QScrollerProperties::AcceleratingFlickSpeedupFactor, // qreal [1..]
-
- QScrollerProperties::SnapPositionRatio, // qreal [0..1]
- QScrollerProperties::SnapTime, // qreal [s]
-
- QScrollerProperties::OvershootDragResistanceFactor, // qreal [0..1]
- QScrollerProperties::OvershootDragDistanceFactor, // qreal [0..1]
- QScrollerProperties::OvershootScrollDistanceFactor, // qreal [0..1]
- QScrollerProperties::OvershootScrollTime, // qreal [s]
- };
-
- for (unsigned int i = 0; i < sizeof(metrics) / sizeof(metrics[0]); i++) {
- sp1.setScrollMetric(metrics[i], 0.9);
- QCOMPARE(sp1.scrollMetric(metrics[i]).toDouble(), 0.9);
- }
- sp1.setScrollMetric(QScrollerProperties::ScrollingCurve, QEasingCurve(QEasingCurve::OutQuart));
- QCOMPARE(sp1.scrollMetric(QScrollerProperties::ScrollingCurve).toEasingCurve().type(), QEasingCurve::OutQuart);
-
- sp1.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootAlwaysOff));
- QCOMPARE(sp1.scrollMetric(QScrollerProperties::HorizontalOvershootPolicy).value<QScrollerProperties::OvershootPolicy>(), QScrollerProperties::OvershootAlwaysOff);
-
- sp1.setScrollMetric(QScrollerProperties::VerticalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootAlwaysOn));
- QCOMPARE(sp1.scrollMetric(QScrollerProperties::VerticalOvershootPolicy).value<QScrollerProperties::OvershootPolicy>(), QScrollerProperties::OvershootAlwaysOn);
-
- sp1.setScrollMetric(QScrollerProperties::FrameRate, QVariant::fromValue(QScrollerProperties::Fps20));
- QCOMPARE(sp1.scrollMetric(QScrollerProperties::FrameRate).value<QScrollerProperties::FrameRates>(), QScrollerProperties::Fps20);
-}
-
-void tst_QScroller::scrollTo()
-{
- {
- tst_QScrollerWidget *sw = new tst_QScrollerWidget();
- sw->scrollArea = QRectF( 0, 0, 1000, 1000 );
- sw->scrollPosition = QPointF( 500, 500 );
-
- QScroller *s1 = QScroller::scroller(sw);
- QCOMPARE( s1->state(), QScroller::Inactive );
-
- // a normal scroll
- s1->scrollTo(QPointF(100,100), 100);
- QTest::qWait(200);
-
- QCOMPARE( sw->receivedPrepare, true );
- QCOMPARE( sw->receivedScroll, true );
- QCOMPARE( sw->receivedFirst, true );
- QCOMPARE( sw->receivedLast, true );
- QCOMPARE( sw->receivedOvershoot, false );
- QVERIFY(qFuzzyCompare( sw->currentPos.x(), 100 ));
- QVERIFY(qFuzzyCompare( sw->currentPos.y(), 100 ));
-
- delete sw;
- }
-}
-
-void tst_QScroller::scroll()
-{
-#if defined(Q_OS_MACX) && (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6)
- QSKIP("Mac OS X < 10.6 does not support QTouchEvents", SkipAll);
- return;
-#endif
-
-#ifndef QT_NO_GESTURES
- // -- good case. normal scroll
- tst_QScrollerWidget *sw = new tst_QScrollerWidget();
- sw->scrollArea = QRectF(0, 0, 1000, 1000);
- QScroller::grabGesture(sw, QScroller::TouchGesture);
- sw->setGeometry(100, 100, 400, 300);
-
- QScroller *s1 = QScroller::scroller(sw);
- kineticScroll(sw, QPointF(500, 500), QPoint(0, 0), QPoint(100, 100), QPoint(200, 200));
- // now we should be scrolling
- QCOMPARE( s1->state(), QScroller::Scrolling );
-
- // wait until finished, check that no further first scroll is send
- sw->receivedFirst = false;
- sw->receivedScroll = false;
- while (s1->state() == QScroller::Scrolling)
- QTest::qWait(100);
-
- QCOMPARE( sw->receivedFirst, false );
- QCOMPARE( sw->receivedScroll, true );
- QCOMPARE( sw->receivedLast, true );
- QVERIFY(sw->currentPos.x() < 400);
- QVERIFY(sw->currentPos.y() < 400);
-
- // -- try to scroll when nothing to scroll
-
- sw->reset();
- sw->scrollArea = QRectF(0, 0, 0, 1000);
- kineticScrollNoTest(sw, QPointF(0, 500), QPoint(0, 0), QPoint(100, 0), QPoint(200, 0));
-
- while (s1->state() != QScroller::Inactive)
- QTest::qWait(20);
-
- QCOMPARE(sw->currentPos.x(), 0.0);
- QCOMPARE(sw->currentPos.y(), 500.0);
-
- delete sw;
-#endif
-}
-
-void tst_QScroller::overshoot()
-{
-#if defined(Q_OS_MACX) && (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6)
- QSKIP("Mac OS X < 10.6 does not support QTouchEvents", SkipAll);
- return;
-#endif
-
-#ifndef QT_NO_GESTURES
- tst_QScrollerWidget *sw = new tst_QScrollerWidget();
- sw->scrollArea = QRectF(0, 0, 1000, 1000);
- QScroller::grabGesture(sw, QScroller::TouchGesture);
- sw->setGeometry(100, 100, 400, 300);
-
- QScroller *s1 = QScroller::scroller(sw);
- QScrollerProperties sp1 = s1->scrollerProperties();
-
- sp1.setScrollMetric(QScrollerProperties::OvershootDragResistanceFactor, 0.5);
- sp1.setScrollMetric(QScrollerProperties::OvershootDragDistanceFactor, 0.2);
- sp1.setScrollMetric(QScrollerProperties::OvershootScrollDistanceFactor, 0.2);
-
- // -- try to scroll with overshoot (when scrollable good case)
-
- sp1.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootWhenScrollable));
- s1->setScrollerProperties(sp1);
- kineticScrollNoTest(sw, QPointF(500, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0));
-
- while (s1->state() != QScroller::Inactive)
- QTest::qWait(20);
-
- //qDebug() << "Overshoot fuzzy: "<<sw->currentPos;
- QVERIFY(qFuzzyCompare( sw->currentPos.x(), 0 ));
- QVERIFY(qFuzzyCompare( sw->currentPos.y(), 500 ));
- QCOMPARE( sw->receivedOvershoot, true );
-
- // -- try to scroll with overshoot (when scrollable bad case)
- sw->reset();
- sw->scrollArea = QRectF(0, 0, 0, 1000);
-
- sp1.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootWhenScrollable));
- s1->setScrollerProperties(sp1);
- kineticScrollNoTest(sw, QPointF(0, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0));
-
- while (s1->state() != QScroller::Inactive)
- QTest::qWait(20);
-
- //qDebug() << "Overshoot fuzzy: "<<sw->currentPos;
- QVERIFY(qFuzzyCompare( sw->currentPos.x(), 0 ));
- QVERIFY(qFuzzyCompare( sw->currentPos.y(), 500 ));
- QCOMPARE( sw->receivedOvershoot, false );
-
- // -- try to scroll with overshoot (always on)
- sw->reset();
- sw->scrollArea = QRectF(0, 0, 0, 1000);
-
- sp1.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootAlwaysOn));
- s1->setScrollerProperties(sp1);
- kineticScrollNoTest(sw, QPointF(0, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0));
-
- while (s1->state() != QScroller::Inactive)
- QTest::qWait(20);
-
- //qDebug() << "Overshoot fuzzy: "<<sw->currentPos;
-
- QVERIFY(qFuzzyCompare( sw->currentPos.x(), 0 ));
- QVERIFY(qFuzzyCompare( sw->currentPos.y(), 500 ));
- QCOMPARE( sw->receivedOvershoot, true );
-
- // -- try to scroll with overshoot (always off)
- sw->reset();
- sw->scrollArea = QRectF(0, 0, 1000, 1000);
-
- sp1.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootAlwaysOff));
- s1->setScrollerProperties(sp1);
- kineticScrollNoTest(sw, QPointF(500, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0));
-
- while (s1->state() != QScroller::Inactive)
- QTest::qWait(20);
-
- QVERIFY(qFuzzyCompare( sw->currentPos.x(), 0 ));
- QVERIFY(qFuzzyCompare( sw->currentPos.y(), 500 ));
- QCOMPARE( sw->receivedOvershoot, false );
-
- // -- try to scroll with overshoot (always on but max overshoot = 0)
- sp1.setScrollMetric(QScrollerProperties::OvershootDragDistanceFactor, 0.0);
- sp1.setScrollMetric(QScrollerProperties::OvershootScrollDistanceFactor, 0.0);
- sw->reset();
- sw->scrollArea = QRectF(0, 0, 1000, 1000);
-
- sp1.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootAlwaysOn));
- s1->setScrollerProperties(sp1);
- kineticScrollNoTest(sw, QPointF(500, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0));
-
- while (s1->state() != QScroller::Inactive)
- QTest::qWait(20);
-
- QVERIFY(qFuzzyCompare( sw->currentPos.x(), 0 ));
- QVERIFY(qFuzzyCompare( sw->currentPos.y(), 500 ));
- QCOMPARE( sw->receivedOvershoot, false );
-
-
- delete sw;
-#endif
-}
-
-
-QTEST_MAIN(tst_QScroller)
-
-#include "tst_qscroller.moc"
diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp
index 507af5e..9badd0b 100644
--- a/tests/auto/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp
@@ -156,6 +156,7 @@ private slots:
void setSslConfiguration_data();
void setSslConfiguration();
void waitForEncrypted();
+ void waitForEncryptedMinusOne();
void waitForConnectedEncryptedReadyRead();
void startClientEncryption();
void startServerEncryption();
@@ -1098,6 +1099,20 @@ void tst_QSslSocket::waitForEncrypted()
QVERIFY(socket->waitForEncrypted(10000));
}
+void tst_QSslSocket::waitForEncryptedMinusOne()
+{
+ if (!QSslSocket::supportsSsl())
+ return;
+
+ QSslSocketPtr socket = newSocket();
+ this->socket = socket;
+
+ connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(ignoreErrorSlot()));
+ socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
+
+ QVERIFY(socket->waitForEncrypted(-1));
+}
+
void tst_QSslSocket::waitForConnectedEncryptedReadyRead()
{
if (!QSslSocket::supportsSsl())
diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
index f83c4cf..d19475f 100644
--- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
@@ -166,7 +166,9 @@ private slots:
void readLineString();
void readChunks();
void waitForBytesWritten();
+ void waitForBytesWrittenMinusOne();
void waitForReadyRead();
+ void waitForReadyReadMinusOne();
void flush();
void synchronousApi();
void dontCloseOnTimeout();
@@ -1417,10 +1419,10 @@ void tst_QTcpSocket::readChunks()
void tst_QTcpSocket::waitForBytesWritten()
{
QTcpSocket *socket = newSocket();
- socket->connectToHost(QtNetworkSettings::serverName(), 22);
+ socket->connectToHost(QtNetworkSettings::serverName(), 80);
QVERIFY(socket->waitForConnected(10000));
- socket->write(QByteArray(10000, '@'));
+ socket->write("GET / HTTP/1.0\r\n\r\n");
qint64 toWrite = socket->bytesToWrite();
QVERIFY(socket->waitForBytesWritten(5000));
QVERIFY(toWrite > socket->bytesToWrite());
@@ -1429,11 +1431,37 @@ void tst_QTcpSocket::waitForBytesWritten()
}
//----------------------------------------------------------------------------------
+void tst_QTcpSocket::waitForBytesWrittenMinusOne()
+{
+ QTcpSocket *socket = newSocket();
+ socket->connectToHost(QtNetworkSettings::serverName(), 80);
+ QVERIFY(socket->waitForConnected(10000));
+
+ socket->write("GET / HTTP/1.0\r\n\r\n");
+ qint64 toWrite = socket->bytesToWrite();
+ QVERIFY(socket->waitForBytesWritten(-1));
+ QVERIFY(toWrite > socket->bytesToWrite());
+
+ delete socket;
+}
+
+//----------------------------------------------------------------------------------
void tst_QTcpSocket::waitForReadyRead()
{
QTcpSocket *socket = newSocket();
- socket->connectToHost(QtNetworkSettings::serverName(), 22);
- socket->waitForReadyRead(0);
+ socket->connectToHost(QtNetworkSettings::serverName(), 80);
+ socket->write("GET / HTTP/1.0\r\n\r\n");
+ QVERIFY(socket->waitForReadyRead(5000));
+ delete socket;
+}
+
+//----------------------------------------------------------------------------------
+void tst_QTcpSocket::waitForReadyReadMinusOne()
+{
+ QTcpSocket *socket = newSocket();
+ socket->connectToHost(QtNetworkSettings::serverName(), 80);
+ socket->write("GET / HTTP/1.0\r\n\r\n");
+ QVERIFY(socket->waitForReadyRead(-1));
delete socket;
}
diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp
index 6675c99..7aa6578 100644
--- a/tests/auto/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp
@@ -180,6 +180,8 @@ private slots:
void escape_data();
void escape();
+ void copiedFontSize();
+
private:
void backgroundImage_checkExpectedHtml(const QTextDocument &doc);
@@ -2734,5 +2736,29 @@ void tst_QTextDocument::escape()
QCOMPARE(Qt::escape(original), expected);
}
+void tst_QTextDocument::copiedFontSize()
+{
+ QTextDocument documentInput;
+ QTextDocument documentOutput;
+
+ QFont fontInput;
+ fontInput.setPixelSize(24);
+
+ QTextCursor cursorInput(&documentInput);
+ QTextCharFormat formatInput = cursorInput.charFormat();
+ formatInput.setFont(fontInput);
+ cursorInput.insertText("Should be the same font", formatInput);
+ cursorInput.select(QTextCursor::Document);
+
+ QTextDocumentFragment fragmentInput(cursorInput);
+ QString html = fragmentInput.toHtml();
+
+ QTextCursor cursorOutput(&documentOutput);
+ QTextDocumentFragment fragmentOutput = QTextDocumentFragment::fromHtml(html);
+ cursorOutput.insertFragment(fragmentOutput);
+
+ QCOMPARE(cursorOutput.charFormat().font().pixelSize(), 24);
+}
+
QTEST_MAIN(tst_QTextDocument)
#include "tst_qtextdocument.moc"
diff --git a/tests/auto/qtextedit/tst_qtextedit.cpp b/tests/auto/qtextedit/tst_qtextedit.cpp
index 41af7bf..6b9a541 100644
--- a/tests/auto/qtextedit/tst_qtextedit.cpp
+++ b/tests/auto/qtextedit/tst_qtextedit.cpp
@@ -2292,7 +2292,7 @@ void tst_QTextEdit::bidiVisualMovement()
option.setTextDirection(basicDir == QChar::DirL ? Qt::LeftToRight : Qt::RightToLeft);
ed->document()->setDefaultTextOption(option);
- ed->document()->setDefaultCursorMoveStyle(QTextCursor::Visual);
+ ed->document()->setDefaultCursorMoveStyle(Qt::VisualMoveStyle);
ed->moveCursor(QTextCursor::Start);
ed->show();
@@ -2346,7 +2346,7 @@ void tst_QTextEdit::bidiLogicalMovement()
option.setTextDirection(basicDir == QChar::DirL ? Qt::LeftToRight : Qt::RightToLeft);
ed->document()->setDefaultTextOption(option);
- ed->document()->setDefaultCursorMoveStyle(QTextCursor::Logical);
+ ed->document()->setDefaultCursorMoveStyle(Qt::LogicalMoveStyle);
ed->moveCursor(QTextCursor::Start);
ed->show();
diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp
index af70c9e..492d0df 100644
--- a/tests/auto/qvariant/tst_qvariant.cpp
+++ b/tests/auto/qvariant/tst_qvariant.cpp
@@ -2650,7 +2650,6 @@ void tst_QVariant::invalidAsByteArray()
void tst_QVariant::invalidQColor() const
{
QVariant va("An invalid QColor::name() value.");
- QTest::ignoreMessage(QtWarningMsg, "QColor::setNamedColor: Unknown color name 'An invalid QColor::name() value.'");
QVERIFY(va.canConvert(QVariant::Color));
QVERIFY(!va.convert(QVariant::Color));
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index e8d9719..f33bdbb 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -4738,7 +4738,8 @@ void tst_QWidget::update()
QCOMPARE(w.visibleRegion(), expectedVisible);
QCOMPARE(w.paintedRegion, expectedVisible);
#ifdef QT_MAC_USE_COCOA
- QEXPECT_FAIL(0, "Cocoa compositor says to paint this.", Continue);
+ if (QApplicationPrivate::graphics_system_name != QLatin1String("raster"))
+ QEXPECT_FAIL(0, "Cocoa compositor says to paint this.", Continue);
#endif
QCOMPARE(child.numPaintEvents, 0);
@@ -6336,11 +6337,15 @@ void tst_QWidget::compatibilityChildInsertedEvents()
expected =
EventRecorder::EventList()
<< qMakePair(&widget, QEvent::PolishRequest)
- << qMakePair(&widget, QEvent::Type(QEvent::User + 1))
-#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) || defined(Q_WS_QPA)
- << qMakePair(&widget, QEvent::UpdateRequest)
-#endif
- ;
+ << qMakePair(&widget, QEvent::Type(QEvent::User + 1));
+
+#ifndef QT_MAC_USE_CARBON
+#ifdef QT_MAC_USE_COCOA
+ if (QApplicationPrivate::graphics_system_name == QLatin1String("raster"))
+#endif // QT_MAC_USE_COCOA
+ expected << qMakePair(&widget, QEvent::UpdateRequest);
+#endif // !QT_MAC_USE_CARBON
+
QCOMPARE(spy.eventList(), expected);
}
@@ -6432,11 +6437,15 @@ void tst_QWidget::compatibilityChildInsertedEvents()
#endif
<< qMakePair(&widget, QEvent::PolishRequest)
<< qMakePair(&widget, QEvent::Type(QEvent::User + 1))
- << qMakePair(&widget, QEvent::Type(QEvent::User + 2))
-#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) || defined(Q_WS_QPA)
- << qMakePair(&widget, QEvent::UpdateRequest)
-#endif
- ;
+ << qMakePair(&widget, QEvent::Type(QEvent::User + 2));
+
+#ifndef QT_MAC_USE_CARBON
+#ifdef QT_MAC_USE_COCOA
+ if (QApplicationPrivate::graphics_system_name == QLatin1String("raster"))
+#endif // QT_MAC_USE_COCOA
+ expected << qMakePair(&widget, QEvent::UpdateRequest);
+#endif // !QT_MAC_USE_CARBON
+
QCOMPARE(spy.eventList(), expected);
}
@@ -6528,11 +6537,15 @@ void tst_QWidget::compatibilityChildInsertedEvents()
#endif
<< qMakePair(&widget, QEvent::PolishRequest)
<< qMakePair(&widget, QEvent::Type(QEvent::User + 1))
- << qMakePair(&widget, QEvent::Type(QEvent::User + 2))
-#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) || defined(Q_WS_QPA)
- << qMakePair(&widget, QEvent::UpdateRequest)
-#endif
- ;
+ << qMakePair(&widget, QEvent::Type(QEvent::User + 2));
+
+#ifndef QT_MAC_USE_CARBON
+#ifdef QT_MAC_USE_COCOA
+ if (QApplicationPrivate::graphics_system_name == QLatin1String("raster"))
+#endif // QT_MAC_USE_COCOA
+ expected << qMakePair(&widget, QEvent::UpdateRequest);
+#endif // !QT_MAC_USE_CARBON
+
QCOMPARE(spy.eventList(), expected);
}
}
diff --git a/tools/qml/texteditautoresizer_maemo5.h b/tools/qml/texteditautoresizer_maemo5.h
index 71dbce0..e82d006 100644
--- a/tools/qml/texteditautoresizer_maemo5.h
+++ b/tools/qml/texteditautoresizer_maemo5.h
@@ -41,7 +41,7 @@
#include <QtGui/qplaintextedit.h>
#include <QtGui/qtextedit.h>
-#include <QtGui/qscroller.h>
+#include <QtGui/qabstractkineticscroller.h>
#include <QtGui/qscrollarea.h>
#include <QtDebug>
@@ -102,11 +102,11 @@ void TextEditAutoResizer::textEditChanged()
QPoint scrollto = area->widget()->mapFrom(edit, cursor.center());
QPoint margin(10 + cursor.width(), 2 * cursor.height());
-#ifdef Q_WS_MAEMO_5
- QScroller::scroller(area)->ensureVisible(scrollto, margin.x(), margin.y());
-#else
- area->ensureVisible(scrollto.x(), scrollto.y(), margin.x(), margin.y());
-#endif
+ if (QAbstractKineticScroller *scroller = area->property("kineticScroller").value<QAbstractKineticScroller *>()) {
+ scroller->ensureVisible(scrollto, margin.x(), margin.y());
+ } else {
+ area->ensureVisible(scrollto.x(), scrollto.y(), margin.x(), margin.y());
+ }
}
}