Replace kDebug/kWarning by categorized logging (org.kde.dolphin)

This commit is contained in:
Emmanuel Pescosta 2015-02-24 13:07:35 +01:00
parent 6d9f5b2131
commit 169cca55b9
20 changed files with 118 additions and 68 deletions

View file

@ -72,6 +72,7 @@ set(dolphinprivate_LIB_SRCS
views/zoomlevelinfo.cpp
dolphinremoveaction.cpp
dolphinnewfilemenu.cpp
dolphindebug.cpp
)
if(HAVE_BALOO)

22
src/dolphindebug.cpp Normal file
View file

@ -0,0 +1,22 @@
/***************************************************************************
* Copyright (C) 2015 by Emmanuel Pescosta <emmanuelpescosta099@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "dolphindebug.h"
Q_LOGGING_CATEGORY(DolphinDebug, "org.kde.dolphin")

27
src/dolphindebug.h Normal file
View file

@ -0,0 +1,27 @@
/***************************************************************************
* Copyright (C) 2015 by Emmanuel Pescosta <emmanuelpescosta099@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#ifndef DOLPHIN_DEBUG_H
#define DOLPHIN_DEBUG_H
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(DolphinDebug)
#endif // DOLPHIN_DEBUG_H

View file

@ -24,7 +24,7 @@
#include <KAboutData>
#include <KActionCollection>
#include <KDebug>
#include "dolphindebug.h"
#include <KIconLoader>
#include <KLocalizedString>
#include <KMessageBox>
@ -138,7 +138,7 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
connect(lister, &KDirLister::newItems, notifyExt, &DolphinPartListingNotificationExtension::slotNewItems);
connect(lister, &KDirLister::itemsDeleted, notifyExt, &DolphinPartListingNotificationExtension::slotItemsDeleted);
} else {
kWarning() << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported";
qCWarning(DolphinDebug) << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported";
}
createActions();
@ -340,7 +340,7 @@ void DolphinPart::slotMessage(const QString& msg)
void DolphinPart::slotErrorMessage(const QString& msg)
{
kDebug() << msg;
qCDebug(DolphinDebug) << msg;
emit canceled(msg);
//KMessageBox::error(m_view, msg);
}
@ -471,7 +471,7 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
void DolphinPart::slotDirectoryRedirection(const QUrl &oldUrl, const QUrl &newUrl)
{
//kDebug() << oldUrl << newUrl << "currentUrl=" << url();
//qCDebug(DolphinDebug) << oldUrl << newUrl << "currentUrl=" << url();
if (oldUrl.matches(url(), QUrl::StripTrailingSlash /* #207572 */)) {
KParts::ReadOnlyPart::setUrl(newUrl);
const QString prettyUrl = newUrl.toDisplayString(QUrl::PreferLocalFile);

View file

@ -24,7 +24,7 @@
#include "dolphin_generalsettings.h"
#include <KLocalizedString>
#include <KDebug>
#include "dolphindebug.h"
#include "private/kfileitemmodelsortalgorithm.h"
#include "private/kfileitemmodeldirlister.h"
@ -339,7 +339,7 @@ QList<QPair<int, QVariant> > KFileItemModel::groups() const
}
#ifdef KFILEITEMMODEL_DEBUG
kDebug() << "[TIME] Calculating groups for" << count() << "items:" << timer.elapsed();
qCDebug(DolphinDebug) << "[TIME] Calculating groups for" << count() << "items:" << timer.elapsed();
#endif
}
@ -408,9 +408,9 @@ int KFileItemModel::index(const QUrl& url) const
if (m_items.count() != m_itemData.count() && printDebugInfo) {
printDebugInfo = false;
kWarning() << "The model is in an inconsistent state.";
kWarning() << "m_items.count() ==" << m_items.count();
kWarning() << "m_itemData.count() ==" << m_itemData.count();
qCWarning(DolphinDebug) << "The model is in an inconsistent state.";
qCWarning(DolphinDebug) << "m_items.count() ==" << m_items.count();
qCWarning(DolphinDebug) << "m_itemData.count() ==" << m_itemData.count();
// Check if there are multiple items with the same URL.
QMultiHash<QUrl, int> indexesForUrl;
@ -420,12 +420,12 @@ int KFileItemModel::index(const QUrl& url) const
foreach (const QUrl& url, indexesForUrl.uniqueKeys()) {
if (indexesForUrl.count(url) > 1) {
kWarning() << "Multiple items found with the URL" << url;
qCWarning(DolphinDebug) << "Multiple items found with the URL" << url;
foreach (int index, indexesForUrl.values(url)) {
const ItemData* data = m_itemData.at(index);
kWarning() << "index" << index << ":" << data->item;
qCWarning(DolphinDebug) << "index" << index << ":" << data->item;
if (data->parent) {
kWarning() << "parent" << data->parent->item;
qCWarning(DolphinDebug) << "parent" << data->parent->item;
}
}
}
@ -795,8 +795,8 @@ void KFileItemModel::resortAllItems()
#ifdef KFILEITEMMODEL_DEBUG
QElapsedTimer timer;
timer.start();
kDebug() << "===========================================================";
kDebug() << "Resorting" << itemCount << "items";
qCDebug(DolphinDebug) << "===========================================================";
qCDebug(DolphinDebug) << "Resorting" << itemCount << "items";
#endif
// Remember the order of the current URLs so
@ -858,7 +858,7 @@ void KFileItemModel::resortAllItems()
}
#ifdef KFILEITEMMODEL_DEBUG
kDebug() << "[TIME] Resorting of" << itemCount << "items:" << timer.elapsed();
qCDebug(DolphinDebug) << "[TIME] Resorting of" << itemCount << "items:" << timer.elapsed();
#endif
}
@ -1013,7 +1013,7 @@ void KFileItemModel::slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >&
{
Q_ASSERT(!items.isEmpty());
#ifdef KFILEITEMMODEL_DEBUG
kDebug() << "Refreshing" << items.count() << "items";
qCDebug(DolphinDebug) << "Refreshing" << items.count() << "items";
#endif
// Get the indexes of all items that have been refreshed
@ -1079,7 +1079,7 @@ void KFileItemModel::slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >&
void KFileItemModel::slotClear()
{
#ifdef KFILEITEMMODEL_DEBUG
kDebug() << "Clearing all items";
qCDebug(DolphinDebug) << "Clearing all items";
#endif
qDeleteAll(m_filteredItems.values());
@ -1126,8 +1126,8 @@ void KFileItemModel::insertItems(QList<ItemData*>& newItems)
#ifdef KFILEITEMMODEL_DEBUG
QElapsedTimer timer;
timer.start();
kDebug() << "===========================================================";
kDebug() << "Inserting" << newItems.count() << "items";
qCDebug(DolphinDebug) << "===========================================================";
qCDebug(DolphinDebug) << "Inserting" << newItems.count() << "items";
#endif
m_groups.clear();
@ -1144,7 +1144,7 @@ void KFileItemModel::insertItems(QList<ItemData*>& newItems)
sort(newItems.begin(), newItems.end());
#ifdef KFILEITEMMODEL_DEBUG
kDebug() << "[TIME] Sorting:" << timer.elapsed();
qCDebug(DolphinDebug) << "[TIME] Sorting:" << timer.elapsed();
#endif
KItemRangeList itemRanges;
@ -1208,7 +1208,7 @@ void KFileItemModel::insertItems(QList<ItemData*>& newItems)
emit itemsInserted(itemRanges);
#ifdef KFILEITEMMODEL_DEBUG
kDebug() << "[TIME] Inserting of" << newItems.count() << "items:" << timer.elapsed();
qCDebug(DolphinDebug) << "[TIME] Inserting of" << newItems.count() << "items:" << timer.elapsed();
#endif
}
@ -2213,19 +2213,19 @@ bool KFileItemModel::isConsistent() const
// Check if m_items and m_itemData are consistent.
const KFileItem item = fileItem(i);
if (item.isNull()) {
qWarning() << "Item" << i << "is null";
qCWarning(DolphinDebug) << "Item" << i << "is null";
return false;
}
const int itemIndex = index(item);
if (itemIndex != i) {
qWarning() << "Item" << i << "has a wrong index:" << itemIndex;
qCWarning(DolphinDebug) << "Item" << i << "has a wrong index:" << itemIndex;
return false;
}
// Check if the items are sorted correctly.
if (i > 0 && !lessThan(m_itemData.at(i - 1), m_itemData.at(i), m_collator)) {
qWarning() << "The order of items" << i - 1 << "and" << i << "is wrong:"
qCWarning(DolphinDebug) << "The order of items" << i - 1 << "and" << i << "is wrong:"
<< fileItem(i - 1) << fileItem(i);
return false;
}
@ -2235,13 +2235,13 @@ bool KFileItemModel::isConsistent() const
const ItemData* parent = data->parent;
if (parent) {
if (expandedParentsCount(data) != expandedParentsCount(parent) + 1) {
qWarning() << "expandedParentsCount is inconsistent for parent" << parent->item << "and child" << data->item;
qCWarning(DolphinDebug) << "expandedParentsCount is inconsistent for parent" << parent->item << "and child" << data->item;
return false;
}
const int parentIndex = index(parent->item);
if (parentIndex >= i) {
qWarning() << "Index" << parentIndex << "of parent" << parent->item << "is not smaller than index" << i << "of child" << data->item;
qCWarning(DolphinDebug) << "Index" << parentIndex << "of parent" << parent->item << "is not smaller than index" << i << "of child" << data->item;
return false;
}
}

View file

@ -22,7 +22,7 @@
#include "kitemlistview.h"
#include <QDebug>
#include "dolphindebug.h"
#include "kitemlistcontainer.h"
#include "kitemlistcontroller.h"
#include "kitemlistheader.h"
@ -543,7 +543,7 @@ void KItemListView::endTransaction()
--m_activeTransactions;
if (m_activeTransactions < 0) {
m_activeTransactions = 0;
qWarning() << "Mismatch between beginTransaction()/endTransaction()";
qCWarning(DolphinDebug) << "Mismatch between beginTransaction()/endTransaction()";
}
if (m_activeTransactions == 0) {
@ -1006,7 +1006,7 @@ void KItemListView::slotItemsInserted(const KItemRangeList& itemRanges)
const int index = range.index + previouslyInsertedCount;
const int count = range.count;
if (index < 0 || count <= 0) {
qWarning() << "Invalid item range (index:" << index << ", count:" << count << ")";
qCWarning(DolphinDebug) << "Invalid item range (index:" << index << ", count:" << count << ")";
continue;
}
previouslyInsertedCount += count;
@ -1114,7 +1114,7 @@ void KItemListView::slotItemsRemoved(const KItemRangeList& itemRanges)
const int index = range.index;
const int count = range.count;
if (index < 0 || count <= 0) {
qWarning() << "Invalid item range (index:" << index << ", count:" << count << ")";
qCWarning(DolphinDebug) << "Invalid item range (index:" << index << ", count:" << count << ")";
continue;
}

View file

@ -22,7 +22,7 @@
#include <kitemviews/kitemmodelbase.h>
#include "kitemlistsizehintresolver.h"
#include <KDebug>
#include "dolphindebug.h"
// #define KITEMLISTVIEWLAYOUTER_DEBUG
@ -516,7 +516,7 @@ void KItemListViewLayouter::doLayout()
}
#ifdef KITEMLISTVIEWLAYOUTER_DEBUG
kDebug() << "[TIME] doLayout() for " << m_model->count() << "items:" << timer.elapsed();
qCDebug(DolphinDebug) << "[TIME] doLayout() for " << m_model->count() << "items:" << timer.elapsed();
#endif
m_dirty = false;
}

View file

@ -28,7 +28,7 @@
#include <QCommandLineOption>
#include <QApplication>
#include <KLocalizedString>
#include <KDebug>
#include "dolphindebug.h"
#include <kdelibs4configmigrator.h>
extern "C" Q_DECL_EXPORT int kdemain(int argc, char **argv)
@ -109,7 +109,7 @@ extern "C" Q_DECL_EXPORT int kdemain(int argc, char **argv)
if (url.isValid()) {
urls.append(url);
} else {
qWarning() << "Invalid URL: " << str;
qCWarning(DolphinDebug) << "Invalid URL: " << str;
}
}
@ -152,7 +152,7 @@ extern "C" Q_DECL_EXPORT int kdemain(int argc, char **argv)
if (className == QLatin1String("DolphinMainWindow")) {
m_mainWindow->restore(1);
} else {
kWarning() << "Unknown class " << className << " in session saved data!";
qCWarning(DolphinDebug) << "Unknown class " << className << " in session saved data!";
}
}

View file

@ -49,7 +49,7 @@
#include <views/draganddrophelper.h>
#include <KDebug>
#include "dolphindebug.h"
FoldersPanel::FoldersPanel(QWidget* parent) :
Panel(parent),

View file

@ -23,7 +23,7 @@
#include "placesitem.h"
#include <KBookmarkManager>
#include <KDebug>
#include "dolphindebug.h"
#include <KDirLister>
#include <KLocalizedString>
#include "placesitemsignalhandler.h"

View file

@ -24,7 +24,7 @@
#include "placesitemeditdialog.h"
#include <KAboutData>
#include <KDebug>
#include "dolphindebug.h"
#include <KFile>
#include <KIconButton>
#include <KLocalizedString>

View file

@ -28,7 +28,7 @@
#include <KBookmark>
#include <KBookmarkGroup>
#include <KBookmarkManager>
#include <KDebug>
#include "dolphindebug.h"
#include <QIcon>
#include <KProtocolInfo>
#include <KLocalizedString>
@ -191,7 +191,7 @@ void PlacesItemModel::setHiddenItemsShown(bool show)
}
#ifdef PLACESITEMMODEL_DEBUG
kDebug() << "Changed visibility of hidden items";
qCDebug(DolphinDebug) << "Changed visibility of hidden items";
showModelState();
#endif
}
@ -496,7 +496,7 @@ void PlacesItemModel::onItemInserted(int index)
}
#ifdef PLACESITEMMODEL_DEBUG
kDebug() << "Inserted item" << index;
qCDebug(DolphinDebug) << "Inserted item" << index;
showModelState();
#endif
}
@ -514,7 +514,7 @@ void PlacesItemModel::onItemRemoved(int index, KStandardItem* removedItem)
m_bookmarkedItems.removeAt(boomarkIndex);
#ifdef PLACESITEMMODEL_DEBUG
kDebug() << "Removed item" << index;
qCDebug(DolphinDebug) << "Removed item" << index;
showModelState();
#endif
}
@ -807,7 +807,7 @@ void PlacesItemModel::loadBookmarks()
}
#ifdef PLACESITEMMODEL_DEBUG
kDebug() << "Loaded bookmarks";
qCDebug(DolphinDebug) << "Loaded bookmarks";
showModelState();
#endif
}
@ -1176,25 +1176,25 @@ QUrl PlacesItemModel::searchUrlForType(const QString& type)
#ifdef PLACESITEMMODEL_DEBUG
void PlacesItemModel::showModelState()
{
kDebug() << "=================================";
kDebug() << "Model:";
kDebug() << "hidden-index model-index text";
qCDebug(DolphinDebug) << "=================================";
qCDebug(DolphinDebug) << "Model:";
qCDebug(DolphinDebug) << "hidden-index model-index text";
int modelIndex = 0;
for (int i = 0; i < m_bookmarkedItems.count(); ++i) {
if (m_bookmarkedItems[i]) {
kDebug() << i << "(Hidden) " << " " << m_bookmarkedItems[i]->dataValue("text").toString();
qCDebug(DolphinDebug) << i << "(Hidden) " << " " << m_bookmarkedItems[i]->dataValue("text").toString();
} else {
if (item(modelIndex)) {
kDebug() << i << " " << modelIndex << " " << item(modelIndex)->dataValue("text").toString();
qCDebug(DolphinDebug) << i << " " << modelIndex << " " << item(modelIndex)->dataValue("text").toString();
} else {
kDebug() << i << " " << modelIndex << " " << "(not available yet)";
qCDebug(DolphinDebug) << i << " " << modelIndex << " " << "(not available yet)";
}
++modelIndex;
}
}
kDebug();
kDebug() << "Bookmarks:";
qCDebug(DolphinDebug);
qCDebug(DolphinDebug) << "Bookmarks:";
int bookmarkIndex = 0;
KBookmarkGroup root = m_bookmarkManager->root();
@ -1203,9 +1203,9 @@ void PlacesItemModel::showModelState()
const QString udi = bookmark.metaDataItem("UDI");
const QString text = udi.isEmpty() ? bookmark.text() : udi;
if (bookmark.metaDataItem("IsHidden") == QLatin1String("true")) {
kDebug() << bookmarkIndex << "(Hidden)" << text;
qCDebug(DolphinDebug) << bookmarkIndex << "(Hidden)" << text;
} else {
kDebug() << bookmarkIndex << " " << text;
qCDebug(DolphinDebug) << bookmarkIndex << " " << text;
}
bookmark = root.next(bookmark);

View file

@ -26,7 +26,7 @@
#include "dolphin_generalsettings.h"
#include <KFileItem>
#include <KDebug>
#include "dolphindebug.h"
#include <KDirNotify>
#include <QIcon>
#include <KIO/Job>

View file

@ -19,7 +19,7 @@
#include "serviceitemdelegate.h"
#include <KDebug>
#include "dolphindebug.h"
#include <QPushButton>
#include <QIcon>

View file

@ -98,13 +98,13 @@ bool KStandardItemModelTest::isModelConsistent() const
for (int i = 0; i < m_model->count(); ++i) {
const KStandardItem* item = m_model->item(i);
if (!item) {
qWarning() << "Item" << i << "is null";
qCWarning(DolphinDebug) << "Item" << i << "is null";
return false;
}
const int itemIndex = m_model->index(item);
if (itemIndex != i) {
qWarning() << "Item" << i << "has a wrong index:" << itemIndex;
qCWarning(DolphinDebug) << "Item" << i << "has a wrong index:" << itemIndex;
return false;
}
}

View file

@ -24,7 +24,7 @@
#include <kversioncontrolplugin2.h>
#include <QColor>
#include <KDebug>
#include "dolphindebug.h"
DolphinFileItemListWidget::DolphinFileItemListWidget(KItemListWidgetInformant* informant,
QGraphicsItem* parent) :

View file

@ -26,7 +26,7 @@
#include "dolphinremoteencoding.h"
#include "dolphinviewactionhandler.h"
#include <KDebug>
#include "dolphindebug.h"
#include <KActionMenu>
#include <KActionCollection>
#include <QIcon>
@ -141,10 +141,10 @@ void DolphinRemoteEncoding::updateMenu()
}
}
kDebug() << "URL=" << m_currentURL << " charset=" << charset;
qCDebug(DolphinDebug) << "URL=" << m_currentURL << " charset=" << charset;
if (!isFound) {
kWarning() << "could not find entry for charset=" << charset ;
qCWarning(DolphinDebug) << "could not find entry for charset=" << charset ;
} else {
m_menu->menu()->actions().at(id)->setChecked(true);
}
@ -211,7 +211,7 @@ void DolphinRemoteEncoding::slotDefault()
}
for (QStringList::const_iterator it = domains.constBegin(); it != domains.constEnd();++it) {
kDebug() << "Domain to remove: " << *it;
qCDebug(DolphinDebug) << "Domain to remove: " << *it;
if (config.hasGroup(*it)) {
config.deleteGroup(*it);
} else if (config.group("").hasKey(*it)) {

View file

@ -39,7 +39,7 @@
#include <KPropertiesDialog>
#include <QIcon>
#include <KDebug>
#include "dolphindebug.h"
#ifdef HAVE_BALOO
#include <Baloo/IndexerConfig>

View file

@ -23,7 +23,7 @@
#include <KLocalizedString>
#include <KService>
#include <KDebug>
#include "dolphindebug.h"
#include <KServiceTypeTrader>
#include <kitemviews/kfileitemmodel.h>
#include <kversioncontrolplugin2.h>
@ -94,7 +94,7 @@ QList<QAction*> VersionControlObserver::actions(const KFileItemList& items) cons
bool hasNullItems = false;
foreach (const KFileItem& item, items) {
if (item.isNull()) {
kWarning() << "Requesting version-control-actions for empty items";
qCWarning(DolphinDebug) << "Requesting version-control-actions for empty items";
hasNullItems = true;
break;
}

View file

@ -24,7 +24,7 @@
#include "dolphin_generalsettings.h"
#include <QUrl>
#include <KDebug>
#include "dolphindebug.h"
#include <QCryptographicHash>
#include <QDate>
@ -359,7 +359,7 @@ void ViewProperties::update()
void ViewProperties::save()
{
kDebug() << "Saving view-properties to" << m_filePath;
qCDebug(DolphinDebug) << "Saving view-properties to" << m_filePath;
QDir dir;
dir.mkpath(m_filePath);
m_node->setVersion(CurrentViewPropertiesVersion);
@ -388,7 +388,7 @@ QString ViewProperties::viewModePrefix() const
case DolphinView::IconsView: prefix = "Icons_"; break;
case DolphinView::CompactView: prefix = "Compact_"; break;
case DolphinView::DetailsView: prefix = "Details_"; break;
default: kWarning() << "Unknown view-mode of the view properties";
default: qCWarning(DolphinDebug) << "Unknown view-mode of the view properties";
}
return prefix;