From 1bdb7fef2d7aebfc1b377e4c9dc9505916352463 Mon Sep 17 00:00:00 2001 From: Montel Laurent Date: Tue, 28 Nov 2017 13:28:01 +0100 Subject: [PATCH] Port to qCDebug --- CMakeLists.txt | 4 ++++ kitemmodels.categories | 1 + src/CMakeLists.txt | 2 ++ src/kextracolumnsproxymodel.cpp | 5 +++-- src/klinkitemselectionmodel.cpp | 5 ++--- src/kmodelindexproxymapper.cpp | 8 ++++---- 6 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 kitemmodels.categories diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b26f7c..a05addc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,7 @@ set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) include(KDEInstallDirs) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) +include(ECMQtDeclareLoggingCategory) set(REQUIRED_QT_VERSION 5.7.0) find_package(Qt5Core ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE) @@ -75,4 +76,7 @@ install(FILES DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel ) +# contains list of debug categories, for kdebugsettings +install(FILES kitemmodels.categories DESTINATION ${KDE_INSTALL_CONFDIR}) + feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/kitemmodels.categories b/kitemmodels.categories new file mode 100644 index 0000000..7c32d91 --- /dev/null +++ b/kitemmodels.categories @@ -0,0 +1 @@ +kf5.kitemmodels KItemModels diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 641dd1d..c6e4a6c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,6 +12,8 @@ set(kitemmodels_SRCS kselectionproxymodel.cpp ) +ecm_qt_declare_logging_category(kitemmodels_SRCS HEADER kitemmodels_debug.h IDENTIFIER KITEMMODELS_LOG CATEGORY_NAME kf5.kitemmodels) + add_library(KF5ItemModels ${kitemmodels_SRCS}) generate_export_header(KF5ItemModels BASE_NAME KItemModels) add_library(KF5::ItemModels ALIAS KF5ItemModels) diff --git a/src/kextracolumnsproxymodel.cpp b/src/kextracolumnsproxymodel.cpp index 3626d26..bd7fedc 100644 --- a/src/kextracolumnsproxymodel.cpp +++ b/src/kextracolumnsproxymodel.cpp @@ -19,8 +19,9 @@ */ #include "kextracolumnsproxymodel.h" +#include "kitemmodels_debug.h" + #include -#include class KExtraColumnsProxyModelPrivate { @@ -115,7 +116,7 @@ QModelIndex KExtraColumnsProxyModel::mapToSource(const QModelIndex &proxyIndex) } const int column = proxyIndex.column(); if (column >= sourceModel()->columnCount()) { - qDebug() << "Returning invalid index in mapToSource"; + qCDebug(KITEMMODELS_LOG) << "Returning invalid index in mapToSource"; return QModelIndex(); } return QIdentityProxyModel::mapToSource(proxyIndex); diff --git a/src/klinkitemselectionmodel.cpp b/src/klinkitemselectionmodel.cpp index 82f016e..b4aad68 100644 --- a/src/klinkitemselectionmodel.cpp +++ b/src/klinkitemselectionmodel.cpp @@ -22,11 +22,10 @@ */ #include "klinkitemselectionmodel.h" - +#include "kitemmodels_debug.h" #include "kmodelindexproxymapper.h" #include -#include class KLinkItemSelectionModelPrivate { @@ -52,7 +51,7 @@ public: { Q_FOREACH (const QItemSelectionRange &range, selection) { if (!range.isValid()) { - qDebug() << selection; + qCDebug(KITEMMODELS_LOG) << selection; } Q_ASSERT(range.isValid()); } diff --git a/src/kmodelindexproxymapper.cpp b/src/kmodelindexproxymapper.cpp index 4eaecb4..49d2f9d 100644 --- a/src/kmodelindexproxymapper.cpp +++ b/src/kmodelindexproxymapper.cpp @@ -22,10 +22,10 @@ */ #include "kmodelindexproxymapper.h" +#include "kitemmodels_debug.h" #include #include -#include #include #include @@ -45,7 +45,7 @@ class KModelIndexProxyMapperPrivate { Q_FOREACH (const QItemSelectionRange &range, selection) { if (!range.isValid()) { - qDebug() << selection << m_leftModel << m_rightModel << m_proxyChainDown << m_proxyChainUp; + qCDebug(KITEMMODELS_LOG) << selection << m_leftModel << m_rightModel << m_proxyChainDown << m_proxyChainUp; } Q_ASSERT(range.isValid()); } @@ -228,7 +228,7 @@ QItemSelection KModelIndexProxyMapper::mapSelectionLeftToRight(const QItemSelect } if (selection.first().model() != d->m_leftModel) { - qDebug() << "FAIL" << selection.first().model() << d->m_leftModel << d->m_rightModel; + qCDebug(KITEMMODELS_LOG) << "FAIL" << selection.first().model() << d->m_leftModel << d->m_rightModel; } Q_ASSERT(selection.first().model() == d->m_leftModel); @@ -282,7 +282,7 @@ QItemSelection KModelIndexProxyMapper::mapSelectionRightToLeft(const QItemSelect } if (selection.first().model() != d->m_rightModel) { - qDebug() << "FAIL" << selection.first().model() << d->m_leftModel << d->m_rightModel; + qCDebug(KITEMMODELS_LOG) << "FAIL" << selection.first().model() << d->m_leftModel << d->m_rightModel; } Q_ASSERT(selection.first().model() == d->m_rightModel);