Git commit 9947954efdf3293bd0b3ea68582ea7eddc265205 by Montel Laurent. Committed on 30/04/2015 at 20:59. Pushed by mlaurent into branch 'master'. Port to qCDebug M +1 -0 korganizer/plugins/picoftheday/CMakeLists.txt A +23 -0 korganizer/plugins/picoftheday/korganizer_picoftheday_plugin= _debug.cpp [License: LGPL (v2+)] A +27 -0 korganizer/plugins/picoftheday/korganizer_picoftheday_plugin= _debug.h [License: LGPL (v2+)] M +25 -25 korganizer/plugins/picoftheday/picoftheday.cpp http://commits.kde.org/kdepim/9947954efdf3293bd0b3ea68582ea7eddc265205 diff --git a/korganizer/plugins/picoftheday/CMakeLists.txt b/korganizer/plu= gins/picoftheday/CMakeLists.txt index b43a2da..3231574 100644 --- a/korganizer/plugins/picoftheday/CMakeLists.txt +++ b/korganizer/plugins/picoftheday/CMakeLists.txt @@ -9,6 +9,7 @@ include_directories( set(korg_picoftheday_PART_SRCS configdialog.cpp picoftheday.cpp + korganizer_picoftheday_plugin_debug.cpp ) = add_library(korg_picoftheday MODULE ${korg_picoftheday_PART_SRCS}) diff --git a/korganizer/plugins/picoftheday/korganizer_picoftheday_plugin_d= ebug.cpp b/korganizer/plugins/picoftheday/korganizer_picoftheday_plugin_deb= ug.cpp new file mode 100644 index 0000000..c95891b --- /dev/null +++ b/korganizer/plugins/picoftheday/korganizer_picoftheday_plugin_debug.cpp @@ -0,0 +1,23 @@ +/* This file is part of the KDE project + Copyright (C) 2015 Laurent Montel + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public Lice= nse + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "korganizer_picoftheday_plugin_debug.h" +Q_LOGGING_CATEGORY(KORGANIZERPICOFTHEDAYPLUGIN_LOG, "log_korganizer_picoft= heday_plugins") + + diff --git a/korganizer/plugins/picoftheday/korganizer_picoftheday_plugin_d= ebug.h b/korganizer/plugins/picoftheday/korganizer_picoftheday_plugin_debug= .h new file mode 100644 index 0000000..1913d14 --- /dev/null +++ b/korganizer/plugins/picoftheday/korganizer_picoftheday_plugin_debug.h @@ -0,0 +1,27 @@ +/* This file is part of the KDE project + Copyright (C) 2015 Laurent Montel + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public Lice= nse + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KORGANIZER_PICOFTHEDAY_PLUGIN_DEBUG_H +#define KORGANIZER_PICOFTHEDAY_PLUGIN_DEBUG_H + +#include +Q_DECLARE_LOGGING_CATEGORY(KORGANIZERPICOFTHEDAYPLUGIN_LOG) + +#endif = + diff --git a/korganizer/plugins/picoftheday/picoftheday.cpp b/korganizer/pl= ugins/picoftheday/picoftheday.cpp index 1b19ccb..1928434 100644 --- a/korganizer/plugins/picoftheday/picoftheday.cpp +++ b/korganizer/plugins/picoftheday/picoftheday.cpp @@ -23,7 +23,7 @@ = #include #include -#include +#include "korganizer_picoftheday_plugin_debug.h" #include #include = @@ -104,10 +104,10 @@ void POTDElement::step1StartDownload() void POTDElement::step1Result(KJob *job) { if (job->error()) { - qWarning() << "POTD:" << mDate << ": could not get POTD file name:= " << job->errorString(); - qDebug() << "POTD:" << mDate << ": file name:" << mFileName; - qDebug() << "POTD:" << mDate << ": full-size image:" << mFullSizeI= mageUrl.url(); - qDebug() << "POTD:" << mDate << ": thumbnail:" << mThumbUrl.url(); + qCWarning(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << = ": could not get POTD file name:" << job->errorString(); + qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ":= file name:" << mFileName; + qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ":= full-size image:" << mFullSizeImageUrl.url(); + qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ":= thumbnail:" << mThumbUrl.url(); mFirstStepCompleted =3D false; return; } @@ -140,8 +140,8 @@ void POTDElement::step1Result(KJob *job) mLongText =3D i18n("Wikipedia POTD: %1", mLongText); emit gotNewLongText(mLongText); = - qDebug() << "FILENAME=3D" << mFileName; - qDebug() << "DESCRIPTION=3D" << mDescription; + qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "FILENAME=3D" << mFileName; + qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "DESCRIPTION=3D" << mDescr= iption; = mFirstStepCompleted =3D true; mFirstStepJob =3D Q_NULLPTR; @@ -174,10 +174,10 @@ void POTDElement::step2GetImagePage() void POTDElement::step2Result(KJob *job) { if (job->error()) { - qWarning() << "POTD:" << mDate << ": could not get POTD image page= :" << job->errorString(); - qDebug() << "POTD:" << mDate << ": file name:" << mFileName; - qDebug() << "POTD:" << mDate << ": full-size image:" << mFullSizeI= mageUrl.url(); - qDebug() << "POTD:" << mDate << ": thumbnail:" << mThumbUrl.url(); + qCWarning(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << = ": could not get POTD image page:" << job->errorString(); + qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ":= file name:" << mFileName; + qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ":= full-size image:" << mFullSizeImageUrl.url(); + qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ":= thumbnail:" << mThumbUrl.url(); mSecondStepCompleted =3D false; return; } @@ -189,14 +189,14 @@ void POTDElement::step2Result(KJob *job) QDomDocument imgPage; if (!imgPage.setContent(QString::fromUtf8(transferJob->data().data(), transferJob->data().size()))) { - qWarning() << "POTD:" << mDate << ": Wikipedia returned an invalid= XML page for image" + qCWarning(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << = ": Wikipedia returned an invalid XML page for image" << mFileName; return; } = // We go through all links and stop at the first right-looking candida= te QDomNodeList links =3D imgPage.elementsByTagName(QLatin1String("a")); - for (uint i =3D 0; i < links.length(); ++i) { + for (int i =3D 0; i < links.length(); ++i) { QString href =3D links.item(i).attributes().namedItem(QLatin1Strin= g("href")).nodeValue(); if (href.startsWith( QLatin1String("//upload.wikimedia.org/wikipedia/common= s/"))) { @@ -208,7 +208,7 @@ void POTDElement::step2Result(KJob *job) // We get the image's width/height ratio mHWRatio =3D 1.0; QDomNodeList images =3D imgPage.elementsByTagName(QLatin1String("img")= ); - for (uint i =3D 0; i < links.length(); ++i) { + for (int i =3D 0; i < links.length(); ++i) { QDomNamedNodeMap attr =3D images.item(i).attributes(); QString src =3D attr.namedItem(QLatin1String("src")).nodeValue(); = @@ -222,8 +222,8 @@ void POTDElement::step2Result(KJob *job) } = } - qDebug() << "POTD:" << mDate << ": h/w ratio:" << mHWRatio; - qDebug() << "POTD:" << mDate << ": got POTD image page source:" << mFu= llSizeImageUrl; + qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": h/w= ratio:" << mHWRatio; + qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": got= POTD image page source:" << mFullSizeImageUrl; = if (!mFullSizeImageUrl.isEmpty()) { mSecondStepCompleted =3D true; @@ -267,16 +267,16 @@ void POTDElement::step3GetThumbnail() thumbHeight =3D static_cast(thumbWidth * mHWRatio); } mDlThumbSize =3D QSize(thumbWidth, thumbHeight); - qDebug() << "POTD:" << mDate << ": will download thumbnail of size" <<= mDlThumbSize; + qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": wil= l download thumbnail of size" << mDlThumbSize; QString thumbUrl =3D QUrl::fromPercentEncoding( thumbnailUrl(mFullSizeImageUrl, thumbWidth).url().toLatin1()); = - qDebug() << "POTD:" << mDate << ": got POTD thumbnail URL:" << thumbUr= l; + qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": got= POTD thumbnail URL:" << thumbUrl; mThumbUrl =3D thumbUrl; = mThirdStepJob =3D KIO::storedGet(thumbUrl, KIO::NoReload, KIO::HidePro= gressInfo); - qDebug() << "POTD:" << mDate << ": get" << thumbUrl;//FIXME + qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": get= " << thumbUrl;//FIXME KIO::Scheduler::setJobPriority(mThirdStepJob, 1); = connect(mThirdStepJob, &KIO::SimpleJob::result, this, &POTDElement::st= ep3Result); @@ -294,17 +294,17 @@ void POTDElement::step3Result(KJob *job) mThirdStepJob =3D Q_NULLPTR; = if (job->error()) { - qWarning() << "POTD:" << mDate << ": could not get POTD:" << job->= errorString(); - qDebug() << "POTD:" << mDate << ": file name:" << mFileName; - qDebug() << "POTD:" << mDate << ": full-size image:" << mFullSizeI= mageUrl.url(); - qDebug() << "POTD:" << mDate << ": thumbnail:" << mThumbUrl.url(); + qCWarning(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << = ": could not get POTD:" << job->errorString(); + qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ":= file name:" << mFileName; + qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ":= full-size image:" << mFullSizeImageUrl.url(); + qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ":= thumbnail:" << mThumbUrl.url(); return; } = // Last step completed: we get the pixmap from the transfer job's data KIO::StoredTransferJob *const transferJob =3D static_cast(job); if (mPixmap.loadFromData(transferJob->data())) { - qDebug() << "POTD:" << mDate << ": got POTD."; + qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ":= got POTD."; emit gotNewPixmap(mPixmap.scaled(mThumbSize, Qt::KeepAspectRatio, Qt::SmoothTransformation)); } @@ -313,7 +313,7 @@ void POTDElement::step3Result(KJob *job) QPixmap POTDElement::newPixmap(const QSize &size) { if ((mThumbSize.width() < size.width()) || (mThumbSize.height() < size= .height())) { - qDebug() << "POTD:" << mDate << ": called for a new pixmap size (" + qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ":= called for a new pixmap size (" << size << "instead of" << mThumbSize << ", stored pixmap= :" << mPixmap.size() << ")"; setThumbnailSize(size);