| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 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 Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/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 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | #include <QtCore/qpropertyanimation.h> | - |
| 43 | #include <QtWidgets/qwidget.h> | - |
| 44 | #include <private/qmainwindowlayout_p.h> | - |
| 45 | | - |
| 46 | #include "qwidgetanimator_p.h" | - |
| 47 | | - |
| 48 | QT_BEGIN_NAMESPACE | - |
| 49 | | - |
| 50 | QWidgetAnimator::QWidgetAnimator(QMainWindowLayout *layout) : m_mainWindowLayout(layout) | - |
| 51 | { | - |
| 52 | } executed: }Execution Count:44 | 44 |
| 53 | | - |
| 54 | void QWidgetAnimator::abort(QWidget *w) | - |
| 55 | { | - |
| 56 | #ifndef QT_NO_ANIMATION | - |
| 57 | AnimationMap::iterator it = m_animation_map.find(w); executed (the execution status of this line is deduced): AnimationMap::iterator it = m_animation_map.find(w); | - |
| 58 | if (it == m_animation_map.end()) evaluated: it == m_animation_map.end()| yes Evaluation Count:22 | yes Evaluation Count:220 |
| 22-220 |
| 59 | return; executed: return;Execution Count:22 | 22 |
| 60 | QPropertyAnimation *anim = *it; executed (the execution status of this line is deduced): QPropertyAnimation *anim = *it; | - |
| 61 | m_animation_map.erase(it); executed (the execution status of this line is deduced): m_animation_map.erase(it); | - |
| 62 | if (anim) { partially evaluated: anim| yes Evaluation Count:220 | no Evaluation Count:0 |
| 0-220 |
| 63 | anim->stop(); executed (the execution status of this line is deduced): anim->stop(); | - |
| 64 | } executed: }Execution Count:220 | 220 |
| 65 | #ifndef QT_NO_MAINWINDOW | - |
| 66 | m_mainWindowLayout->animationFinished(w); executed (the execution status of this line is deduced): m_mainWindowLayout->animationFinished(w); | - |
| 67 | #endif | - |
| 68 | #else | - |
| 69 | Q_UNUSED(w); //there is no animation to abort | - |
| 70 | #endif //QT_NO_ANIMATION | - |
| 71 | } executed: }Execution Count:220 | 220 |
| 72 | | - |
| 73 | #ifndef QT_NO_ANIMATION | - |
| 74 | void QWidgetAnimator::animationFinished() | - |
| 75 | { | - |
| 76 | QPropertyAnimation *anim = qobject_cast<QPropertyAnimation*>(sender()); executed (the execution status of this line is deduced): QPropertyAnimation *anim = qobject_cast<QPropertyAnimation*>(sender()); | - |
| 77 | abort(static_cast<QWidget*>(anim->targetObject())); executed: abort(static_cast<QWidget*>(anim->targetObject()));Execution Count:220 | 220 |
| 78 | } | - |
| 79 | #endif //QT_NO_ANIMATION | - |
| 80 | | - |
| 81 | void QWidgetAnimator::animate(QWidget *widget, const QRect &_final_geometry, bool animate) | - |
| 82 | { | - |
| 83 | QRect r = widget->geometry(); executed (the execution status of this line is deduced): QRect r = widget->geometry(); | - |
| 84 | if (r.right() < 0 || r.bottom() < 0) evaluated: r.right() < 0| yes Evaluation Count:19 | yes Evaluation Count:201 |
partially evaluated: r.bottom() < 0| no Evaluation Count:0 | yes Evaluation Count:201 |
| 0-201 |
| 85 | r = QRect(); executed: r = QRect();Execution Count:19 | 19 |
| 86 | | - |
| 87 | animate = animate && !r.isNull() && !_final_geometry.isNull(); partially evaluated: animate| no Evaluation Count:0 | yes Evaluation Count:220 |
never evaluated: !r.isNull() never evaluated: !_final_geometry.isNull() | 0-220 |
| 88 | | - |
| 89 | // might make the wigdet go away by sending it to negative space | - |
| 90 | const QRect final_geometry = _final_geometry.isValid() || widget->isWindow() ? _final_geometry : evaluated: _final_geometry.isValid()| yes Evaluation Count:197 | yes Evaluation Count:23 |
partially evaluated: widget->isWindow()| no Evaluation Count:0 | yes Evaluation Count:23 |
| 0-197 |
| 91 | QRect(QPoint(-500 - widget->width(), -500 - widget->height()), widget->size()); executed (the execution status of this line is deduced): QRect(QPoint(-500 - widget->width(), -500 - widget->height()), widget->size()); | - |
| 92 | | - |
| 93 | #ifndef QT_NO_ANIMATION | - |
| 94 | AnimationMap::const_iterator it = m_animation_map.constFind(widget); executed (the execution status of this line is deduced): AnimationMap::const_iterator it = m_animation_map.constFind(widget); | - |
| 95 | if (it != m_animation_map.constEnd() && (*it)->endValue().toRect() == final_geometry) partially evaluated: it != m_animation_map.constEnd()| no Evaluation Count:0 | yes Evaluation Count:220 |
never evaluated: (*it)->endValue().toRect() == final_geometry | 0-220 |
| 96 | return; | 0 |
| 97 | | - |
| 98 | QPropertyAnimation *anim = new QPropertyAnimation(widget, "geometry", widget); executed (the execution status of this line is deduced): QPropertyAnimation *anim = new QPropertyAnimation(widget, "geometry", widget); | - |
| 99 | anim->setDuration(animate ? 200 : 0); executed (the execution status of this line is deduced): anim->setDuration(animate ? 200 : 0); | - |
| 100 | anim->setEasingCurve(QEasingCurve::InOutQuad); executed (the execution status of this line is deduced): anim->setEasingCurve(QEasingCurve::InOutQuad); | - |
| 101 | anim->setEndValue(final_geometry); executed (the execution status of this line is deduced): anim->setEndValue(final_geometry); | - |
| 102 | m_animation_map[widget] = anim; executed (the execution status of this line is deduced): m_animation_map[widget] = anim; | - |
| 103 | connect(anim, SIGNAL(finished()), SLOT(animationFinished())); executed (the execution status of this line is deduced): connect(anim, "2""finished()", "1""animationFinished()"); | - |
| 104 | anim->start(QPropertyAnimation::DeleteWhenStopped); executed (the execution status of this line is deduced): anim->start(QPropertyAnimation::DeleteWhenStopped); | - |
| 105 | #else | - |
| 106 | //we do it in one shot | - |
| 107 | widget->setGeometry(final_geometry); | - |
| 108 | #ifndef QT_NO_MAINWINDOW | - |
| 109 | m_mainWindowLayout->animationFinished(widget); | - |
| 110 | #endif //QT_NO_MAINWINDOW | - |
| 111 | #endif //QT_NO_ANIMATION | - |
| 112 | } executed: }Execution Count:220 | 220 |
| 113 | | - |
| 114 | bool QWidgetAnimator::animating() const | - |
| 115 | { | - |
| 116 | return !m_animation_map.isEmpty(); executed: return !m_animation_map.isEmpty();Execution Count:440 | 440 |
| 117 | } | - |
| 118 | | - |
| 119 | QT_END_NAMESPACE | - |
| 120 | | - |
| | |