| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/statemachine/qbasicmouseeventtransition.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the QtWidgets module of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||
| 16 | ** | - | ||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
| 19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||
| 25 | ** | - | ||||||||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||
| 29 | ** | - | ||||||||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 31 | ** | - | ||||||||||||
| 32 | ****************************************************************************/ | - | ||||||||||||
| 33 | - | |||||||||||||
| 34 | #include "qbasicmouseeventtransition_p.h" | - | ||||||||||||
| 35 | - | |||||||||||||
| 36 | #ifndef QT_NO_STATEMACHINE | - | ||||||||||||
| 37 | - | |||||||||||||
| 38 | #include <QtGui/qevent.h> | - | ||||||||||||
| 39 | #include <QtGui/qpainterpath.h> | - | ||||||||||||
| 40 | #include <qdebug.h> | - | ||||||||||||
| 41 | #include <private/qabstracttransition_p.h> | - | ||||||||||||
| 42 | - | |||||||||||||
| 43 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 44 | - | |||||||||||||
| 45 | /*! | - | ||||||||||||
| 46 | \internal | - | ||||||||||||
| 47 | \class QBasicMouseEventTransition | - | ||||||||||||
| 48 | \since 4.6 | - | ||||||||||||
| 49 | \ingroup statemachine | - | ||||||||||||
| 50 | - | |||||||||||||
| 51 | \brief The QBasicMouseEventTransition class provides a transition for Qt mouse events. | - | ||||||||||||
| 52 | */ | - | ||||||||||||
| 53 | - | |||||||||||||
| 54 | class QBasicMouseEventTransitionPrivate : public QAbstractTransitionPrivate | - | ||||||||||||
| 55 | { | - | ||||||||||||
| 56 | Q_DECLARE_PUBLIC(QBasicMouseEventTransition) | - | ||||||||||||
| 57 | public: | - | ||||||||||||
| 58 | QBasicMouseEventTransitionPrivate(); | - | ||||||||||||
| 59 | - | |||||||||||||
| 60 | static QBasicMouseEventTransitionPrivate *get(QBasicMouseEventTransition *q); | - | ||||||||||||
| 61 | - | |||||||||||||
| 62 | QEvent::Type eventType; | - | ||||||||||||
| 63 | Qt::MouseButton button; | - | ||||||||||||
| 64 | Qt::KeyboardModifiers modifierMask; | - | ||||||||||||
| 65 | QPainterPath path; | - | ||||||||||||
| 66 | }; | - | ||||||||||||
| 67 | - | |||||||||||||
| 68 | QBasicMouseEventTransitionPrivate::QBasicMouseEventTransitionPrivate() | - | ||||||||||||
| 69 | { | - | ||||||||||||
| 70 | eventType = QEvent::None; | - | ||||||||||||
| 71 | button = Qt::NoButton; | - | ||||||||||||
| 72 | } never executed: end of block | 0 | ||||||||||||
| 73 | - | |||||||||||||
| 74 | QBasicMouseEventTransitionPrivate *QBasicMouseEventTransitionPrivate::get(QBasicMouseEventTransition *q) | - | ||||||||||||
| 75 | { | - | ||||||||||||
| 76 | return q->d_func(); never executed: return q->d_func(); | 0 | ||||||||||||
| 77 | } | - | ||||||||||||
| 78 | - | |||||||||||||
| 79 | /*! | - | ||||||||||||
| 80 | Constructs a new mouse event transition with the given \a sourceState. | - | ||||||||||||
| 81 | */ | - | ||||||||||||
| 82 | QBasicMouseEventTransition::QBasicMouseEventTransition(QState *sourceState) | - | ||||||||||||
| 83 | : QAbstractTransition(*new QBasicMouseEventTransitionPrivate, sourceState) | - | ||||||||||||
| 84 | { | - | ||||||||||||
| 85 | } never executed: end of block | 0 | ||||||||||||
| 86 | - | |||||||||||||
| 87 | /*! | - | ||||||||||||
| 88 | Constructs a new mouse event transition for events of the given \a type. | - | ||||||||||||
| 89 | */ | - | ||||||||||||
| 90 | QBasicMouseEventTransition::QBasicMouseEventTransition(QEvent::Type type, | - | ||||||||||||
| 91 | Qt::MouseButton button, | - | ||||||||||||
| 92 | QState *sourceState) | - | ||||||||||||
| 93 | : QAbstractTransition(*new QBasicMouseEventTransitionPrivate, sourceState) | - | ||||||||||||
| 94 | { | - | ||||||||||||
| 95 | Q_D(QBasicMouseEventTransition); | - | ||||||||||||
| 96 | d->eventType = type; | - | ||||||||||||
| 97 | d->button = button; | - | ||||||||||||
| 98 | } never executed: end of block | 0 | ||||||||||||
| 99 | - | |||||||||||||
| 100 | /*! | - | ||||||||||||
| 101 | Destroys this mouse event transition. | - | ||||||||||||
| 102 | */ | - | ||||||||||||
| 103 | QBasicMouseEventTransition::~QBasicMouseEventTransition() | - | ||||||||||||
| 104 | { | - | ||||||||||||
| 105 | } | - | ||||||||||||
| 106 | - | |||||||||||||
| 107 | /*! | - | ||||||||||||
| 108 | Returns the event type that this mouse event transition is associated with. | - | ||||||||||||
| 109 | */ | - | ||||||||||||
| 110 | QEvent::Type QBasicMouseEventTransition::eventType() const | - | ||||||||||||
| 111 | { | - | ||||||||||||
| 112 | Q_D(const QBasicMouseEventTransition); | - | ||||||||||||
| 113 | return d->eventType; never executed: return d->eventType; | 0 | ||||||||||||
| 114 | } | - | ||||||||||||
| 115 | - | |||||||||||||
| 116 | /*! | - | ||||||||||||
| 117 | Sets the event \a type that this mouse event transition is associated with. | - | ||||||||||||
| 118 | */ | - | ||||||||||||
| 119 | void QBasicMouseEventTransition::setEventType(QEvent::Type type) | - | ||||||||||||
| 120 | { | - | ||||||||||||
| 121 | Q_D(QBasicMouseEventTransition); | - | ||||||||||||
| 122 | d->eventType = type; | - | ||||||||||||
| 123 | } never executed: end of block | 0 | ||||||||||||
| 124 | - | |||||||||||||
| 125 | /*! | - | ||||||||||||
| 126 | Returns the button that this mouse event transition checks for. | - | ||||||||||||
| 127 | */ | - | ||||||||||||
| 128 | Qt::MouseButton QBasicMouseEventTransition::button() const | - | ||||||||||||
| 129 | { | - | ||||||||||||
| 130 | Q_D(const QBasicMouseEventTransition); | - | ||||||||||||
| 131 | return d->button; never executed: return d->button; | 0 | ||||||||||||
| 132 | } | - | ||||||||||||
| 133 | - | |||||||||||||
| 134 | /*! | - | ||||||||||||
| 135 | Sets the button that this mouse event transition will check for. | - | ||||||||||||
| 136 | */ | - | ||||||||||||
| 137 | void QBasicMouseEventTransition::setButton(Qt::MouseButton button) | - | ||||||||||||
| 138 | { | - | ||||||||||||
| 139 | Q_D(QBasicMouseEventTransition); | - | ||||||||||||
| 140 | d->button = button; | - | ||||||||||||
| 141 | } never executed: end of block | 0 | ||||||||||||
| 142 | - | |||||||||||||
| 143 | /*! | - | ||||||||||||
| 144 | Returns the keyboard modifier mask that this mouse event transition checks | - | ||||||||||||
| 145 | for. | - | ||||||||||||
| 146 | */ | - | ||||||||||||
| 147 | Qt::KeyboardModifiers QBasicMouseEventTransition::modifierMask() const | - | ||||||||||||
| 148 | { | - | ||||||||||||
| 149 | Q_D(const QBasicMouseEventTransition); | - | ||||||||||||
| 150 | return d->modifierMask; never executed: return d->modifierMask; | 0 | ||||||||||||
| 151 | } | - | ||||||||||||
| 152 | - | |||||||||||||
| 153 | /*! | - | ||||||||||||
| 154 | Sets the keyboard modifier mask that this mouse event transition will check | - | ||||||||||||
| 155 | for. | - | ||||||||||||
| 156 | */ | - | ||||||||||||
| 157 | void QBasicMouseEventTransition::setModifierMask(Qt::KeyboardModifiers modifierMask) | - | ||||||||||||
| 158 | { | - | ||||||||||||
| 159 | Q_D(QBasicMouseEventTransition); | - | ||||||||||||
| 160 | d->modifierMask = modifierMask; | - | ||||||||||||
| 161 | } never executed: end of block | 0 | ||||||||||||
| 162 | - | |||||||||||||
| 163 | /*! | - | ||||||||||||
| 164 | Returns the hit test path for this mouse event transition. | - | ||||||||||||
| 165 | */ | - | ||||||||||||
| 166 | QPainterPath QBasicMouseEventTransition::hitTestPath() const | - | ||||||||||||
| 167 | { | - | ||||||||||||
| 168 | Q_D(const QBasicMouseEventTransition); | - | ||||||||||||
| 169 | return d->path; never executed: return d->path; | 0 | ||||||||||||
| 170 | } | - | ||||||||||||
| 171 | - | |||||||||||||
| 172 | /*! | - | ||||||||||||
| 173 | Sets the hit test path for this mouse event transition. | - | ||||||||||||
| 174 | */ | - | ||||||||||||
| 175 | void QBasicMouseEventTransition::setHitTestPath(const QPainterPath &path) | - | ||||||||||||
| 176 | { | - | ||||||||||||
| 177 | Q_D(QBasicMouseEventTransition); | - | ||||||||||||
| 178 | d->path = path; | - | ||||||||||||
| 179 | } never executed: end of block | 0 | ||||||||||||
| 180 | - | |||||||||||||
| 181 | /*! | - | ||||||||||||
| 182 | \reimp | - | ||||||||||||
| 183 | */ | - | ||||||||||||
| 184 | bool QBasicMouseEventTransition::eventTest(QEvent *event) | - | ||||||||||||
| 185 | { | - | ||||||||||||
| 186 | Q_D(const QBasicMouseEventTransition); | - | ||||||||||||
| 187 | if (event->type() == d->eventType) {
| 0 | ||||||||||||
| 188 | QMouseEvent *me = static_cast<QMouseEvent*>(event); | - | ||||||||||||
| 189 | return (me->button() == d->button) never executed: return (me->button() == d->button) && ((me->modifiers() & d->modifierMask) == d->modifierMask) && (d->path.isEmpty() || d->path.contains(me->pos()));
| 0 | ||||||||||||
| 190 | && ((me->modifiers() & d->modifierMask) == d->modifierMask) never executed: return (me->button() == d->button) && ((me->modifiers() & d->modifierMask) == d->modifierMask) && (d->path.isEmpty() || d->path.contains(me->pos()));
| 0 | ||||||||||||
| 191 | && (d->path.isEmpty() || d->path.contains(me->pos())); never executed: return (me->button() == d->button) && ((me->modifiers() & d->modifierMask) == d->modifierMask) && (d->path.isEmpty() || d->path.contains(me->pos()));
| 0 | ||||||||||||
| 192 | } | - | ||||||||||||
| 193 | return false; never executed: return false; | 0 | ||||||||||||
| 194 | } | - | ||||||||||||
| 195 | - | |||||||||||||
| 196 | /*! | - | ||||||||||||
| 197 | \reimp | - | ||||||||||||
| 198 | */ | - | ||||||||||||
| 199 | void QBasicMouseEventTransition::onTransition(QEvent *) | - | ||||||||||||
| 200 | { | - | ||||||||||||
| 201 | } | - | ||||||||||||
| 202 | - | |||||||||||||
| 203 | QT_END_NAMESPACE | - | ||||||||||||
| 204 | - | |||||||||||||
| 205 | #include "moc_qbasicmouseeventtransition_p.cpp" | - | ||||||||||||
| 206 | - | |||||||||||||
| 207 | #endif //QT_NO_STATEMACHINE | - | ||||||||||||
| Source code | Switch to Preprocessed file |