diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2018-06-28 14:45:22 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2018-12-17 11:57:50 +0000 |
commit | 8bf2dacabf0a9e5d37df6a202ef0a337995fc8ed (patch) | |
tree | 5ff1bfc24b01d5b6f96c00cc5c98537ddc72bd09 | |
parent | c98f8abe34c526bbf66000567b8e1084a788b26b (diff) |
Add logging categories for Tumbler and TumblerView
Both types are complex, so it helps having logging that can simply
be turned on or off to aid debugging.
Change-Id: Id90a8b48b949d17710e8e0882531a497e80aae8b
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
-rw-r--r-- | src/quickcontrols2/qquicktumblerview.cpp | 15 | ||||
-rw-r--r-- | src/quicktemplates2/qquicktumbler.cpp | 37 | ||||
-rw-r--r-- | src/quicktemplates2/qquicktumbler_p_p.h | 2 |
3 files changed, 54 insertions, 0 deletions
diff --git a/src/quickcontrols2/qquicktumblerview.cpp b/src/quickcontrols2/qquicktumblerview.cpp index a510a1fe..5f5c065d 100644 --- a/src/quickcontrols2/qquicktumblerview.cpp +++ b/src/quickcontrols2/qquicktumblerview.cpp @@ -36,6 +36,7 @@ #include "qquicktumblerview_p.h" +#include <QtCore/qloggingcategory.h> #include <QtQuick/private/qquickitem_p.h> #include <QtQuick/private/qquicklistview_p.h> #include <QtQuick/private/qquickpathview_p.h> @@ -45,6 +46,8 @@ QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcTumblerView, "qt.quick.controls.tumblerview") + QQuickTumblerView::QQuickTumblerView(QQuickItem *parent) : QQuickItem(parent) { @@ -59,6 +62,8 @@ QVariant QQuickTumblerView::model() const void QQuickTumblerView::setModel(const QVariant &model) { + qCDebug(lcTumblerView) << "setting model to:" << model << "on" + << (m_pathView ? static_cast<QObject*>(m_pathView) : static_cast<QObject*>(m_listView)); if (model == m_model) return; @@ -85,6 +90,8 @@ QQmlComponent *QQuickTumblerView::delegate() const void QQuickTumblerView::setDelegate(QQmlComponent *delegate) { + qCDebug(lcTumblerView) << "setting delegate to:" << delegate << "on" + << (m_pathView ? static_cast<QObject*>(m_pathView) : static_cast<QObject*>(m_listView)); if (delegate == m_delegate) return; @@ -135,6 +142,8 @@ void QQuickTumblerView::createView() } if (!m_pathView) { + qCDebug(lcTumblerView) << "creating PathView"; + m_pathView = new QQuickPathView; QQmlEngine::setContextForObject(m_pathView, qmlContext(this)); QQml_setParent_noEvent(m_pathView, this); @@ -150,6 +159,8 @@ void QQuickTumblerView::createView() updateView(); // Set the model. updateModel(); + + qCDebug(lcTumblerView) << "finished creating PathView"; } } else { if (m_pathView) { @@ -162,6 +173,8 @@ void QQuickTumblerView::createView() } if (!m_listView) { + qCDebug(lcTumblerView) << "creating ListView"; + m_listView = new QQuickListView; QQmlEngine::setContextForObject(m_listView, qmlContext(this)); QQml_setParent_noEvent(m_listView, this); @@ -181,6 +194,8 @@ void QQuickTumblerView::createView() // which we don't want when the contentItem has just been created. m_listView->setDelegate(m_delegate); m_listView->setHighlightMoveDuration(1000); + + qCDebug(lcTumblerView) << "finished creating ListView"; } } } diff --git a/src/quicktemplates2/qquicktumbler.cpp b/src/quicktemplates2/qquicktumbler.cpp index 25710231..8b702c60 100644 --- a/src/quicktemplates2/qquicktumbler.cpp +++ b/src/quicktemplates2/qquicktumbler.cpp @@ -36,6 +36,7 @@ #include "qquicktumbler_p.h" +#include <QtCore/qloggingcategory.h> #include <QtGui/qpa/qplatformtheme.h> #include <QtQml/qqmlinfo.h> #include <QtQuick/private/qquickflickable_p.h> @@ -44,6 +45,8 @@ QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcTumbler, "qt.quick.controls.tumbler") + /*! \qmltype Tumbler \inherits Control @@ -190,11 +193,22 @@ void QQuickTumblerPrivate::_q_onViewCurrentIndexChanged() // If the user set currentIndex in the onModelChanged handler, // we have to respect that currentIndex by ignoring changes in the view // until the model has finished being set. + qCDebug(lcTumbler).nospace() << "view currentIndex changed to " + << (view ? view->property("currentIndex").toString() : QStringLiteral("unknown index (no view)")) + << ", but we're ignoring it because one or more of the following conditions are true:" + << "\n- !view: " << !view + << "\n- ignoreCurrentIndexChanges: " << ignoreCurrentIndexChanges + << "\n- currentIndexSetDuringModelChange: " << currentIndexSetDuringModelChange; return; } const int oldCurrentIndex = currentIndex; currentIndex = view->property("currentIndex").toInt(); + + qCDebug(lcTumbler).nospace() << "view currentIndex changed to " + << (view ? view->property("currentIndex").toString() : QStringLiteral("unknown index (no view)")) + << ", our old currentIndex was " << oldCurrentIndex; + if (oldCurrentIndex != currentIndex) emit q->currentIndexChanged(); } @@ -202,6 +216,7 @@ void QQuickTumblerPrivate::_q_onViewCurrentIndexChanged() void QQuickTumblerPrivate::_q_onViewCountChanged() { Q_Q(QQuickTumbler); + qCDebug(lcTumbler) << "view count changed - ignoring signals?" << ignoreSignals; if (ignoreSignals) return; @@ -513,10 +528,12 @@ void QQuickTumbler::geometryChanged(const QRectF &newGeometry, const QRectF &old void QQuickTumbler::componentComplete() { Q_D(QQuickTumbler); + qCDebug(lcTumbler) << "componentComplete()"; QQuickControl::componentComplete(); if (!d->view) { // Force the view to be created. + qCDebug(lcTumbler) << "emitting wrapChanged() to force view to be created"; emit wrapChanged(); // Determine the type of view for attached properties, etc. d->setupViewData(d->contentItem); @@ -532,6 +549,8 @@ void QQuickTumbler::componentComplete() d->_q_updateItemHeights(); d->_q_updateItemWidths(); d->_q_onViewCountChanged(); + + qCDebug(lcTumbler) << "componentComplete() is done"; } void QQuickTumbler::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) @@ -659,18 +678,29 @@ void QQuickTumblerPrivate::syncCurrentIndex() void QQuickTumblerPrivate::setPendingCurrentIndex(int index) { + qCDebug(lcTumbler) << "setting pendingCurrentIndex to" << index; pendingCurrentIndex = index; } +QString QQuickTumblerPrivate::propertyChangeReasonToString( + QQuickTumblerPrivate::PropertyChangeReason changeReason) +{ + return changeReason == UserChange ? QStringLiteral("UserChange") : QStringLiteral("InternalChange"); +} + void QQuickTumblerPrivate::setCurrentIndex(int newCurrentIndex, QQuickTumblerPrivate::PropertyChangeReason changeReason) { Q_Q(QQuickTumbler); + qCDebug(lcTumbler).nospace() << "setting currentIndex to " << newCurrentIndex + << ", old currentIndex was " << currentIndex + << ", changeReason is " << propertyChangeReasonToString(changeReason); if (newCurrentIndex == currentIndex || newCurrentIndex < -1) return; if (!q->isComponentComplete()) { // Views can't set currentIndex until they're ready. + qCDebug(lcTumbler) << "we're not complete; setting pendingCurrentIndex instead"; setPendingCurrentIndex(newCurrentIndex); return; } @@ -680,6 +710,7 @@ void QQuickTumblerPrivate::setCurrentIndex(int newCurrentIndex, // the model is in the process of being set and the user has set // the currentIndex in onModelChanged. We have to queue the currentIndex // change until we're ready. + qCDebug(lcTumbler) << "a model is being set; setting pendingCurrentIndex instead"; setPendingCurrentIndex(newCurrentIndex); return; } @@ -717,11 +748,16 @@ void QQuickTumblerPrivate::setCurrentIndex(int newCurrentIndex, currentIndex = newCurrentIndex; emit q->currentIndexChanged(); } + + qCDebug(lcTumbler) << "view's currentIndex is now" << view->property("currentIndex").toInt() + << "and ours is" << currentIndex; } } void QQuickTumblerPrivate::setCount(int newCount) { + qCDebug(lcTumbler).nospace() << "setting count to " << newCount + << ", old count was " << count; if (newCount == count) return; @@ -743,6 +779,7 @@ void QQuickTumblerPrivate::setWrapBasedOnCount() void QQuickTumblerPrivate::setWrap(bool shouldWrap, bool isExplicit) { + qCDebug(lcTumbler) << "setting wrap to" << shouldWrap << "- exlicit?" << isExplicit; if (isExplicit) explicitWrap = true; diff --git a/src/quicktemplates2/qquicktumbler_p_p.h b/src/quicktemplates2/qquicktumbler_p_p.h index 75c6cd1b..049ab8a1 100644 --- a/src/quicktemplates2/qquicktumbler_p_p.h +++ b/src/quicktemplates2/qquicktumbler_p_p.h @@ -111,6 +111,8 @@ public: InternalChange }; + static QString propertyChangeReasonToString(PropertyChangeReason changeReason); + void setCurrentIndex(int newCurrentIndex, PropertyChangeReason changeReason = InternalChange); void setCount(int newCount); void setWrapBasedOnCount(); |