| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickpathview.cpp | 
| Source code | Switch to Preprocessed file | 
| Line | Source | Count | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||||||||||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||||||||||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||||||||||||||
| 5 | ** | - | ||||||||||||||||||||||||||||||
| 6 | ** This file is part of the QtQuick 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 The Qt Company. For licensing terms | - | ||||||||||||||||||||||||||||||
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||||||||
| 15 | ** information use the contact form at https://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 3 as published by the Free Software | - | ||||||||||||||||||||||||||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||||||||||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||||||||||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||||||||||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||||||||||||||
| 24 | ** | - | ||||||||||||||||||||||||||||||
| 25 | ** GNU General Public License Usage | - | ||||||||||||||||||||||||||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||||||||||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||||||||||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||||||||||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||||||||||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||||||||||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||||||||||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||||||||||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||||||||||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||||||||||||||
| 35 | ** | - | ||||||||||||||||||||||||||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||||||||
| 37 | ** | - | ||||||||||||||||||||||||||||||
| 38 | ****************************************************************************/ | - | ||||||||||||||||||||||||||||||
| 39 | - | |||||||||||||||||||||||||||||||
| 40 | #include "qquickpathview_p.h" | - | ||||||||||||||||||||||||||||||
| 41 | #include "qquickpathview_p_p.h" | - | ||||||||||||||||||||||||||||||
| 42 | #include "qquickwindow.h" | - | ||||||||||||||||||||||||||||||
| 43 | #include "qquickflickablebehavior_p.h" //Contains flicking behavior defines | - | ||||||||||||||||||||||||||||||
| 44 | #include "qquicktext_p.h" | - | ||||||||||||||||||||||||||||||
| 45 | - | |||||||||||||||||||||||||||||||
| 46 | #include <QtQuick/private/qquickstate_p.h> | - | ||||||||||||||||||||||||||||||
| 47 | #include <private/qqmlglobal_p.h> | - | ||||||||||||||||||||||||||||||
| 48 | #include <private/qqmlopenmetaobject_p.h> | - | ||||||||||||||||||||||||||||||
| 49 | #include <private/qqmlchangeset_p.h> | - | ||||||||||||||||||||||||||||||
| 50 | - | |||||||||||||||||||||||||||||||
| 51 | #include <QtQml/qqmlinfo.h> | - | ||||||||||||||||||||||||||||||
| 52 | #include <QtGui/qevent.h> | - | ||||||||||||||||||||||||||||||
| 53 | #include <QtGui/qevent.h> | - | ||||||||||||||||||||||||||||||
| 54 | #include <QtGui/qguiapplication.h> | - | ||||||||||||||||||||||||||||||
| 55 | #include <QtGui/qstylehints.h> | - | ||||||||||||||||||||||||||||||
| 56 | #include <QtCore/qmath.h> | - | ||||||||||||||||||||||||||||||
| 57 | - | |||||||||||||||||||||||||||||||
| 58 | #include <cmath> | - | ||||||||||||||||||||||||||||||
| 59 | - | |||||||||||||||||||||||||||||||
| 60 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||||||||
| 61 | - | |||||||||||||||||||||||||||||||
| 62 | Q_DECLARE_LOGGING_CATEGORY(lcItemViewDelegateLifecycle) | - | ||||||||||||||||||||||||||||||
| 63 | - | |||||||||||||||||||||||||||||||
| 64 | const qreal MinimumFlickVelocity = 75.0; | - | ||||||||||||||||||||||||||||||
| 65 | - | |||||||||||||||||||||||||||||||
| 66 | static QQmlOpenMetaObjectType *qPathViewAttachedType = nullptr; | - | ||||||||||||||||||||||||||||||
| 67 | - | |||||||||||||||||||||||||||||||
| 68 | QQuickPathViewAttached::QQuickPathViewAttached(QObject *parent) | - | ||||||||||||||||||||||||||||||
| 69 | : QObject(parent), m_percent(-1), m_view(nullptr), m_onPath(false), m_isCurrent(false) | - | ||||||||||||||||||||||||||||||
| 70 | { | - | ||||||||||||||||||||||||||||||
| 71 |     if (qPathViewAttachedType) {
  | 1450-1888 | ||||||||||||||||||||||||||||||
| 72 | m_metaobject = new QQmlOpenMetaObject(this, qPathViewAttachedType); | - | ||||||||||||||||||||||||||||||
| 73 | m_metaobject->setCached(true); | - | ||||||||||||||||||||||||||||||
| 74 |     } else { executed 1888 times by 3 tests:  end of blockExecuted by: 
  | 1888 | ||||||||||||||||||||||||||||||
| 75 | m_metaobject = new QQmlOpenMetaObject(this); | - | ||||||||||||||||||||||||||||||
| 76 |     } executed 1450 times by 2 tests:  end of blockExecuted by: 
  | 1450 | ||||||||||||||||||||||||||||||
| 77 | } | - | ||||||||||||||||||||||||||||||
| 78 | - | |||||||||||||||||||||||||||||||
| 79 | QQuickPathViewAttached::~QQuickPathViewAttached() | - | ||||||||||||||||||||||||||||||
| 80 | { | - | ||||||||||||||||||||||||||||||
| 81 | } | - | ||||||||||||||||||||||||||||||
| 82 | - | |||||||||||||||||||||||||||||||
| 83 | QVariant QQuickPathViewAttached::value(const QByteArray &name) const | - | ||||||||||||||||||||||||||||||
| 84 | { | - | ||||||||||||||||||||||||||||||
| 85 |     return m_metaobject->value(name); never executed:  return m_metaobject->value(name); | 0 | ||||||||||||||||||||||||||||||
| 86 | } | - | ||||||||||||||||||||||||||||||
| 87 | void QQuickPathViewAttached::setValue(const QByteArray &name, const QVariant &val) | - | ||||||||||||||||||||||||||||||
| 88 | { | - | ||||||||||||||||||||||||||||||
| 89 | m_metaobject->setValue(name, val); | - | ||||||||||||||||||||||||||||||
| 90 | } executed 5154 times by 2 tests:  end of blockExecuted by: 
  | 5154 | ||||||||||||||||||||||||||||||
| 91 | - | |||||||||||||||||||||||||||||||
| 92 | QQuickPathViewPrivate::QQuickPathViewPrivate() | - | ||||||||||||||||||||||||||||||
| 93 | : path(nullptr), currentIndex(0), currentItemOffset(0.0), startPc(0) | - | ||||||||||||||||||||||||||||||
| 94 | , offset(0.0), offsetAdj(0.0), mappedRange(1.0), mappedCache(0.0) | - | ||||||||||||||||||||||||||||||
| 95 | , stealMouse(false), ownModel(false), interactive(true), haveHighlightRange(true) | - | ||||||||||||||||||||||||||||||
| 96 | , autoHighlight(true), highlightUp(false), layoutScheduled(false) | - | ||||||||||||||||||||||||||||||
| 97 | , moving(false), flicking(false), dragging(false), inRequest(false), delegateValidated(false) | - | ||||||||||||||||||||||||||||||
| 98 | , inRefill(false) | - | ||||||||||||||||||||||||||||||
| 99 | , dragMargin(0), deceleration(100), maximumFlickVelocity(QML_FLICK_DEFAULTMAXVELOCITY) | - | ||||||||||||||||||||||||||||||
| 100 | , moveOffset(this, &QQuickPathViewPrivate::setAdjustedOffset), flickDuration(0) | - | ||||||||||||||||||||||||||||||
| 101 | , pathItems(-1), requestedIndex(-1), cacheSize(0), requestedZ(0) | - | ||||||||||||||||||||||||||||||
| 102 | , moveReason(Other), movementDirection(QQuickPathView::Shortest), moveDirection(QQuickPathView::Shortest) | - | ||||||||||||||||||||||||||||||
| 103 | , attType(nullptr), highlightComponent(nullptr), highlightItem(nullptr) | - | ||||||||||||||||||||||||||||||
| 104 | , moveHighlight(this, &QQuickPathViewPrivate::setHighlightPosition) | - | ||||||||||||||||||||||||||||||
| 105 | , highlightPosition(0) | - | ||||||||||||||||||||||||||||||
| 106 | , highlightRangeStart(0), highlightRangeEnd(0) | - | ||||||||||||||||||||||||||||||
| 107 | , highlightRangeMode(QQuickPathView::StrictlyEnforceRange) | - | ||||||||||||||||||||||||||||||
| 108 | , highlightMoveDuration(300), modelCount(0), snapMode(QQuickPathView::NoSnap) | - | ||||||||||||||||||||||||||||||
| 109 | { | - | ||||||||||||||||||||||||||||||
| 110 | } executed 282 times by 3 tests:  end of blockExecuted by: 
  | 282 | ||||||||||||||||||||||||||||||
| 111 | - | |||||||||||||||||||||||||||||||
| 112 | void QQuickPathViewPrivate::init() | - | ||||||||||||||||||||||||||||||
| 113 | { | - | ||||||||||||||||||||||||||||||
| 114 | Q_Q(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 115 | offset = 0; | - | ||||||||||||||||||||||||||||||
| 116 | q->setAcceptedMouseButtons(Qt::LeftButton); | - | ||||||||||||||||||||||||||||||
| 117 | q->setFlag(QQuickItem::ItemIsFocusScope); | - | ||||||||||||||||||||||||||||||
| 118 | q->setFiltersChildMouseEvents(true); | - | ||||||||||||||||||||||||||||||
| 119 |     qmlobject_connect(&tl, QQuickTimeLine, SIGNAL(updated()), executed 6 times by 3 tests:  end of blockExecuted by: 
 executed 6 times by 3 tests:  methodIdx = QQuickPathView::staticMetaObject.indexOfSlot(method+1);Executed by: 
 never executed:  methodIdx = QQuickPathView::staticMetaObject.indexOfSignal(method+1);
 
 
  | 0-276 | ||||||||||||||||||||||||||||||
| 120 | q, QQuickPathView, SLOT(ticked())) | - | ||||||||||||||||||||||||||||||
| 121 | timer.invalidate(); | - | ||||||||||||||||||||||||||||||
| 122 |     qmlobject_connect(&tl, QQuickTimeLine, SIGNAL(completed()), executed 6 times by 3 tests:  end of blockExecuted by: 
 executed 6 times by 3 tests:  methodIdx = QQuickPathView::staticMetaObject.indexOfSlot(method+1);Executed by: 
 never executed:  methodIdx = QQuickPathView::staticMetaObject.indexOfSignal(method+1);
 
 
  | 0-276 | ||||||||||||||||||||||||||||||
| 123 | q, QQuickPathView, SLOT(movementEnding())) | - | ||||||||||||||||||||||||||||||
| 124 | } executed 282 times by 3 tests:  end of blockExecuted by: 
  | 282 | ||||||||||||||||||||||||||||||
| 125 | - | |||||||||||||||||||||||||||||||
| 126 | QQuickItem *QQuickPathViewPrivate::getItem(int modelIndex, qreal z, bool async) | - | ||||||||||||||||||||||||||||||
| 127 | { | - | ||||||||||||||||||||||||||||||
| 128 | Q_Q(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 129 | requestedIndex = modelIndex; | - | ||||||||||||||||||||||||||||||
| 130 | requestedZ = z; | - | ||||||||||||||||||||||||||||||
| 131 | inRequest = true; | - | ||||||||||||||||||||||||||||||
| 132 | QObject *object = model->object(modelIndex, async ? QQmlIncubator::Asynchronous : QQmlIncubator::AsynchronousIfNested); | - | ||||||||||||||||||||||||||||||
| 133 | QQuickItem *item = qmlobject_cast<QQuickItem*>(object); | - | ||||||||||||||||||||||||||||||
| 134 |     if (!item) {
  | 30-4393 | ||||||||||||||||||||||||||||||
| 135 |         if (object) {
  | 0-30 | ||||||||||||||||||||||||||||||
| 136 | model->release(object); | - | ||||||||||||||||||||||||||||||
| 137 |             if (!delegateValidated) {
  | 0 | ||||||||||||||||||||||||||||||
| 138 | delegateValidated = true; | - | ||||||||||||||||||||||||||||||
| 139 | QObject* delegate = q->delegate(); | - | ||||||||||||||||||||||||||||||
| 140 | qmlWarning(delegate ? delegate : q) << QQuickPathView::tr("Delegate must be of Item type"); | - | ||||||||||||||||||||||||||||||
| 141 |             } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 142 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 143 |     } else { executed 30 times by 1 test:  end of blockExecuted by: 
  | 30 | ||||||||||||||||||||||||||||||
| 144 | item->setParentItem(q); | - | ||||||||||||||||||||||||||||||
| 145 | requestedIndex = -1; | - | ||||||||||||||||||||||||||||||
| 146 | QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item); | - | ||||||||||||||||||||||||||||||
| 147 | itemPrivate->addItemChangeListener(this, QQuickItemPrivate::Geometry); | - | ||||||||||||||||||||||||||||||
| 148 |     } executed 4393 times by 3 tests:  end of blockExecuted by: 
  | 4393 | ||||||||||||||||||||||||||||||
| 149 | inRequest = false; | - | ||||||||||||||||||||||||||||||
| 150 |     return item; executed 4423 times by 3 tests:  return item;Executed by: 
  | 4423 | ||||||||||||||||||||||||||||||
| 151 | } | - | ||||||||||||||||||||||||||||||
| 152 | - | |||||||||||||||||||||||||||||||
| 153 | void QQuickPathView::createdItem(int index, QObject *object) | - | ||||||||||||||||||||||||||||||
| 154 | { | - | ||||||||||||||||||||||||||||||
| 155 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 156 | QQuickItem *item = qmlobject_cast<QQuickItem*>(object); | - | ||||||||||||||||||||||||||||||
| 157 |     if (d->requestedIndex != index) {
  | 86-3264 | ||||||||||||||||||||||||||||||
| 158 | qPathViewAttachedType = d->attachedType(); | - | ||||||||||||||||||||||||||||||
| 159 | QQuickPathViewAttached *att = static_cast<QQuickPathViewAttached *>(qmlAttachedPropertiesObject<QQuickPathView>(item)); | - | ||||||||||||||||||||||||||||||
| 160 | qPathViewAttachedType = nullptr; | - | ||||||||||||||||||||||||||||||
| 161 |         if (att) {
  | 0-86 | ||||||||||||||||||||||||||||||
| 162 | att->m_view = this; | - | ||||||||||||||||||||||||||||||
| 163 | att->setOnPath(false); | - | ||||||||||||||||||||||||||||||
| 164 |         } executed 86 times by 2 tests:  end of blockExecuted by: 
  | 86 | ||||||||||||||||||||||||||||||
| 165 | item->setParentItem(this); | - | ||||||||||||||||||||||||||||||
| 166 | d->updateItem(item, 1.0); | - | ||||||||||||||||||||||||||||||
| 167 |     } else { executed 86 times by 2 tests:  end of blockExecuted by: 
  | 86 | ||||||||||||||||||||||||||||||
| 168 | d->requestedIndex = -1; | - | ||||||||||||||||||||||||||||||
| 169 |         if (!d->inRequest)
  | 30-3234 | ||||||||||||||||||||||||||||||
| 170 |             refill(); executed 30 times by 1 test:  refill();Executed by: 
  | 30 | ||||||||||||||||||||||||||||||
| 171 |     } executed 3264 times by 3 tests:  end of blockExecuted by: 
  | 3264 | ||||||||||||||||||||||||||||||
| 172 | } | - | ||||||||||||||||||||||||||||||
| 173 | - | |||||||||||||||||||||||||||||||
| 174 | void QQuickPathView::initItem(int index, QObject *object) | - | ||||||||||||||||||||||||||||||
| 175 | { | - | ||||||||||||||||||||||||||||||
| 176 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 177 | QQuickItem *item = qmlobject_cast<QQuickItem*>(object); | - | ||||||||||||||||||||||||||||||
| 178 |     if (item && d->requestedIndex == index) {
 
  | 0-3350 | ||||||||||||||||||||||||||||||
| 179 | QQuickItemPrivate::get(item)->setCulled(true); | - | ||||||||||||||||||||||||||||||
| 180 | item->setParentItem(this); | - | ||||||||||||||||||||||||||||||
| 181 | qPathViewAttachedType = d->attachedType(); | - | ||||||||||||||||||||||||||||||
| 182 | QQuickPathViewAttached *att = static_cast<QQuickPathViewAttached *>(qmlAttachedPropertiesObject<QQuickPathView>(item)); | - | ||||||||||||||||||||||||||||||
| 183 | qPathViewAttachedType = nullptr; | - | ||||||||||||||||||||||||||||||
| 184 |         if (att) {
  | 0-3264 | ||||||||||||||||||||||||||||||
| 185 | att->m_view = this; | - | ||||||||||||||||||||||||||||||
| 186 | qreal percent = d->positionOfIndex(index); | - | ||||||||||||||||||||||||||||||
| 187 |             if (percent < 1.0 && d->path) {
 
  | 2-3218 | ||||||||||||||||||||||||||||||
| 188 | const auto attributes = d->path->attributes(); | - | ||||||||||||||||||||||||||||||
| 189 | for (const QString &attr : attributes) | - | ||||||||||||||||||||||||||||||
| 190 |                     att->setValue(attr.toUtf8(), d->path->attributeAt(attr, percent)); executed 1710 times by 2 tests:  att->setValue(attr.toUtf8(), d->path->attributeAt(attr, percent));Executed by: 
  | 1710 | ||||||||||||||||||||||||||||||
| 191 | item->setZ(d->requestedZ); | - | ||||||||||||||||||||||||||||||
| 192 |             } executed 3216 times by 3 tests:  end of blockExecuted by: 
  | 3216 | ||||||||||||||||||||||||||||||
| 193 | att->setOnPath(percent < 1.0); | - | ||||||||||||||||||||||||||||||
| 194 |         } executed 3264 times by 3 tests:  end of blockExecuted by: 
  | 3264 | ||||||||||||||||||||||||||||||
| 195 |     } executed 3264 times by 3 tests:  end of blockExecuted by: 
  | 3264 | ||||||||||||||||||||||||||||||
| 196 | } executed 3350 times by 3 tests:  end of blockExecuted by: 
  | 3350 | ||||||||||||||||||||||||||||||
| 197 | - | |||||||||||||||||||||||||||||||
| 198 | void QQuickPathViewPrivate::releaseItem(QQuickItem *item) | - | ||||||||||||||||||||||||||||||
| 199 | { | - | ||||||||||||||||||||||||||||||
| 200 |     if (!item || !model)
 
  | 0-4381 | ||||||||||||||||||||||||||||||
| 201 |         return; executed 48 times by 1 test:  return;Executed by: 
  | 48 | ||||||||||||||||||||||||||||||
| 202 |     qCDebug(lcItemViewDelegateLifecycle) << "release" << item; never executed:  QMessageLogger(__FILE__, 202, __PRETTY_FUNCTION__, lcItemViewDelegateLifecycle().categoryName()).debug() << "release" << item;
  | 0-4333 | ||||||||||||||||||||||||||||||
| 203 | QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item); | - | ||||||||||||||||||||||||||||||
| 204 | itemPrivate->removeItemChangeListener(this, QQuickItemPrivate::Geometry); | - | ||||||||||||||||||||||||||||||
| 205 | QQmlInstanceModel::ReleaseFlags flags = model->release(item); | - | ||||||||||||||||||||||||||||||
| 206 |     if (!flags) {
  | 1979-2354 | ||||||||||||||||||||||||||||||
| 207 | // item was not destroyed, and we no longer reference it. | - | ||||||||||||||||||||||||||||||
| 208 |         if (QQuickPathViewAttached *att = attached(item))
  | 0-1979 | ||||||||||||||||||||||||||||||
| 209 |             att->setOnPath(false); executed 1979 times by 3 tests:  att->setOnPath(false);Executed by: 
  | 1979 | ||||||||||||||||||||||||||||||
| 210 |     } else if (flags & QQmlInstanceModel::Destroyed) { executed 1979 times by 3 tests:  end of blockExecuted by: 
 
  | 871-1979 | ||||||||||||||||||||||||||||||
| 211 | // but we still reference it | - | ||||||||||||||||||||||||||||||
| 212 | item->setParentItem(nullptr); | - | ||||||||||||||||||||||||||||||
| 213 |     } executed 1483 times by 1 test:  end of blockExecuted by: 
  | 1483 | ||||||||||||||||||||||||||||||
| 214 | } executed 4333 times by 3 tests:  end of blockExecuted by: 
  | 4333 | ||||||||||||||||||||||||||||||
| 215 | - | |||||||||||||||||||||||||||||||
| 216 | QQuickPathViewAttached *QQuickPathViewPrivate::attached(QQuickItem *item) | - | ||||||||||||||||||||||||||||||
| 217 | { | - | ||||||||||||||||||||||||||||||
| 218 |     return static_cast<QQuickPathViewAttached *>(qmlAttachedPropertiesObject<QQuickPathView>(item, false)); executed 53457 times by 3 tests:  return static_cast<QQuickPathViewAttached *>(qmlAttachedPropertiesObject<QQuickPathView>(item, false));Executed by: 
  | 53457 | ||||||||||||||||||||||||||||||
| 219 | } | - | ||||||||||||||||||||||||||||||
| 220 | - | |||||||||||||||||||||||||||||||
| 221 | QQmlOpenMetaObjectType *QQuickPathViewPrivate::attachedType() | - | ||||||||||||||||||||||||||||||
| 222 | { | - | ||||||||||||||||||||||||||||||
| 223 | Q_Q(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 224 |     if (!attType) {
  | 280-3070 | ||||||||||||||||||||||||||||||
| 225 | // pre-create one metatype to share with all attached objects | - | ||||||||||||||||||||||||||||||
| 226 | attType = new QQmlOpenMetaObjectType(&QQuickPathViewAttached::staticMetaObject, qmlEngine(q)); | - | ||||||||||||||||||||||||||||||
| 227 |         if (path) {
  | 2-278 | ||||||||||||||||||||||||||||||
| 228 | const auto attributes = path->attributes(); | - | ||||||||||||||||||||||||||||||
| 229 | for (const QString &attr : attributes) | - | ||||||||||||||||||||||||||||||
| 230 |                 attType->createProperty(attr.toUtf8()); executed 174 times by 2 tests:  attType->createProperty(attr.toUtf8());Executed by: 
  | 174 | ||||||||||||||||||||||||||||||
| 231 |         } executed 278 times by 3 tests:  end of blockExecuted by: 
  | 278 | ||||||||||||||||||||||||||||||
| 232 |     } executed 280 times by 3 tests:  end of blockExecuted by: 
  | 280 | ||||||||||||||||||||||||||||||
| 233 | - | |||||||||||||||||||||||||||||||
| 234 |     return attType; executed 3350 times by 3 tests:  return attType;Executed by: 
  | 3350 | ||||||||||||||||||||||||||||||
| 235 | } | - | ||||||||||||||||||||||||||||||
| 236 | - | |||||||||||||||||||||||||||||||
| 237 | void QQuickPathViewPrivate::clear() | - | ||||||||||||||||||||||||||||||
| 238 | { | - | ||||||||||||||||||||||||||||||
| 239 |     if (currentItem) {
  | 392-452 | ||||||||||||||||||||||||||||||
| 240 | releaseItem(currentItem); | - | ||||||||||||||||||||||||||||||
| 241 | currentItem = nullptr; | - | ||||||||||||||||||||||||||||||
| 242 |     } executed 392 times by 3 tests:  end of blockExecuted by: 
  | 392 | ||||||||||||||||||||||||||||||
| 243 | - | |||||||||||||||||||||||||||||||
| 244 | for (QQuickItem *p : qAsConst(items)) | - | ||||||||||||||||||||||||||||||
| 245 |         releaseItem(p); executed 1832 times by 3 tests:  releaseItem(p);Executed by: 
  | 1832 | ||||||||||||||||||||||||||||||
| 246 | - | |||||||||||||||||||||||||||||||
| 247 | for (QQuickItem *p : qAsConst(itemCache)) | - | ||||||||||||||||||||||||||||||
| 248 |         releaseItem(p); executed 787 times by 1 test:  releaseItem(p);Executed by: 
  | 787 | ||||||||||||||||||||||||||||||
| 249 | - | |||||||||||||||||||||||||||||||
| 250 |     if (requestedIndex >= 0) {
  | 0-844 | ||||||||||||||||||||||||||||||
| 251 |         if (model)
  | 0 | ||||||||||||||||||||||||||||||
| 252 |             model->cancel(requestedIndex); never executed:  model->cancel(requestedIndex); | 0 | ||||||||||||||||||||||||||||||
| 253 | requestedIndex = -1; | - | ||||||||||||||||||||||||||||||
| 254 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 255 | - | |||||||||||||||||||||||||||||||
| 256 | items.clear(); | - | ||||||||||||||||||||||||||||||
| 257 | itemCache.clear(); | - | ||||||||||||||||||||||||||||||
| 258 | tl.clear(); | - | ||||||||||||||||||||||||||||||
| 259 | } executed 844 times by 3 tests:  end of blockExecuted by: 
  | 844 | ||||||||||||||||||||||||||||||
| 260 | - | |||||||||||||||||||||||||||||||
| 261 | void QQuickPathViewPrivate::updateMappedRange() | - | ||||||||||||||||||||||||||||||
| 262 | { | - | ||||||||||||||||||||||||||||||
| 263 |     if (model && pathItems != -1 && pathItems < modelCount) {
 
  | 114-410 | ||||||||||||||||||||||||||||||
| 264 | mappedRange = qreal(modelCount)/pathItems; | - | ||||||||||||||||||||||||||||||
| 265 | mappedCache = qreal(cacheSize)/pathItems/2; // Half of cache at each end | - | ||||||||||||||||||||||||||||||
| 266 |     } else { executed 194 times by 2 tests:  end of blockExecuted by: 
  | 194 | ||||||||||||||||||||||||||||||
| 267 | mappedRange = 1.0; | - | ||||||||||||||||||||||||||||||
| 268 | mappedCache = 0.0; | - | ||||||||||||||||||||||||||||||
| 269 |     } executed 528 times by 3 tests:  end of blockExecuted by: 
  | 528 | ||||||||||||||||||||||||||||||
| 270 | } | - | ||||||||||||||||||||||||||||||
| 271 | - | |||||||||||||||||||||||||||||||
| 272 | qreal QQuickPathViewPrivate::positionOfIndex(qreal index) const | - | ||||||||||||||||||||||||||||||
| 273 | { | - | ||||||||||||||||||||||||||||||
| 274 | qreal pos = -1.0; | - | ||||||||||||||||||||||||||||||
| 275 | - | |||||||||||||||||||||||||||||||
| 276 |     if (model && index >= 0 && index < modelCount) {
 
  | 0-51273 | ||||||||||||||||||||||||||||||
| 277 | qreal start = 0.0; | - | ||||||||||||||||||||||||||||||
| 278 |         if (haveHighlightRange && (highlightRangeMode != QQuickPathView::NoHighlightRange
 
  | 122-51151 | ||||||||||||||||||||||||||||||
| 279 |                                    || snapMode != QQuickPathView::NoSnap))
  | 762-2642 | ||||||||||||||||||||||||||||||
| 280 |             start = highlightRangeStart; executed 48509 times by 3 tests:  start = highlightRangeStart;Executed by: 
  | 48509 | ||||||||||||||||||||||||||||||
| 281 | qreal globalPos = index + offset; | - | ||||||||||||||||||||||||||||||
| 282 | globalPos = std::fmod(globalPos, qreal(modelCount)) / modelCount; | - | ||||||||||||||||||||||||||||||
| 283 |         if (pathItems != -1 && pathItems < modelCount) {
 
  | 204-33188 | ||||||||||||||||||||||||||||||
| 284 | globalPos += start / mappedRange; | - | ||||||||||||||||||||||||||||||
| 285 | globalPos = std::fmod(globalPos, qreal(1.0)); | - | ||||||||||||||||||||||||||||||
| 286 | pos = globalPos * mappedRange; | - | ||||||||||||||||||||||||||||||
| 287 |         } else { executed 32984 times by 2 tests:  end of blockExecuted by: 
  | 32984 | ||||||||||||||||||||||||||||||
| 288 | pos = std::fmod(globalPos + start, qreal(1.0)); | - | ||||||||||||||||||||||||||||||
| 289 |         } executed 18289 times by 3 tests:  end of blockExecuted by: 
  | 18289 | ||||||||||||||||||||||||||||||
| 290 | } | - | ||||||||||||||||||||||||||||||
| 291 | - | |||||||||||||||||||||||||||||||
| 292 |     return pos; executed 51273 times by 3 tests:  return pos;Executed by: 
  | 51273 | ||||||||||||||||||||||||||||||
| 293 | } | - | ||||||||||||||||||||||||||||||
| 294 | - | |||||||||||||||||||||||||||||||
| 295 | // returns true if position is between lower and upper, taking into | - | ||||||||||||||||||||||||||||||
| 296 | // account the circular space. | - | ||||||||||||||||||||||||||||||
| 297 | bool QQuickPathViewPrivate::isInBound(qreal position, qreal lower, qreal upper) const | - | ||||||||||||||||||||||||||||||
| 298 | { | - | ||||||||||||||||||||||||||||||
| 299 |     if (lower == upper)
  | 80-5522 | ||||||||||||||||||||||||||||||
| 300 |         return true; executed 80 times by 1 test:  return true;Executed by: 
  | 80 | ||||||||||||||||||||||||||||||
| 301 |     if (lower > upper) {
  | 1932-3590 | ||||||||||||||||||||||||||||||
| 302 |         if (position > upper && position > lower)
 
  | 18-1313 | ||||||||||||||||||||||||||||||
| 303 |             position -= mappedRange; executed 18 times by 1 test:  position -= mappedRange;Executed by: 
  | 18 | ||||||||||||||||||||||||||||||
| 304 | lower -= mappedRange; | - | ||||||||||||||||||||||||||||||
| 305 |     } executed 1932 times by 3 tests:  end of blockExecuted by: 
  | 1932 | ||||||||||||||||||||||||||||||
| 306 |     return position >= lower && position < upper; executed 5522 times by 3 tests:  return position >= lower && position < upper;Executed by: 
  | 5522 | ||||||||||||||||||||||||||||||
| 307 | } | - | ||||||||||||||||||||||||||||||
| 308 | - | |||||||||||||||||||||||||||||||
| 309 | void QQuickPathViewPrivate::createHighlight() | - | ||||||||||||||||||||||||||||||
| 310 | { | - | ||||||||||||||||||||||||||||||
| 311 | Q_Q(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 312 |     if (!q->isComponentComplete())
  | 116-282 | ||||||||||||||||||||||||||||||
| 313 |         return; executed 116 times by 2 tests:  return;Executed by: 
  | 116 | ||||||||||||||||||||||||||||||
| 314 | - | |||||||||||||||||||||||||||||||
| 315 | bool changed = false; | - | ||||||||||||||||||||||||||||||
| 316 |     if (highlightItem) {
  | 0-282 | ||||||||||||||||||||||||||||||
| 317 | highlightItem->setParentItem(nullptr); | - | ||||||||||||||||||||||||||||||
| 318 | highlightItem->deleteLater(); | - | ||||||||||||||||||||||||||||||
| 319 | highlightItem = nullptr; | - | ||||||||||||||||||||||||||||||
| 320 | changed = true; | - | ||||||||||||||||||||||||||||||
| 321 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 322 | - | |||||||||||||||||||||||||||||||
| 323 | QQuickItem *item = nullptr; | - | ||||||||||||||||||||||||||||||
| 324 |     if (highlightComponent) {
  | 116-166 | ||||||||||||||||||||||||||||||
| 325 | QQmlContext *creationContext = highlightComponent->creationContext(); | - | ||||||||||||||||||||||||||||||
| 326 | QQmlContext *highlightContext = new QQmlContext( | - | ||||||||||||||||||||||||||||||
| 327 | creationContext ? creationContext : qmlContext(q)); | - | ||||||||||||||||||||||||||||||
| 328 | QObject *nobj = highlightComponent->create(highlightContext); | - | ||||||||||||||||||||||||||||||
| 329 |         if (nobj) {
  | 0-116 | ||||||||||||||||||||||||||||||
| 330 | QQml_setParent_noEvent(highlightContext, nobj); | - | ||||||||||||||||||||||||||||||
| 331 | item = qobject_cast<QQuickItem *>(nobj); | - | ||||||||||||||||||||||||||||||
| 332 |             if (!item)
  | 0-116 | ||||||||||||||||||||||||||||||
| 333 |                 delete nobj; never executed:  delete nobj; | 0 | ||||||||||||||||||||||||||||||
| 334 |         } else { executed 116 times by 2 tests:  end of blockExecuted by: 
  | 116 | ||||||||||||||||||||||||||||||
| 335 | delete highlightContext; | - | ||||||||||||||||||||||||||||||
| 336 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 337 | } else { | - | ||||||||||||||||||||||||||||||
| 338 | item = new QQuickItem; | - | ||||||||||||||||||||||||||||||
| 339 |     } executed 166 times by 3 tests:  end of blockExecuted by: 
  | 166 | ||||||||||||||||||||||||||||||
| 340 |     if (item) {
  | 0-282 | ||||||||||||||||||||||||||||||
| 341 | QQml_setParent_noEvent(item, q); | - | ||||||||||||||||||||||||||||||
| 342 | item->setParentItem(q); | - | ||||||||||||||||||||||||||||||
| 343 | highlightItem = item; | - | ||||||||||||||||||||||||||||||
| 344 | changed = true; | - | ||||||||||||||||||||||||||||||
| 345 |     } executed 282 times by 3 tests:  end of blockExecuted by: 
  | 282 | ||||||||||||||||||||||||||||||
| 346 |     if (changed)
  | 0-282 | ||||||||||||||||||||||||||||||
| 347 |         emit q->highlightItemChanged(); executed 282 times by 3 tests:  q->highlightItemChanged();Executed by: 
  | 282 | ||||||||||||||||||||||||||||||
| 348 | } executed 282 times by 3 tests:  end of blockExecuted by: 
  | 282 | ||||||||||||||||||||||||||||||
| 349 | - | |||||||||||||||||||||||||||||||
| 350 | void QQuickPathViewPrivate::updateHighlight() | - | ||||||||||||||||||||||||||||||
| 351 | { | - | ||||||||||||||||||||||||||||||
| 352 | Q_Q(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 353 |     if (!q->isComponentComplete() || !isValid())
 
  | 16-426 | ||||||||||||||||||||||||||||||
| 354 |         return; executed 132 times by 2 tests:  return;Executed by: 
  | 132 | ||||||||||||||||||||||||||||||
| 355 |     if (highlightItem) {
  | 0-410 | ||||||||||||||||||||||||||||||
| 356 |         if (haveHighlightRange && highlightRangeMode == QQuickPathView::StrictlyEnforceRange) {
 
  | 0-410 | ||||||||||||||||||||||||||||||
| 357 | updateItem(highlightItem, highlightRangeStart); | - | ||||||||||||||||||||||||||||||
| 358 |         } else { executed 334 times by 3 tests:  end of blockExecuted by: 
  | 334 | ||||||||||||||||||||||||||||||
| 359 | qreal target = currentIndex; | - | ||||||||||||||||||||||||||||||
| 360 | - | |||||||||||||||||||||||||||||||
| 361 | offsetAdj = 0.0; | - | ||||||||||||||||||||||||||||||
| 362 | tl.reset(moveHighlight); | - | ||||||||||||||||||||||||||||||
| 363 | moveHighlight.setValue(highlightPosition); | - | ||||||||||||||||||||||||||||||
| 364 | - | |||||||||||||||||||||||||||||||
| 365 | const int duration = highlightMoveDuration; | - | ||||||||||||||||||||||||||||||
| 366 | - | |||||||||||||||||||||||||||||||
| 367 |             if (target - highlightPosition > modelCount/2) {
  | 2-74 | ||||||||||||||||||||||||||||||
| 368 | highlightUp = false; | - | ||||||||||||||||||||||||||||||
| 369 | qreal distance = modelCount - target + highlightPosition; | - | ||||||||||||||||||||||||||||||
| 370 | tl.move(moveHighlight, 0.0, QEasingCurve(QEasingCurve::InQuad), int(duration * highlightPosition / distance)); | - | ||||||||||||||||||||||||||||||
| 371 | tl.set(moveHighlight, modelCount-0.01); | - | ||||||||||||||||||||||||||||||
| 372 | tl.move(moveHighlight, target, QEasingCurve(QEasingCurve::OutQuad), int(duration * (modelCount-target) / distance)); | - | ||||||||||||||||||||||||||||||
| 373 |             } else if (target - highlightPosition <= -modelCount/2) { executed 2 times by 1 test:  end of blockExecuted by: 
 
  | 2-72 | ||||||||||||||||||||||||||||||
| 374 | highlightUp = true; | - | ||||||||||||||||||||||||||||||
| 375 | qreal distance = modelCount - highlightPosition + target; | - | ||||||||||||||||||||||||||||||
| 376 | tl.move(moveHighlight, modelCount-0.01, QEasingCurve(QEasingCurve::InQuad), int(duration * (modelCount-highlightPosition) / distance)); | - | ||||||||||||||||||||||||||||||
| 377 | tl.set(moveHighlight, 0.0); | - | ||||||||||||||||||||||||||||||
| 378 | tl.move(moveHighlight, target, QEasingCurve(QEasingCurve::OutQuad), int(duration * target / distance)); | - | ||||||||||||||||||||||||||||||
| 379 |             } else { executed 2 times by 1 test:  end of blockExecuted by: 
  | 2 | ||||||||||||||||||||||||||||||
| 380 | highlightUp = highlightPosition - target < 0; | - | ||||||||||||||||||||||||||||||
| 381 | tl.move(moveHighlight, target, QEasingCurve(QEasingCurve::InOutQuad), duration); | - | ||||||||||||||||||||||||||||||
| 382 |             } executed 72 times by 1 test:  end of blockExecuted by: 
  | 72 | ||||||||||||||||||||||||||||||
| 383 | } | - | ||||||||||||||||||||||||||||||
| 384 | } | - | ||||||||||||||||||||||||||||||
| 385 | } executed 410 times by 3 tests:  end of blockExecuted by: 
  | 410 | ||||||||||||||||||||||||||||||
| 386 | - | |||||||||||||||||||||||||||||||
| 387 | void QQuickPathViewPrivate::setHighlightPosition(qreal pos) | - | ||||||||||||||||||||||||||||||
| 388 | { | - | ||||||||||||||||||||||||||||||
| 389 |     if (pos != highlightPosition) {
  | 2-76 | ||||||||||||||||||||||||||||||
| 390 | qreal start = 0.0; | - | ||||||||||||||||||||||||||||||
| 391 | qreal end = 1.0; | - | ||||||||||||||||||||||||||||||
| 392 |         if (haveHighlightRange && highlightRangeMode != QQuickPathView::NoHighlightRange) {
 
  | 0-2 | ||||||||||||||||||||||||||||||
| 393 | start = highlightRangeStart; | - | ||||||||||||||||||||||||||||||
| 394 | end = highlightRangeEnd; | - | ||||||||||||||||||||||||||||||
| 395 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 396 | - | |||||||||||||||||||||||||||||||
| 397 | qreal range = qreal(modelCount); | - | ||||||||||||||||||||||||||||||
| 398 | // calc normalized position of highlight relative to offset | - | ||||||||||||||||||||||||||||||
| 399 | qreal relativeHighlight = std::fmod(pos + offset, range) / range; | - | ||||||||||||||||||||||||||||||
| 400 | - | |||||||||||||||||||||||||||||||
| 401 |         if (!highlightUp && relativeHighlight > end / mappedRange) {
 
  | 0-2 | ||||||||||||||||||||||||||||||
| 402 | qreal diff = 1.0 - relativeHighlight; | - | ||||||||||||||||||||||||||||||
| 403 | setOffset(offset + diff * range); | - | ||||||||||||||||||||||||||||||
| 404 |         } else if (highlightUp && relativeHighlight >= (end - start) / mappedRange) { executed 2 times by 1 test:  end of blockExecuted by: 
 
 
  | 0-2 | ||||||||||||||||||||||||||||||
| 405 | qreal diff = relativeHighlight - (end - start) / mappedRange; | - | ||||||||||||||||||||||||||||||
| 406 | setOffset(offset - diff * range - 0.00001); | - | ||||||||||||||||||||||||||||||
| 407 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 408 | - | |||||||||||||||||||||||||||||||
| 409 | highlightPosition = pos; | - | ||||||||||||||||||||||||||||||
| 410 | qreal pathPos = positionOfIndex(pos); | - | ||||||||||||||||||||||||||||||
| 411 | updateItem(highlightItem, pathPos); | - | ||||||||||||||||||||||||||||||
| 412 |         if (QQuickPathViewAttached *att = attached(highlightItem))
  | 0-2 | ||||||||||||||||||||||||||||||
| 413 |             att->setOnPath(pathPos < 1.0); never executed:  att->setOnPath(pathPos < 1.0); | 0 | ||||||||||||||||||||||||||||||
| 414 |     } executed 2 times by 1 test:  end of blockExecuted by: 
  | 2 | ||||||||||||||||||||||||||||||
| 415 | } executed 78 times by 1 test:  end of blockExecuted by: 
  | 78 | ||||||||||||||||||||||||||||||
| 416 | - | |||||||||||||||||||||||||||||||
| 417 | void QQuickPathView::pathUpdated() | - | ||||||||||||||||||||||||||||||
| 418 | { | - | ||||||||||||||||||||||||||||||
| 419 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 420 | for (QQuickItem *item : qAsConst(d->items)) { | - | ||||||||||||||||||||||||||||||
| 421 |         if (QQuickPathViewAttached *att = d->attached(item))
  | 0-100 | ||||||||||||||||||||||||||||||
| 422 |             att->m_percent = -1; executed 100 times by 1 test:  att->m_percent = -1;Executed by: 
  | 100 | ||||||||||||||||||||||||||||||
| 423 |     } executed 100 times by 1 test:  end of blockExecuted by: 
  | 100 | ||||||||||||||||||||||||||||||
| 424 | refill(); | - | ||||||||||||||||||||||||||||||
| 425 | } executed 312 times by 3 tests:  end of blockExecuted by: 
  | 312 | ||||||||||||||||||||||||||||||
| 426 | - | |||||||||||||||||||||||||||||||
| 427 | void QQuickPathViewPrivate::updateItem(QQuickItem *item, qreal percent) | - | ||||||||||||||||||||||||||||||
| 428 | { | - | ||||||||||||||||||||||||||||||
| 429 |     if (!path)
  | 2-45324 | ||||||||||||||||||||||||||||||
| 430 |         return; executed 2 times by 1 test:  return;Executed by: 
  | 2 | ||||||||||||||||||||||||||||||
| 431 |     if (QQuickPathViewAttached *att = attached(item)) {
  | 4250-41074 | ||||||||||||||||||||||||||||||
| 432 |         if (qFuzzyCompare(att->m_percent, percent))
  | 309-40765 | ||||||||||||||||||||||||||||||
| 433 |             return; executed 309 times by 1 test:  return;Executed by: 
  | 309 | ||||||||||||||||||||||||||||||
| 434 | att->m_percent = percent; | - | ||||||||||||||||||||||||||||||
| 435 | const auto attributes = path->attributes(); | - | ||||||||||||||||||||||||||||||
| 436 | for (const QString &attr : attributes) | - | ||||||||||||||||||||||||||||||
| 437 |             att->setValue(attr.toUtf8(), path->attributeAt(attr, percent)); executed 3444 times by 2 tests:  att->setValue(attr.toUtf8(), path->attributeAt(attr, percent));Executed by: 
  | 3444 | ||||||||||||||||||||||||||||||
| 438 | att->setOnPath(percent < 1.0); | - | ||||||||||||||||||||||||||||||
| 439 |     } executed 40765 times by 3 tests:  end of blockExecuted by: 
  | 40765 | ||||||||||||||||||||||||||||||
| 440 | QQuickItemPrivate::get(item)->setCulled(percent >= 1.0); | - | ||||||||||||||||||||||||||||||
| 441 | QPointF pf = path->pointAt(qMin(percent, qreal(1.0))); | - | ||||||||||||||||||||||||||||||
| 442 | item->setX(pf.x() - item->width()/2); | - | ||||||||||||||||||||||||||||||
| 443 | item->setY(pf.y() - item->height()/2); | - | ||||||||||||||||||||||||||||||
| 444 | } executed 45015 times by 3 tests:  end of blockExecuted by: 
  | 45015 | ||||||||||||||||||||||||||||||
| 445 | - | |||||||||||||||||||||||||||||||
| 446 | void QQuickPathViewPrivate::regenerate() | - | ||||||||||||||||||||||||||||||
| 447 | { | - | ||||||||||||||||||||||||||||||
| 448 | Q_Q(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 449 |     if (!q->isComponentComplete())
  | 430-542 | ||||||||||||||||||||||||||||||
| 450 |         return; executed 542 times by 3 tests:  return;Executed by: 
  | 542 | ||||||||||||||||||||||||||||||
| 451 | - | |||||||||||||||||||||||||||||||
| 452 | clear(); | - | ||||||||||||||||||||||||||||||
| 453 | - | |||||||||||||||||||||||||||||||
| 454 |     if (!isValid())
  | 20-410 | ||||||||||||||||||||||||||||||
| 455 |         return; executed 20 times by 2 tests:  return;Executed by: 
  | 20 | ||||||||||||||||||||||||||||||
| 456 | - | |||||||||||||||||||||||||||||||
| 457 | updateMappedRange(); | - | ||||||||||||||||||||||||||||||
| 458 | q->refill(); | - | ||||||||||||||||||||||||||||||
| 459 | } executed 410 times by 3 tests:  end of blockExecuted by: 
  | 410 | ||||||||||||||||||||||||||||||
| 460 | - | |||||||||||||||||||||||||||||||
| 461 | void QQuickPathViewPrivate::setDragging(bool d) | - | ||||||||||||||||||||||||||||||
| 462 | { | - | ||||||||||||||||||||||||||||||
| 463 | Q_Q(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 464 |     if (dragging == d)
  | 44-68 | ||||||||||||||||||||||||||||||
| 465 |         return; executed 68 times by 1 test:  return;Executed by: 
  | 68 | ||||||||||||||||||||||||||||||
| 466 | - | |||||||||||||||||||||||||||||||
| 467 | dragging = d; | - | ||||||||||||||||||||||||||||||
| 468 |     if (dragging)
  | 22 | ||||||||||||||||||||||||||||||
| 469 |         emit q->dragStarted(); executed 22 times by 1 test:  q->dragStarted();Executed by: 
  | 22 | ||||||||||||||||||||||||||||||
| 470 | else | - | ||||||||||||||||||||||||||||||
| 471 |         emit q->dragEnded(); executed 22 times by 1 test:  q->dragEnded();Executed by: 
  | 22 | ||||||||||||||||||||||||||||||
| 472 | - | |||||||||||||||||||||||||||||||
| 473 | emit q->draggingChanged(); | - | ||||||||||||||||||||||||||||||
| 474 | } executed 44 times by 1 test:  end of blockExecuted by: 
  | 44 | ||||||||||||||||||||||||||||||
| 475 | - | |||||||||||||||||||||||||||||||
| 476 | /*! | - | ||||||||||||||||||||||||||||||
| 477 | \qmltype PathView | - | ||||||||||||||||||||||||||||||
| 478 | \instantiates QQuickPathView | - | ||||||||||||||||||||||||||||||
| 479 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||||||||
| 480 | \ingroup qtquick-paths | - | ||||||||||||||||||||||||||||||
| 481 | \ingroup qtquick-views | - | ||||||||||||||||||||||||||||||
| 482 | \inherits Item | - | ||||||||||||||||||||||||||||||
| 483 | \brief Lays out model-provided items on a path. | - | ||||||||||||||||||||||||||||||
| 484 | - | |||||||||||||||||||||||||||||||
| 485 | A PathView displays data from models created from built-in QML types like ListModel | - | ||||||||||||||||||||||||||||||
| 486 | and XmlListModel, or custom model classes defined in C++ that inherit from | - | ||||||||||||||||||||||||||||||
| 487 | QAbstractListModel. | - | ||||||||||||||||||||||||||||||
| 488 | - | |||||||||||||||||||||||||||||||
| 489 | The view has a \l model, which defines the data to be displayed, and | - | ||||||||||||||||||||||||||||||
| 490 | a \l delegate, which defines how the data should be displayed. | - | ||||||||||||||||||||||||||||||
| 491 | The \l delegate is instantiated for each item on the \l path. | - | ||||||||||||||||||||||||||||||
| 492 | The items may be flicked to move them along the path. | - | ||||||||||||||||||||||||||||||
| 493 | - | |||||||||||||||||||||||||||||||
| 494 | For example, if there is a simple list model defined in a file \c ContactModel.qml like this: | - | ||||||||||||||||||||||||||||||
| 495 | - | |||||||||||||||||||||||||||||||
| 496 | \snippet qml/pathview/ContactModel.qml 0 | - | ||||||||||||||||||||||||||||||
| 497 | - | |||||||||||||||||||||||||||||||
| 498 | This data can be represented as a PathView, like this: | - | ||||||||||||||||||||||||||||||
| 499 | - | |||||||||||||||||||||||||||||||
| 500 | \snippet qml/pathview/pathview.qml 0 | - | ||||||||||||||||||||||||||||||
| 501 | - | |||||||||||||||||||||||||||||||
| 502 | \image pathview.gif | - | ||||||||||||||||||||||||||||||
| 503 | - | |||||||||||||||||||||||||||||||
| 504 | (Note the above example uses PathAttribute to scale and modify the | - | ||||||||||||||||||||||||||||||
| 505 | opacity of the items as they rotate. This additional code can be seen in the | - | ||||||||||||||||||||||||||||||
| 506 | PathAttribute documentation.) | - | ||||||||||||||||||||||||||||||
| 507 | - | |||||||||||||||||||||||||||||||
| 508 | PathView does not automatically handle keyboard navigation. This is because | - | ||||||||||||||||||||||||||||||
| 509 | the keys to use for navigation will depend upon the shape of the path. Navigation | - | ||||||||||||||||||||||||||||||
| 510 | can be added quite simply by setting \c focus to \c true and calling | - | ||||||||||||||||||||||||||||||
| 511 | \l decrementCurrentIndex() or \l incrementCurrentIndex(), for example to navigate | - | ||||||||||||||||||||||||||||||
| 512 | using the left and right arrow keys: | - | ||||||||||||||||||||||||||||||
| 513 | - | |||||||||||||||||||||||||||||||
| 514 | \qml | - | ||||||||||||||||||||||||||||||
| 515 | PathView { | - | ||||||||||||||||||||||||||||||
| 516 | // ... | - | ||||||||||||||||||||||||||||||
| 517 | focus: true | - | ||||||||||||||||||||||||||||||
| 518 | Keys.onLeftPressed: decrementCurrentIndex() | - | ||||||||||||||||||||||||||||||
| 519 | Keys.onRightPressed: incrementCurrentIndex() | - | ||||||||||||||||||||||||||||||
| 520 | } | - | ||||||||||||||||||||||||||||||
| 521 | \endqml | - | ||||||||||||||||||||||||||||||
| 522 | - | |||||||||||||||||||||||||||||||
| 523 | The path view itself is a focus scope (see \l{Keyboard Focus in Qt Quick} for more details). | - | ||||||||||||||||||||||||||||||
| 524 | - | |||||||||||||||||||||||||||||||
| 525 | Delegates are instantiated as needed and may be destroyed at any time. | - | ||||||||||||||||||||||||||||||
| 526 | State should \e never be stored in a delegate. | - | ||||||||||||||||||||||||||||||
| 527 | - | |||||||||||||||||||||||||||||||
| 528 | PathView attaches a number of properties to the root item of the delegate, for example | - | ||||||||||||||||||||||||||||||
| 529 | \c {PathView.isCurrentItem}. In the following example, the root delegate item can access | - | ||||||||||||||||||||||||||||||
| 530 | this attached property directly as \c PathView.isCurrentItem, while the child | - | ||||||||||||||||||||||||||||||
| 531 | \c nameText object must refer to this property as \c wrapper.PathView.isCurrentItem. | - | ||||||||||||||||||||||||||||||
| 532 | - | |||||||||||||||||||||||||||||||
| 533 | \snippet qml/pathview/pathview.qml 1 | - | ||||||||||||||||||||||||||||||
| 534 | - | |||||||||||||||||||||||||||||||
| 535 | \b Note that views do not enable \e clip automatically. If the view | - | ||||||||||||||||||||||||||||||
| 536 | is not clipped by another item or the screen, it will be necessary | - | ||||||||||||||||||||||||||||||
| 537 | to set \e {clip: true} in order to have the out of view items clipped | - | ||||||||||||||||||||||||||||||
| 538 | nicely. | - | ||||||||||||||||||||||||||||||
| 539 | - | |||||||||||||||||||||||||||||||
| 540 | \sa Path, {QML Data Models}, ListView, GridView, {Qt Quick Examples - Views} | - | ||||||||||||||||||||||||||||||
| 541 | */ | - | ||||||||||||||||||||||||||||||
| 542 | - | |||||||||||||||||||||||||||||||
| 543 | QQuickPathView::QQuickPathView(QQuickItem *parent) | - | ||||||||||||||||||||||||||||||
| 544 | : QQuickItem(*(new QQuickPathViewPrivate), parent) | - | ||||||||||||||||||||||||||||||
| 545 | { | - | ||||||||||||||||||||||||||||||
| 546 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 547 | d->init(); | - | ||||||||||||||||||||||||||||||
| 548 | } executed 282 times by 3 tests:  end of blockExecuted by: 
  | 282 | ||||||||||||||||||||||||||||||
| 549 | - | |||||||||||||||||||||||||||||||
| 550 | QQuickPathView::~QQuickPathView() | - | ||||||||||||||||||||||||||||||
| 551 | { | - | ||||||||||||||||||||||||||||||
| 552 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 553 | d->clear(); | - | ||||||||||||||||||||||||||||||
| 554 |     if (d->attType)
  | 6-276 | ||||||||||||||||||||||||||||||
| 555 |         d->attType->release(); executed 276 times by 3 tests:  d->attType->release();Executed by: 
  | 276 | ||||||||||||||||||||||||||||||
| 556 |     if (d->ownModel)
  | 22-260 | ||||||||||||||||||||||||||||||
| 557 |         delete d->model; executed 260 times by 3 tests:  delete d->model;Executed by: 
  | 260 | ||||||||||||||||||||||||||||||
| 558 | } executed 282 times by 3 tests:  end of blockExecuted by: 
  | 282 | ||||||||||||||||||||||||||||||
| 559 | - | |||||||||||||||||||||||||||||||
| 560 | /*! | - | ||||||||||||||||||||||||||||||
| 561 | \qmlattachedproperty PathView QtQuick::PathView::view | - | ||||||||||||||||||||||||||||||
| 562 | This attached property holds the view that manages this delegate instance. | - | ||||||||||||||||||||||||||||||
| 563 | - | |||||||||||||||||||||||||||||||
| 564 | It is attached to each instance of the delegate. | - | ||||||||||||||||||||||||||||||
| 565 | */ | - | ||||||||||||||||||||||||||||||
| 566 | - | |||||||||||||||||||||||||||||||
| 567 | /*! | - | ||||||||||||||||||||||||||||||
| 568 | \qmlattachedproperty bool QtQuick::PathView::onPath | - | ||||||||||||||||||||||||||||||
| 569 | This attached property holds whether the item is currently on the path. | - | ||||||||||||||||||||||||||||||
| 570 | - | |||||||||||||||||||||||||||||||
| 571 | If a pathItemCount has been set, it is possible that some items may | - | ||||||||||||||||||||||||||||||
| 572 | be instantiated, but not considered to be currently on the path. | - | ||||||||||||||||||||||||||||||
| 573 | Usually, these items would be set invisible, for example: | - | ||||||||||||||||||||||||||||||
| 574 | - | |||||||||||||||||||||||||||||||
| 575 | \qml | - | ||||||||||||||||||||||||||||||
| 576 | Component { | - | ||||||||||||||||||||||||||||||
| 577 | Rectangle { | - | ||||||||||||||||||||||||||||||
| 578 | visible: PathView.onPath | - | ||||||||||||||||||||||||||||||
| 579 | // ... | - | ||||||||||||||||||||||||||||||
| 580 | } | - | ||||||||||||||||||||||||||||||
| 581 | } | - | ||||||||||||||||||||||||||||||
| 582 | \endqml | - | ||||||||||||||||||||||||||||||
| 583 | - | |||||||||||||||||||||||||||||||
| 584 | It is attached to each instance of the delegate. | - | ||||||||||||||||||||||||||||||
| 585 | */ | - | ||||||||||||||||||||||||||||||
| 586 | - | |||||||||||||||||||||||||||||||
| 587 | /*! | - | ||||||||||||||||||||||||||||||
| 588 | \qmlattachedproperty bool QtQuick::PathView::isCurrentItem | - | ||||||||||||||||||||||||||||||
| 589 | This attached property is true if this delegate is the current item; otherwise false. | - | ||||||||||||||||||||||||||||||
| 590 | - | |||||||||||||||||||||||||||||||
| 591 | It is attached to each instance of the delegate. | - | ||||||||||||||||||||||||||||||
| 592 | - | |||||||||||||||||||||||||||||||
| 593 | This property may be used to adjust the appearance of the current item. | - | ||||||||||||||||||||||||||||||
| 594 | - | |||||||||||||||||||||||||||||||
| 595 | \snippet qml/pathview/pathview.qml 1 | - | ||||||||||||||||||||||||||||||
| 596 | */ | - | ||||||||||||||||||||||||||||||
| 597 | - | |||||||||||||||||||||||||||||||
| 598 | /*! | - | ||||||||||||||||||||||||||||||
| 599 | \qmlproperty model QtQuick::PathView::model | - | ||||||||||||||||||||||||||||||
| 600 | This property holds the model providing data for the view. | - | ||||||||||||||||||||||||||||||
| 601 | - | |||||||||||||||||||||||||||||||
| 602 | The model provides a set of data that is used to create the items for the view. | - | ||||||||||||||||||||||||||||||
| 603 | For large or dynamic datasets the model is usually provided by a C++ model object. | - | ||||||||||||||||||||||||||||||
| 604 | Models can also be created directly in QML, using the ListModel type. | - | ||||||||||||||||||||||||||||||
| 605 | - | |||||||||||||||||||||||||||||||
| 606 | \note changing the model will reset the offset and currentIndex to 0. | - | ||||||||||||||||||||||||||||||
| 607 | - | |||||||||||||||||||||||||||||||
| 608 | \sa {qml-data-models}{Data Models} | - | ||||||||||||||||||||||||||||||
| 609 | */ | - | ||||||||||||||||||||||||||||||
| 610 | QVariant QQuickPathView::model() const | - | ||||||||||||||||||||||||||||||
| 611 | { | - | ||||||||||||||||||||||||||||||
| 612 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 613 |     return d->modelVariant; executed 22 times by 1 test:  return d->modelVariant;Executed by: 
  | 22 | ||||||||||||||||||||||||||||||
| 614 | } | - | ||||||||||||||||||||||||||||||
| 615 | - | |||||||||||||||||||||||||||||||
| 616 | void QQuickPathView::setModel(const QVariant &m) | - | ||||||||||||||||||||||||||||||
| 617 | { | - | ||||||||||||||||||||||||||||||
| 618 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 619 | QVariant model = m; | - | ||||||||||||||||||||||||||||||
| 620 |     if (model.userType() == qMetaTypeId<QJSValue>())
  | 6-282 | ||||||||||||||||||||||||||||||
| 621 |         model = model.value<QJSValue>().toVariant(); executed 6 times by 1 test:  model = model.value<QJSValue>().toVariant();Executed by: 
  | 6 | ||||||||||||||||||||||||||||||
| 622 | - | |||||||||||||||||||||||||||||||
| 623 |     if (d->modelVariant == model)
  | 4-284 | ||||||||||||||||||||||||||||||
| 624 |         return; executed 4 times by 1 test:  return;Executed by: 
  | 4 | ||||||||||||||||||||||||||||||
| 625 | - | |||||||||||||||||||||||||||||||
| 626 |     if (d->model) {
  | 126-158 | ||||||||||||||||||||||||||||||
| 627 |         qmlobject_disconnect(d->model, QQmlInstanceModel, SIGNAL(modelUpdated(QQmlChangeSet,bool)), executed 6 times by 3 tests:  end of blockExecuted by: 
 executed 6 times by 3 tests:  methodIdx = QQuickPathView::staticMetaObject.indexOfSlot(method+1);Executed by: 
 never executed:  methodIdx = QQuickPathView::staticMetaObject.indexOfSignal(method+1);
 
 
  | 0-120 | ||||||||||||||||||||||||||||||
| 628 | this, QQuickPathView, SLOT(modelUpdated(QQmlChangeSet,bool))); | - | ||||||||||||||||||||||||||||||
| 629 |         qmlobject_disconnect(d->model, QQmlInstanceModel, SIGNAL(createdItem(int,QObject*)), executed 6 times by 3 tests:  end of blockExecuted by: 
 executed 6 times by 3 tests:  methodIdx = QQuickPathView::staticMetaObject.indexOfSlot(method+1);Executed by: 
 never executed:  methodIdx = QQuickPathView::staticMetaObject.indexOfSignal(method+1);
 
 
  | 0-120 | ||||||||||||||||||||||||||||||
| 630 | this, QQuickPathView, SLOT(createdItem(int,QObject*))); | - | ||||||||||||||||||||||||||||||
| 631 |         qmlobject_disconnect(d->model, QQmlInstanceModel, SIGNAL(initItem(int,QObject*)), executed 6 times by 3 tests:  end of blockExecuted by: 
 executed 6 times by 3 tests:  methodIdx = QQuickPathView::staticMetaObject.indexOfSlot(method+1);Executed by: 
 never executed:  methodIdx = QQuickPathView::staticMetaObject.indexOfSignal(method+1);
 
 
  | 0-120 | ||||||||||||||||||||||||||||||
| 632 | this, QQuickPathView, SLOT(initItem(int,QObject*))); | - | ||||||||||||||||||||||||||||||
| 633 | d->clear(); | - | ||||||||||||||||||||||||||||||
| 634 |     } executed 126 times by 3 tests:  end of blockExecuted by: 
  | 126 | ||||||||||||||||||||||||||||||
| 635 | - | |||||||||||||||||||||||||||||||
| 636 | d->modelVariant = model; | - | ||||||||||||||||||||||||||||||
| 637 | QObject *object = qvariant_cast<QObject*>(model); | - | ||||||||||||||||||||||||||||||
| 638 | QQmlInstanceModel *vim = nullptr; | - | ||||||||||||||||||||||||||||||
| 639 |     if (object && (vim = qobject_cast<QQmlInstanceModel *>(object))) {
 
  | 20-248 | ||||||||||||||||||||||||||||||
| 640 |         if (d->ownModel) {
  | 0-20 | ||||||||||||||||||||||||||||||
| 641 | delete d->model; | - | ||||||||||||||||||||||||||||||
| 642 | d->ownModel = false; | - | ||||||||||||||||||||||||||||||
| 643 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 644 | d->model = vim; | - | ||||||||||||||||||||||||||||||
| 645 |     } else { executed 20 times by 2 tests:  end of blockExecuted by: 
  | 20 | ||||||||||||||||||||||||||||||
| 646 |         if (!d->ownModel) {
  | 126-138 | ||||||||||||||||||||||||||||||
| 647 | d->model = new QQmlDelegateModel(qmlContext(this)); | - | ||||||||||||||||||||||||||||||
| 648 | d->ownModel = true; | - | ||||||||||||||||||||||||||||||
| 649 |             if (isComponentComplete())
  | 2-136 | ||||||||||||||||||||||||||||||
| 650 |                 static_cast<QQmlDelegateModel *>(d->model.data())->componentComplete(); executed 2 times by 1 test:  static_cast<QQmlDelegateModel *>(d->model.data())->componentComplete();Executed by: 
  | 2 | ||||||||||||||||||||||||||||||
| 651 |         } executed 138 times by 2 tests:  end of blockExecuted by: 
  | 138 | ||||||||||||||||||||||||||||||
| 652 |         if (QQmlDelegateModel *dataModel = qobject_cast<QQmlDelegateModel*>(d->model))
  | 0-264 | ||||||||||||||||||||||||||||||
| 653 |             dataModel->setModel(model); executed 264 times by 3 tests:  dataModel->setModel(model);Executed by: 
  | 264 | ||||||||||||||||||||||||||||||
| 654 |     } executed 264 times by 3 tests:  end of blockExecuted by: 
  | 264 | ||||||||||||||||||||||||||||||
| 655 | int oldModelCount = d->modelCount; | - | ||||||||||||||||||||||||||||||
| 656 | d->modelCount = 0; | - | ||||||||||||||||||||||||||||||
| 657 |     if (d->model) {
  | 0-284 | ||||||||||||||||||||||||||||||
| 658 |         qmlobject_connect(d->model, QQmlInstanceModel, SIGNAL(modelUpdated(QQmlChangeSet,bool)), executed 6 times by 3 tests:  end of blockExecuted by: 
 executed 6 times by 3 tests:  methodIdx = QQuickPathView::staticMetaObject.indexOfSlot(method+1);Executed by: 
 never executed:  methodIdx = QQuickPathView::staticMetaObject.indexOfSignal(method+1);
 
 
  | 0-278 | ||||||||||||||||||||||||||||||
| 659 | this, QQuickPathView, SLOT(modelUpdated(QQmlChangeSet,bool))); | - | ||||||||||||||||||||||||||||||
| 660 |         qmlobject_connect(d->model, QQmlInstanceModel, SIGNAL(createdItem(int,QObject*)), executed 6 times by 3 tests:  end of blockExecuted by: 
 executed 6 times by 3 tests:  methodIdx = QQuickPathView::staticMetaObject.indexOfSlot(method+1);Executed by: 
 never executed:  methodIdx = QQuickPathView::staticMetaObject.indexOfSignal(method+1);
 
 
  | 0-278 | ||||||||||||||||||||||||||||||
| 661 | this, QQuickPathView, SLOT(createdItem(int,QObject*))); | - | ||||||||||||||||||||||||||||||
| 662 |         qmlobject_connect(d->model, QQmlInstanceModel, SIGNAL(initItem(int,QObject*)), executed 6 times by 3 tests:  end of blockExecuted by: 
 executed 6 times by 3 tests:  methodIdx = QQuickPathView::staticMetaObject.indexOfSlot(method+1);Executed by: 
 never executed:  methodIdx = QQuickPathView::staticMetaObject.indexOfSignal(method+1);
 
 
  | 0-278 | ||||||||||||||||||||||||||||||
| 663 | this, QQuickPathView, SLOT(initItem(int,QObject*))); | - | ||||||||||||||||||||||||||||||
| 664 | d->modelCount = d->model->count(); | - | ||||||||||||||||||||||||||||||
| 665 |     } executed 284 times by 3 tests:  end of blockExecuted by: 
  | 284 | ||||||||||||||||||||||||||||||
| 666 |     if (isComponentComplete()) {
  | 6-278 | ||||||||||||||||||||||||||||||
| 667 |         if (d->currentIndex != 0) {
  | 2-4 | ||||||||||||||||||||||||||||||
| 668 | d->currentIndex = 0; | - | ||||||||||||||||||||||||||||||
| 669 | emit currentIndexChanged(); | - | ||||||||||||||||||||||||||||||
| 670 |         } executed 2 times by 1 test:  end of blockExecuted by: 
  | 2 | ||||||||||||||||||||||||||||||
| 671 |         if (d->offset != 0.0) {
  | 2-4 | ||||||||||||||||||||||||||||||
| 672 | d->offset = 0; | - | ||||||||||||||||||||||||||||||
| 673 | emit offsetChanged(); | - | ||||||||||||||||||||||||||||||
| 674 |         } executed 2 times by 1 test:  end of blockExecuted by: 
  | 2 | ||||||||||||||||||||||||||||||
| 675 |     } executed 6 times by 1 test:  end of blockExecuted by: 
  | 6 | ||||||||||||||||||||||||||||||
| 676 | d->regenerate(); | - | ||||||||||||||||||||||||||||||
| 677 |     if (d->modelCount != oldModelCount)
  | 14-270 | ||||||||||||||||||||||||||||||
| 678 |         emit countChanged(); executed 14 times by 1 test:  countChanged();Executed by: 
  | 14 | ||||||||||||||||||||||||||||||
| 679 | emit modelChanged(); | - | ||||||||||||||||||||||||||||||
| 680 | } executed 284 times by 3 tests:  end of blockExecuted by: 
  | 284 | ||||||||||||||||||||||||||||||
| 681 | - | |||||||||||||||||||||||||||||||
| 682 | /*! | - | ||||||||||||||||||||||||||||||
| 683 | \qmlproperty int QtQuick::PathView::count | - | ||||||||||||||||||||||||||||||
| 684 | This property holds the number of items in the model. | - | ||||||||||||||||||||||||||||||
| 685 | */ | - | ||||||||||||||||||||||||||||||
| 686 | int QQuickPathView::count() const | - | ||||||||||||||||||||||||||||||
| 687 | { | - | ||||||||||||||||||||||||||||||
| 688 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 689 |     return d->model ? d->modelCount : 0; executed 358 times by 1 test:  return d->model ? d->modelCount : 0;Executed by: 
  | 358 | ||||||||||||||||||||||||||||||
| 690 | } | - | ||||||||||||||||||||||||||||||
| 691 | - | |||||||||||||||||||||||||||||||
| 692 | /*! | - | ||||||||||||||||||||||||||||||
| 693 | \qmlproperty Path QtQuick::PathView::path | - | ||||||||||||||||||||||||||||||
| 694 | This property holds the path used to lay out the items. | - | ||||||||||||||||||||||||||||||
| 695 | For more information see the \l Path documentation. | - | ||||||||||||||||||||||||||||||
| 696 | */ | - | ||||||||||||||||||||||||||||||
| 697 | QQuickPath *QQuickPathView::path() const | - | ||||||||||||||||||||||||||||||
| 698 | { | - | ||||||||||||||||||||||||||||||
| 699 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 700 |     return d->path; executed 58 times by 1 test:  return d->path;Executed by: 
  | 58 | ||||||||||||||||||||||||||||||
| 701 | } | - | ||||||||||||||||||||||||||||||
| 702 | - | |||||||||||||||||||||||||||||||
| 703 | void QQuickPathView::setPath(QQuickPath *path) | - | ||||||||||||||||||||||||||||||
| 704 | { | - | ||||||||||||||||||||||||||||||
| 705 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 706 |     if (d->path == path)
  | 2-280 | ||||||||||||||||||||||||||||||
| 707 |         return; executed 2 times by 1 test:  return;Executed by: 
  | 2 | ||||||||||||||||||||||||||||||
| 708 |     if (d->path)
  | 4-276 | ||||||||||||||||||||||||||||||
| 709 |         qmlobject_disconnect(d->path, QQuickPath, SIGNAL(changed()), executed 2 times by 1 test:  end of blockExecuted by: 
 executed 2 times by 1 test:  methodIdx = QQuickPathView::staticMetaObject.indexOfSlot(method+1);Executed by: 
 never executed:  methodIdx = QQuickPathView::staticMetaObject.indexOfSignal(method+1);executed 4 times by 1 test:  end of blockExecuted by: 
 
 
 
  | 0-4 | ||||||||||||||||||||||||||||||
| 710 | this, QQuickPathView, SLOT(pathUpdated())); | - | ||||||||||||||||||||||||||||||
| 711 | d->path = path; | - | ||||||||||||||||||||||||||||||
| 712 | - | |||||||||||||||||||||||||||||||
| 713 |     if (path) {
  | 2-278 | ||||||||||||||||||||||||||||||
| 714 |         qmlobject_connect(d->path, QQuickPath, SIGNAL(changed()), executed 6 times by 3 tests:  end of blockExecuted by: 
 executed 6 times by 3 tests:  methodIdx = QQuickPathView::staticMetaObject.indexOfSlot(method+1);Executed by: 
 never executed:  methodIdx = QQuickPathView::staticMetaObject.indexOfSignal(method+1);
 
 
  | 0-272 | ||||||||||||||||||||||||||||||
| 715 | this, QQuickPathView, SLOT(pathUpdated())); | - | ||||||||||||||||||||||||||||||
| 716 |     } executed 278 times by 3 tests:  end of blockExecuted by: 
  | 278 | ||||||||||||||||||||||||||||||
| 717 | - | |||||||||||||||||||||||||||||||
| 718 |     if (isComponentComplete()) {
  | 6-274 | ||||||||||||||||||||||||||||||
| 719 | d->clear(); | - | ||||||||||||||||||||||||||||||
| 720 |         if (d->isValid()) {
  | 2-4 | ||||||||||||||||||||||||||||||
| 721 |             if (d->attType) {
  | 0-4 | ||||||||||||||||||||||||||||||
| 722 | d->attType->release(); | - | ||||||||||||||||||||||||||||||
| 723 | d->attType = nullptr; | - | ||||||||||||||||||||||||||||||
| 724 |             } executed 4 times by 1 test:  end of blockExecuted by: 
  | 4 | ||||||||||||||||||||||||||||||
| 725 | d->regenerate(); | - | ||||||||||||||||||||||||||||||
| 726 |         } executed 4 times by 1 test:  end of blockExecuted by: 
  | 4 | ||||||||||||||||||||||||||||||
| 727 |     } executed 6 times by 1 test:  end of blockExecuted by: 
  | 6 | ||||||||||||||||||||||||||||||
| 728 | - | |||||||||||||||||||||||||||||||
| 729 | emit pathChanged(); | - | ||||||||||||||||||||||||||||||
| 730 | } executed 280 times by 3 tests:  end of blockExecuted by: 
  | 280 | ||||||||||||||||||||||||||||||
| 731 | - | |||||||||||||||||||||||||||||||
| 732 | /*! | - | ||||||||||||||||||||||||||||||
| 733 | \qmlproperty int QtQuick::PathView::currentIndex | - | ||||||||||||||||||||||||||||||
| 734 | This property holds the index of the current item. | - | ||||||||||||||||||||||||||||||
| 735 | */ | - | ||||||||||||||||||||||||||||||
| 736 | int QQuickPathView::currentIndex() const | - | ||||||||||||||||||||||||||||||
| 737 | { | - | ||||||||||||||||||||||||||||||
| 738 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 739 |     return d->currentIndex; executed 845 times by 2 tests:  return d->currentIndex;Executed by: 
  | 845 | ||||||||||||||||||||||||||||||
| 740 | } | - | ||||||||||||||||||||||||||||||
| 741 | - | |||||||||||||||||||||||||||||||
| 742 | void QQuickPathView::setCurrentIndex(int idx) | - | ||||||||||||||||||||||||||||||
| 743 | { | - | ||||||||||||||||||||||||||||||
| 744 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 745 |     if (!isComponentComplete()) {
  | 6-146 | ||||||||||||||||||||||||||||||
| 746 |         if (idx != d->currentIndex) {
  | 0-6 | ||||||||||||||||||||||||||||||
| 747 | d->currentIndex = idx; | - | ||||||||||||||||||||||||||||||
| 748 | emit currentIndexChanged(); | - | ||||||||||||||||||||||||||||||
| 749 |         } executed 6 times by 1 test:  end of blockExecuted by: 
  | 6 | ||||||||||||||||||||||||||||||
| 750 |         return; executed 6 times by 1 test:  return;Executed by: 
  | 6 | ||||||||||||||||||||||||||||||
| 751 | } | - | ||||||||||||||||||||||||||||||
| 752 | - | |||||||||||||||||||||||||||||||
| 753 |     idx = d->modelCount
  | 0-146 | ||||||||||||||||||||||||||||||
| 754 | ? ((idx % d->modelCount) + d->modelCount) % d->modelCount | - | ||||||||||||||||||||||||||||||
| 755 | : 0; | - | ||||||||||||||||||||||||||||||
| 756 |     if (d->model && (idx != d->currentIndex || !d->currentItem)) {
 
  | 0-144 | ||||||||||||||||||||||||||||||
| 757 |         if (d->currentItem) {
  | 0-144 | ||||||||||||||||||||||||||||||
| 758 |             if (QQuickPathViewAttached *att = d->attached(d->currentItem))
  | 0-144 | ||||||||||||||||||||||||||||||
| 759 |                 att->setIsCurrentItem(false); executed 144 times by 1 test:  att->setIsCurrentItem(false);Executed by: 
  | 144 | ||||||||||||||||||||||||||||||
| 760 | d->releaseItem(d->currentItem); | - | ||||||||||||||||||||||||||||||
| 761 |         } executed 144 times by 1 test:  end of blockExecuted by: 
  | 144 | ||||||||||||||||||||||||||||||
| 762 | int oldCurrentIdx = d->currentIndex; | - | ||||||||||||||||||||||||||||||
| 763 | QQuickItem *oldCurrentItem = d->currentItem; | - | ||||||||||||||||||||||||||||||
| 764 | d->currentItem = nullptr; | - | ||||||||||||||||||||||||||||||
| 765 | d->moveReason = QQuickPathViewPrivate::SetIndex; | - | ||||||||||||||||||||||||||||||
| 766 | d->currentIndex = idx; | - | ||||||||||||||||||||||||||||||
| 767 |         if (d->modelCount) {
  | 0-144 | ||||||||||||||||||||||||||||||
| 768 | d->createCurrentItem(); | - | ||||||||||||||||||||||||||||||
| 769 |             if (d->haveHighlightRange && d->highlightRangeMode == QQuickPathView::StrictlyEnforceRange)
 
  | 0-144 | ||||||||||||||||||||||||||||||
| 770 |                 d->snapToIndex(d->currentIndex, QQuickPathViewPrivate::SetIndex); executed 76 times by 1 test:  d->snapToIndex(d->currentIndex, QQuickPathViewPrivate::SetIndex);Executed by: 
  | 76 | ||||||||||||||||||||||||||||||
| 771 | d->currentItemOffset = d->positionOfIndex(d->currentIndex); | - | ||||||||||||||||||||||||||||||
| 772 | d->updateHighlight(); | - | ||||||||||||||||||||||||||||||
| 773 |         } executed 144 times by 1 test:  end of blockExecuted by: 
  | 144 | ||||||||||||||||||||||||||||||
| 774 |         if (oldCurrentIdx != d->currentIndex)
  | 0-144 | ||||||||||||||||||||||||||||||
| 775 |             emit currentIndexChanged(); executed 144 times by 1 test:  currentIndexChanged();Executed by: 
  | 144 | ||||||||||||||||||||||||||||||
| 776 |         if (oldCurrentItem != d->currentItem)
  | 0-144 | ||||||||||||||||||||||||||||||
| 777 |             emit currentItemChanged(); executed 144 times by 1 test:  currentItemChanged();Executed by: 
  | 144 | ||||||||||||||||||||||||||||||
| 778 |     } executed 144 times by 1 test:  end of blockExecuted by: 
  | 144 | ||||||||||||||||||||||||||||||
| 779 | } executed 146 times by 1 test:  end of blockExecuted by: 
  | 146 | ||||||||||||||||||||||||||||||
| 780 | - | |||||||||||||||||||||||||||||||
| 781 | /*! | - | ||||||||||||||||||||||||||||||
| 782 | \qmlproperty Item QtQuick::PathView::currentItem | - | ||||||||||||||||||||||||||||||
| 783 | This property holds the current item in the view. | - | ||||||||||||||||||||||||||||||
| 784 | */ | - | ||||||||||||||||||||||||||||||
| 785 | QQuickItem *QQuickPathView::currentItem() const | - | ||||||||||||||||||||||||||||||
| 786 | { | - | ||||||||||||||||||||||||||||||
| 787 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 788 |     return d->currentItem; executed 44 times by 1 test:  return d->currentItem;Executed by: 
  | 44 | ||||||||||||||||||||||||||||||
| 789 | } | - | ||||||||||||||||||||||||||||||
| 790 | - | |||||||||||||||||||||||||||||||
| 791 | /*! | - | ||||||||||||||||||||||||||||||
| 792 | \qmlmethod QtQuick::PathView::incrementCurrentIndex() | - | ||||||||||||||||||||||||||||||
| 793 | - | |||||||||||||||||||||||||||||||
| 794 | Increments the current index. | - | ||||||||||||||||||||||||||||||
| 795 | - | |||||||||||||||||||||||||||||||
| 796 | \b Note: methods should only be called after the Component has completed. | - | ||||||||||||||||||||||||||||||
| 797 | */ | - | ||||||||||||||||||||||||||||||
| 798 | void QQuickPathView::incrementCurrentIndex() | - | ||||||||||||||||||||||||||||||
| 799 | { | - | ||||||||||||||||||||||||||||||
| 800 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 801 | d->moveDirection = QQuickPathView::Positive; | - | ||||||||||||||||||||||||||||||
| 802 | setCurrentIndex(currentIndex()+1); | - | ||||||||||||||||||||||||||||||
| 803 | } executed 4 times by 1 test:  end of blockExecuted by: 
  | 4 | ||||||||||||||||||||||||||||||
| 804 | - | |||||||||||||||||||||||||||||||
| 805 | /*! | - | ||||||||||||||||||||||||||||||
| 806 | \qmlmethod QtQuick::PathView::decrementCurrentIndex() | - | ||||||||||||||||||||||||||||||
| 807 | - | |||||||||||||||||||||||||||||||
| 808 | Decrements the current index. | - | ||||||||||||||||||||||||||||||
| 809 | - | |||||||||||||||||||||||||||||||
| 810 | \b Note: methods should only be called after the Component has completed. | - | ||||||||||||||||||||||||||||||
| 811 | */ | - | ||||||||||||||||||||||||||||||
| 812 | void QQuickPathView::decrementCurrentIndex() | - | ||||||||||||||||||||||||||||||
| 813 | { | - | ||||||||||||||||||||||||||||||
| 814 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 815 | d->moveDirection = QQuickPathView::Negative; | - | ||||||||||||||||||||||||||||||
| 816 | setCurrentIndex(currentIndex()-1); | - | ||||||||||||||||||||||||||||||
| 817 | } executed 12 times by 1 test:  end of blockExecuted by: 
  | 12 | ||||||||||||||||||||||||||||||
| 818 | - | |||||||||||||||||||||||||||||||
| 819 | /*! | - | ||||||||||||||||||||||||||||||
| 820 | \qmlproperty real QtQuick::PathView::offset | - | ||||||||||||||||||||||||||||||
| 821 | - | |||||||||||||||||||||||||||||||
| 822 | The offset specifies how far along the path the items are from their initial positions. | - | ||||||||||||||||||||||||||||||
| 823 | This is a real number that ranges from 0.0 to the count of items in the model. | - | ||||||||||||||||||||||||||||||
| 824 | */ | - | ||||||||||||||||||||||||||||||
| 825 | qreal QQuickPathView::offset() const | - | ||||||||||||||||||||||||||||||
| 826 | { | - | ||||||||||||||||||||||||||||||
| 827 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 828 |     return d->offset; executed 1706 times by 1 test:  return d->offset;Executed by: 
  | 1706 | ||||||||||||||||||||||||||||||
| 829 | } | - | ||||||||||||||||||||||||||||||
| 830 | - | |||||||||||||||||||||||||||||||
| 831 | void QQuickPathView::setOffset(qreal offset) | - | ||||||||||||||||||||||||||||||
| 832 | { | - | ||||||||||||||||||||||||||||||
| 833 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 834 | d->moveReason = QQuickPathViewPrivate::Other; | - | ||||||||||||||||||||||||||||||
| 835 | d->setOffset(offset); | - | ||||||||||||||||||||||||||||||
| 836 | d->updateCurrent(); | - | ||||||||||||||||||||||||||||||
| 837 | } executed 328 times by 1 test:  end of blockExecuted by: 
  | 328 | ||||||||||||||||||||||||||||||
| 838 | - | |||||||||||||||||||||||||||||||
| 839 | void QQuickPathViewPrivate::setOffset(qreal o) | - | ||||||||||||||||||||||||||||||
| 840 | { | - | ||||||||||||||||||||||||||||||
| 841 | Q_Q(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 842 |     if (offset != o) {
  | 124-3491 | ||||||||||||||||||||||||||||||
| 843 |         if (isValid() && q->isComponentComplete()) {
 
  | 0-3417 | ||||||||||||||||||||||||||||||
| 844 | qreal oldOffset = offset; | - | ||||||||||||||||||||||||||||||
| 845 | offset = std::fmod(o, qreal(modelCount)); | - | ||||||||||||||||||||||||||||||
| 846 |             if (offset < 0)
  | 16-3401 | ||||||||||||||||||||||||||||||
| 847 |                 offset += qreal(modelCount); executed 16 times by 1 test:  offset += qreal(modelCount);Executed by: 
  | 16 | ||||||||||||||||||||||||||||||
| 848 |             qCDebug(lcItemViewDelegateLifecycle) << o << "was" << oldOffset << "now" << offset; never executed:  QMessageLogger(__FILE__, 848, __PRETTY_FUNCTION__, lcItemViewDelegateLifecycle().categoryName()).debug() << o << "was" << oldOffset << "now" << offset;
  | 0-3417 | ||||||||||||||||||||||||||||||
| 849 | q->refill(); | - | ||||||||||||||||||||||||||||||
| 850 |         } else { executed 3417 times by 1 test:  end of blockExecuted by: 
  | 3417 | ||||||||||||||||||||||||||||||
| 851 | offset = o; | - | ||||||||||||||||||||||||||||||
| 852 |         } executed 74 times by 1 test:  end of blockExecuted by: 
  | 74 | ||||||||||||||||||||||||||||||
| 853 | emit q->offsetChanged(); | - | ||||||||||||||||||||||||||||||
| 854 |     } executed 3491 times by 1 test:  end of blockExecuted by: 
  | 3491 | ||||||||||||||||||||||||||||||
| 855 | } executed 3615 times by 1 test:  end of blockExecuted by: 
  | 3615 | ||||||||||||||||||||||||||||||
| 856 | - | |||||||||||||||||||||||||||||||
| 857 | void QQuickPathViewPrivate::setAdjustedOffset(qreal o) | - | ||||||||||||||||||||||||||||||
| 858 | { | - | ||||||||||||||||||||||||||||||
| 859 | setOffset(o+offsetAdj); | - | ||||||||||||||||||||||||||||||
| 860 | } executed 3285 times by 1 test:  end of blockExecuted by: 
  | 3285 | ||||||||||||||||||||||||||||||
| 861 | - | |||||||||||||||||||||||||||||||
| 862 | /*! | - | ||||||||||||||||||||||||||||||
| 863 | \qmlproperty Component QtQuick::PathView::highlight | - | ||||||||||||||||||||||||||||||
| 864 | This property holds the component to use as the highlight. | - | ||||||||||||||||||||||||||||||
| 865 | - | |||||||||||||||||||||||||||||||
| 866 | An instance of the highlight component will be created for each view. | - | ||||||||||||||||||||||||||||||
| 867 | The geometry of the resultant component instance will be managed by the view | - | ||||||||||||||||||||||||||||||
| 868 | so as to stay with the current item. | - | ||||||||||||||||||||||||||||||
| 869 | - | |||||||||||||||||||||||||||||||
| 870 | The below example demonstrates how to make a simple highlight. Note the use | - | ||||||||||||||||||||||||||||||
| 871 | of the \l{PathView::onPath}{PathView.onPath} attached property to ensure that | - | ||||||||||||||||||||||||||||||
| 872 | the highlight is hidden when flicked away from the path. | - | ||||||||||||||||||||||||||||||
| 873 | - | |||||||||||||||||||||||||||||||
| 874 | \qml | - | ||||||||||||||||||||||||||||||
| 875 | Component { | - | ||||||||||||||||||||||||||||||
| 876 | Rectangle { | - | ||||||||||||||||||||||||||||||
| 877 | visible: PathView.onPath | - | ||||||||||||||||||||||||||||||
| 878 | // ... | - | ||||||||||||||||||||||||||||||
| 879 | } | - | ||||||||||||||||||||||||||||||
| 880 | } | - | ||||||||||||||||||||||||||||||
| 881 | \endqml | - | ||||||||||||||||||||||||||||||
| 882 | - | |||||||||||||||||||||||||||||||
| 883 | \sa highlightItem, highlightRangeMode | - | ||||||||||||||||||||||||||||||
| 884 | */ | - | ||||||||||||||||||||||||||||||
| 885 | - | |||||||||||||||||||||||||||||||
| 886 | QQmlComponent *QQuickPathView::highlight() const | - | ||||||||||||||||||||||||||||||
| 887 | { | - | ||||||||||||||||||||||||||||||
| 888 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 889 |     return d->highlightComponent; never executed:  return d->highlightComponent; | 0 | ||||||||||||||||||||||||||||||
| 890 | } | - | ||||||||||||||||||||||||||||||
| 891 | - | |||||||||||||||||||||||||||||||
| 892 | void QQuickPathView::setHighlight(QQmlComponent *highlight) | - | ||||||||||||||||||||||||||||||
| 893 | { | - | ||||||||||||||||||||||||||||||
| 894 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 895 |     if (highlight != d->highlightComponent) {
  | 0-116 | ||||||||||||||||||||||||||||||
| 896 | d->highlightComponent = highlight; | - | ||||||||||||||||||||||||||||||
| 897 | d->createHighlight(); | - | ||||||||||||||||||||||||||||||
| 898 | d->updateHighlight(); | - | ||||||||||||||||||||||||||||||
| 899 | emit highlightChanged(); | - | ||||||||||||||||||||||||||||||
| 900 |     } executed 116 times by 2 tests:  end of blockExecuted by: 
  | 116 | ||||||||||||||||||||||||||||||
| 901 | } executed 116 times by 2 tests:  end of blockExecuted by: 
  | 116 | ||||||||||||||||||||||||||||||
| 902 | - | |||||||||||||||||||||||||||||||
| 903 | /*! | - | ||||||||||||||||||||||||||||||
| 904 | \qmlproperty Item QtQuick::PathView::highlightItem | - | ||||||||||||||||||||||||||||||
| 905 | - | |||||||||||||||||||||||||||||||
| 906 | \c highlightItem holds the highlight item, which was created | - | ||||||||||||||||||||||||||||||
| 907 | from the \l highlight component. | - | ||||||||||||||||||||||||||||||
| 908 | - | |||||||||||||||||||||||||||||||
| 909 | \sa highlight | - | ||||||||||||||||||||||||||||||
| 910 | */ | - | ||||||||||||||||||||||||||||||
| 911 | QQuickItem *QQuickPathView::highlightItem() const | - | ||||||||||||||||||||||||||||||
| 912 | { | - | ||||||||||||||||||||||||||||||
| 913 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 914 |     return d->highlightItem; executed 10 times by 1 test:  return d->highlightItem;Executed by: 
  | 10 | ||||||||||||||||||||||||||||||
| 915 | } | - | ||||||||||||||||||||||||||||||
| 916 | /*! | - | ||||||||||||||||||||||||||||||
| 917 | \qmlproperty real QtQuick::PathView::preferredHighlightBegin | - | ||||||||||||||||||||||||||||||
| 918 | \qmlproperty real QtQuick::PathView::preferredHighlightEnd | - | ||||||||||||||||||||||||||||||
| 919 | \qmlproperty enumeration QtQuick::PathView::highlightRangeMode | - | ||||||||||||||||||||||||||||||
| 920 | - | |||||||||||||||||||||||||||||||
| 921 | These properties set the preferred range of the highlight (current item) | - | ||||||||||||||||||||||||||||||
| 922 | within the view. The preferred values must be in the range 0.0-1.0. | - | ||||||||||||||||||||||||||||||
| 923 | - | |||||||||||||||||||||||||||||||
| 924 | Valid values for \c highlightRangeMode are: | - | ||||||||||||||||||||||||||||||
| 925 | - | |||||||||||||||||||||||||||||||
| 926 | \list | - | ||||||||||||||||||||||||||||||
| 927 | \li \e PathView.NoHighlightRange - no range is applied and the | - | ||||||||||||||||||||||||||||||
| 928 | highlight will move freely within the view. | - | ||||||||||||||||||||||||||||||
| 929 | \li \e PathView.ApplyRange - the view will attempt to maintain | - | ||||||||||||||||||||||||||||||
| 930 | the highlight within the range, however the highlight can | - | ||||||||||||||||||||||||||||||
| 931 | move outside of the range at the ends of the path or due to | - | ||||||||||||||||||||||||||||||
| 932 | a mouse interaction. | - | ||||||||||||||||||||||||||||||
| 933 | \li \e PathView.StrictlyEnforceRange - the highlight will never | - | ||||||||||||||||||||||||||||||
| 934 | move outside of the range. This means that the current item | - | ||||||||||||||||||||||||||||||
| 935 | will change if a keyboard or mouse action would cause the | - | ||||||||||||||||||||||||||||||
| 936 | highlight to move outside of the range. | - | ||||||||||||||||||||||||||||||
| 937 | \endlist | - | ||||||||||||||||||||||||||||||
| 938 | - | |||||||||||||||||||||||||||||||
| 939 | The default value is \e PathView.StrictlyEnforceRange. | - | ||||||||||||||||||||||||||||||
| 940 | - | |||||||||||||||||||||||||||||||
| 941 | Defining a highlight range is the correct way to influence where the | - | ||||||||||||||||||||||||||||||
| 942 | current item ends up when the view moves. For example, if you want the | - | ||||||||||||||||||||||||||||||
| 943 | currently selected item to be in the middle of the path, then set the | - | ||||||||||||||||||||||||||||||
| 944 | highlight range to be 0.5,0.5 and highlightRangeMode to \e PathView.StrictlyEnforceRange. | - | ||||||||||||||||||||||||||||||
| 945 | Then, when the path scrolls, | - | ||||||||||||||||||||||||||||||
| 946 | the currently selected item will be the item at that position. This also applies to | - | ||||||||||||||||||||||||||||||
| 947 | when the currently selected item changes - it will scroll to within the preferred | - | ||||||||||||||||||||||||||||||
| 948 | highlight range. Furthermore, the behaviour of the current item index will occur | - | ||||||||||||||||||||||||||||||
| 949 | whether or not a highlight exists. | - | ||||||||||||||||||||||||||||||
| 950 | - | |||||||||||||||||||||||||||||||
| 951 | \note A valid range requires \c preferredHighlightEnd to be greater | - | ||||||||||||||||||||||||||||||
| 952 | than or equal to \c preferredHighlightBegin. | - | ||||||||||||||||||||||||||||||
| 953 | */ | - | ||||||||||||||||||||||||||||||
| 954 | qreal QQuickPathView::preferredHighlightBegin() const | - | ||||||||||||||||||||||||||||||
| 955 | { | - | ||||||||||||||||||||||||||||||
| 956 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 957 |     return d->highlightRangeStart; executed 12 times by 1 test:  return d->highlightRangeStart;Executed by: 
  | 12 | ||||||||||||||||||||||||||||||
| 958 | } | - | ||||||||||||||||||||||||||||||
| 959 | - | |||||||||||||||||||||||||||||||
| 960 | void QQuickPathView::setPreferredHighlightBegin(qreal start) | - | ||||||||||||||||||||||||||||||
| 961 | { | - | ||||||||||||||||||||||||||||||
| 962 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 963 |     if (d->highlightRangeStart == start || start < 0 || start > 1.0)
 
 
  | 0-120 | ||||||||||||||||||||||||||||||
| 964 |         return; executed 4 times by 1 test:  return;Executed by: 
  | 4 | ||||||||||||||||||||||||||||||
| 965 | d->highlightRangeStart = start; | - | ||||||||||||||||||||||||||||||
| 966 | d->haveHighlightRange = d->highlightRangeStart <= d->highlightRangeEnd; | - | ||||||||||||||||||||||||||||||
| 967 | refill(); | - | ||||||||||||||||||||||||||||||
| 968 | emit preferredHighlightBeginChanged(); | - | ||||||||||||||||||||||||||||||
| 969 | } executed 120 times by 2 tests:  end of blockExecuted by: 
  | 120 | ||||||||||||||||||||||||||||||
| 970 | - | |||||||||||||||||||||||||||||||
| 971 | qreal QQuickPathView::preferredHighlightEnd() const | - | ||||||||||||||||||||||||||||||
| 972 | { | - | ||||||||||||||||||||||||||||||
| 973 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 974 |     return d->highlightRangeEnd; executed 2 times by 1 test:  return d->highlightRangeEnd;Executed by: 
  | 2 | ||||||||||||||||||||||||||||||
| 975 | } | - | ||||||||||||||||||||||||||||||
| 976 | - | |||||||||||||||||||||||||||||||
| 977 | void QQuickPathView::setPreferredHighlightEnd(qreal end) | - | ||||||||||||||||||||||||||||||
| 978 | { | - | ||||||||||||||||||||||||||||||
| 979 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 980 |     if (d->highlightRangeEnd == end || end < 0 || end > 1.0)
 
 
  | 0-120 | ||||||||||||||||||||||||||||||
| 981 |         return; executed 4 times by 1 test:  return;Executed by: 
  | 4 | ||||||||||||||||||||||||||||||
| 982 | d->highlightRangeEnd = end; | - | ||||||||||||||||||||||||||||||
| 983 | d->haveHighlightRange = d->highlightRangeStart <= d->highlightRangeEnd; | - | ||||||||||||||||||||||||||||||
| 984 | refill(); | - | ||||||||||||||||||||||||||||||
| 985 | emit preferredHighlightEndChanged(); | - | ||||||||||||||||||||||||||||||
| 986 | } executed 120 times by 2 tests:  end of blockExecuted by: 
  | 120 | ||||||||||||||||||||||||||||||
| 987 | - | |||||||||||||||||||||||||||||||
| 988 | QQuickPathView::HighlightRangeMode QQuickPathView::highlightRangeMode() const | - | ||||||||||||||||||||||||||||||
| 989 | { | - | ||||||||||||||||||||||||||||||
| 990 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 991 |     return d->highlightRangeMode; never executed:  return d->highlightRangeMode; | 0 | ||||||||||||||||||||||||||||||
| 992 | } | - | ||||||||||||||||||||||||||||||
| 993 | - | |||||||||||||||||||||||||||||||
| 994 | void QQuickPathView::setHighlightRangeMode(HighlightRangeMode mode) | - | ||||||||||||||||||||||||||||||
| 995 | { | - | ||||||||||||||||||||||||||||||
| 996 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 997 |     if (d->highlightRangeMode == mode)
  | 92-122 | ||||||||||||||||||||||||||||||
| 998 |         return; executed 122 times by 1 test:  return;Executed by: 
  | 122 | ||||||||||||||||||||||||||||||
| 999 | d->highlightRangeMode = mode; | - | ||||||||||||||||||||||||||||||
| 1000 | d->haveHighlightRange = d->highlightRangeStart <= d->highlightRangeEnd; | - | ||||||||||||||||||||||||||||||
| 1001 |     if (d->haveHighlightRange) {
  | 0-92 | ||||||||||||||||||||||||||||||
| 1002 | d->regenerate(); | - | ||||||||||||||||||||||||||||||
| 1003 |         int index = d->highlightRangeMode != NoHighlightRange ? d->currentIndex : d->calcCurrentIndex();
  | 6-86 | ||||||||||||||||||||||||||||||
| 1004 |         if (index >= 0)
  | 0-92 | ||||||||||||||||||||||||||||||
| 1005 |             d->snapToIndex(index, QQuickPathViewPrivate::Other); executed 92 times by 1 test:  d->snapToIndex(index, QQuickPathViewPrivate::Other);Executed by: 
  | 92 | ||||||||||||||||||||||||||||||
| 1006 |     } executed 92 times by 1 test:  end of blockExecuted by: 
  | 92 | ||||||||||||||||||||||||||||||
| 1007 | emit highlightRangeModeChanged(); | - | ||||||||||||||||||||||||||||||
| 1008 | } executed 92 times by 1 test:  end of blockExecuted by: 
  | 92 | ||||||||||||||||||||||||||||||
| 1009 | - | |||||||||||||||||||||||||||||||
| 1010 | /*! | - | ||||||||||||||||||||||||||||||
| 1011 | \qmlproperty int QtQuick::PathView::highlightMoveDuration | - | ||||||||||||||||||||||||||||||
| 1012 | This property holds the move animation duration of the highlight delegate. | - | ||||||||||||||||||||||||||||||
| 1013 | - | |||||||||||||||||||||||||||||||
| 1014 | If the highlightRangeMode is StrictlyEnforceRange then this property | - | ||||||||||||||||||||||||||||||
| 1015 | determines the speed that the items move along the path. | - | ||||||||||||||||||||||||||||||
| 1016 | - | |||||||||||||||||||||||||||||||
| 1017 | The default value for the duration is 300ms. | - | ||||||||||||||||||||||||||||||
| 1018 | */ | - | ||||||||||||||||||||||||||||||
| 1019 | int QQuickPathView::highlightMoveDuration() const | - | ||||||||||||||||||||||||||||||
| 1020 | { | - | ||||||||||||||||||||||||||||||
| 1021 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1022 |     return d->highlightMoveDuration; never executed:  return d->highlightMoveDuration; | 0 | ||||||||||||||||||||||||||||||
| 1023 | } | - | ||||||||||||||||||||||||||||||
| 1024 | - | |||||||||||||||||||||||||||||||
| 1025 | void QQuickPathView::setHighlightMoveDuration(int duration) | - | ||||||||||||||||||||||||||||||
| 1026 | { | - | ||||||||||||||||||||||||||||||
| 1027 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1028 |     if (d->highlightMoveDuration == duration)
  | 0-18 | ||||||||||||||||||||||||||||||
| 1029 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 1030 | d->highlightMoveDuration = duration; | - | ||||||||||||||||||||||||||||||
| 1031 | emit highlightMoveDurationChanged(); | - | ||||||||||||||||||||||||||||||
| 1032 | } executed 18 times by 1 test:  end of blockExecuted by: 
  | 18 | ||||||||||||||||||||||||||||||
| 1033 | - | |||||||||||||||||||||||||||||||
| 1034 | /*! | - | ||||||||||||||||||||||||||||||
| 1035 | \qmlproperty real QtQuick::PathView::dragMargin | - | ||||||||||||||||||||||||||||||
| 1036 | This property holds the maximum distance from the path that initiates mouse dragging. | - | ||||||||||||||||||||||||||||||
| 1037 | - | |||||||||||||||||||||||||||||||
| 1038 | By default the path can only be dragged by clicking on an item. If | - | ||||||||||||||||||||||||||||||
| 1039 | dragMargin is greater than zero, a drag can be initiated by clicking | - | ||||||||||||||||||||||||||||||
| 1040 | within dragMargin pixels of the path. | - | ||||||||||||||||||||||||||||||
| 1041 | */ | - | ||||||||||||||||||||||||||||||
| 1042 | qreal QQuickPathView::dragMargin() const | - | ||||||||||||||||||||||||||||||
| 1043 | { | - | ||||||||||||||||||||||||||||||
| 1044 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1045 |     return d->dragMargin; executed 12 times by 1 test:  return d->dragMargin;Executed by: 
  | 12 | ||||||||||||||||||||||||||||||
| 1046 | } | - | ||||||||||||||||||||||||||||||
| 1047 | - | |||||||||||||||||||||||||||||||
| 1048 | void QQuickPathView::setDragMargin(qreal dragMargin) | - | ||||||||||||||||||||||||||||||
| 1049 | { | - | ||||||||||||||||||||||||||||||
| 1050 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1051 |     if (d->dragMargin == dragMargin)
  | 4-100 | ||||||||||||||||||||||||||||||
| 1052 |         return; executed 4 times by 2 tests:  return;Executed by: 
  | 4 | ||||||||||||||||||||||||||||||
| 1053 | d->dragMargin = dragMargin; | - | ||||||||||||||||||||||||||||||
| 1054 | emit dragMarginChanged(); | - | ||||||||||||||||||||||||||||||
| 1055 | } executed 100 times by 2 tests:  end of blockExecuted by: 
  | 100 | ||||||||||||||||||||||||||||||
| 1056 | - | |||||||||||||||||||||||||||||||
| 1057 | /*! | - | ||||||||||||||||||||||||||||||
| 1058 | \qmlproperty real QtQuick::PathView::flickDeceleration | - | ||||||||||||||||||||||||||||||
| 1059 | This property holds the rate at which a flick will decelerate. | - | ||||||||||||||||||||||||||||||
| 1060 | - | |||||||||||||||||||||||||||||||
| 1061 | The default is 100. | - | ||||||||||||||||||||||||||||||
| 1062 | */ | - | ||||||||||||||||||||||||||||||
| 1063 | qreal QQuickPathView::flickDeceleration() const | - | ||||||||||||||||||||||||||||||
| 1064 | { | - | ||||||||||||||||||||||||||||||
| 1065 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1066 |     return d->deceleration; never executed:  return d->deceleration; | 0 | ||||||||||||||||||||||||||||||
| 1067 | } | - | ||||||||||||||||||||||||||||||
| 1068 | - | |||||||||||||||||||||||||||||||
| 1069 | void QQuickPathView::setFlickDeceleration(qreal dec) | - | ||||||||||||||||||||||||||||||
| 1070 | { | - | ||||||||||||||||||||||||||||||
| 1071 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1072 |     if (d->deceleration == dec)
  | 0-8 | ||||||||||||||||||||||||||||||
| 1073 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 1074 | d->deceleration = dec; | - | ||||||||||||||||||||||||||||||
| 1075 | emit flickDecelerationChanged(); | - | ||||||||||||||||||||||||||||||
| 1076 | } executed 8 times by 1 test:  end of blockExecuted by: 
  | 8 | ||||||||||||||||||||||||||||||
| 1077 | - | |||||||||||||||||||||||||||||||
| 1078 | /*! | - | ||||||||||||||||||||||||||||||
| 1079 | \qmlproperty real QtQuick::PathView::maximumFlickVelocity | - | ||||||||||||||||||||||||||||||
| 1080 | This property holds the approximate maximum velocity that the user can flick the view in pixels/second. | - | ||||||||||||||||||||||||||||||
| 1081 | - | |||||||||||||||||||||||||||||||
| 1082 | The default value is platform dependent. | - | ||||||||||||||||||||||||||||||
| 1083 | */ | - | ||||||||||||||||||||||||||||||
| 1084 | qreal QQuickPathView::maximumFlickVelocity() const | - | ||||||||||||||||||||||||||||||
| 1085 | { | - | ||||||||||||||||||||||||||||||
| 1086 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1087 |     return d->maximumFlickVelocity; never executed:  return d->maximumFlickVelocity; | 0 | ||||||||||||||||||||||||||||||
| 1088 | } | - | ||||||||||||||||||||||||||||||
| 1089 | - | |||||||||||||||||||||||||||||||
| 1090 | void QQuickPathView::setMaximumFlickVelocity(qreal vel) | - | ||||||||||||||||||||||||||||||
| 1091 | { | - | ||||||||||||||||||||||||||||||
| 1092 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1093 |     if (vel == d->maximumFlickVelocity)
  | 2-8 | ||||||||||||||||||||||||||||||
| 1094 |         return; executed 2 times by 1 test:  return;Executed by: 
  | 2 | ||||||||||||||||||||||||||||||
| 1095 | d->maximumFlickVelocity = vel; | - | ||||||||||||||||||||||||||||||
| 1096 | emit maximumFlickVelocityChanged(); | - | ||||||||||||||||||||||||||||||
| 1097 | } executed 8 times by 1 test:  end of blockExecuted by: 
  | 8 | ||||||||||||||||||||||||||||||
| 1098 | - | |||||||||||||||||||||||||||||||
| 1099 | - | |||||||||||||||||||||||||||||||
| 1100 | /*! | - | ||||||||||||||||||||||||||||||
| 1101 | \qmlproperty bool QtQuick::PathView::interactive | - | ||||||||||||||||||||||||||||||
| 1102 | - | |||||||||||||||||||||||||||||||
| 1103 | A user cannot drag or flick a PathView that is not interactive. | - | ||||||||||||||||||||||||||||||
| 1104 | - | |||||||||||||||||||||||||||||||
| 1105 | This property is useful for temporarily disabling flicking. This allows | - | ||||||||||||||||||||||||||||||
| 1106 | special interaction with PathView's children. | - | ||||||||||||||||||||||||||||||
| 1107 | */ | - | ||||||||||||||||||||||||||||||
| 1108 | bool QQuickPathView::isInteractive() const | - | ||||||||||||||||||||||||||||||
| 1109 | { | - | ||||||||||||||||||||||||||||||
| 1110 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1111 |     return d->interactive; never executed:  return d->interactive; | 0 | ||||||||||||||||||||||||||||||
| 1112 | } | - | ||||||||||||||||||||||||||||||
| 1113 | - | |||||||||||||||||||||||||||||||
| 1114 | void QQuickPathView::setInteractive(bool interactive) | - | ||||||||||||||||||||||||||||||
| 1115 | { | - | ||||||||||||||||||||||||||||||
| 1116 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1117 |     if (interactive != d->interactive) {
  | 0-2 | ||||||||||||||||||||||||||||||
| 1118 | d->interactive = interactive; | - | ||||||||||||||||||||||||||||||
| 1119 |         if (!interactive)
  | 0-2 | ||||||||||||||||||||||||||||||
| 1120 |             d->tl.clear(); executed 2 times by 1 test:  d->tl.clear();Executed by: 
  | 2 | ||||||||||||||||||||||||||||||
| 1121 | emit interactiveChanged(); | - | ||||||||||||||||||||||||||||||
| 1122 |     } executed 2 times by 1 test:  end of blockExecuted by: 
  | 2 | ||||||||||||||||||||||||||||||
| 1123 | } executed 2 times by 1 test:  end of blockExecuted by: 
  | 2 | ||||||||||||||||||||||||||||||
| 1124 | - | |||||||||||||||||||||||||||||||
| 1125 | /*! | - | ||||||||||||||||||||||||||||||
| 1126 | \qmlproperty bool QtQuick::PathView::moving | - | ||||||||||||||||||||||||||||||
| 1127 | - | |||||||||||||||||||||||||||||||
| 1128 | This property holds whether the view is currently moving | - | ||||||||||||||||||||||||||||||
| 1129 | due to the user either dragging or flicking the view. | - | ||||||||||||||||||||||||||||||
| 1130 | */ | - | ||||||||||||||||||||||||||||||
| 1131 | bool QQuickPathView::isMoving() const | - | ||||||||||||||||||||||||||||||
| 1132 | { | - | ||||||||||||||||||||||||||||||
| 1133 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1134 |     return d->moving; executed 582 times by 1 test:  return d->moving;Executed by: 
  | 582 | ||||||||||||||||||||||||||||||
| 1135 | } | - | ||||||||||||||||||||||||||||||
| 1136 | - | |||||||||||||||||||||||||||||||
| 1137 | /*! | - | ||||||||||||||||||||||||||||||
| 1138 | \qmlproperty bool QtQuick::PathView::flicking | - | ||||||||||||||||||||||||||||||
| 1139 | - | |||||||||||||||||||||||||||||||
| 1140 | This property holds whether the view is currently moving | - | ||||||||||||||||||||||||||||||
| 1141 | due to the user flicking the view. | - | ||||||||||||||||||||||||||||||
| 1142 | */ | - | ||||||||||||||||||||||||||||||
| 1143 | bool QQuickPathView::isFlicking() const | - | ||||||||||||||||||||||||||||||
| 1144 | { | - | ||||||||||||||||||||||||||||||
| 1145 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1146 |     return d->flicking; executed 6 times by 1 test:  return d->flicking;Executed by: 
  | 6 | ||||||||||||||||||||||||||||||
| 1147 | } | - | ||||||||||||||||||||||||||||||
| 1148 | - | |||||||||||||||||||||||||||||||
| 1149 | /*! | - | ||||||||||||||||||||||||||||||
| 1150 | \qmlproperty bool QtQuick::PathView::dragging | - | ||||||||||||||||||||||||||||||
| 1151 | - | |||||||||||||||||||||||||||||||
| 1152 | This property holds whether the view is currently moving | - | ||||||||||||||||||||||||||||||
| 1153 | due to the user dragging the view. | - | ||||||||||||||||||||||||||||||
| 1154 | */ | - | ||||||||||||||||||||||||||||||
| 1155 | bool QQuickPathView::isDragging() const | - | ||||||||||||||||||||||||||||||
| 1156 | { | - | ||||||||||||||||||||||||||||||
| 1157 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1158 |     return d->dragging; executed 12 times by 1 test:  return d->dragging;Executed by: 
  | 12 | ||||||||||||||||||||||||||||||
| 1159 | } | - | ||||||||||||||||||||||||||||||
| 1160 | - | |||||||||||||||||||||||||||||||
| 1161 | /*! | - | ||||||||||||||||||||||||||||||
| 1162 | \qmlsignal QtQuick::PathView::movementStarted() | - | ||||||||||||||||||||||||||||||
| 1163 | - | |||||||||||||||||||||||||||||||
| 1164 | This signal is emitted when the view begins moving due to user | - | ||||||||||||||||||||||||||||||
| 1165 | interaction. | - | ||||||||||||||||||||||||||||||
| 1166 | - | |||||||||||||||||||||||||||||||
| 1167 | The corresponding handler is \c onMovementStarted. | - | ||||||||||||||||||||||||||||||
| 1168 | */ | - | ||||||||||||||||||||||||||||||
| 1169 | - | |||||||||||||||||||||||||||||||
| 1170 | /*! | - | ||||||||||||||||||||||||||||||
| 1171 | \qmlsignal QtQuick::PathView::movementEnded() | - | ||||||||||||||||||||||||||||||
| 1172 | - | |||||||||||||||||||||||||||||||
| 1173 | This signal is emitted when the view stops moving due to user | - | ||||||||||||||||||||||||||||||
| 1174 | interaction. If a flick was generated, this signal will | - | ||||||||||||||||||||||||||||||
| 1175 | be emitted once the flick stops. If a flick was not | - | ||||||||||||||||||||||||||||||
| 1176 | generated, this signal will be emitted when the | - | ||||||||||||||||||||||||||||||
| 1177 | user stops dragging - i.e. a mouse or touch release. | - | ||||||||||||||||||||||||||||||
| 1178 | - | |||||||||||||||||||||||||||||||
| 1179 | The corresponding handler is \c onMovementEnded. | - | ||||||||||||||||||||||||||||||
| 1180 | */ | - | ||||||||||||||||||||||||||||||
| 1181 | - | |||||||||||||||||||||||||||||||
| 1182 | /*! | - | ||||||||||||||||||||||||||||||
| 1183 | \qmlsignal QtQuick::PathView::flickStarted() | - | ||||||||||||||||||||||||||||||
| 1184 | - | |||||||||||||||||||||||||||||||
| 1185 | This signal is emitted when the view is flicked. A flick | - | ||||||||||||||||||||||||||||||
| 1186 | starts from the point that the mouse or touch is released, | - | ||||||||||||||||||||||||||||||
| 1187 | while still in motion. | - | ||||||||||||||||||||||||||||||
| 1188 | - | |||||||||||||||||||||||||||||||
| 1189 | The corresponding handler is \c onFlickStarted. | - | ||||||||||||||||||||||||||||||
| 1190 | */ | - | ||||||||||||||||||||||||||||||
| 1191 | - | |||||||||||||||||||||||||||||||
| 1192 | /*! | - | ||||||||||||||||||||||||||||||
| 1193 | \qmlsignal QtQuick::PathView::flickEnded() | - | ||||||||||||||||||||||||||||||
| 1194 | - | |||||||||||||||||||||||||||||||
| 1195 | This signal is emitted when the view stops moving due to a flick. | - | ||||||||||||||||||||||||||||||
| 1196 | - | |||||||||||||||||||||||||||||||
| 1197 | The corresponding handler is \c onFlickEnded. | - | ||||||||||||||||||||||||||||||
| 1198 | */ | - | ||||||||||||||||||||||||||||||
| 1199 | - | |||||||||||||||||||||||||||||||
| 1200 | /*! | - | ||||||||||||||||||||||||||||||
| 1201 | \qmlsignal QtQuick::PathView::dragStarted() | - | ||||||||||||||||||||||||||||||
| 1202 | - | |||||||||||||||||||||||||||||||
| 1203 | This signal is emitted when the view starts to be dragged due to user | - | ||||||||||||||||||||||||||||||
| 1204 | interaction. | - | ||||||||||||||||||||||||||||||
| 1205 | - | |||||||||||||||||||||||||||||||
| 1206 | The corresponding handler is \c onDragStarted. | - | ||||||||||||||||||||||||||||||
| 1207 | */ | - | ||||||||||||||||||||||||||||||
| 1208 | - | |||||||||||||||||||||||||||||||
| 1209 | /*! | - | ||||||||||||||||||||||||||||||
| 1210 | \qmlsignal QtQuick::PathView::dragEnded() | - | ||||||||||||||||||||||||||||||
| 1211 | - | |||||||||||||||||||||||||||||||
| 1212 | This signal is emitted when the user stops dragging the view. | - | ||||||||||||||||||||||||||||||
| 1213 | - | |||||||||||||||||||||||||||||||
| 1214 | If the velocity of the drag is suffient at the time the | - | ||||||||||||||||||||||||||||||
| 1215 | touch/mouse button is released then a flick will start. | - | ||||||||||||||||||||||||||||||
| 1216 | - | |||||||||||||||||||||||||||||||
| 1217 | The corresponding handler is \c onDragEnded. | - | ||||||||||||||||||||||||||||||
| 1218 | */ | - | ||||||||||||||||||||||||||||||
| 1219 | - | |||||||||||||||||||||||||||||||
| 1220 | /*! | - | ||||||||||||||||||||||||||||||
| 1221 | \qmlproperty Component QtQuick::PathView::delegate | - | ||||||||||||||||||||||||||||||
| 1222 | - | |||||||||||||||||||||||||||||||
| 1223 | The delegate provides a template defining each item instantiated by the view. | - | ||||||||||||||||||||||||||||||
| 1224 | The index is exposed as an accessible \c index property. Properties of the | - | ||||||||||||||||||||||||||||||
| 1225 | model are also available depending upon the type of \l {qml-data-models}{Data Model}. | - | ||||||||||||||||||||||||||||||
| 1226 | - | |||||||||||||||||||||||||||||||
| 1227 | The number of objects and bindings in the delegate has a direct effect on the | - | ||||||||||||||||||||||||||||||
| 1228 | flicking performance of the view when pathItemCount is specified. If at all possible, place functionality | - | ||||||||||||||||||||||||||||||
| 1229 | that is not needed for the normal display of the delegate in a \l Loader which | - | ||||||||||||||||||||||||||||||
| 1230 | can load additional components when needed. | - | ||||||||||||||||||||||||||||||
| 1231 | - | |||||||||||||||||||||||||||||||
| 1232 | Note that the PathView will layout the items based on the size of the root | - | ||||||||||||||||||||||||||||||
| 1233 | item in the delegate. | - | ||||||||||||||||||||||||||||||
| 1234 | - | |||||||||||||||||||||||||||||||
| 1235 | Here is an example delegate: | - | ||||||||||||||||||||||||||||||
| 1236 | \snippet qml/pathview/pathview.qml 1 | - | ||||||||||||||||||||||||||||||
| 1237 | */ | - | ||||||||||||||||||||||||||||||
| 1238 | QQmlComponent *QQuickPathView::delegate() const | - | ||||||||||||||||||||||||||||||
| 1239 | { | - | ||||||||||||||||||||||||||||||
| 1240 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1241 |      if (d->model) {
  | 124-146 | ||||||||||||||||||||||||||||||
| 1242 |         if (QQmlDelegateModel *dataModel = qobject_cast<QQmlDelegateModel*>(d->model))
  | 0-146 | ||||||||||||||||||||||||||||||
| 1243 |             return dataModel->delegate(); executed 146 times by 2 tests:  return dataModel->delegate();Executed by: 
  | 146 | ||||||||||||||||||||||||||||||
| 1244 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1245 | - | |||||||||||||||||||||||||||||||
| 1246 |     return nullptr; executed 124 times by 3 tests:  return nullptr;Executed by: 
  | 124 | ||||||||||||||||||||||||||||||
| 1247 | } | - | ||||||||||||||||||||||||||||||
| 1248 | - | |||||||||||||||||||||||||||||||
| 1249 | void QQuickPathView::setDelegate(QQmlComponent *delegate) | - | ||||||||||||||||||||||||||||||
| 1250 | { | - | ||||||||||||||||||||||||||||||
| 1251 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1252 |     if (delegate == this->delegate())
  | 2-258 | ||||||||||||||||||||||||||||||
| 1253 |         return; executed 2 times by 1 test:  return;Executed by: 
  | 2 | ||||||||||||||||||||||||||||||
| 1254 |     if (!d->ownModel) {
  | 122-136 | ||||||||||||||||||||||||||||||
| 1255 | d->model = new QQmlDelegateModel(qmlContext(this)); | - | ||||||||||||||||||||||||||||||
| 1256 | d->ownModel = true; | - | ||||||||||||||||||||||||||||||
| 1257 |         if (isComponentComplete())
  | 0-122 | ||||||||||||||||||||||||||||||
| 1258 |             static_cast<QQmlDelegateModel *>(d->model.data())->componentComplete(); never executed:  static_cast<QQmlDelegateModel *>(d->model.data())->componentComplete(); | 0 | ||||||||||||||||||||||||||||||
| 1259 |     } executed 122 times by 3 tests:  end of blockExecuted by: 
  | 122 | ||||||||||||||||||||||||||||||
| 1260 |     if (QQmlDelegateModel *dataModel = qobject_cast<QQmlDelegateModel*>(d->model)) {
  | 0-258 | ||||||||||||||||||||||||||||||
| 1261 | int oldCount = dataModel->count(); | - | ||||||||||||||||||||||||||||||
| 1262 | dataModel->setDelegate(delegate); | - | ||||||||||||||||||||||||||||||
| 1263 | d->modelCount = dataModel->count(); | - | ||||||||||||||||||||||||||||||
| 1264 | d->regenerate(); | - | ||||||||||||||||||||||||||||||
| 1265 |         if (oldCount != dataModel->count())
  | 0-258 | ||||||||||||||||||||||||||||||
| 1266 |             emit countChanged(); never executed:  countChanged(); | 0 | ||||||||||||||||||||||||||||||
| 1267 | emit delegateChanged(); | - | ||||||||||||||||||||||||||||||
| 1268 | d->delegateValidated = false; | - | ||||||||||||||||||||||||||||||
| 1269 |     } executed 258 times by 3 tests:  end of blockExecuted by: 
  | 258 | ||||||||||||||||||||||||||||||
| 1270 | } executed 258 times by 3 tests:  end of blockExecuted by: 
  | 258 | ||||||||||||||||||||||||||||||
| 1271 | - | |||||||||||||||||||||||||||||||
| 1272 | /*! | - | ||||||||||||||||||||||||||||||
| 1273 | \qmlproperty int QtQuick::PathView::pathItemCount | - | ||||||||||||||||||||||||||||||
| 1274 | This property holds the number of items visible on the path at any one time. | - | ||||||||||||||||||||||||||||||
| 1275 | - | |||||||||||||||||||||||||||||||
| 1276 | Setting pathItemCount to undefined will show all items on the path. | - | ||||||||||||||||||||||||||||||
| 1277 | */ | - | ||||||||||||||||||||||||||||||
| 1278 | int QQuickPathView::pathItemCount() const | - | ||||||||||||||||||||||||||||||
| 1279 | { | - | ||||||||||||||||||||||||||||||
| 1280 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1281 |     return d->pathItems; executed 24 times by 2 tests:  return d->pathItems;Executed by: 
  | 24 | ||||||||||||||||||||||||||||||
| 1282 | } | - | ||||||||||||||||||||||||||||||
| 1283 | - | |||||||||||||||||||||||||||||||
| 1284 | void QQuickPathView::setPathItemCount(int i) | - | ||||||||||||||||||||||||||||||
| 1285 | { | - | ||||||||||||||||||||||||||||||
| 1286 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1287 |     if (i == d->pathItems)
  | 2-136 | ||||||||||||||||||||||||||||||
| 1288 |         return; executed 2 times by 1 test:  return;Executed by: 
  | 2 | ||||||||||||||||||||||||||||||
| 1289 |     if (i < 1)
  | 2-134 | ||||||||||||||||||||||||||||||
| 1290 |         i = 1; executed 2 times by 1 test:  i = 1;Executed by: 
  | 2 | ||||||||||||||||||||||||||||||
| 1291 | d->pathItems = i; | - | ||||||||||||||||||||||||||||||
| 1292 | d->updateMappedRange(); | - | ||||||||||||||||||||||||||||||
| 1293 |     if (d->isValid() && isComponentComplete()) {
 
  | 0-104 | ||||||||||||||||||||||||||||||
| 1294 | d->regenerate(); | - | ||||||||||||||||||||||||||||||
| 1295 |     } executed 32 times by 2 tests:  end of blockExecuted by: 
  | 32 | ||||||||||||||||||||||||||||||
| 1296 | emit pathItemCountChanged(); | - | ||||||||||||||||||||||||||||||
| 1297 | } executed 136 times by 2 tests:  end of blockExecuted by: 
  | 136 | ||||||||||||||||||||||||||||||
| 1298 | - | |||||||||||||||||||||||||||||||
| 1299 | void QQuickPathView::resetPathItemCount() | - | ||||||||||||||||||||||||||||||
| 1300 | { | - | ||||||||||||||||||||||||||||||
| 1301 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1302 |     if (-1 == d->pathItems)
  | 0-18 | ||||||||||||||||||||||||||||||
| 1303 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 1304 | d->pathItems = -1; | - | ||||||||||||||||||||||||||||||
| 1305 | d->updateMappedRange(); | - | ||||||||||||||||||||||||||||||
| 1306 |     if (d->isValid() && isComponentComplete())
 
  | 0-18 | ||||||||||||||||||||||||||||||
| 1307 |         d->regenerate(); executed 18 times by 1 test:  d->regenerate();Executed by: 
  | 18 | ||||||||||||||||||||||||||||||
| 1308 | emit pathItemCountChanged(); | - | ||||||||||||||||||||||||||||||
| 1309 | } executed 18 times by 1 test:  end of blockExecuted by: 
  | 18 | ||||||||||||||||||||||||||||||
| 1310 | - | |||||||||||||||||||||||||||||||
| 1311 | /*! | - | ||||||||||||||||||||||||||||||
| 1312 | \qmlproperty int QtQuick::PathView::cacheItemCount | - | ||||||||||||||||||||||||||||||
| 1313 | This property holds the maximum number of items to cache off the path. | - | ||||||||||||||||||||||||||||||
| 1314 | - | |||||||||||||||||||||||||||||||
| 1315 | For example, a PathView with a model containing 20 items, a pathItemCount | - | ||||||||||||||||||||||||||||||
| 1316 | of 10, and an cacheItemCount of 4 will create up to 14 items, with 10 visible | - | ||||||||||||||||||||||||||||||
| 1317 | on the path and 4 invisible cached items. | - | ||||||||||||||||||||||||||||||
| 1318 | - | |||||||||||||||||||||||||||||||
| 1319 | The cached delegates are created asynchronously, | - | ||||||||||||||||||||||||||||||
| 1320 | allowing creation to occur across multiple frames and reducing the | - | ||||||||||||||||||||||||||||||
| 1321 | likelihood of skipping frames. | - | ||||||||||||||||||||||||||||||
| 1322 | - | |||||||||||||||||||||||||||||||
| 1323 | \note Setting this property is not a replacement for creating efficient delegates. | - | ||||||||||||||||||||||||||||||
| 1324 | It can improve the smoothness of scrolling behavior at the expense of additional | - | ||||||||||||||||||||||||||||||
| 1325 | memory usage. The fewer objects and bindings in a delegate, the faster a | - | ||||||||||||||||||||||||||||||
| 1326 | view can be scrolled. It is important to realize that setting cacheItemCount | - | ||||||||||||||||||||||||||||||
| 1327 | will only postpone issues caused by slow-loading delegates, it is not a | - | ||||||||||||||||||||||||||||||
| 1328 | solution for this scenario. | - | ||||||||||||||||||||||||||||||
| 1329 | - | |||||||||||||||||||||||||||||||
| 1330 | \sa pathItemCount | - | ||||||||||||||||||||||||||||||
| 1331 | */ | - | ||||||||||||||||||||||||||||||
| 1332 | int QQuickPathView::cacheItemCount() const | - | ||||||||||||||||||||||||||||||
| 1333 | { | - | ||||||||||||||||||||||||||||||
| 1334 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1335 |     return d->cacheSize; executed 4 times by 1 test:  return d->cacheSize;Executed by: 
  | 4 | ||||||||||||||||||||||||||||||
| 1336 | } | - | ||||||||||||||||||||||||||||||
| 1337 | - | |||||||||||||||||||||||||||||||
| 1338 | void QQuickPathView::setCacheItemCount(int i) | - | ||||||||||||||||||||||||||||||
| 1339 | { | - | ||||||||||||||||||||||||||||||
| 1340 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1341 |     if (i == d->cacheSize || i < 0)
 
  | 0-4 | ||||||||||||||||||||||||||||||
| 1342 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 1343 | - | |||||||||||||||||||||||||||||||
| 1344 | d->cacheSize = i; | - | ||||||||||||||||||||||||||||||
| 1345 | d->updateMappedRange(); | - | ||||||||||||||||||||||||||||||
| 1346 | refill(); | - | ||||||||||||||||||||||||||||||
| 1347 | emit cacheItemCountChanged(); | - | ||||||||||||||||||||||||||||||
| 1348 | } executed 4 times by 1 test:  end of blockExecuted by: 
  | 4 | ||||||||||||||||||||||||||||||
| 1349 | - | |||||||||||||||||||||||||||||||
| 1350 | /*! | - | ||||||||||||||||||||||||||||||
| 1351 | \qmlproperty enumeration QtQuick::PathView::snapMode | - | ||||||||||||||||||||||||||||||
| 1352 | - | |||||||||||||||||||||||||||||||
| 1353 | This property determines how the items will settle following a drag or flick. | - | ||||||||||||||||||||||||||||||
| 1354 | The possible values are: | - | ||||||||||||||||||||||||||||||
| 1355 | - | |||||||||||||||||||||||||||||||
| 1356 | \list | - | ||||||||||||||||||||||||||||||
| 1357 | \li PathView.NoSnap (default) - the items stop anywhere along the path. | - | ||||||||||||||||||||||||||||||
| 1358 | \li PathView.SnapToItem - the items settle with an item aligned with the \l preferredHighlightBegin. | - | ||||||||||||||||||||||||||||||
| 1359 | \li PathView.SnapOneItem - the items settle no more than one item away from the item nearest | - | ||||||||||||||||||||||||||||||
| 1360 | \l preferredHighlightBegin at the time the press is released. This mode is particularly | - | ||||||||||||||||||||||||||||||
| 1361 | useful for moving one page at a time. | - | ||||||||||||||||||||||||||||||
| 1362 | \endlist | - | ||||||||||||||||||||||||||||||
| 1363 | - | |||||||||||||||||||||||||||||||
| 1364 | \c snapMode does not affect the \l currentIndex. To update the | - | ||||||||||||||||||||||||||||||
| 1365 | \l currentIndex as the view is moved, set \l highlightRangeMode | - | ||||||||||||||||||||||||||||||
| 1366 | to \c PathView.StrictlyEnforceRange (default for PathView). | - | ||||||||||||||||||||||||||||||
| 1367 | - | |||||||||||||||||||||||||||||||
| 1368 | \sa highlightRangeMode | - | ||||||||||||||||||||||||||||||
| 1369 | */ | - | ||||||||||||||||||||||||||||||
| 1370 | QQuickPathView::SnapMode QQuickPathView::snapMode() const | - | ||||||||||||||||||||||||||||||
| 1371 | { | - | ||||||||||||||||||||||||||||||
| 1372 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1373 |     return d->snapMode; never executed:  return d->snapMode; | 0 | ||||||||||||||||||||||||||||||
| 1374 | } | - | ||||||||||||||||||||||||||||||
| 1375 | - | |||||||||||||||||||||||||||||||
| 1376 | void QQuickPathView::setSnapMode(SnapMode mode) | - | ||||||||||||||||||||||||||||||
| 1377 | { | - | ||||||||||||||||||||||||||||||
| 1378 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1379 |     if (mode == d->snapMode)
  | 0-22 | ||||||||||||||||||||||||||||||
| 1380 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 1381 | d->snapMode = mode; | - | ||||||||||||||||||||||||||||||
| 1382 | emit snapModeChanged(); | - | ||||||||||||||||||||||||||||||
| 1383 | } executed 22 times by 1 test:  end of blockExecuted by: 
  | 22 | ||||||||||||||||||||||||||||||
| 1384 | - | |||||||||||||||||||||||||||||||
| 1385 | /*! | - | ||||||||||||||||||||||||||||||
| 1386 | \qmlproperty enumeration QtQuick::PathView::movementDirection | - | ||||||||||||||||||||||||||||||
| 1387 | \since 5.7 | - | ||||||||||||||||||||||||||||||
| 1388 | - | |||||||||||||||||||||||||||||||
| 1389 | This property determines the direction in which items move when setting the current index. | - | ||||||||||||||||||||||||||||||
| 1390 | The possible values are: | - | ||||||||||||||||||||||||||||||
| 1391 | - | |||||||||||||||||||||||||||||||
| 1392 | \list | - | ||||||||||||||||||||||||||||||
| 1393 | \li PathView.Shortest (default) - the items move in the direction that requires the least | - | ||||||||||||||||||||||||||||||
| 1394 | movement, which could be either \c Negative or \c Positive. | - | ||||||||||||||||||||||||||||||
| 1395 | \li PathView.Negative - the items move backwards towards their destination. | - | ||||||||||||||||||||||||||||||
| 1396 | \li PathView.Positive - the items move forwards towards their destination. | - | ||||||||||||||||||||||||||||||
| 1397 | \endlist | - | ||||||||||||||||||||||||||||||
| 1398 | - | |||||||||||||||||||||||||||||||
| 1399 | For example, suppose that there are 5 items in the model, and \l currentIndex is \c 0. | - | ||||||||||||||||||||||||||||||
| 1400 | If currentIndex is set to \c 2, | - | ||||||||||||||||||||||||||||||
| 1401 | - | |||||||||||||||||||||||||||||||
| 1402 | \list | - | ||||||||||||||||||||||||||||||
| 1403 | \li a \c Positive movement direction will result in the following order: 0, 1, 2 | - | ||||||||||||||||||||||||||||||
| 1404 | \li a \c Negative movement direction will result in the following order: 0, 5, 4, 3, 2 | - | ||||||||||||||||||||||||||||||
| 1405 | \li a \c Shortest movement direction will result in same order with \c Positive . | - | ||||||||||||||||||||||||||||||
| 1406 | \endlist | - | ||||||||||||||||||||||||||||||
| 1407 | - | |||||||||||||||||||||||||||||||
| 1408 | \note this property doesn't affect the movement of \l incrementCurrentIndex() and \l decrementCurrentIndex(). | - | ||||||||||||||||||||||||||||||
| 1409 | */ | - | ||||||||||||||||||||||||||||||
| 1410 | QQuickPathView::MovementDirection QQuickPathView::movementDirection() const | - | ||||||||||||||||||||||||||||||
| 1411 | { | - | ||||||||||||||||||||||||||||||
| 1412 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1413 |     return d->movementDirection; executed 6 times by 1 test:  return d->movementDirection;Executed by: 
  | 6 | ||||||||||||||||||||||||||||||
| 1414 | } | - | ||||||||||||||||||||||||||||||
| 1415 | - | |||||||||||||||||||||||||||||||
| 1416 | void QQuickPathView::setMovementDirection(QQuickPathView::MovementDirection dir) | - | ||||||||||||||||||||||||||||||
| 1417 | { | - | ||||||||||||||||||||||||||||||
| 1418 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1419 |     if (dir == d->movementDirection)
  | 2-6 | ||||||||||||||||||||||||||||||
| 1420 |         return; executed 2 times by 1 test:  return;Executed by: 
  | 2 | ||||||||||||||||||||||||||||||
| 1421 | d->movementDirection = dir; | - | ||||||||||||||||||||||||||||||
| 1422 |     if (!d->tl.isActive())
  | 0-6 | ||||||||||||||||||||||||||||||
| 1423 |         d->moveDirection = d->movementDirection; executed 6 times by 1 test:  d->moveDirection = d->movementDirection;Executed by: 
  | 6 | ||||||||||||||||||||||||||||||
| 1424 | emit movementDirectionChanged(); | - | ||||||||||||||||||||||||||||||
| 1425 | } executed 6 times by 1 test:  end of blockExecuted by: 
  | 6 | ||||||||||||||||||||||||||||||
| 1426 | - | |||||||||||||||||||||||||||||||
| 1427 | /*! | - | ||||||||||||||||||||||||||||||
| 1428 | \qmlmethod QtQuick::PathView::positionViewAtIndex(int index, PositionMode mode) | - | ||||||||||||||||||||||||||||||
| 1429 | - | |||||||||||||||||||||||||||||||
| 1430 | Positions the view such that the \a index is at the position specified by | - | ||||||||||||||||||||||||||||||
| 1431 | \a mode: | - | ||||||||||||||||||||||||||||||
| 1432 | - | |||||||||||||||||||||||||||||||
| 1433 | \list | - | ||||||||||||||||||||||||||||||
| 1434 | \li PathView.Beginning - position item at the beginning of the path. | - | ||||||||||||||||||||||||||||||
| 1435 | \li PathView.Center - position item in the center of the path. | - | ||||||||||||||||||||||||||||||
| 1436 | \li PathView.End - position item at the end of the path. | - | ||||||||||||||||||||||||||||||
| 1437 | \li PathView.Contain - ensure the item is positioned on the path. | - | ||||||||||||||||||||||||||||||
| 1438 | \li PathView.SnapPosition - position the item at \l preferredHighlightBegin. This mode | - | ||||||||||||||||||||||||||||||
| 1439 | is only valid if \l highlightRangeMode is StrictlyEnforceRange or snapping is enabled | - | ||||||||||||||||||||||||||||||
| 1440 | via \l snapMode. | - | ||||||||||||||||||||||||||||||
| 1441 | \endlist | - | ||||||||||||||||||||||||||||||
| 1442 | - | |||||||||||||||||||||||||||||||
| 1443 | \b Note: methods should only be called after the Component has completed. To position | - | ||||||||||||||||||||||||||||||
| 1444 | the view at startup, this method should be called by Component.onCompleted. For | - | ||||||||||||||||||||||||||||||
| 1445 | example, to position the view at the end: | - | ||||||||||||||||||||||||||||||
| 1446 | - | |||||||||||||||||||||||||||||||
| 1447 | \code | - | ||||||||||||||||||||||||||||||
| 1448 | Component.onCompleted: positionViewAtIndex(count - 1, PathView.End) | - | ||||||||||||||||||||||||||||||
| 1449 | \endcode | - | ||||||||||||||||||||||||||||||
| 1450 | */ | - | ||||||||||||||||||||||||||||||
| 1451 | void QQuickPathView::positionViewAtIndex(int index, int mode) | - | ||||||||||||||||||||||||||||||
| 1452 | { | - | ||||||||||||||||||||||||||||||
| 1453 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1454 |     if (!d->isValid())
  | 0-44 | ||||||||||||||||||||||||||||||
| 1455 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 1456 |     if (mode < QQuickPathView::Beginning || mode > QQuickPathView::SnapPosition || mode == 3) // 3 is unused in PathView
 
 
  | 0-44 | ||||||||||||||||||||||||||||||
| 1457 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 1458 | - | |||||||||||||||||||||||||||||||
| 1459 |     if (mode == QQuickPathView::Contain && (d->pathItems < 0 || d->modelCount <= d->pathItems))
 
 
  | 0-28 | ||||||||||||||||||||||||||||||
| 1460 |         return; executed 4 times by 1 test:  return;Executed by: 
  | 4 | ||||||||||||||||||||||||||||||
| 1461 | - | |||||||||||||||||||||||||||||||
| 1462 |     int count = d->pathItems == -1 ? d->modelCount : qMin(d->pathItems, d->modelCount);
  | 14-26 | ||||||||||||||||||||||||||||||
| 1463 | int idx = (index+d->modelCount) % d->modelCount; | - | ||||||||||||||||||||||||||||||
| 1464 |     bool snap = d->haveHighlightRange && (d->highlightRangeMode != QQuickPathView::NoHighlightRange
 
  | 0-40 | ||||||||||||||||||||||||||||||
| 1465 |             || d->snapMode != QQuickPathView::NoSnap);
  | 0-18 | ||||||||||||||||||||||||||||||
| 1466 | - | |||||||||||||||||||||||||||||||
| 1467 | qreal beginOffset; | - | ||||||||||||||||||||||||||||||
| 1468 | qreal endOffset; | - | ||||||||||||||||||||||||||||||
| 1469 |     if (snap) {
  | 18-22 | ||||||||||||||||||||||||||||||
| 1470 | beginOffset = d->modelCount - idx - qFloor(count * d->highlightRangeStart); | - | ||||||||||||||||||||||||||||||
| 1471 | endOffset = beginOffset + count - 1; | - | ||||||||||||||||||||||||||||||
| 1472 |     } else { executed 22 times by 1 test:  end of blockExecuted by: 
  | 22 | ||||||||||||||||||||||||||||||
| 1473 | beginOffset = d->modelCount - idx; | - | ||||||||||||||||||||||||||||||
| 1474 | // Small offset since the last point coincides with the first and | - | ||||||||||||||||||||||||||||||
| 1475 | // this the only "end" position that gives the expected visual result. | - | ||||||||||||||||||||||||||||||
| 1476 |         qreal adj = sizeof(qreal) == sizeof(float) ? 0.00001f : 0.000000000001;
  | 0-18 | ||||||||||||||||||||||||||||||
| 1477 | endOffset = std::fmod(beginOffset + count, qreal(d->modelCount)) - adj; | - | ||||||||||||||||||||||||||||||
| 1478 |     } executed 18 times by 1 test:  end of blockExecuted by: 
  | 18 | ||||||||||||||||||||||||||||||
| 1479 | qreal offset = d->offset; | - | ||||||||||||||||||||||||||||||
| 1480 | switch (mode) { | - | ||||||||||||||||||||||||||||||
| 1481 |     case Beginning: executed 8 times by 1 test:  case Beginning:Executed by: 
  | 8 | ||||||||||||||||||||||||||||||
| 1482 | offset = beginOffset; | - | ||||||||||||||||||||||||||||||
| 1483 |         break; executed 8 times by 1 test:  break;Executed by: 
  | 8 | ||||||||||||||||||||||||||||||
| 1484 |     case End: executed 8 times by 1 test:  case End:Executed by: 
  | 8 | ||||||||||||||||||||||||||||||
| 1485 | offset = endOffset; | - | ||||||||||||||||||||||||||||||
| 1486 |         break; executed 8 times by 1 test:  break;Executed by: 
  | 8 | ||||||||||||||||||||||||||||||
| 1487 |     case Center: executed 8 times by 1 test:  case Center:Executed by: 
  | 8 | ||||||||||||||||||||||||||||||
| 1488 |         if (beginOffset < endOffset)
  | 4 | ||||||||||||||||||||||||||||||
| 1489 |             offset = (beginOffset + endOffset)/2; executed 4 times by 1 test:  offset = (beginOffset + endOffset)/2;Executed by: 
  | 4 | ||||||||||||||||||||||||||||||
| 1490 | else | - | ||||||||||||||||||||||||||||||
| 1491 |             offset = (beginOffset + (endOffset + d->modelCount))/2; executed 4 times by 1 test:  offset = (beginOffset + (endOffset + d->modelCount))/2;Executed by: 
  | 4 | ||||||||||||||||||||||||||||||
| 1492 |         if (snap)
  | 4 | ||||||||||||||||||||||||||||||
| 1493 |             offset = qRound(offset); executed 4 times by 1 test:  offset = qRound(offset);Executed by: 
  | 4 | ||||||||||||||||||||||||||||||
| 1494 |         break; executed 8 times by 1 test:  break;Executed by: 
  | 8 | ||||||||||||||||||||||||||||||
| 1495 |     case Contain: executed 12 times by 1 test:  case Contain:Executed by: 
  | 12 | ||||||||||||||||||||||||||||||
| 1496 |         if ((beginOffset < endOffset && (d->offset < beginOffset || d->offset > endOffset))
 
 
  | 0-6 | ||||||||||||||||||||||||||||||
| 1497 |                 || (d->offset < beginOffset && d->offset > endOffset)) {
 
  | 0-6 | ||||||||||||||||||||||||||||||
| 1498 | qreal diff1 = std::fmod(beginOffset - d->offset + d->modelCount, qreal(d->modelCount)); | - | ||||||||||||||||||||||||||||||
| 1499 | qreal diff2 = std::fmod(d->offset - endOffset + d->modelCount, qreal(d->modelCount)); | - | ||||||||||||||||||||||||||||||
| 1500 |             if (diff1 < diff2)
  | 4-6 | ||||||||||||||||||||||||||||||
| 1501 |                 offset = beginOffset; executed 4 times by 1 test:  offset = beginOffset;Executed by: 
  | 4 | ||||||||||||||||||||||||||||||
| 1502 | else | - | ||||||||||||||||||||||||||||||
| 1503 |                 offset = endOffset; executed 6 times by 1 test:  offset = endOffset;Executed by: 
  | 6 | ||||||||||||||||||||||||||||||
| 1504 | } | - | ||||||||||||||||||||||||||||||
| 1505 |         break; executed 12 times by 1 test:  break;Executed by: 
  | 12 | ||||||||||||||||||||||||||||||
| 1506 |     case SnapPosition: executed 4 times by 1 test:  case SnapPosition:Executed by: 
  | 4 | ||||||||||||||||||||||||||||||
| 1507 | offset = d->modelCount - idx; | - | ||||||||||||||||||||||||||||||
| 1508 |         break; executed 4 times by 1 test:  break;Executed by: 
  | 4 | ||||||||||||||||||||||||||||||
| 1509 | } | - | ||||||||||||||||||||||||||||||
| 1510 | - | |||||||||||||||||||||||||||||||
| 1511 | d->tl.clear(); | - | ||||||||||||||||||||||||||||||
| 1512 | setOffset(offset); | - | ||||||||||||||||||||||||||||||
| 1513 | } executed 40 times by 1 test:  end of blockExecuted by: 
  | 40 | ||||||||||||||||||||||||||||||
| 1514 | - | |||||||||||||||||||||||||||||||
| 1515 | /*! | - | ||||||||||||||||||||||||||||||
| 1516 | \qmlmethod int QtQuick::PathView::indexAt(real x, real y) | - | ||||||||||||||||||||||||||||||
| 1517 | - | |||||||||||||||||||||||||||||||
| 1518 | Returns the index of the item containing the point \a x, \a y in content | - | ||||||||||||||||||||||||||||||
| 1519 | coordinates. If there is no item at the point specified, -1 is returned. | - | ||||||||||||||||||||||||||||||
| 1520 | - | |||||||||||||||||||||||||||||||
| 1521 | \b Note: methods should only be called after the Component has completed. | - | ||||||||||||||||||||||||||||||
| 1522 | */ | - | ||||||||||||||||||||||||||||||
| 1523 | int QQuickPathView::indexAt(qreal x, qreal y) const | - | ||||||||||||||||||||||||||||||
| 1524 | { | - | ||||||||||||||||||||||||||||||
| 1525 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1526 | QQuickItem *item = itemAt(x, y); | - | ||||||||||||||||||||||||||||||
| 1527 |     return item ? d->model->indexOf(item, nullptr) : -1; executed 10 times by 1 test:  return item ? d->model->indexOf(item, nullptr) : -1;Executed by: 
  | 10 | ||||||||||||||||||||||||||||||
| 1528 | } | - | ||||||||||||||||||||||||||||||
| 1529 | - | |||||||||||||||||||||||||||||||
| 1530 | /*! | - | ||||||||||||||||||||||||||||||
| 1531 | \qmlmethod Item QtQuick::PathView::itemAt(real x, real y) | - | ||||||||||||||||||||||||||||||
| 1532 | - | |||||||||||||||||||||||||||||||
| 1533 | Returns the item containing the point \a x, \a y in content | - | ||||||||||||||||||||||||||||||
| 1534 | coordinates. If there is no item at the point specified, null is returned. | - | ||||||||||||||||||||||||||||||
| 1535 | - | |||||||||||||||||||||||||||||||
| 1536 | \b Note: methods should only be called after the Component has completed. | - | ||||||||||||||||||||||||||||||
| 1537 | */ | - | ||||||||||||||||||||||||||||||
| 1538 | QQuickItem *QQuickPathView::itemAt(qreal x, qreal y) const | - | ||||||||||||||||||||||||||||||
| 1539 | { | - | ||||||||||||||||||||||||||||||
| 1540 | Q_D(const QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1541 |     if (!d->isValid())
  | 0-20 | ||||||||||||||||||||||||||||||
| 1542 |         return nullptr; never executed:  return nullptr; | 0 | ||||||||||||||||||||||||||||||
| 1543 | - | |||||||||||||||||||||||||||||||
| 1544 | for (QQuickItem *item : d->items) { | - | ||||||||||||||||||||||||||||||
| 1545 | QPointF p = item->mapFromItem(this, QPointF(x, y)); | - | ||||||||||||||||||||||||||||||
| 1546 |         if (item->contains(p))
  | 12-64 | ||||||||||||||||||||||||||||||
| 1547 |             return item; executed 12 times by 1 test:  return item;Executed by: 
  | 12 | ||||||||||||||||||||||||||||||
| 1548 |     } executed 64 times by 1 test:  end of blockExecuted by: 
  | 64 | ||||||||||||||||||||||||||||||
| 1549 | - | |||||||||||||||||||||||||||||||
| 1550 |     return nullptr; executed 8 times by 1 test:  return nullptr;Executed by: 
  | 8 | ||||||||||||||||||||||||||||||
| 1551 | } | - | ||||||||||||||||||||||||||||||
| 1552 | - | |||||||||||||||||||||||||||||||
| 1553 | QPointF QQuickPathViewPrivate::pointNear(const QPointF &point, qreal *nearPercent) const | - | ||||||||||||||||||||||||||||||
| 1554 | { | - | ||||||||||||||||||||||||||||||
| 1555 | const auto pathLength = path->path().length(); | - | ||||||||||||||||||||||||||||||
| 1556 | qreal samples = qMin(pathLength / 5, qreal(500.0)); | - | ||||||||||||||||||||||||||||||
| 1557 | qreal res = pathLength / samples; | - | ||||||||||||||||||||||||||||||
| 1558 | - | |||||||||||||||||||||||||||||||
| 1559 | qreal mindist = 1e10; // big number | - | ||||||||||||||||||||||||||||||
| 1560 | QPointF nearPoint = path->pointAt(0); | - | ||||||||||||||||||||||||||||||
| 1561 | qreal nearPc = 0; | - | ||||||||||||||||||||||||||||||
| 1562 | - | |||||||||||||||||||||||||||||||
| 1563 | // get rough pos | - | ||||||||||||||||||||||||||||||
| 1564 |     for (qreal i=1; i < samples; i++) {
  | 156-22836 | ||||||||||||||||||||||||||||||
| 1565 | QPointF pt = path->pointAt(i/samples); | - | ||||||||||||||||||||||||||||||
| 1566 | QPointF diff = pt - point; | - | ||||||||||||||||||||||||||||||
| 1567 | qreal dist = diff.x()*diff.x() + diff.y()*diff.y(); | - | ||||||||||||||||||||||||||||||
| 1568 |         if (dist < mindist) {
  | 8382-14454 | ||||||||||||||||||||||||||||||
| 1569 | nearPoint = pt; | - | ||||||||||||||||||||||||||||||
| 1570 | nearPc = i; | - | ||||||||||||||||||||||||||||||
| 1571 | mindist = dist; | - | ||||||||||||||||||||||||||||||
| 1572 |         } executed 8382 times by 1 test:  end of blockExecuted by: 
  | 8382 | ||||||||||||||||||||||||||||||
| 1573 |     } executed 22836 times by 1 test:  end of blockExecuted by: 
  | 22836 | ||||||||||||||||||||||||||||||
| 1574 | - | |||||||||||||||||||||||||||||||
| 1575 | // now refine | - | ||||||||||||||||||||||||||||||
| 1576 | qreal approxPc = nearPc; | - | ||||||||||||||||||||||||||||||
| 1577 |     for (qreal i = approxPc-1.0; i < approxPc+1.0; i += 1/(2*res)) {
  | 156-3204 | ||||||||||||||||||||||||||||||
| 1578 | QPointF pt = path->pointAt(i/samples); | - | ||||||||||||||||||||||||||||||
| 1579 | QPointF diff = pt - point; | - | ||||||||||||||||||||||||||||||
| 1580 | qreal dist = diff.x()*diff.x() + diff.y()*diff.y(); | - | ||||||||||||||||||||||||||||||
| 1581 |         if (dist < mindist) {
  | 252-2952 | ||||||||||||||||||||||||||||||
| 1582 | nearPoint = pt; | - | ||||||||||||||||||||||||||||||
| 1583 | nearPc = i; | - | ||||||||||||||||||||||||||||||
| 1584 | mindist = dist; | - | ||||||||||||||||||||||||||||||
| 1585 |         } executed 252 times by 1 test:  end of blockExecuted by: 
  | 252 | ||||||||||||||||||||||||||||||
| 1586 |     } executed 3204 times by 1 test:  end of blockExecuted by: 
  | 3204 | ||||||||||||||||||||||||||||||
| 1587 | - | |||||||||||||||||||||||||||||||
| 1588 |     if (nearPercent)
  | 0-156 | ||||||||||||||||||||||||||||||
| 1589 |         *nearPercent = nearPc / samples; executed 156 times by 1 test:  *nearPercent = nearPc / samples;Executed by: 
  | 156 | ||||||||||||||||||||||||||||||
| 1590 | - | |||||||||||||||||||||||||||||||
| 1591 |     return nearPoint; executed 156 times by 1 test:  return nearPoint;Executed by: 
  | 156 | ||||||||||||||||||||||||||||||
| 1592 | } | - | ||||||||||||||||||||||||||||||
| 1593 | - | |||||||||||||||||||||||||||||||
| 1594 | void QQuickPathViewPrivate::addVelocitySample(qreal v) | - | ||||||||||||||||||||||||||||||
| 1595 | { | - | ||||||||||||||||||||||||||||||
| 1596 | velocityBuffer.append(v); | - | ||||||||||||||||||||||||||||||
| 1597 |     if (velocityBuffer.count() > QML_FLICK_SAMPLEBUFFER)
  | 16-52 | ||||||||||||||||||||||||||||||
| 1598 |         velocityBuffer.remove(0); executed 16 times by 1 test:  velocityBuffer.remove(0);Executed by: 
  | 16 | ||||||||||||||||||||||||||||||
| 1599 | } executed 68 times by 1 test:  end of blockExecuted by: 
  | 68 | ||||||||||||||||||||||||||||||
| 1600 | - | |||||||||||||||||||||||||||||||
| 1601 | qreal QQuickPathViewPrivate::calcVelocity() const | - | ||||||||||||||||||||||||||||||
| 1602 | { | - | ||||||||||||||||||||||||||||||
| 1603 | qreal velocity = 0; | - | ||||||||||||||||||||||||||||||
| 1604 |     if (velocityBuffer.count() > QML_FLICK_DISCARDSAMPLES) {
  | 2-18 | ||||||||||||||||||||||||||||||
| 1605 | int count = velocityBuffer.count()-QML_FLICK_DISCARDSAMPLES; | - | ||||||||||||||||||||||||||||||
| 1606 |         for (int i = 0; i < count; ++i) {
  | 18-50 | ||||||||||||||||||||||||||||||
| 1607 | qreal v = velocityBuffer.at(i); | - | ||||||||||||||||||||||||||||||
| 1608 | velocity += v; | - | ||||||||||||||||||||||||||||||
| 1609 |         } executed 50 times by 1 test:  end of blockExecuted by: 
  | 50 | ||||||||||||||||||||||||||||||
| 1610 | velocity /= count; | - | ||||||||||||||||||||||||||||||
| 1611 |     } executed 18 times by 1 test:  end of blockExecuted by: 
  | 18 | ||||||||||||||||||||||||||||||
| 1612 |     return velocity; executed 20 times by 1 test:  return velocity;Executed by: 
  | 20 | ||||||||||||||||||||||||||||||
| 1613 | } | - | ||||||||||||||||||||||||||||||
| 1614 | - | |||||||||||||||||||||||||||||||
| 1615 | qint64 QQuickPathViewPrivate::computeCurrentTime(QInputEvent *event) const | - | ||||||||||||||||||||||||||||||
| 1616 | { | - | ||||||||||||||||||||||||||||||
| 1617 |     if (0 != event->timestamp())
  | 4-152 | ||||||||||||||||||||||||||||||
| 1618 |         return event->timestamp(); executed 152 times by 1 test:  return event->timestamp();Executed by: 
  | 152 | ||||||||||||||||||||||||||||||
| 1619 |     return timer.elapsed(); executed 4 times by 1 test:  return timer.elapsed();Executed by: 
  | 4 | ||||||||||||||||||||||||||||||
| 1620 | } | - | ||||||||||||||||||||||||||||||
| 1621 | - | |||||||||||||||||||||||||||||||
| 1622 | void QQuickPathView::mousePressEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||
| 1623 | { | - | ||||||||||||||||||||||||||||||
| 1624 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1625 |     if (d->interactive) {
  | 0-20 | ||||||||||||||||||||||||||||||
| 1626 | d->handleMousePressEvent(event); | - | ||||||||||||||||||||||||||||||
| 1627 | event->accept(); | - | ||||||||||||||||||||||||||||||
| 1628 |     } else { executed 20 times by 1 test:  end of blockExecuted by: 
  | 20 | ||||||||||||||||||||||||||||||
| 1629 | QQuickItem::mousePressEvent(event); | - | ||||||||||||||||||||||||||||||
| 1630 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1631 | } | - | ||||||||||||||||||||||||||||||
| 1632 | - | |||||||||||||||||||||||||||||||
| 1633 | void QQuickPathViewPrivate::handleMousePressEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||
| 1634 | { | - | ||||||||||||||||||||||||||||||
| 1635 |     if (!interactive || !items.count() || !model || !modelCount)
 
 
 
  | 0-26 | ||||||||||||||||||||||||||||||
| 1636 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 1637 | velocityBuffer.clear(); | - | ||||||||||||||||||||||||||||||
| 1638 | int idx = 0; | - | ||||||||||||||||||||||||||||||
| 1639 |     for (; idx < items.count(); ++idx) {
  | 10-232 | ||||||||||||||||||||||||||||||
| 1640 | QQuickItem *item = items.at(idx); | - | ||||||||||||||||||||||||||||||
| 1641 |         if (item->contains(item->mapFromScene(event->windowPos())))
  | 16-216 | ||||||||||||||||||||||||||||||
| 1642 |             break; executed 16 times by 1 test:  break;Executed by: 
  | 16 | ||||||||||||||||||||||||||||||
| 1643 |     } executed 216 times by 1 test:  end of blockExecuted by: 
  | 216 | ||||||||||||||||||||||||||||||
| 1644 |     if (idx == items.count() && dragMargin == 0.)  // didn't click on an item
 
  | 0-16 | ||||||||||||||||||||||||||||||
| 1645 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 1646 | - | |||||||||||||||||||||||||||||||
| 1647 | startPoint = pointNear(event->localPos(), &startPc); | - | ||||||||||||||||||||||||||||||
| 1648 | startPos = event->localPos(); | - | ||||||||||||||||||||||||||||||
| 1649 |     if (idx == items.count()) {
  | 10-16 | ||||||||||||||||||||||||||||||
| 1650 | qreal distance = qAbs(event->localPos().x() - startPoint.x()) + qAbs(event->localPos().y() - startPoint.y()); | - | ||||||||||||||||||||||||||||||
| 1651 |         if (distance > dragMargin)
  | 0-10 | ||||||||||||||||||||||||||||||
| 1652 |             return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 1653 |     } executed 10 times by 1 test:  end of blockExecuted by: 
  | 10 | ||||||||||||||||||||||||||||||
| 1654 | - | |||||||||||||||||||||||||||||||
| 1655 | - | |||||||||||||||||||||||||||||||
| 1656 |     if (tl.isActive() && flicking && flickDuration && qreal(tl.time())/flickDuration < 0.8)
 
 
 
  | 0-22 | ||||||||||||||||||||||||||||||
| 1657 |         stealMouse = true; // If we've been flicked then steal the click. never executed:  stealMouse = true; | 0 | ||||||||||||||||||||||||||||||
| 1658 | else | - | ||||||||||||||||||||||||||||||
| 1659 |         stealMouse = false; executed 26 times by 1 test:  stealMouse = false;Executed by: 
  | 26 | ||||||||||||||||||||||||||||||
| 1660 | - | |||||||||||||||||||||||||||||||
| 1661 | timer.start(); | - | ||||||||||||||||||||||||||||||
| 1662 | lastPosTime = computeCurrentTime(event); | - | ||||||||||||||||||||||||||||||
| 1663 | tl.clear(); | - | ||||||||||||||||||||||||||||||
| 1664 | } executed 26 times by 1 test:  end of blockExecuted by: 
  | 26 | ||||||||||||||||||||||||||||||
| 1665 | - | |||||||||||||||||||||||||||||||
| 1666 | void QQuickPathView::mouseMoveEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||
| 1667 | { | - | ||||||||||||||||||||||||||||||
| 1668 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1669 |     if (d->interactive) {
  | 0-106 | ||||||||||||||||||||||||||||||
| 1670 | d->handleMouseMoveEvent(event); | - | ||||||||||||||||||||||||||||||
| 1671 | event->accept(); | - | ||||||||||||||||||||||||||||||
| 1672 |     } else { executed 106 times by 1 test:  end of blockExecuted by: 
  | 106 | ||||||||||||||||||||||||||||||
| 1673 | QQuickItem::mouseMoveEvent(event); | - | ||||||||||||||||||||||||||||||
| 1674 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1675 | } | - | ||||||||||||||||||||||||||||||
| 1676 | - | |||||||||||||||||||||||||||||||
| 1677 | void QQuickPathViewPrivate::handleMouseMoveEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||
| 1678 | { | - | ||||||||||||||||||||||||||||||
| 1679 | Q_Q(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1680 |     if (!interactive || !timer.isValid() || !model || !modelCount)
 
 
 
  | 0-132 | ||||||||||||||||||||||||||||||
| 1681 |         return; executed 2 times by 1 test:  return;Executed by: 
  | 2 | ||||||||||||||||||||||||||||||
| 1682 | - | |||||||||||||||||||||||||||||||
| 1683 | qint64 currentTimestamp = computeCurrentTime(event); | - | ||||||||||||||||||||||||||||||
| 1684 | qreal newPc; | - | ||||||||||||||||||||||||||||||
| 1685 | QPointF pathPoint = pointNear(event->localPos(), &newPc); | - | ||||||||||||||||||||||||||||||
| 1686 |     if (!stealMouse) {
  | 42-88 | ||||||||||||||||||||||||||||||
| 1687 | QPointF posDelta = event->localPos() - startPos; | - | ||||||||||||||||||||||||||||||
| 1688 |         if (QQuickWindowPrivate::dragOverThreshold(posDelta.y(), Qt::YAxis, event) || QQuickWindowPrivate::dragOverThreshold(posDelta.x(), Qt::XAxis, event)) {
 
  | 0-42 | ||||||||||||||||||||||||||||||
| 1689 | // The touch has exceeded the threshold. If the movement along the path is close to the drag threshold | - | ||||||||||||||||||||||||||||||
| 1690 | // then we'll assume that this gesture targets the PathView. This ensures PathView gesture grabbing | - | ||||||||||||||||||||||||||||||
| 1691 | // is in sync with other items. | - | ||||||||||||||||||||||||||||||
| 1692 | QPointF pathDelta = pathPoint - startPoint; | - | ||||||||||||||||||||||||||||||
| 1693 | const int startDragDistance = QGuiApplication::styleHints()->startDragDistance(); | - | ||||||||||||||||||||||||||||||
| 1694 |             if (qAbs(pathDelta.x()) > startDragDistance * 0.8
  | 0-26 | ||||||||||||||||||||||||||||||
| 1695 |                     || qAbs(pathDelta.y()) > startDragDistance * 0.8) {
  | 0 | ||||||||||||||||||||||||||||||
| 1696 | stealMouse = true; | - | ||||||||||||||||||||||||||||||
| 1697 | q->setKeepMouseGrab(true); | - | ||||||||||||||||||||||||||||||
| 1698 |             } executed 26 times by 1 test:  end of blockExecuted by: 
  | 26 | ||||||||||||||||||||||||||||||
| 1699 |         } executed 26 times by 1 test:  end of blockExecuted by: 
  | 26 | ||||||||||||||||||||||||||||||
| 1700 |     } else { executed 42 times by 1 test:  end of blockExecuted by: 
  | 42 | ||||||||||||||||||||||||||||||
| 1701 | moveReason = QQuickPathViewPrivate::Mouse; | - | ||||||||||||||||||||||||||||||
| 1702 |         int count = pathItems == -1 ? modelCount : qMin(pathItems, modelCount);
  | 38-50 | ||||||||||||||||||||||||||||||
| 1703 | qreal diff = (newPc - startPc)*count; | - | ||||||||||||||||||||||||||||||
| 1704 |         if (diff) {
  | 16-72 | ||||||||||||||||||||||||||||||
| 1705 | q->setOffset(offset + diff); | - | ||||||||||||||||||||||||||||||
| 1706 | - | |||||||||||||||||||||||||||||||
| 1707 |             if (diff > modelCount/2)
  | 0-72 | ||||||||||||||||||||||||||||||
| 1708 |                 diff -= modelCount; never executed:  diff -= modelCount; | 0 | ||||||||||||||||||||||||||||||
| 1709 |             else if (diff < -modelCount/2)
  | 0-72 | ||||||||||||||||||||||||||||||
| 1710 |                 diff += modelCount; never executed:  diff += modelCount; | 0 | ||||||||||||||||||||||||||||||
| 1711 | - | |||||||||||||||||||||||||||||||
| 1712 | qint64 elapsed = currentTimestamp - lastPosTime; | - | ||||||||||||||||||||||||||||||
| 1713 |             if (elapsed > 0)
  | 4-68 | ||||||||||||||||||||||||||||||
| 1714 |                 addVelocitySample(diff / (qreal(elapsed) / 1000.)); executed 68 times by 1 test:  addVelocitySample(diff / (qreal(elapsed) / 1000.));Executed by: 
  | 68 | ||||||||||||||||||||||||||||||
| 1715 |         } executed 72 times by 1 test:  end of blockExecuted by: 
  | 72 | ||||||||||||||||||||||||||||||
| 1716 |         if (!moving) {
  | 22-66 | ||||||||||||||||||||||||||||||
| 1717 | moving = true; | - | ||||||||||||||||||||||||||||||
| 1718 | emit q->movingChanged(); | - | ||||||||||||||||||||||||||||||
| 1719 | emit q->movementStarted(); | - | ||||||||||||||||||||||||||||||
| 1720 |         } executed 22 times by 1 test:  end of blockExecuted by: 
  | 22 | ||||||||||||||||||||||||||||||
| 1721 | setDragging(true); | - | ||||||||||||||||||||||||||||||
| 1722 |     } executed 88 times by 1 test:  end of blockExecuted by: 
  | 88 | ||||||||||||||||||||||||||||||
| 1723 | startPc = newPc; | - | ||||||||||||||||||||||||||||||
| 1724 | lastPosTime = currentTimestamp; | - | ||||||||||||||||||||||||||||||
| 1725 | } executed 130 times by 1 test:  end of blockExecuted by: 
  | 130 | ||||||||||||||||||||||||||||||
| 1726 | - | |||||||||||||||||||||||||||||||
| 1727 | void QQuickPathView::mouseReleaseEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||
| 1728 | { | - | ||||||||||||||||||||||||||||||
| 1729 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1730 |     if (d->interactive) {
  | 0-20 | ||||||||||||||||||||||||||||||
| 1731 | d->handleMouseReleaseEvent(event); | - | ||||||||||||||||||||||||||||||
| 1732 | event->accept(); | - | ||||||||||||||||||||||||||||||
| 1733 | ungrabMouse(); | - | ||||||||||||||||||||||||||||||
| 1734 |     } else { executed 20 times by 1 test:  end of blockExecuted by: 
  | 20 | ||||||||||||||||||||||||||||||
| 1735 | QQuickItem::mouseReleaseEvent(event); | - | ||||||||||||||||||||||||||||||
| 1736 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1737 | } | - | ||||||||||||||||||||||||||||||
| 1738 | - | |||||||||||||||||||||||||||||||
| 1739 | void QQuickPathViewPrivate::handleMouseReleaseEvent(QMouseEvent *) | - | ||||||||||||||||||||||||||||||
| 1740 | { | - | ||||||||||||||||||||||||||||||
| 1741 | Q_Q(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1742 | stealMouse = false; | - | ||||||||||||||||||||||||||||||
| 1743 | q->setKeepMouseGrab(false); | - | ||||||||||||||||||||||||||||||
| 1744 | setDragging(false); | - | ||||||||||||||||||||||||||||||
| 1745 |     if (!interactive || !timer.isValid() || !model || !modelCount) {
 
 
 
  | 0-22 | ||||||||||||||||||||||||||||||
| 1746 | timer.invalidate(); | - | ||||||||||||||||||||||||||||||
| 1747 |         if (!tl.isActive())
  | 0-2 | ||||||||||||||||||||||||||||||
| 1748 |             q->movementEnding(); executed 2 times by 1 test:  q->movementEnding();Executed by: 
  | 2 | ||||||||||||||||||||||||||||||
| 1749 |         return; executed 2 times by 1 test:  return;Executed by: 
  | 2 | ||||||||||||||||||||||||||||||
| 1750 | } | - | ||||||||||||||||||||||||||||||
| 1751 | - | |||||||||||||||||||||||||||||||
| 1752 | qreal velocity = calcVelocity(); | - | ||||||||||||||||||||||||||||||
| 1753 |     qreal count = pathItems == -1 ? modelCount : qMin(pathItems, modelCount);
  | 10 | ||||||||||||||||||||||||||||||
| 1754 | const auto averageItemLength = path->path().length() / count; | - | ||||||||||||||||||||||||||||||
| 1755 | qreal pixelVelocity = averageItemLength * velocity; | - | ||||||||||||||||||||||||||||||
| 1756 |     if (qAbs(pixelVelocity) > MinimumFlickVelocity) {
  | 2-18 | ||||||||||||||||||||||||||||||
| 1757 |         if (qAbs(pixelVelocity) > maximumFlickVelocity || snapMode == QQuickPathView::SnapOneItem) {
 
  | 4-10 | ||||||||||||||||||||||||||||||
| 1758 | // limit velocity | - | ||||||||||||||||||||||||||||||
| 1759 |             qreal maxVel = velocity < 0 ? -maximumFlickVelocity : maximumFlickVelocity;
  | 2-10 | ||||||||||||||||||||||||||||||
| 1760 | velocity = maxVel / averageItemLength; | - | ||||||||||||||||||||||||||||||
| 1761 |         } executed 12 times by 1 test:  end of blockExecuted by: 
  | 12 | ||||||||||||||||||||||||||||||
| 1762 | // Calculate the distance to be travelled | - | ||||||||||||||||||||||||||||||
| 1763 | qreal v2 = velocity*velocity; | - | ||||||||||||||||||||||||||||||
| 1764 | qreal accel = deceleration/10; | - | ||||||||||||||||||||||||||||||
| 1765 | qreal dist = 0; | - | ||||||||||||||||||||||||||||||
| 1766 |         if (haveHighlightRange && (highlightRangeMode == QQuickPathView::StrictlyEnforceRange
 
  | 0-18 | ||||||||||||||||||||||||||||||
| 1767 |                 || snapMode != QQuickPathView::NoSnap)) {
  | 0-4 | ||||||||||||||||||||||||||||||
| 1768 |             if (snapMode == QQuickPathView::SnapOneItem) {
  | 4-14 | ||||||||||||||||||||||||||||||
| 1769 | // encourage snapping one item in direction of motion | - | ||||||||||||||||||||||||||||||
| 1770 |                 if (velocity > 0.)
  | 0-4 | ||||||||||||||||||||||||||||||
| 1771 |                     dist = qRound(0.5 + offset) - offset; never executed:  dist = qRound(0.5 + offset) - offset; | 0 | ||||||||||||||||||||||||||||||
| 1772 | else | - | ||||||||||||||||||||||||||||||
| 1773 |                     dist = qRound(0.5 - offset) + offset; executed 4 times by 1 test:  dist = qRound(0.5 - offset) + offset;Executed by: 
  | 4 | ||||||||||||||||||||||||||||||
| 1774 | } else { | - | ||||||||||||||||||||||||||||||
| 1775 | // + 0.25 to encourage moving at least one item in the flick direction | - | ||||||||||||||||||||||||||||||
| 1776 | dist = qMin(qreal(modelCount-1), qreal(v2 / (accel * 2.0) + 0.25)); | - | ||||||||||||||||||||||||||||||
| 1777 | - | |||||||||||||||||||||||||||||||
| 1778 | // round to nearest item. | - | ||||||||||||||||||||||||||||||
| 1779 |                 if (velocity > 0.)
  | 4-10 | ||||||||||||||||||||||||||||||
| 1780 |                     dist = qRound(dist + offset) - offset; executed 4 times by 1 test:  dist = qRound(dist + offset) - offset;Executed by: 
  | 4 | ||||||||||||||||||||||||||||||
| 1781 | else | - | ||||||||||||||||||||||||||||||
| 1782 |                     dist = qRound(dist - offset) + offset; executed 10 times by 1 test:  dist = qRound(dist - offset) + offset;Executed by: 
  | 10 | ||||||||||||||||||||||||||||||
| 1783 | } | - | ||||||||||||||||||||||||||||||
| 1784 | // Calculate accel required to stop on item boundary | - | ||||||||||||||||||||||||||||||
| 1785 |             if (dist <= 0.) {
  | 2-16 | ||||||||||||||||||||||||||||||
| 1786 | dist = 0.; | - | ||||||||||||||||||||||||||||||
| 1787 | accel = 0.; | - | ||||||||||||||||||||||||||||||
| 1788 |             } else { executed 2 times by 1 test:  end of blockExecuted by: 
  | 2 | ||||||||||||||||||||||||||||||
| 1789 | accel = v2 / (2.0f * qAbs(dist)); | - | ||||||||||||||||||||||||||||||
| 1790 |             } executed 16 times by 1 test:  end of blockExecuted by: 
  | 16 | ||||||||||||||||||||||||||||||
| 1791 | } else { | - | ||||||||||||||||||||||||||||||
| 1792 | dist = qMin(qreal(modelCount-1), qreal(v2 / (accel * 2.0))); | - | ||||||||||||||||||||||||||||||
| 1793 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1794 | flickDuration = static_cast<int>(1000 * qAbs(velocity) / accel); | - | ||||||||||||||||||||||||||||||
| 1795 | offsetAdj = 0.0; | - | ||||||||||||||||||||||||||||||
| 1796 | moveOffset.setValue(offset); | - | ||||||||||||||||||||||||||||||
| 1797 | tl.accel(moveOffset, velocity, accel, dist); | - | ||||||||||||||||||||||||||||||
| 1798 | tl.callback(QQuickTimeLineCallback(&moveOffset, fixOffsetCallback, this)); | - | ||||||||||||||||||||||||||||||
| 1799 |         if (!flicking) {
  | 0-18 | ||||||||||||||||||||||||||||||
| 1800 | flicking = true; | - | ||||||||||||||||||||||||||||||
| 1801 | emit q->flickingChanged(); | - | ||||||||||||||||||||||||||||||
| 1802 | emit q->flickStarted(); | - | ||||||||||||||||||||||||||||||
| 1803 |         } executed 18 times by 1 test:  end of blockExecuted by: 
  | 18 | ||||||||||||||||||||||||||||||
| 1804 |     } else { executed 18 times by 1 test:  end of blockExecuted by: 
  | 18 | ||||||||||||||||||||||||||||||
| 1805 | fixOffset(); | - | ||||||||||||||||||||||||||||||
| 1806 |     } executed 2 times by 1 test:  end of blockExecuted by: 
  | 2 | ||||||||||||||||||||||||||||||
| 1807 | - | |||||||||||||||||||||||||||||||
| 1808 | timer.invalidate(); | - | ||||||||||||||||||||||||||||||
| 1809 |     if (!tl.isActive())
  | 0-20 | ||||||||||||||||||||||||||||||
| 1810 |         q->movementEnding(); never executed:  q->movementEnding(); | 0 | ||||||||||||||||||||||||||||||
| 1811 | } executed 20 times by 1 test:  end of blockExecuted by: 
  | 20 | ||||||||||||||||||||||||||||||
| 1812 | - | |||||||||||||||||||||||||||||||
| 1813 | bool QQuickPathView::sendMouseEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||
| 1814 | { | - | ||||||||||||||||||||||||||||||
| 1815 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1816 | QPointF localPos = mapFromScene(event->windowPos()); | - | ||||||||||||||||||||||||||||||
| 1817 | - | |||||||||||||||||||||||||||||||
| 1818 | QQuickWindow *c = window(); | - | ||||||||||||||||||||||||||||||
| 1819 |     QQuickItem *grabber = c ? c->mouseGrabberItem() : nullptr;
  | 0-48 | ||||||||||||||||||||||||||||||
| 1820 |     if (grabber == this && d->stealMouse) {
 
  | 0-48 | ||||||||||||||||||||||||||||||
| 1821 | // we are already the grabber and we do want the mouse event to ourselves. | - | ||||||||||||||||||||||||||||||
| 1822 |         return true; never executed:  return true; | 0 | ||||||||||||||||||||||||||||||
| 1823 | } | - | ||||||||||||||||||||||||||||||
| 1824 | - | |||||||||||||||||||||||||||||||
| 1825 |     bool grabberDisabled = grabber && !grabber->isEnabled();
 
  | 0-42 | ||||||||||||||||||||||||||||||
| 1826 | bool stealThisEvent = d->stealMouse; | - | ||||||||||||||||||||||||||||||
| 1827 |     if ((stealThisEvent || contains(localPos)) && (!grabber || !grabber->keepMouseGrab() || grabberDisabled)) {
 
 
 
 
  | 0-42 | ||||||||||||||||||||||||||||||
| 1828 | QScopedPointer<QMouseEvent> mouseEvent(QQuickWindowPrivate::cloneMouseEvent(event, &localPos)); | - | ||||||||||||||||||||||||||||||
| 1829 | mouseEvent->setAccepted(false); | - | ||||||||||||||||||||||||||||||
| 1830 | - | |||||||||||||||||||||||||||||||
| 1831 | switch (mouseEvent->type()) { | - | ||||||||||||||||||||||||||||||
| 1832 |         case QEvent::MouseMove: executed 26 times by 1 test:  case QEvent::MouseMove:Executed by: 
  | 26 | ||||||||||||||||||||||||||||||
| 1833 | d->handleMouseMoveEvent(mouseEvent.data()); | - | ||||||||||||||||||||||||||||||
| 1834 |             break; executed 26 times by 1 test:  break;Executed by: 
  | 26 | ||||||||||||||||||||||||||||||
| 1835 |         case QEvent::MouseButtonPress: executed 6 times by 1 test:  case QEvent::MouseButtonPress:Executed by: 
  | 6 | ||||||||||||||||||||||||||||||
| 1836 | d->handleMousePressEvent(mouseEvent.data()); | - | ||||||||||||||||||||||||||||||
| 1837 | stealThisEvent = d->stealMouse; // Update stealThisEvent in case changed by function call above | - | ||||||||||||||||||||||||||||||
| 1838 |             break; executed 6 times by 1 test:  break;Executed by: 
  | 6 | ||||||||||||||||||||||||||||||
| 1839 |         case QEvent::MouseButtonRelease: executed 2 times by 1 test:  case QEvent::MouseButtonRelease:Executed by: 
  | 2 | ||||||||||||||||||||||||||||||
| 1840 | d->handleMouseReleaseEvent(mouseEvent.data()); | - | ||||||||||||||||||||||||||||||
| 1841 |             break; executed 2 times by 1 test:  break;Executed by: 
  | 2 | ||||||||||||||||||||||||||||||
| 1842 |         default: never executed:  default: | 0 | ||||||||||||||||||||||||||||||
| 1843 |             break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1844 | } | - | ||||||||||||||||||||||||||||||
| 1845 |         grabber = c ? c->mouseGrabberItem() : nullptr;
  | 0-34 | ||||||||||||||||||||||||||||||
| 1846 |         if ((grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this) || grabberDisabled) {
 
 
 
 
  | 0-32 | ||||||||||||||||||||||||||||||
| 1847 | grabMouse(); | - | ||||||||||||||||||||||||||||||
| 1848 |         } executed 2 times by 1 test:  end of blockExecuted by: 
  | 2 | ||||||||||||||||||||||||||||||
| 1849 | - | |||||||||||||||||||||||||||||||
| 1850 |         const bool filtered = stealThisEvent || grabberDisabled;
 
  | 0-32 | ||||||||||||||||||||||||||||||
| 1851 |         if (filtered) {
  | 2-32 | ||||||||||||||||||||||||||||||
| 1852 | event->setAccepted(false); | - | ||||||||||||||||||||||||||||||
| 1853 |         } executed 2 times by 1 test:  end of blockExecuted by: 
  | 2 | ||||||||||||||||||||||||||||||
| 1854 |         return filtered; executed 34 times by 1 test:  return filtered;Executed by: 
  | 34 | ||||||||||||||||||||||||||||||
| 1855 |     } else if (d->timer.isValid()) {
  | 4-10 | ||||||||||||||||||||||||||||||
| 1856 | d->timer.invalidate(); | - | ||||||||||||||||||||||||||||||
| 1857 | d->fixOffset(); | - | ||||||||||||||||||||||||||||||
| 1858 |     } executed 4 times by 1 test:  end of blockExecuted by: 
  | 4 | ||||||||||||||||||||||||||||||
| 1859 |     if (event->type() == QEvent::MouseButtonRelease || (grabber && grabber->keepMouseGrab() && !grabberDisabled)) {
 
 
 
  | 0-10 | ||||||||||||||||||||||||||||||
| 1860 | d->stealMouse = false; | - | ||||||||||||||||||||||||||||||
| 1861 |     } executed 14 times by 1 test:  end of blockExecuted by: 
  | 14 | ||||||||||||||||||||||||||||||
| 1862 |     return false; executed 14 times by 1 test:  return false;Executed by: 
  | 14 | ||||||||||||||||||||||||||||||
| 1863 | } | - | ||||||||||||||||||||||||||||||
| 1864 | - | |||||||||||||||||||||||||||||||
| 1865 | bool QQuickPathView::childMouseEventFilter(QQuickItem *i, QEvent *e) | - | ||||||||||||||||||||||||||||||
| 1866 | { | - | ||||||||||||||||||||||||||||||
| 1867 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1868 |     if (!isVisible() || !d->interactive)
 
  | 0-58 | ||||||||||||||||||||||||||||||
| 1869 |         return QQuickItem::childMouseEventFilter(i, e); never executed:  return QQuickItem::childMouseEventFilter(i, e); | 0 | ||||||||||||||||||||||||||||||
| 1870 | - | |||||||||||||||||||||||||||||||
| 1871 | switch (e->type()) { | - | ||||||||||||||||||||||||||||||
| 1872 |     case QEvent::MouseButtonPress: executed 6 times by 1 test:  case QEvent::MouseButtonPress:Executed by: 
  | 6 | ||||||||||||||||||||||||||||||
| 1873 |     case QEvent::MouseMove: executed 36 times by 1 test:  case QEvent::MouseMove:Executed by: 
  | 36 | ||||||||||||||||||||||||||||||
| 1874 |     case QEvent::MouseButtonRelease: executed 6 times by 1 test:  case QEvent::MouseButtonRelease:Executed by: 
  | 6 | ||||||||||||||||||||||||||||||
| 1875 |         return sendMouseEvent(static_cast<QMouseEvent *>(e)); executed 48 times by 1 test:  return sendMouseEvent(static_cast<QMouseEvent *>(e));Executed by: 
  | 48 | ||||||||||||||||||||||||||||||
| 1876 |     default: executed 10 times by 1 test:  default:Executed by: 
  | 10 | ||||||||||||||||||||||||||||||
| 1877 |         break; executed 10 times by 1 test:  break;Executed by: 
  | 10 | ||||||||||||||||||||||||||||||
| 1878 | } | - | ||||||||||||||||||||||||||||||
| 1879 | - | |||||||||||||||||||||||||||||||
| 1880 |     return QQuickItem::childMouseEventFilter(i, e); executed 10 times by 1 test:  return QQuickItem::childMouseEventFilter(i, e);Executed by: 
  | 10 | ||||||||||||||||||||||||||||||
| 1881 | } | - | ||||||||||||||||||||||||||||||
| 1882 | - | |||||||||||||||||||||||||||||||
| 1883 | void QQuickPathView::mouseUngrabEvent() | - | ||||||||||||||||||||||||||||||
| 1884 | { | - | ||||||||||||||||||||||||||||||
| 1885 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1886 |     if (d->stealMouse) {
  | 2-20 | ||||||||||||||||||||||||||||||
| 1887 | // if our mouse grab has been removed (probably by a Flickable), | - | ||||||||||||||||||||||||||||||
| 1888 | // fix our state | - | ||||||||||||||||||||||||||||||
| 1889 | d->stealMouse = false; | - | ||||||||||||||||||||||||||||||
| 1890 | setKeepMouseGrab(false); | - | ||||||||||||||||||||||||||||||
| 1891 | d->timer.invalidate(); | - | ||||||||||||||||||||||||||||||
| 1892 | d->fixOffset(); | - | ||||||||||||||||||||||||||||||
| 1893 | d->setDragging(false); | - | ||||||||||||||||||||||||||||||
| 1894 |         if (!d->tl.isActive())
  | 0-2 | ||||||||||||||||||||||||||||||
| 1895 |             movementEnding(); never executed:  movementEnding(); | 0 | ||||||||||||||||||||||||||||||
| 1896 |     } executed 2 times by 1 test:  end of blockExecuted by: 
  | 2 | ||||||||||||||||||||||||||||||
| 1897 | } executed 22 times by 1 test:  end of blockExecuted by: 
  | 22 | ||||||||||||||||||||||||||||||
| 1898 | - | |||||||||||||||||||||||||||||||
| 1899 | void QQuickPathView::updatePolish() | - | ||||||||||||||||||||||||||||||
| 1900 | { | - | ||||||||||||||||||||||||||||||
| 1901 | QQuickItem::updatePolish(); | - | ||||||||||||||||||||||||||||||
| 1902 | refill(); | - | ||||||||||||||||||||||||||||||
| 1903 | } executed 37 times by 2 tests:  end of blockExecuted by: 
  | 37 | ||||||||||||||||||||||||||||||
| 1904 | - | |||||||||||||||||||||||||||||||
| 1905 | static inline int currentIndexRemainder(int currentIndex, int modelCount) Q_DECL_NOTHROW | - | ||||||||||||||||||||||||||||||
| 1906 | { | - | ||||||||||||||||||||||||||||||
| 1907 |     if (currentIndex < 0)
  | 0-6 | ||||||||||||||||||||||||||||||
| 1908 |         return modelCount + currentIndex % modelCount; never executed:  return modelCount + currentIndex % modelCount; | 0 | ||||||||||||||||||||||||||||||
| 1909 | else | - | ||||||||||||||||||||||||||||||
| 1910 |         return currentIndex % modelCount; executed 6 times by 1 test:  return currentIndex % modelCount;Executed by: 
  | 6 | ||||||||||||||||||||||||||||||
| 1911 | } | - | ||||||||||||||||||||||||||||||
| 1912 | - | |||||||||||||||||||||||||||||||
| 1913 | void QQuickPathView::componentComplete() | - | ||||||||||||||||||||||||||||||
| 1914 | { | - | ||||||||||||||||||||||||||||||
| 1915 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1916 |     if (d->model && d->ownModel)
  | 20-258 | ||||||||||||||||||||||||||||||
| 1917 |         static_cast<QQmlDelegateModel *>(d->model.data())->componentComplete(); executed 258 times by 3 tests:  static_cast<QQmlDelegateModel *>(d->model.data())->componentComplete();Executed by: 
  | 258 | ||||||||||||||||||||||||||||||
| 1918 | - | |||||||||||||||||||||||||||||||
| 1919 | QQuickItem::componentComplete(); | - | ||||||||||||||||||||||||||||||
| 1920 | - | |||||||||||||||||||||||||||||||
| 1921 |     if (d->model) {
  | 4-278 | ||||||||||||||||||||||||||||||
| 1922 | d->modelCount = d->model->count(); | - | ||||||||||||||||||||||||||||||
| 1923 |         if (d->modelCount && d->currentIndex != 0) // an initial value has been provided for currentIndex
 
  | 6-268 | ||||||||||||||||||||||||||||||
| 1924 |             d->offset = std::fmod(qreal(d->modelCount - currentIndexRemainder(d->currentIndex, d->modelCount)), qreal(d->modelCount)); executed 6 times by 1 test:  d->offset = std::fmod(qreal(d->modelCount - currentIndexRemainder(d->currentIndex, d->modelCount)), qreal(d->modelCount));Executed by: 
  | 6 | ||||||||||||||||||||||||||||||
| 1925 |     } executed 278 times by 3 tests:  end of blockExecuted by: 
  | 278 | ||||||||||||||||||||||||||||||
| 1926 | - | |||||||||||||||||||||||||||||||
| 1927 | d->createHighlight(); | - | ||||||||||||||||||||||||||||||
| 1928 | d->regenerate(); | - | ||||||||||||||||||||||||||||||
| 1929 | d->updateHighlight(); | - | ||||||||||||||||||||||||||||||
| 1930 | d->updateCurrent(); | - | ||||||||||||||||||||||||||||||
| 1931 | - | |||||||||||||||||||||||||||||||
| 1932 |     if (d->modelCount)
  | 14-268 | ||||||||||||||||||||||||||||||
| 1933 |         emit countChanged(); executed 268 times by 3 tests:  countChanged();Executed by: 
  | 268 | ||||||||||||||||||||||||||||||
| 1934 | } executed 282 times by 3 tests:  end of blockExecuted by: 
  | 282 | ||||||||||||||||||||||||||||||
| 1935 | - | |||||||||||||||||||||||||||||||
| 1936 | void QQuickPathView::refill() | - | ||||||||||||||||||||||||||||||
| 1937 | { | - | ||||||||||||||||||||||||||||||
| 1938 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 1939 | - | |||||||||||||||||||||||||||||||
| 1940 |     if (d->inRefill) {
  | 2-4448 | ||||||||||||||||||||||||||||||
| 1941 | d->scheduleLayout(); | - | ||||||||||||||||||||||||||||||
| 1942 |         return; executed 2 times by 1 test:  return;Executed by: 
  | 2 | ||||||||||||||||||||||||||||||
| 1943 | } | - | ||||||||||||||||||||||||||||||
| 1944 | - | |||||||||||||||||||||||||||||||
| 1945 | d->layoutScheduled = false; | - | ||||||||||||||||||||||||||||||
| 1946 | - | |||||||||||||||||||||||||||||||
| 1947 |     if (!d->isValid() || !isComponentComplete())
 
  | 12-3948 | ||||||||||||||||||||||||||||||
| 1948 |         return; executed 512 times by 3 tests:  return;Executed by: 
  | 512 | ||||||||||||||||||||||||||||||
| 1949 | - | |||||||||||||||||||||||||||||||
| 1950 | d->inRefill = true; | - | ||||||||||||||||||||||||||||||
| 1951 | - | |||||||||||||||||||||||||||||||
| 1952 | bool currentVisible = false; | - | ||||||||||||||||||||||||||||||
| 1953 |     int count = d->pathItems == -1 ? d->modelCount : qMin(d->pathItems, d->modelCount);
  | 1555-2381 | ||||||||||||||||||||||||||||||
| 1954 | - | |||||||||||||||||||||||||||||||
| 1955 | // first move existing items and remove items off path | - | ||||||||||||||||||||||||||||||
| 1956 |     qCDebug(lcItemViewDelegateLifecycle) << "currentIndex" << d->currentIndex << "offset" << d->offset; never executed:  QMessageLogger(__FILE__, 1956, __PRETTY_FUNCTION__, lcItemViewDelegateLifecycle().categoryName()).debug() << "currentIndex" << d->currentIndex << "offset" << d->offset;
  | 0-3936 | ||||||||||||||||||||||||||||||
| 1957 | QList<QQuickItem*>::iterator it = d->items.begin(); | - | ||||||||||||||||||||||||||||||
| 1958 |     while (it != d->items.end()) {
  | 3936-37500 | ||||||||||||||||||||||||||||||
| 1959 | QQuickItem *item = *it; | - | ||||||||||||||||||||||||||||||
| 1960 | int idx = d->model->indexOf(item, nullptr); | - | ||||||||||||||||||||||||||||||
| 1961 | qreal pos = d->positionOfIndex(idx); | - | ||||||||||||||||||||||||||||||
| 1962 |         if (lcItemViewDelegateLifecycle().isDebugEnabled()) {
  | 0-37500 | ||||||||||||||||||||||||||||||
| 1963 | QQuickText *text = qmlobject_cast<QQuickText*>(item); | - | ||||||||||||||||||||||||||||||
| 1964 |             if (text)
  | 0 | ||||||||||||||||||||||||||||||
| 1965 |                 qCDebug(lcItemViewDelegateLifecycle) << "idx" << idx << "@" << pos << ": QQuickText" << text->objectName() << text->text().leftRef(40); never executed:  QMessageLogger(__FILE__, 1965, __PRETTY_FUNCTION__, lcItemViewDelegateLifecycle().categoryName()).debug() << "idx" << idx << "@" << pos << ": QQuickText" << text->objectName() << text->text().leftRef(40);
  | 0 | ||||||||||||||||||||||||||||||
| 1966 | else | - | ||||||||||||||||||||||||||||||
| 1967 |                 qCDebug(lcItemViewDelegateLifecycle) << "idx" << idx << "@" << pos << ":" << item; never executed:  QMessageLogger(__FILE__, 1967, __PRETTY_FUNCTION__, lcItemViewDelegateLifecycle().categoryName()).debug() << "idx" << idx << "@" << pos << ":" << item;
  | 0 | ||||||||||||||||||||||||||||||
| 1968 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1969 |         if (pos < 1.0) {
  | 594-36906 | ||||||||||||||||||||||||||||||
| 1970 | d->updateItem(item, pos); | - | ||||||||||||||||||||||||||||||
| 1971 |             if (idx == d->currentIndex) {
  | 3361-33545 | ||||||||||||||||||||||||||||||
| 1972 | currentVisible = true; | - | ||||||||||||||||||||||||||||||
| 1973 | d->currentItemOffset = pos; | - | ||||||||||||||||||||||||||||||
| 1974 |             } executed 3361 times by 1 test:  end of blockExecuted by: 
  | 3361 | ||||||||||||||||||||||||||||||
| 1975 | ++it; | - | ||||||||||||||||||||||||||||||
| 1976 |         } else { executed 36906 times by 1 test:  end of blockExecuted by: 
  | 36906 | ||||||||||||||||||||||||||||||
| 1977 | d->updateItem(item, pos); | - | ||||||||||||||||||||||||||||||
| 1978 |             if (QQuickPathViewAttached *att = d->attached(item))
  | 0-594 | ||||||||||||||||||||||||||||||
| 1979 |                 att->setOnPath(pos < 1.0); executed 594 times by 1 test:  att->setOnPath(pos < 1.0);Executed by: 
  | 594 | ||||||||||||||||||||||||||||||
| 1980 |             if (!d->isInBound(pos, d->mappedRange - d->mappedCache, 1.0 + d->mappedCache)) {
  | 40-554 | ||||||||||||||||||||||||||||||
| 1981 |                 qCDebug(lcItemViewDelegateLifecycle) << "release" << idx << "@" << pos << ", !isInBound: lower" << (d->mappedRange - d->mappedCache) << "upper" << (1.0 + d->mappedCache); never executed:  QMessageLogger(__FILE__, 1981, __PRETTY_FUNCTION__, lcItemViewDelegateLifecycle().categoryName()).debug() << "release" << idx << "@" << pos << ", !isInBound: lower" << (d->mappedRange - d->mappedCache) << "upper" << (1.0 + d->mappedCache);
  | 0-554 | ||||||||||||||||||||||||||||||
| 1982 | d->releaseItem(item); | - | ||||||||||||||||||||||||||||||
| 1983 | it = d->items.erase(it); | - | ||||||||||||||||||||||||||||||
| 1984 |             } else { executed 554 times by 1 test:  end of blockExecuted by: 
  | 554 | ||||||||||||||||||||||||||||||
| 1985 | ++it; | - | ||||||||||||||||||||||||||||||
| 1986 |             } executed 40 times by 1 test:  end of blockExecuted by: 
  | 40 | ||||||||||||||||||||||||||||||
| 1987 | } | - | ||||||||||||||||||||||||||||||
| 1988 | } | - | ||||||||||||||||||||||||||||||
| 1989 | - | |||||||||||||||||||||||||||||||
| 1990 | bool waiting = false; | - | ||||||||||||||||||||||||||||||
| 1991 |     if (d->modelCount) {
  | 18-3918 | ||||||||||||||||||||||||||||||
| 1992 | // add items as needed | - | ||||||||||||||||||||||||||||||
| 1993 |         if (d->items.count() < count+d->cacheSize) {
  | 805-3113 | ||||||||||||||||||||||||||||||
| 1994 | int endIdx = 0; | - | ||||||||||||||||||||||||||||||
| 1995 | qreal endPos; | - | ||||||||||||||||||||||||||||||
| 1996 | int startIdx = 0; | - | ||||||||||||||||||||||||||||||
| 1997 | qreal startPos = 0.0; | - | ||||||||||||||||||||||||||||||
| 1998 | const bool wasEmpty = d->items.isEmpty(); | - | ||||||||||||||||||||||||||||||
| 1999 |             if (!wasEmpty) {
  | 350-455 | ||||||||||||||||||||||||||||||
| 2000 | //Find the beginning and end, items may not be in sorted order | - | ||||||||||||||||||||||||||||||
| 2001 | endPos = -1.0; | - | ||||||||||||||||||||||||||||||
| 2002 | startPos = 2.0; | - | ||||||||||||||||||||||||||||||
| 2003 | - | |||||||||||||||||||||||||||||||
| 2004 | for (QQuickItem * item : qAsConst(d->items)) { | - | ||||||||||||||||||||||||||||||
| 2005 | int idx = d->model->indexOf(item, nullptr); | - | ||||||||||||||||||||||||||||||
| 2006 | qreal curPos = d->positionOfIndex(idx); | - | ||||||||||||||||||||||||||||||
| 2007 |                     if (curPos > endPos) {
  | 44-4838 | ||||||||||||||||||||||||||||||
| 2008 | endPos = curPos; | - | ||||||||||||||||||||||||||||||
| 2009 | endIdx = idx; | - | ||||||||||||||||||||||||||||||
| 2010 |                     } executed 4838 times by 1 test:  end of blockExecuted by: 
  | 4838 | ||||||||||||||||||||||||||||||
| 2011 | - | |||||||||||||||||||||||||||||||
| 2012 |                     if (curPos < startPos) {
  | 356-4526 | ||||||||||||||||||||||||||||||
| 2013 | startPos = curPos; | - | ||||||||||||||||||||||||||||||
| 2014 | startIdx = idx; | - | ||||||||||||||||||||||||||||||
| 2015 |                     } executed 356 times by 1 test:  end of blockExecuted by: 
  | 356 | ||||||||||||||||||||||||||||||
| 2016 |                 } executed 4882 times by 1 test:  end of blockExecuted by: 
  | 4882 | ||||||||||||||||||||||||||||||
| 2017 |             } else { executed 350 times by 1 test:  end of blockExecuted by: 
  | 350 | ||||||||||||||||||||||||||||||
| 2018 |                 if (d->haveHighlightRange
  | 0-455 | ||||||||||||||||||||||||||||||
| 2019 |                             && (d->highlightRangeMode != QQuickPathView::NoHighlightRange
  | 114-341 | ||||||||||||||||||||||||||||||
| 2020 |                                     || d->snapMode != QQuickPathView::NoSnap))
  | 8-106 | ||||||||||||||||||||||||||||||
| 2021 |                     startPos = d->highlightRangeStart; executed 349 times by 3 tests:  startPos = d->highlightRangeStart;Executed by: 
  | 349 | ||||||||||||||||||||||||||||||
| 2022 | // With no items, then "end" is just off the top so we populate via append | - | ||||||||||||||||||||||||||||||
| 2023 | endIdx = (qRound(d->modelCount - d->offset) - 1) % d->modelCount; | - | ||||||||||||||||||||||||||||||
| 2024 | endPos = d->positionOfIndex(endIdx); | - | ||||||||||||||||||||||||||||||
| 2025 |             } executed 455 times by 3 tests:  end of blockExecuted by: 
  | 455 | ||||||||||||||||||||||||||||||
| 2026 | //Append | - | ||||||||||||||||||||||||||||||
| 2027 | int idx = endIdx + 1; | - | ||||||||||||||||||||||||||||||
| 2028 |             if (idx >= d->modelCount)
  | 300-505 | ||||||||||||||||||||||||||||||
| 2029 |                 idx = 0; executed 300 times by 3 tests:  idx = 0;Executed by: 
  | 300 | ||||||||||||||||||||||||||||||
| 2030 | qreal nextPos = d->positionOfIndex(idx); | - | ||||||||||||||||||||||||||||||
| 2031 |             while ((d->isInBound(nextPos, endPos, 1.0 + d->mappedCache) || !d->items.count())
 
  | 250-2615 | ||||||||||||||||||||||||||||||
| 2032 |                     && d->items.count() < count+d->cacheSize) {
  | 8-2857 | ||||||||||||||||||||||||||||||
| 2033 |                 qCDebug(lcItemViewDelegateLifecycle) << "append" << idx << "@" << nextPos << (d->currentIndex == idx ? "current" : "") << "items count was" << d->items.count(); never executed:  QMessageLogger(__FILE__, 2033, __PRETTY_FUNCTION__, lcItemViewDelegateLifecycle().categoryName()).debug() << "append" << idx << "@" << nextPos << (d->currentIndex == idx ? "current" : "") << "items count was" << d->items.count();
  | 0-2857 | ||||||||||||||||||||||||||||||
| 2034 | QQuickItem *item = d->getItem(idx, idx+1, nextPos >= 1.0); | - | ||||||||||||||||||||||||||||||
| 2035 |                 if (!item) {
  | 18-2839 | ||||||||||||||||||||||||||||||
| 2036 | waiting = true; | - | ||||||||||||||||||||||||||||||
| 2037 |                     break; executed 18 times by 1 test:  break;Executed by: 
  | 18 | ||||||||||||||||||||||||||||||
| 2038 | } | - | ||||||||||||||||||||||||||||||
| 2039 |                 if (d->items.contains(item)) {
  | 6-2833 | ||||||||||||||||||||||||||||||
| 2040 | d->releaseItem(item); | - | ||||||||||||||||||||||||||||||
| 2041 |                     break; //Otherwise we'd "re-add" it, and get confused executed 6 times by 1 test:  break;Executed by: 
  | 6 | ||||||||||||||||||||||||||||||
| 2042 | } | - | ||||||||||||||||||||||||||||||
| 2043 |                 if (d->currentIndex == idx) {
  | 441-2392 | ||||||||||||||||||||||||||||||
| 2044 | currentVisible = true; | - | ||||||||||||||||||||||||||||||
| 2045 | d->currentItemOffset = nextPos; | - | ||||||||||||||||||||||||||||||
| 2046 |                 } executed 441 times by 3 tests:  end of blockExecuted by: 
  | 441 | ||||||||||||||||||||||||||||||
| 2047 | d->items.append(item); | - | ||||||||||||||||||||||||||||||
| 2048 | d->updateItem(item, nextPos); | - | ||||||||||||||||||||||||||||||
| 2049 | endIdx = idx; | - | ||||||||||||||||||||||||||||||
| 2050 | endPos = nextPos; | - | ||||||||||||||||||||||||||||||
| 2051 | ++idx; | - | ||||||||||||||||||||||||||||||
| 2052 |                 if (idx >= d->modelCount)
  | 395-2438 | ||||||||||||||||||||||||||||||
| 2053 |                     idx = 0; executed 395 times by 3 tests:  idx = 0;Executed by: 
  | 395 | ||||||||||||||||||||||||||||||
| 2054 | nextPos = d->positionOfIndex(idx); | - | ||||||||||||||||||||||||||||||
| 2055 |             } executed 2833 times by 3 tests:  end of blockExecuted by: 
  | 2833 | ||||||||||||||||||||||||||||||
| 2056 | - | |||||||||||||||||||||||||||||||
| 2057 | //Prepend | - | ||||||||||||||||||||||||||||||
| 2058 |             idx = (wasEmpty ? d->calcCurrentIndex() : startIdx) - 1;
  | 350-455 | ||||||||||||||||||||||||||||||
| 2059 | - | |||||||||||||||||||||||||||||||
| 2060 |             if (idx < 0)
  | 323-482 | ||||||||||||||||||||||||||||||
| 2061 |                 idx = d->modelCount - 1; executed 323 times by 3 tests:  idx = d->modelCount - 1;Executed by: 
  | 323 | ||||||||||||||||||||||||||||||
| 2062 | nextPos = d->positionOfIndex(idx); | - | ||||||||||||||||||||||||||||||
| 2063 |             while (!waiting && d->isInBound(nextPos, d->mappedRange - d->mappedCache, startPos)
 
  | 18-1318 | ||||||||||||||||||||||||||||||
| 2064 |                     && d->items.count() < count+d->cacheSize) {
  | 0-545 | ||||||||||||||||||||||||||||||
| 2065 |                 qCDebug(lcItemViewDelegateLifecycle) << "prepend" << idx << "@" << nextPos << (d->currentIndex == idx ? "current" : "") << "items count was" << d->items.count(); never executed:  QMessageLogger(__FILE__, 2065, __PRETTY_FUNCTION__, lcItemViewDelegateLifecycle().categoryName()).debug() << "prepend" << idx << "@" << nextPos << (d->currentIndex == idx ? "current" : "") << "items count was" << d->items.count();
  | 0-545 | ||||||||||||||||||||||||||||||
| 2066 | QQuickItem *item = d->getItem(idx, idx+1, nextPos >= 1.0); | - | ||||||||||||||||||||||||||||||
| 2067 |                 if (!item) {
  | 8-537 | ||||||||||||||||||||||||||||||
| 2068 | waiting = true; | - | ||||||||||||||||||||||||||||||
| 2069 |                     break; executed 8 times by 1 test:  break;Executed by: 
  | 8 | ||||||||||||||||||||||||||||||
| 2070 | } | - | ||||||||||||||||||||||||||||||
| 2071 |                 if (d->items.contains(item)) {
  | 6-531 | ||||||||||||||||||||||||||||||
| 2072 | d->releaseItem(item); | - | ||||||||||||||||||||||||||||||
| 2073 |                     break; //Otherwise we'd "re-add" it, and get confused executed 6 times by 1 test:  break;Executed by: 
  | 6 | ||||||||||||||||||||||||||||||
| 2074 | } | - | ||||||||||||||||||||||||||||||
| 2075 |                 if (d->currentIndex == idx) {
  | 22-509 | ||||||||||||||||||||||||||||||
| 2076 | currentVisible = true; | - | ||||||||||||||||||||||||||||||
| 2077 | d->currentItemOffset = nextPos; | - | ||||||||||||||||||||||||||||||
| 2078 |                 } executed 22 times by 1 test:  end of blockExecuted by: 
  | 22 | ||||||||||||||||||||||||||||||
| 2079 | d->items.prepend(item); | - | ||||||||||||||||||||||||||||||
| 2080 | d->updateItem(item, nextPos); | - | ||||||||||||||||||||||||||||||
| 2081 | startIdx = idx; | - | ||||||||||||||||||||||||||||||
| 2082 | startPos = nextPos; | - | ||||||||||||||||||||||||||||||
| 2083 | --idx; | - | ||||||||||||||||||||||||||||||
| 2084 |                 if (idx < 0)
  | 5-526 | ||||||||||||||||||||||||||||||
| 2085 |                     idx = d->modelCount - 1; executed 5 times by 1 test:  idx = d->modelCount - 1;Executed by: 
  | 5 | ||||||||||||||||||||||||||||||
| 2086 | nextPos = d->positionOfIndex(idx); | - | ||||||||||||||||||||||||||||||
| 2087 |             } executed 531 times by 2 tests:  end of blockExecuted by: 
  | 531 | ||||||||||||||||||||||||||||||
| 2088 | - | |||||||||||||||||||||||||||||||
| 2089 | // In rare cases, when jumping around with pathCount close to modelCount, | - | ||||||||||||||||||||||||||||||
| 2090 | // new items appear in the middle. This more generic addition iteration handles this | - | ||||||||||||||||||||||||||||||
| 2091 | // Since this is the rare case, we try append/prepend first and only do this if | - | ||||||||||||||||||||||||||||||
| 2092 | // there are gaps still left to fill. | - | ||||||||||||||||||||||||||||||
| 2093 |             if (!waiting && d->items.count() < count+d->cacheSize) {
 
  | 6-779 | ||||||||||||||||||||||||||||||
| 2094 |                 qCDebug(lcItemViewDelegateLifecycle) << "Checking for pathview middle inserts, items count was" << d->items.count(); never executed:  QMessageLogger(__FILE__, 2094, __PRETTY_FUNCTION__, lcItemViewDelegateLifecycle().categoryName()).debug() << "Checking for pathview middle inserts, items count was" << d->items.count();
  | 0-6 | ||||||||||||||||||||||||||||||
| 2095 | idx = startIdx; | - | ||||||||||||||||||||||||||||||
| 2096 | QQuickItem *lastItem = d->items.at(0); | - | ||||||||||||||||||||||||||||||
| 2097 |                 while (idx != endIdx) {
  | 2-52 | ||||||||||||||||||||||||||||||
| 2098 | nextPos = d->positionOfIndex(idx); | - | ||||||||||||||||||||||||||||||
| 2099 |                     if (d->isInBound(nextPos, d->mappedRange - d->mappedCache, 1.0 + d->mappedCache)) {
  | 0-52 | ||||||||||||||||||||||||||||||
| 2100 | //This gets the reference from the delegate model, and will not re-create | - | ||||||||||||||||||||||||||||||
| 2101 | QQuickItem *item = d->getItem(idx, idx+1, nextPos >= 1.0); | - | ||||||||||||||||||||||||||||||
| 2102 |                         if (!item) {
  | 4-48 | ||||||||||||||||||||||||||||||
| 2103 | waiting = true; | - | ||||||||||||||||||||||||||||||
| 2104 |                             break; executed 4 times by 1 test:  break;Executed by: 
  | 4 | ||||||||||||||||||||||||||||||
| 2105 | } | - | ||||||||||||||||||||||||||||||
| 2106 | - | |||||||||||||||||||||||||||||||
| 2107 |                         if (!d->items.contains(item)) { //We found a hole
  | 4-44 | ||||||||||||||||||||||||||||||
| 2108 |                             qCDebug(lcItemViewDelegateLifecycle) << "middle insert" << idx << "@" << nextPos never executed:  QMessageLogger(__FILE__, 2108, __PRETTY_FUNCTION__, lcItemViewDelegateLifecycle().categoryName()).debug() << "middle insert" << idx << "@" << nextPos << (d->currentIndex == idx ? "current" : "") << "items count was" << d->items.count();
  | 0-4 | ||||||||||||||||||||||||||||||
| 2109 |                                                                  << (d->currentIndex == idx ? "current" : "") never executed:  QMessageLogger(__FILE__, 2108, __PRETTY_FUNCTION__, lcItemViewDelegateLifecycle().categoryName()).debug() << "middle insert" << idx << "@" << nextPos << (d->currentIndex == idx ? "current" : "") << "items count was" << d->items.count(); | 0 | ||||||||||||||||||||||||||||||
| 2110 |                                                                  << "items count was" << d->items.count(); never executed:  QMessageLogger(__FILE__, 2108, __PRETTY_FUNCTION__, lcItemViewDelegateLifecycle().categoryName()).debug() << "middle insert" << idx << "@" << nextPos << (d->currentIndex == idx ? "current" : "") << "items count was" << d->items.count(); | 0 | ||||||||||||||||||||||||||||||
| 2111 |                             if (d->currentIndex == idx) {
  | 0-4 | ||||||||||||||||||||||||||||||
| 2112 | currentVisible = true; | - | ||||||||||||||||||||||||||||||
| 2113 | d->currentItemOffset = nextPos; | - | ||||||||||||||||||||||||||||||
| 2114 |                             } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2115 | int lastListIdx = d->items.indexOf(lastItem); | - | ||||||||||||||||||||||||||||||
| 2116 | d->items.insert(lastListIdx + 1, item); | - | ||||||||||||||||||||||||||||||
| 2117 | d->updateItem(item, nextPos); | - | ||||||||||||||||||||||||||||||
| 2118 |                         } else { executed 4 times by 1 test:  end of blockExecuted by: 
  | 4 | ||||||||||||||||||||||||||||||
| 2119 | d->releaseItem(item); | - | ||||||||||||||||||||||||||||||
| 2120 |                         } executed 44 times by 1 test:  end of blockExecuted by: 
  | 44 | ||||||||||||||||||||||||||||||
| 2121 | - | |||||||||||||||||||||||||||||||
| 2122 | lastItem = item; | - | ||||||||||||||||||||||||||||||
| 2123 |                     } executed 48 times by 1 test:  end of blockExecuted by: 
  | 48 | ||||||||||||||||||||||||||||||
| 2124 | - | |||||||||||||||||||||||||||||||
| 2125 | ++idx; | - | ||||||||||||||||||||||||||||||
| 2126 |                     if (idx >= d->modelCount)
  | 6-42 | ||||||||||||||||||||||||||||||
| 2127 |                         idx = 0; executed 6 times by 1 test:  idx = 0;Executed by: 
  | 6 | ||||||||||||||||||||||||||||||
| 2128 |                 } executed 48 times by 1 test:  end of blockExecuted by: 
  | 48 | ||||||||||||||||||||||||||||||
| 2129 |             } executed 6 times by 1 test:  end of blockExecuted by: 
  | 6 | ||||||||||||||||||||||||||||||
| 2130 |         } executed 805 times by 3 tests:  end of blockExecuted by: 
  | 805 | ||||||||||||||||||||||||||||||
| 2131 |     } executed 3918 times by 3 tests:  end of blockExecuted by: 
  | 3918 | ||||||||||||||||||||||||||||||
| 2132 | - | |||||||||||||||||||||||||||||||
| 2133 | bool currentChanged = false; | - | ||||||||||||||||||||||||||||||
| 2134 |     if (!currentVisible) {
  | 112-3824 | ||||||||||||||||||||||||||||||
| 2135 | d->currentItemOffset = 1.0; | - | ||||||||||||||||||||||||||||||
| 2136 |         if (d->currentItem) {
  | 20-92 | ||||||||||||||||||||||||||||||
| 2137 | d->updateItem(d->currentItem, 1.0); | - | ||||||||||||||||||||||||||||||
| 2138 |         } else if (!waiting && d->currentIndex >= 0 && d->currentIndex < d->modelCount) { executed 92 times by 1 test:  end of blockExecuted by: 
 
 
 
  | 0-92 | ||||||||||||||||||||||||||||||
| 2139 |             if ((d->currentItem = d->getItem(d->currentIndex, d->currentIndex))) {
  | 0 | ||||||||||||||||||||||||||||||
| 2140 | currentChanged = true; | - | ||||||||||||||||||||||||||||||
| 2141 | d->updateItem(d->currentItem, 1.0); | - | ||||||||||||||||||||||||||||||
| 2142 |                 if (QQuickPathViewAttached *att = d->attached(d->currentItem))
  | 0 | ||||||||||||||||||||||||||||||
| 2143 |                     att->setIsCurrentItem(true); never executed:  att->setIsCurrentItem(true); | 0 | ||||||||||||||||||||||||||||||
| 2144 |             } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2145 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2146 |     } else if (!waiting && !d->currentItem) { executed 112 times by 2 tests:  end of blockExecuted by: 
 
 
  | 26-3798 | ||||||||||||||||||||||||||||||
| 2147 |         if ((d->currentItem = d->getItem(d->currentIndex, d->currentIndex))) {
  | 0-420 | ||||||||||||||||||||||||||||||
| 2148 | currentChanged = true; | - | ||||||||||||||||||||||||||||||
| 2149 | d->currentItem->setFocus(true); | - | ||||||||||||||||||||||||||||||
| 2150 |             if (QQuickPathViewAttached *att = d->attached(d->currentItem))
  | 0-420 | ||||||||||||||||||||||||||||||
| 2151 |                 att->setIsCurrentItem(true); executed 420 times by 3 tests:  att->setIsCurrentItem(true);Executed by: 
  | 420 | ||||||||||||||||||||||||||||||
| 2152 |         } executed 420 times by 3 tests:  end of blockExecuted by: 
  | 420 | ||||||||||||||||||||||||||||||
| 2153 |     } executed 420 times by 3 tests:  end of blockExecuted by: 
  | 420 | ||||||||||||||||||||||||||||||
| 2154 | - | |||||||||||||||||||||||||||||||
| 2155 |     if (d->highlightItem && d->haveHighlightRange && d->highlightRangeMode == QQuickPathView::StrictlyEnforceRange) {
 
 
  | 4-3918 | ||||||||||||||||||||||||||||||
| 2156 | d->updateItem(d->highlightItem, d->highlightRangeStart); | - | ||||||||||||||||||||||||||||||
| 2157 |         if (QQuickPathViewAttached *att = d->attached(d->highlightItem))
  | 0-3476 | ||||||||||||||||||||||||||||||
| 2158 |             att->setOnPath(true); never executed:  att->setOnPath(true); | 0 | ||||||||||||||||||||||||||||||
| 2159 |     } else if (d->highlightItem && d->moveReason != QQuickPathViewPrivate::SetIndex) { executed 3476 times by 3 tests:  end of blockExecuted by: 
 
 
  | 4-3476 | ||||||||||||||||||||||||||||||
| 2160 | d->updateItem(d->highlightItem, d->currentItemOffset); | - | ||||||||||||||||||||||||||||||
| 2161 |         if (QQuickPathViewAttached *att = d->attached(d->highlightItem))
  | 0-438 | ||||||||||||||||||||||||||||||
| 2162 |             att->setOnPath(currentVisible); never executed:  att->setOnPath(currentVisible); | 0 | ||||||||||||||||||||||||||||||
| 2163 |     } executed 438 times by 1 test:  end of blockExecuted by: 
  | 438 | ||||||||||||||||||||||||||||||
| 2164 | for (QQuickItem *item : qAsConst(d->itemCache)) | - | ||||||||||||||||||||||||||||||
| 2165 |         d->releaseItem(item); executed 141 times by 1 test:  d->releaseItem(item);Executed by: 
  | 141 | ||||||||||||||||||||||||||||||
| 2166 | d->itemCache.clear(); | - | ||||||||||||||||||||||||||||||
| 2167 | - | |||||||||||||||||||||||||||||||
| 2168 | d->inRefill = false; | - | ||||||||||||||||||||||||||||||
| 2169 |     if (currentChanged)
  | 420-3516 | ||||||||||||||||||||||||||||||
| 2170 |         emit currentItemChanged(); executed 420 times by 3 tests:  currentItemChanged();Executed by: 
  | 420 | ||||||||||||||||||||||||||||||
| 2171 | } executed 3936 times by 3 tests:  end of blockExecuted by: 
  | 3936 | ||||||||||||||||||||||||||||||
| 2172 | - | |||||||||||||||||||||||||||||||
| 2173 | void QQuickPathView::modelUpdated(const QQmlChangeSet &changeSet, bool reset) | - | ||||||||||||||||||||||||||||||
| 2174 | { | - | ||||||||||||||||||||||||||||||
| 2175 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 2176 |     if (!d->model || !d->model->isValid() || !d->path || !isComponentComplete())
 
 
 
  | 0-690 | ||||||||||||||||||||||||||||||
| 2177 |         return; executed 524 times by 3 tests:  return;Executed by: 
  | 524 | ||||||||||||||||||||||||||||||
| 2178 | - | |||||||||||||||||||||||||||||||
| 2179 |     if (reset) {
  | 2-164 | ||||||||||||||||||||||||||||||
| 2180 | d->modelCount = d->model->count(); | - | ||||||||||||||||||||||||||||||
| 2181 | d->regenerate(); | - | ||||||||||||||||||||||||||||||
| 2182 | emit countChanged(); | - | ||||||||||||||||||||||||||||||
| 2183 |         return; executed 2 times by 1 test:  return;Executed by: 
  | 2 | ||||||||||||||||||||||||||||||
| 2184 | } | - | ||||||||||||||||||||||||||||||
| 2185 | - | |||||||||||||||||||||||||||||||
| 2186 |     if (changeSet.removes().isEmpty() && changeSet.inserts().isEmpty())
 
  | 0-98 | ||||||||||||||||||||||||||||||
| 2187 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 2188 | - | |||||||||||||||||||||||||||||||
| 2189 | const int modelCount = d->modelCount; | - | ||||||||||||||||||||||||||||||
| 2190 | int moveId = -1; | - | ||||||||||||||||||||||||||||||
| 2191 | int moveOffset = 0; | - | ||||||||||||||||||||||||||||||
| 2192 | bool currentChanged = false; | - | ||||||||||||||||||||||||||||||
| 2193 | bool changedOffset = false; | - | ||||||||||||||||||||||||||||||
| 2194 | for (const QQmlChangeSet::Change &r : changeSet.removes()) { | - | ||||||||||||||||||||||||||||||
| 2195 |         if (moveId == -1 && d->currentIndex >= r.index + r.count) {
 
  | 0-98 | ||||||||||||||||||||||||||||||
| 2196 | d->currentIndex -= r.count; | - | ||||||||||||||||||||||||||||||
| 2197 | currentChanged = true; | - | ||||||||||||||||||||||||||||||
| 2198 |         } else if (moveId == -1 && d->currentIndex >= r.index && d->currentIndex < r.index + r.count) { executed 36 times by 1 test:  end of blockExecuted by: 
 
 
 
  | 0-62 | ||||||||||||||||||||||||||||||
| 2199 | // current item has been removed. | - | ||||||||||||||||||||||||||||||
| 2200 |             if (r.isMove()) {
  | 10-18 | ||||||||||||||||||||||||||||||
| 2201 | moveId = r.moveId; | - | ||||||||||||||||||||||||||||||
| 2202 | moveOffset = d->currentIndex - r.index; | - | ||||||||||||||||||||||||||||||
| 2203 |             } else if (d->currentItem) { executed 10 times by 1 test:  end of blockExecuted by: 
 
  | 2-16 | ||||||||||||||||||||||||||||||
| 2204 |                 if (QQuickPathViewAttached *att = d->attached(d->currentItem))
  | 0-16 | ||||||||||||||||||||||||||||||
| 2205 |                     att->setIsCurrentItem(true); executed 16 times by 1 test:  att->setIsCurrentItem(true);Executed by: 
  | 16 | ||||||||||||||||||||||||||||||
| 2206 | d->releaseItem(d->currentItem); | - | ||||||||||||||||||||||||||||||
| 2207 | d->currentItem = nullptr; | - | ||||||||||||||||||||||||||||||
| 2208 |             } executed 16 times by 1 test:  end of blockExecuted by: 
  | 16 | ||||||||||||||||||||||||||||||
| 2209 | d->currentIndex = qMin(r.index, d->modelCount - r.count - 1); | - | ||||||||||||||||||||||||||||||
| 2210 | currentChanged = true; | - | ||||||||||||||||||||||||||||||
| 2211 |         } executed 28 times by 2 tests:  end of blockExecuted by: 
  | 28 | ||||||||||||||||||||||||||||||
| 2212 | - | |||||||||||||||||||||||||||||||
| 2213 |         if (r.index > d->currentIndex) {
  | 48-50 | ||||||||||||||||||||||||||||||
| 2214 | changedOffset = true; | - | ||||||||||||||||||||||||||||||
| 2215 | d->offset -= r.count; | - | ||||||||||||||||||||||||||||||
| 2216 | d->offsetAdj -= r.count; | - | ||||||||||||||||||||||||||||||
| 2217 |         } executed 50 times by 2 tests:  end of blockExecuted by: 
  | 50 | ||||||||||||||||||||||||||||||
| 2218 | d->modelCount -= r.count; | - | ||||||||||||||||||||||||||||||
| 2219 |     } executed 98 times by 2 tests:  end of blockExecuted by: 
  | 98 | ||||||||||||||||||||||||||||||
| 2220 | for (const QQmlChangeSet::Change &i : changeSet.inserts()) { | - | ||||||||||||||||||||||||||||||
| 2221 |         if (d->modelCount) {
  | 14-96 | ||||||||||||||||||||||||||||||
| 2222 |             if (moveId == -1 && i.index <= d->currentIndex) {
 
  | 10-86 | ||||||||||||||||||||||||||||||
| 2223 | d->currentIndex += i.count; | - | ||||||||||||||||||||||||||||||
| 2224 | currentChanged = true; | - | ||||||||||||||||||||||||||||||
| 2225 |             } else { executed 38 times by 1 test:  end of blockExecuted by: 
  | 38 | ||||||||||||||||||||||||||||||
| 2226 |                 if (moveId != -1 && moveId == i.moveId) {
 
  | 0-48 | ||||||||||||||||||||||||||||||
| 2227 | d->currentIndex = i.index + moveOffset; | - | ||||||||||||||||||||||||||||||
| 2228 | currentChanged = true; | - | ||||||||||||||||||||||||||||||
| 2229 |                 } executed 10 times by 1 test:  end of blockExecuted by: 
  | 10 | ||||||||||||||||||||||||||||||
| 2230 |                 if (i.index > d->currentIndex) {
  | 10-48 | ||||||||||||||||||||||||||||||
| 2231 | d->offset += i.count; | - | ||||||||||||||||||||||||||||||
| 2232 | d->offsetAdj += i.count; | - | ||||||||||||||||||||||||||||||
| 2233 | changedOffset = true; | - | ||||||||||||||||||||||||||||||
| 2234 |                 } executed 48 times by 1 test:  end of blockExecuted by: 
  | 48 | ||||||||||||||||||||||||||||||
| 2235 |             } executed 58 times by 1 test:  end of blockExecuted by: 
  | 58 | ||||||||||||||||||||||||||||||
| 2236 | } | - | ||||||||||||||||||||||||||||||
| 2237 | d->modelCount += i.count; | - | ||||||||||||||||||||||||||||||
| 2238 |     } executed 110 times by 2 tests:  end of blockExecuted by: 
  | 110 | ||||||||||||||||||||||||||||||
| 2239 | - | |||||||||||||||||||||||||||||||
| 2240 | d->offset = std::fmod(d->offset, qreal(d->modelCount)); | - | ||||||||||||||||||||||||||||||
| 2241 |     if (d->offset < 0)
  | 2-162 | ||||||||||||||||||||||||||||||
| 2242 |         d->offset += d->modelCount; executed 2 times by 1 test:  d->offset += d->modelCount;Executed by: 
  | 2 | ||||||||||||||||||||||||||||||
| 2243 |     if (d->currentIndex == -1)
  | 12-152 | ||||||||||||||||||||||||||||||
| 2244 |         d->currentIndex = d->calcCurrentIndex(); executed 12 times by 2 tests:  d->currentIndex = d->calcCurrentIndex();Executed by: 
  | 12 | ||||||||||||||||||||||||||||||
| 2245 | - | |||||||||||||||||||||||||||||||
| 2246 | d->itemCache += d->items; | - | ||||||||||||||||||||||||||||||
| 2247 | d->items.clear(); | - | ||||||||||||||||||||||||||||||
| 2248 | - | |||||||||||||||||||||||||||||||
| 2249 |     if (!d->modelCount) {
  | 10-154 | ||||||||||||||||||||||||||||||
| 2250 | for (QQuickItem * item : qAsConst(d->itemCache)) | - | ||||||||||||||||||||||||||||||
| 2251 |             d->releaseItem(item); executed 54 times by 1 test:  d->releaseItem(item);Executed by: 
  | 54 | ||||||||||||||||||||||||||||||
| 2252 | d->itemCache.clear(); | - | ||||||||||||||||||||||||||||||
| 2253 | d->offset = 0; | - | ||||||||||||||||||||||||||||||
| 2254 | changedOffset = true; | - | ||||||||||||||||||||||||||||||
| 2255 | d->tl.reset(d->moveOffset); | - | ||||||||||||||||||||||||||||||
| 2256 |     } else { executed 10 times by 2 tests:  end of blockExecuted by: 
  | 10 | ||||||||||||||||||||||||||||||
| 2257 |         if (!d->flicking && !d->moving && d->haveHighlightRange && d->highlightRangeMode == QQuickPathView::StrictlyEnforceRange) {
 
 
 
  | 0-154 | ||||||||||||||||||||||||||||||
| 2258 | d->offset = std::fmod(qreal(d->modelCount - d->currentIndex), qreal(d->modelCount)); | - | ||||||||||||||||||||||||||||||
| 2259 | changedOffset = true; | - | ||||||||||||||||||||||||||||||
| 2260 |         } executed 88 times by 2 tests:  end of blockExecuted by: 
  | 88 | ||||||||||||||||||||||||||||||
| 2261 | d->updateMappedRange(); | - | ||||||||||||||||||||||||||||||
| 2262 | d->scheduleLayout(); | - | ||||||||||||||||||||||||||||||
| 2263 |     } executed 154 times by 2 tests:  end of blockExecuted by: 
  | 154 | ||||||||||||||||||||||||||||||
| 2264 |     if (changedOffset)
  | 36-128 | ||||||||||||||||||||||||||||||
| 2265 |         emit offsetChanged(); executed 128 times by 2 tests:  offsetChanged();Executed by: 
  | 128 | ||||||||||||||||||||||||||||||
| 2266 |     if (currentChanged)
  | 70-94 | ||||||||||||||||||||||||||||||
| 2267 |         emit currentIndexChanged(); executed 94 times by 2 tests:  currentIndexChanged();Executed by: 
  | 94 | ||||||||||||||||||||||||||||||
| 2268 |     if (d->modelCount != modelCount)
  | 44-120 | ||||||||||||||||||||||||||||||
| 2269 |         emit countChanged(); executed 120 times by 2 tests:  countChanged();Executed by: 
  | 120 | ||||||||||||||||||||||||||||||
| 2270 | } executed 164 times by 2 tests:  end of blockExecuted by: 
  | 164 | ||||||||||||||||||||||||||||||
| 2271 | - | |||||||||||||||||||||||||||||||
| 2272 | void QQuickPathView::destroyingItem(QObject *item) | - | ||||||||||||||||||||||||||||||
| 2273 | { | - | ||||||||||||||||||||||||||||||
| 2274 | Q_UNUSED(item); | - | ||||||||||||||||||||||||||||||
| 2275 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2276 | - | |||||||||||||||||||||||||||||||
| 2277 | void QQuickPathView::ticked() | - | ||||||||||||||||||||||||||||||
| 2278 | { | - | ||||||||||||||||||||||||||||||
| 2279 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 2280 | d->updateCurrent(); | - | ||||||||||||||||||||||||||||||
| 2281 | } executed 3334 times by 1 test:  end of blockExecuted by: 
  | 3334 | ||||||||||||||||||||||||||||||
| 2282 | - | |||||||||||||||||||||||||||||||
| 2283 | void QQuickPathView::movementEnding() | - | ||||||||||||||||||||||||||||||
| 2284 | { | - | ||||||||||||||||||||||||||||||
| 2285 | Q_D(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 2286 |     if (d->flicking) {
  | 16-98 | ||||||||||||||||||||||||||||||
| 2287 | d->flicking = false; | - | ||||||||||||||||||||||||||||||
| 2288 | emit flickingChanged(); | - | ||||||||||||||||||||||||||||||
| 2289 | emit flickEnded(); | - | ||||||||||||||||||||||||||||||
| 2290 |     } executed 16 times by 1 test:  end of blockExecuted by: 
  | 16 | ||||||||||||||||||||||||||||||
| 2291 |     if (d->moving && !d->stealMouse) {
 
  | 0-94 | ||||||||||||||||||||||||||||||
| 2292 | d->moving = false; | - | ||||||||||||||||||||||||||||||
| 2293 | emit movingChanged(); | - | ||||||||||||||||||||||||||||||
| 2294 | emit movementEnded(); | - | ||||||||||||||||||||||||||||||
| 2295 |     } executed 20 times by 1 test:  end of blockExecuted by: 
  | 20 | ||||||||||||||||||||||||||||||
| 2296 | d->moveDirection = d->movementDirection; | - | ||||||||||||||||||||||||||||||
| 2297 | } executed 114 times by 1 test:  end of blockExecuted by: 
  | 114 | ||||||||||||||||||||||||||||||
| 2298 | - | |||||||||||||||||||||||||||||||
| 2299 | // find the item closest to the snap position | - | ||||||||||||||||||||||||||||||
| 2300 | int QQuickPathViewPrivate::calcCurrentIndex() | - | ||||||||||||||||||||||||||||||
| 2301 | { | - | ||||||||||||||||||||||||||||||
| 2302 | int current = 0; | - | ||||||||||||||||||||||||||||||
| 2303 |     if (modelCount && model && items.count()) {
 
  | 10-2435 | ||||||||||||||||||||||||||||||
| 2304 | offset = std::fmod(offset, qreal(modelCount)); | - | ||||||||||||||||||||||||||||||
| 2305 |         if (offset < 0)
  | 0-2421 | ||||||||||||||||||||||||||||||
| 2306 |             offset += modelCount; never executed:  offset += modelCount; | 0 | ||||||||||||||||||||||||||||||
| 2307 | current = qRound(qAbs(std::fmod(modelCount - offset, qreal(modelCount)))); | - | ||||||||||||||||||||||||||||||
| 2308 | current = current % modelCount; | - | ||||||||||||||||||||||||||||||
| 2309 |     } executed 2421 times by 3 tests:  end of blockExecuted by: 
  | 2421 | ||||||||||||||||||||||||||||||
| 2310 | - | |||||||||||||||||||||||||||||||
| 2311 |     return current; executed 2445 times by 3 tests:  return current;Executed by: 
  | 2445 | ||||||||||||||||||||||||||||||
| 2312 | } | - | ||||||||||||||||||||||||||||||
| 2313 | - | |||||||||||||||||||||||||||||||
| 2314 | void QQuickPathViewPrivate::createCurrentItem() | - | ||||||||||||||||||||||||||||||
| 2315 | { | - | ||||||||||||||||||||||||||||||
| 2316 |     if (requestedIndex != -1)
  | 6-549 | ||||||||||||||||||||||||||||||
| 2317 |         return; executed 6 times by 1 test:  return;Executed by: 
  | 6 | ||||||||||||||||||||||||||||||
| 2318 | - | |||||||||||||||||||||||||||||||
| 2319 | bool inItems = false; | - | ||||||||||||||||||||||||||||||
| 2320 | for (QQuickItem *item : qAsConst(items)) { | - | ||||||||||||||||||||||||||||||
| 2321 |         if (model->indexOf(item, nullptr) == currentIndex) {
  | 519-3277 | ||||||||||||||||||||||||||||||
| 2322 | inItems = true; | - | ||||||||||||||||||||||||||||||
| 2323 |             break; executed 519 times by 1 test:  break;Executed by: 
  | 519 | ||||||||||||||||||||||||||||||
| 2324 | } | - | ||||||||||||||||||||||||||||||
| 2325 |     } executed 3277 times by 1 test:  end of blockExecuted by: 
  | 3277 | ||||||||||||||||||||||||||||||
| 2326 | - | |||||||||||||||||||||||||||||||
| 2327 |     if (inItems) {
  | 30-519 | ||||||||||||||||||||||||||||||
| 2328 |         if ((currentItem = getItem(currentIndex, currentIndex))) {
  | 0-519 | ||||||||||||||||||||||||||||||
| 2329 | currentItem->setFocus(true); | - | ||||||||||||||||||||||||||||||
| 2330 |             if (QQuickPathViewAttached *att = attached(currentItem))
  | 0-519 | ||||||||||||||||||||||||||||||
| 2331 |                 att->setIsCurrentItem(true); executed 519 times by 1 test:  att->setIsCurrentItem(true);Executed by: 
  | 519 | ||||||||||||||||||||||||||||||
| 2332 |         } executed 519 times by 1 test:  end of blockExecuted by: 
  | 519 | ||||||||||||||||||||||||||||||
| 2333 |     } else if (currentIndex >= 0 && currentIndex < modelCount) { executed 519 times by 1 test:  end of blockExecuted by: 
 
 
  | 0-519 | ||||||||||||||||||||||||||||||
| 2334 |         if ((currentItem = getItem(currentIndex, currentIndex))) {
  | 0-30 | ||||||||||||||||||||||||||||||
| 2335 | updateItem(currentItem, 1.0); | - | ||||||||||||||||||||||||||||||
| 2336 |             if (QQuickPathViewAttached *att = attached(currentItem))
  | 0-30 | ||||||||||||||||||||||||||||||
| 2337 |                 att->setIsCurrentItem(true); executed 30 times by 1 test:  att->setIsCurrentItem(true);Executed by: 
  | 30 | ||||||||||||||||||||||||||||||
| 2338 |         } executed 30 times by 1 test:  end of blockExecuted by: 
  | 30 | ||||||||||||||||||||||||||||||
| 2339 |     } executed 30 times by 1 test:  end of blockExecuted by: 
  | 30 | ||||||||||||||||||||||||||||||
| 2340 | } executed 549 times by 1 test:  end of blockExecuted by: 
  | 549 | ||||||||||||||||||||||||||||||
| 2341 | - | |||||||||||||||||||||||||||||||
| 2342 | void QQuickPathViewPrivate::updateCurrent() | - | ||||||||||||||||||||||||||||||
| 2343 | { | - | ||||||||||||||||||||||||||||||
| 2344 | Q_Q(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 2345 |     if (moveReason == SetIndex)
  | 1646-2298 | ||||||||||||||||||||||||||||||
| 2346 |         return; executed 1646 times by 1 test:  return;Executed by: 
  | 1646 | ||||||||||||||||||||||||||||||
| 2347 |     if (!modelCount || !haveHighlightRange || highlightRangeMode != QQuickPathView::StrictlyEnforceRange)
 
 
  | 0-2210 | ||||||||||||||||||||||||||||||
| 2348 |         return; executed 432 times by 2 tests:  return;Executed by: 
  | 432 | ||||||||||||||||||||||||||||||
| 2349 | - | |||||||||||||||||||||||||||||||
| 2350 | int idx = calcCurrentIndex(); | - | ||||||||||||||||||||||||||||||
| 2351 |     if (model && (idx != currentIndex || !currentItem)) {
 
  | 6-1461 | ||||||||||||||||||||||||||||||
| 2352 |         if (currentItem) {
  | 6-405 | ||||||||||||||||||||||||||||||
| 2353 |             if (QQuickPathViewAttached *att = attached(currentItem))
  | 0-405 | ||||||||||||||||||||||||||||||
| 2354 |                 att->setIsCurrentItem(false); executed 405 times by 1 test:  att->setIsCurrentItem(false);Executed by: 
  | 405 | ||||||||||||||||||||||||||||||
| 2355 | releaseItem(currentItem); | - | ||||||||||||||||||||||||||||||
| 2356 |         } executed 405 times by 1 test:  end of blockExecuted by: 
  | 405 | ||||||||||||||||||||||||||||||
| 2357 | int oldCurrentIndex = currentIndex; | - | ||||||||||||||||||||||||||||||
| 2358 | currentIndex = idx; | - | ||||||||||||||||||||||||||||||
| 2359 | currentItem = nullptr; | - | ||||||||||||||||||||||||||||||
| 2360 | createCurrentItem(); | - | ||||||||||||||||||||||||||||||
| 2361 |         if (oldCurrentIndex != currentIndex)
  | 6-405 | ||||||||||||||||||||||||||||||
| 2362 |             emit q->currentIndexChanged(); executed 405 times by 1 test:  q->currentIndexChanged();Executed by: 
  | 405 | ||||||||||||||||||||||||||||||
| 2363 | emit q->currentItemChanged(); | - | ||||||||||||||||||||||||||||||
| 2364 |     } executed 411 times by 1 test:  end of blockExecuted by: 
  | 411 | ||||||||||||||||||||||||||||||
| 2365 | } executed 1866 times by 3 tests:  end of blockExecuted by: 
  | 1866 | ||||||||||||||||||||||||||||||
| 2366 | - | |||||||||||||||||||||||||||||||
| 2367 | void QQuickPathViewPrivate::fixOffsetCallback(void *d) | - | ||||||||||||||||||||||||||||||
| 2368 | { | - | ||||||||||||||||||||||||||||||
| 2369 | ((QQuickPathViewPrivate *)d)->fixOffset(); | - | ||||||||||||||||||||||||||||||
| 2370 | } executed 18 times by 1 test:  end of blockExecuted by: 
  | 18 | ||||||||||||||||||||||||||||||
| 2371 | - | |||||||||||||||||||||||||||||||
| 2372 | void QQuickPathViewPrivate::fixOffset() | - | ||||||||||||||||||||||||||||||
| 2373 | { | - | ||||||||||||||||||||||||||||||
| 2374 | Q_Q(QQuickPathView); | - | ||||||||||||||||||||||||||||||
| 2375 |     if (model && items.count()) {
  | 0-26 | ||||||||||||||||||||||||||||||
| 2376 |         if (haveHighlightRange && (highlightRangeMode == QQuickPathView::StrictlyEnforceRange
 
  | 0-26 | ||||||||||||||||||||||||||||||
| 2377 |                 || snapMode != QQuickPathView::NoSnap)) {
  | 0-4 | ||||||||||||||||||||||||||||||
| 2378 | int curr = calcCurrentIndex(); | - | ||||||||||||||||||||||||||||||
| 2379 |             if (curr != currentIndex && highlightRangeMode == QQuickPathView::StrictlyEnforceRange)
 
  | 0-22 | ||||||||||||||||||||||||||||||
| 2380 |                 q->setCurrentIndex(curr); never executed:  q->setCurrentIndex(curr); | 0 | ||||||||||||||||||||||||||||||
| 2381 | else | - | ||||||||||||||||||||||||||||||
| 2382 |                 snapToIndex(curr, Other); executed 26 times by 1 test:  snapToIndex(curr, Other);Executed by: 
  | 26 | ||||||||||||||||||||||||||||||
| 2383 | } | - | ||||||||||||||||||||||||||||||
| 2384 |     } executed 26 times by 1 test:  end of blockExecuted by: 
  | 26 | ||||||||||||||||||||||||||||||
| 2385 | } executed 26 times by 1 test:  end of blockExecuted by: 
  | 26 | ||||||||||||||||||||||||||||||
| 2386 | - | |||||||||||||||||||||||||||||||
| 2387 | void QQuickPathViewPrivate::snapToIndex(int index, MovementReason reason) | - | ||||||||||||||||||||||||||||||
| 2388 | { | - | ||||||||||||||||||||||||||||||
| 2389 |     if (!model || modelCount <= 0)
 
  | 0-194 | ||||||||||||||||||||||||||||||
| 2390 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 2391 | - | |||||||||||||||||||||||||||||||
| 2392 | qreal targetOffset = std::fmod(qreal(modelCount - index), qreal(modelCount)); | - | ||||||||||||||||||||||||||||||
| 2393 | - | |||||||||||||||||||||||||||||||
| 2394 |     if (offset == targetOffset)
  | 96-98 | ||||||||||||||||||||||||||||||
| 2395 |         return; executed 96 times by 1 test:  return;Executed by: 
  | 96 | ||||||||||||||||||||||||||||||
| 2396 | - | |||||||||||||||||||||||||||||||
| 2397 | moveReason = reason; | - | ||||||||||||||||||||||||||||||
| 2398 | offsetAdj = 0.0; | - | ||||||||||||||||||||||||||||||
| 2399 | tl.reset(moveOffset); | - | ||||||||||||||||||||||||||||||
| 2400 | moveOffset.setValue(offset); | - | ||||||||||||||||||||||||||||||
| 2401 | - | |||||||||||||||||||||||||||||||
| 2402 | const int duration = highlightMoveDuration; | - | ||||||||||||||||||||||||||||||
| 2403 | - | |||||||||||||||||||||||||||||||
| 2404 |     if (!duration) {
  | 6-92 | ||||||||||||||||||||||||||||||
| 2405 | tl.set(moveOffset, targetOffset); | - | ||||||||||||||||||||||||||||||
| 2406 |     } else if (moveDirection == QQuickPathView::Positive || (moveDirection == QQuickPathView::Shortest && targetOffset - offset > modelCount/2.0)) { executed 6 times by 1 test:  end of blockExecuted by: 
 
 
 
  | 4-84 | ||||||||||||||||||||||||||||||
| 2407 | qreal distance = modelCount - targetOffset + offset; | - | ||||||||||||||||||||||||||||||
| 2408 |         if (targetOffset > moveOffset) {
  | 4-8 | ||||||||||||||||||||||||||||||
| 2409 | tl.move(moveOffset, 0.0, QEasingCurve(QEasingCurve::InQuad), int(duration * offset / distance)); | - | ||||||||||||||||||||||||||||||
| 2410 | tl.set(moveOffset, modelCount); | - | ||||||||||||||||||||||||||||||
| 2411 | tl.move(moveOffset, targetOffset, QEasingCurve(offset == 0.0 ? QEasingCurve::InOutQuad : QEasingCurve::OutQuad), int(duration * (modelCount-targetOffset) / distance)); | - | ||||||||||||||||||||||||||||||
| 2412 |         } else { executed 8 times by 1 test:  end of blockExecuted by: 
  | 8 | ||||||||||||||||||||||||||||||
| 2413 | tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), duration); | - | ||||||||||||||||||||||||||||||
| 2414 |         } executed 4 times by 1 test:  end of blockExecuted by: 
  | 4 | ||||||||||||||||||||||||||||||
| 2415 |     } else if (moveDirection == QQuickPathView::Negative || targetOffset - offset <= -modelCount/2.0) {
 
  | 0-72 | ||||||||||||||||||||||||||||||
| 2416 | qreal distance = modelCount - offset + targetOffset; | - | ||||||||||||||||||||||||||||||
| 2417 |         if (targetOffset < moveOffset) {
  | 2-6 | ||||||||||||||||||||||||||||||
| 2418 | tl.move(moveOffset, modelCount, QEasingCurve(targetOffset == 0 ? QEasingCurve::InOutQuad : QEasingCurve::InQuad), int(duration * (modelCount-offset) / distance)); | - | ||||||||||||||||||||||||||||||
| 2419 | tl.set(moveOffset, 0.0); | - | ||||||||||||||||||||||||||||||
| 2420 | tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::OutQuad), int(duration * targetOffset / distance)); | - | ||||||||||||||||||||||||||||||
| 2421 |         } else { executed 2 times by 1 test:  end of blockExecuted by: 
  | 2 | ||||||||||||||||||||||||||||||
| 2422 | tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), duration); | - | ||||||||||||||||||||||||||||||
| 2423 |         } executed 6 times by 1 test:  end of blockExecuted by: 
  | 6 | ||||||||||||||||||||||||||||||
| 2424 | } else { | - | ||||||||||||||||||||||||||||||
| 2425 | tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), duration); | - | ||||||||||||||||||||||||||||||
| 2426 |     } executed 72 times by 1 test:  end of blockExecuted by: 
  | 72 | ||||||||||||||||||||||||||||||
| 2427 | } | - | ||||||||||||||||||||||||||||||
| 2428 | - | |||||||||||||||||||||||||||||||
| 2429 | QQuickPathViewAttached *QQuickPathView::qmlAttachedProperties(QObject *obj) | - | ||||||||||||||||||||||||||||||
| 2430 | { | - | ||||||||||||||||||||||||||||||
| 2431 |     return new QQuickPathViewAttached(obj); executed 3338 times by 3 tests:  return new QQuickPathViewAttached(obj);Executed by: 
  | 3338 | ||||||||||||||||||||||||||||||
| 2432 | } | - | ||||||||||||||||||||||||||||||
| 2433 | - | |||||||||||||||||||||||||||||||
| 2434 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||||||||
| 2435 | - | |||||||||||||||||||||||||||||||
| 2436 | #include "moc_qquickpathview_p.cpp" | - | ||||||||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |