Changeset 561 for trunk/demos/shared


Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/demos/shared/arthurstyle.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the demonstration applications of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/demos/shared/arthurstyle.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the demonstration applications of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/demos/shared/arthurwidgets.cpp

    r514 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the demonstration applications of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/demos/shared/arthurwidgets.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the demonstration applications of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5050#if defined(QT_OPENGL_SUPPORT)
    5151#include <QGLWidget>
     52#include <QEvent>
    5253class GLWidget : public QGLWidget
    5354{
    5455public:
    5556    GLWidget(QWidget *parent)
    56         : QGLWidget(QGLFormat(QGL::SampleBuffers), parent) {}
     57        : QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
     58    {
     59        setAttribute(Qt::WA_AcceptTouchEvents);
     60    }
    5761    void disableAutoBufferSwap() { setAutoBufferSwap(false); }
    5862    void paintEvent(QPaintEvent *) { parentWidget()->update(); }
     63protected:
     64    bool event(QEvent *event)
     65    {
     66        switch (event->type()) {
     67        case QEvent::TouchBegin:
     68        case QEvent::TouchUpdate:
     69        case QEvent::TouchEnd:
     70            event->ignore();
     71            return false;
     72            break;
     73        default:
     74            break;
     75        }
     76        return QGLWidget::event(event);
     77    }
    5978};
    6079#endif
  • trunk/demos/shared/hoverpoints.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the demonstration applications of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5454    m_widget = widget;
    5555    widget->installEventFilter(this);
     56    widget->setAttribute(Qt::WA_AcceptTouchEvents);
    5657
    5758    m_connectionType = CurveConnection;
     
    6667    m_enabled = true;
    6768
    68     connect(this, SIGNAL(pointsChanged(const QPolygonF &)),
     69    connect(this, SIGNAL(pointsChanged(QPolygonF)),
    6970            m_widget, SLOT(update()));
    7071}
     
    8788        case QEvent::MouseButtonPress:
    8889        {
     90            if (!m_fingerPointMapping.isEmpty())
     91                return true;
    8992            QMouseEvent *me = (QMouseEvent *) event;
    9093
     
    148151
    149152        case QEvent::MouseButtonRelease:
     153            if (!m_fingerPointMapping.isEmpty())
     154                return true;
    150155            m_currentIndex = -1;
    151156            break;
    152157
    153158        case QEvent::MouseMove:
     159            if (!m_fingerPointMapping.isEmpty())
     160                return true;
    154161            if (m_currentIndex >= 0)
    155162                movePoint(m_currentIndex, ((QMouseEvent *)event)->pos());
     163            break;
     164        case QEvent::TouchBegin:
     165        case QEvent::TouchUpdate:
     166            {
     167                const QTouchEvent *const touchEvent = static_cast<const QTouchEvent*>(event);
     168                const QList<QTouchEvent::TouchPoint> points = touchEvent->touchPoints();
     169                const qreal pointSize = qMax(m_pointSize.width(), m_pointSize.height());
     170                foreach (const QTouchEvent::TouchPoint &touchPoint, points) {
     171                    const int id = touchPoint.id();
     172                    switch (touchPoint.state()) {
     173                    case Qt::TouchPointPressed:
     174                        {
     175                            // find the point, move it
     176                            QSet<int> activePoints = QSet<int>::fromList(m_fingerPointMapping.values());
     177                            int activePoint = -1;
     178                            qreal distance = -1;
     179                            const int pointsCount = m_points.size();
     180                            const int activePointCount = activePoints.size();
     181                            if (pointsCount == 2 && activePointCount == 1) { // only two points
     182                                activePoint = activePoints.contains(0) ? 1 : 0;
     183                            } else {
     184                                for (int i=0; i<pointsCount; ++i) {
     185                                    if (activePoints.contains(i))
     186                                        continue;
     187
     188                                    qreal d = QLineF(touchPoint.pos(), m_points.at(i)).length();
     189                                    if ((distance < 0 && d < 12 * pointSize) || d < distance) {
     190                                        distance = d;
     191                                        activePoint = i;
     192                                    }
     193
     194                                }
     195                            }
     196                            if (activePoint != -1) {
     197                                m_fingerPointMapping.insert(touchPoint.id(), activePoint);
     198                                movePoint(activePoint, touchPoint.pos());
     199                            }
     200                        }
     201                        break;
     202                    case Qt::TouchPointReleased:
     203                        {
     204                            // move the point and release
     205                            QHash<int,int>::iterator it = m_fingerPointMapping.find(id);
     206                            movePoint(it.value(), touchPoint.pos());
     207                            m_fingerPointMapping.erase(it);
     208                        }
     209                        break;
     210                    case Qt::TouchPointMoved:
     211                        {
     212                            // move the point
     213                            const int pointIdx = m_fingerPointMapping.value(id, -1);
     214                            if (pointIdx >= 0) // do we track this point?
     215                                movePoint(pointIdx, touchPoint.pos());
     216                        }
     217                        break;
     218                    default:
     219                        break;
     220                    }
     221                }
     222                if (m_fingerPointMapping.isEmpty()) {
     223                    event->ignore();
     224                    return false;
     225                } else {
     226                    return true;
     227                }
     228            }
     229            break;
     230        case QEvent::TouchEnd:
     231            if (m_fingerPointMapping.isEmpty()) {
     232                event->ignore();
     233                return false;
     234            }
     235            return true;
    156236            break;
    157237
     
    263343void HoverPoints::setPoints(const QPolygonF &points)
    264344{
     345    if (points.size() != m_points.size())
     346        m_fingerPointMapping.clear();
    265347    m_points.clear();
    266348    for (int i=0; i<points.size(); ++i)
  • trunk/demos/shared/hoverpoints.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the demonstration applications of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    134134    bool m_enabled;
    135135
     136    QHash<int, int> m_fingerPointMapping;
     137
    136138    QPen m_pointPen;
    137139    QBrush m_pointBrush;
  • trunk/demos/shared/shared.pri

    r2 r561  
    1717hpux-acc*:LIBS += $$SHARED_FOLDER/libdemo_shared.a
    1818hpuxi-acc*:LIBS += $$SHARED_FOLDER/libdemo_shared.a
    19 !hpuxi-acc*:!hpux-acc*:LIBS += -ldemo_shared
     19symbian:LIBS += -ldemo_shared.lib
     20!hpuxi-acc*:!hpux-acc*:!symbian:LIBS += -ldemo_shared
    2021
  • trunk/demos/shared/shared.pro

    r2 r561  
    3030sources.path = $$[QT_INSTALL_DEMOS]/shared
    3131INSTALLS += sources
     32
    3233!cross_compile:INSTALLS += target
    3334
     35symbian {
     36    TARGET.UID3 = 0xA000A63C
     37    include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri)
     38}
Note: See TracChangeset for help on using the changeset viewer.